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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/macro-assembler.h" | 10 #include "src/macro-assembler.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 #endif | 177 #endif |
178 | 178 |
179 #undef __ | 179 #undef __ |
180 | 180 |
181 // ------------------------------------------------------------------------- | 181 // ------------------------------------------------------------------------- |
182 // Code generators | 182 // Code generators |
183 | 183 |
184 #define __ ACCESS_MASM(masm) | 184 #define __ ACCESS_MASM(masm) |
185 | 185 |
186 void ElementsTransitionGenerator::GenerateMapChangeElementsTransition( | 186 void ElementsTransitionGenerator::GenerateMapChangeElementsTransition( |
187 MacroAssembler* masm, AllocationSiteMode mode, | 187 MacroAssembler* masm, |
| 188 Register receiver, |
| 189 Register key, |
| 190 Register value, |
| 191 Register target_map, |
| 192 AllocationSiteMode mode, |
188 Label* allocation_memento_found) { | 193 Label* allocation_memento_found) { |
189 // ----------- S t a t e ------------- | 194 // Return address is on the stack. |
190 // -- rax : value | 195 Register scratch = rdi; |
191 // -- rbx : target map | 196 ASSERT(!AreAliased(receiver, key, value, target_map, scratch)); |
192 // -- rcx : key | 197 |
193 // -- rdx : receiver | |
194 // -- rsp[0] : return address | |
195 // ----------------------------------- | |
196 if (mode == TRACK_ALLOCATION_SITE) { | 198 if (mode == TRACK_ALLOCATION_SITE) { |
197 ASSERT(allocation_memento_found != NULL); | 199 ASSERT(allocation_memento_found != NULL); |
198 __ JumpIfJSArrayHasAllocationMemento(rdx, rdi, allocation_memento_found); | 200 __ JumpIfJSArrayHasAllocationMemento( |
| 201 receiver, scratch, allocation_memento_found); |
199 } | 202 } |
200 | 203 |
201 // Set transitioned map. | 204 // Set transitioned map. |
202 __ movp(FieldOperand(rdx, HeapObject::kMapOffset), rbx); | 205 __ movp(FieldOperand(receiver, HeapObject::kMapOffset), target_map); |
203 __ RecordWriteField(rdx, | 206 __ RecordWriteField(receiver, |
204 HeapObject::kMapOffset, | 207 HeapObject::kMapOffset, |
205 rbx, | 208 target_map, |
206 rdi, | 209 scratch, |
207 kDontSaveFPRegs, | 210 kDontSaveFPRegs, |
208 EMIT_REMEMBERED_SET, | 211 EMIT_REMEMBERED_SET, |
209 OMIT_SMI_CHECK); | 212 OMIT_SMI_CHECK); |
210 } | 213 } |
211 | 214 |
212 | 215 |
213 void ElementsTransitionGenerator::GenerateSmiToDouble( | 216 void ElementsTransitionGenerator::GenerateSmiToDouble( |
214 MacroAssembler* masm, AllocationSiteMode mode, Label* fail) { | 217 MacroAssembler* masm, |
215 // ----------- S t a t e ------------- | 218 Register receiver, |
216 // -- rax : value | 219 Register key, |
217 // -- rbx : target map | 220 Register value, |
218 // -- rcx : key | 221 Register target_map, |
219 // -- rdx : receiver | 222 AllocationSiteMode mode, |
220 // -- rsp[0] : return address | 223 Label* fail) { |
221 // ----------------------------------- | 224 // Return address is on the stack. |
| 225 ASSERT(receiver.is(rdx)); |
| 226 ASSERT(key.is(rcx)); |
| 227 ASSERT(value.is(rax)); |
| 228 ASSERT(target_map.is(rbx)); |
| 229 |
222 // The fail label is not actually used since we do not allocate. | 230 // The fail label is not actually used since we do not allocate. |
223 Label allocated, new_backing_store, only_change_map, done; | 231 Label allocated, new_backing_store, only_change_map, done; |
224 | 232 |
225 if (mode == TRACK_ALLOCATION_SITE) { | 233 if (mode == TRACK_ALLOCATION_SITE) { |
226 __ JumpIfJSArrayHasAllocationMemento(rdx, rdi, fail); | 234 __ JumpIfJSArrayHasAllocationMemento(rdx, rdi, fail); |
227 } | 235 } |
228 | 236 |
229 // Check for empty arrays, which only require a map transition and no changes | 237 // Check for empty arrays, which only require a map transition and no changes |
230 // to the backing store. | 238 // to the backing store. |
231 __ movp(r8, FieldOperand(rdx, JSObject::kElementsOffset)); | 239 __ movp(r8, FieldOperand(rdx, JSObject::kElementsOffset)); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 __ movq(FieldOperand(r14, r9, times_8, FixedDoubleArray::kHeaderSize), r15); | 346 __ movq(FieldOperand(r14, r9, times_8, FixedDoubleArray::kHeaderSize), r15); |
339 __ bind(&entry); | 347 __ bind(&entry); |
340 __ decp(r9); | 348 __ decp(r9); |
341 __ j(not_sign, &loop); | 349 __ j(not_sign, &loop); |
342 | 350 |
343 __ bind(&done); | 351 __ bind(&done); |
344 } | 352 } |
345 | 353 |
346 | 354 |
347 void ElementsTransitionGenerator::GenerateDoubleToObject( | 355 void ElementsTransitionGenerator::GenerateDoubleToObject( |
348 MacroAssembler* masm, AllocationSiteMode mode, Label* fail) { | 356 MacroAssembler* masm, |
349 // ----------- S t a t e ------------- | 357 Register receiver, |
350 // -- rax : value | 358 Register key, |
351 // -- rbx : target map | 359 Register value, |
352 // -- rcx : key | 360 Register target_map, |
353 // -- rdx : receiver | 361 AllocationSiteMode mode, |
354 // -- rsp[0] : return address | 362 Label* fail) { |
355 // ----------------------------------- | 363 // Return address is on the stack. |
| 364 ASSERT(receiver.is(rdx)); |
| 365 ASSERT(key.is(rcx)); |
| 366 ASSERT(value.is(rax)); |
| 367 ASSERT(target_map.is(rbx)); |
| 368 |
356 Label loop, entry, convert_hole, gc_required, only_change_map; | 369 Label loop, entry, convert_hole, gc_required, only_change_map; |
357 | 370 |
358 if (mode == TRACK_ALLOCATION_SITE) { | 371 if (mode == TRACK_ALLOCATION_SITE) { |
359 __ JumpIfJSArrayHasAllocationMemento(rdx, rdi, fail); | 372 __ JumpIfJSArrayHasAllocationMemento(rdx, rdi, fail); |
360 } | 373 } |
361 | 374 |
362 // Check for empty arrays, which only require a map transition and no changes | 375 // Check for empty arrays, which only require a map transition and no changes |
363 // to the backing store. | 376 // to the backing store. |
364 __ movp(r8, FieldOperand(rdx, JSObject::kElementsOffset)); | 377 __ movp(r8, FieldOperand(rdx, JSObject::kElementsOffset)); |
365 __ CompareRoot(r8, Heap::kEmptyFixedArrayRootIndex); | 378 __ CompareRoot(r8, Heap::kEmptyFixedArrayRootIndex); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 // argument_count_reg_ * times_pointer_size + (receiver - 1) * kPointerSize. | 705 // argument_count_reg_ * times_pointer_size + (receiver - 1) * kPointerSize. |
693 return Operand(base_reg_, argument_count_reg_, times_pointer_size, | 706 return Operand(base_reg_, argument_count_reg_, times_pointer_size, |
694 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); | 707 displacement_to_last_argument + (receiver - 1 - index) * kPointerSize); |
695 } | 708 } |
696 } | 709 } |
697 | 710 |
698 | 711 |
699 } } // namespace v8::internal | 712 } } // namespace v8::internal |
700 | 713 |
701 #endif // V8_TARGET_ARCH_X64 | 714 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |