OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 5156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5167 // Initialize the JSValue. | 5167 // Initialize the JSValue. |
5168 LoadGlobalFunctionInitialMap(constructor, scratch); | 5168 LoadGlobalFunctionInitialMap(constructor, scratch); |
5169 movp(FieldOperand(result, HeapObject::kMapOffset), scratch); | 5169 movp(FieldOperand(result, HeapObject::kMapOffset), scratch); |
5170 LoadRoot(scratch, Heap::kEmptyFixedArrayRootIndex); | 5170 LoadRoot(scratch, Heap::kEmptyFixedArrayRootIndex); |
5171 movp(FieldOperand(result, JSObject::kPropertiesOffset), scratch); | 5171 movp(FieldOperand(result, JSObject::kPropertiesOffset), scratch); |
5172 movp(FieldOperand(result, JSObject::kElementsOffset), scratch); | 5172 movp(FieldOperand(result, JSObject::kElementsOffset), scratch); |
5173 movp(FieldOperand(result, JSValue::kValueOffset), value); | 5173 movp(FieldOperand(result, JSValue::kValueOffset), value); |
5174 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); | 5174 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); |
5175 } | 5175 } |
5176 | 5176 |
5177 | |
5178 // Copy memory, byte-by-byte, from source to destination. Not optimized for | |
5179 // long or aligned copies. The contents of scratch and length are destroyed. | |
5180 // Destination is incremented by length, source, length and scratch are | |
5181 // clobbered. | |
5182 // A simpler loop is faster on small copies, but slower on large ones. | |
5183 // The cld() instruction must have been emitted, to set the direction flag(), | |
5184 // before calling this function. | |
5185 void MacroAssembler::CopyBytes(Register destination, | |
5186 Register source, | |
5187 Register length, | |
5188 int min_length, | |
5189 Register scratch) { | |
5190 DCHECK(min_length >= 0); | |
5191 if (emit_debug_code()) { | |
5192 cmpl(length, Immediate(min_length)); | |
5193 Assert(greater_equal, kInvalidMinLength); | |
5194 } | |
5195 Label short_loop, len8, len16, len24, done, short_string; | |
5196 | |
5197 const int kLongStringLimit = 4 * kPointerSize; | |
5198 if (min_length <= kLongStringLimit) { | |
5199 cmpl(length, Immediate(kPointerSize)); | |
5200 j(below, &short_string, Label::kNear); | |
5201 } | |
5202 | |
5203 DCHECK(source.is(rsi)); | |
5204 DCHECK(destination.is(rdi)); | |
5205 DCHECK(length.is(rcx)); | |
5206 | |
5207 if (min_length <= kLongStringLimit) { | |
5208 cmpl(length, Immediate(2 * kPointerSize)); | |
5209 j(below_equal, &len8, Label::kNear); | |
5210 cmpl(length, Immediate(3 * kPointerSize)); | |
5211 j(below_equal, &len16, Label::kNear); | |
5212 cmpl(length, Immediate(4 * kPointerSize)); | |
5213 j(below_equal, &len24, Label::kNear); | |
5214 } | |
5215 | |
5216 // Because source is 8-byte aligned in our uses of this function, | |
5217 // we keep source aligned for the rep movs operation by copying the odd bytes | |
5218 // at the end of the ranges. | |
5219 movp(scratch, length); | |
5220 shrl(length, Immediate(kPointerSizeLog2)); | |
5221 repmovsp(); | |
5222 // Move remaining bytes of length. | |
5223 andl(scratch, Immediate(kPointerSize - 1)); | |
5224 movp(length, Operand(source, scratch, times_1, -kPointerSize)); | |
5225 movp(Operand(destination, scratch, times_1, -kPointerSize), length); | |
5226 addp(destination, scratch); | |
5227 | |
5228 if (min_length <= kLongStringLimit) { | |
5229 jmp(&done, Label::kNear); | |
5230 bind(&len24); | |
5231 movp(scratch, Operand(source, 2 * kPointerSize)); | |
5232 movp(Operand(destination, 2 * kPointerSize), scratch); | |
5233 bind(&len16); | |
5234 movp(scratch, Operand(source, kPointerSize)); | |
5235 movp(Operand(destination, kPointerSize), scratch); | |
5236 bind(&len8); | |
5237 movp(scratch, Operand(source, 0)); | |
5238 movp(Operand(destination, 0), scratch); | |
5239 // Move remaining bytes of length. | |
5240 movp(scratch, Operand(source, length, times_1, -kPointerSize)); | |
5241 movp(Operand(destination, length, times_1, -kPointerSize), scratch); | |
5242 addp(destination, length); | |
5243 jmp(&done, Label::kNear); | |
5244 | |
5245 bind(&short_string); | |
5246 if (min_length == 0) { | |
5247 testl(length, length); | |
5248 j(zero, &done, Label::kNear); | |
5249 } | |
5250 | |
5251 bind(&short_loop); | |
5252 movb(scratch, Operand(source, 0)); | |
5253 movb(Operand(destination, 0), scratch); | |
5254 incp(source); | |
5255 incp(destination); | |
5256 decl(length); | |
5257 j(not_zero, &short_loop, Label::kNear); | |
5258 } | |
5259 | |
5260 bind(&done); | |
5261 } | |
5262 | |
5263 | |
5264 void MacroAssembler::InitializeFieldsWithFiller(Register current_address, | 5177 void MacroAssembler::InitializeFieldsWithFiller(Register current_address, |
5265 Register end_address, | 5178 Register end_address, |
5266 Register filler) { | 5179 Register filler) { |
5267 Label loop, entry; | 5180 Label loop, entry; |
5268 jmp(&entry, Label::kNear); | 5181 jmp(&entry, Label::kNear); |
5269 bind(&loop); | 5182 bind(&loop); |
5270 movp(Operand(current_address, 0), filler); | 5183 movp(Operand(current_address, 0), filler); |
5271 addp(current_address, Immediate(kPointerSize)); | 5184 addp(current_address, Immediate(kPointerSize)); |
5272 bind(&entry); | 5185 bind(&entry); |
5273 cmpp(current_address, end_address); | 5186 cmpp(current_address, end_address); |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5713 movl(rax, dividend); | 5626 movl(rax, dividend); |
5714 shrl(rax, Immediate(31)); | 5627 shrl(rax, Immediate(31)); |
5715 addl(rdx, rax); | 5628 addl(rdx, rax); |
5716 } | 5629 } |
5717 | 5630 |
5718 | 5631 |
5719 } // namespace internal | 5632 } // namespace internal |
5720 } // namespace v8 | 5633 } // namespace v8 |
5721 | 5634 |
5722 #endif // V8_TARGET_ARCH_X64 | 5635 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |