OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/globals.h" // NOLINT | 5 #include "vm/globals.h" // NOLINT |
6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/cpu.h" | 9 #include "vm/cpu.h" |
10 #include "vm/heap.h" | 10 #include "vm/heap.h" |
(...skipping 3400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3411 Register instance_reg, | 3411 Register instance_reg, |
3412 Register temp) { | 3412 Register temp) { |
3413 ASSERT(failure != NULL); | 3413 ASSERT(failure != NULL); |
3414 if (FLAG_inline_alloc) { | 3414 if (FLAG_inline_alloc) { |
3415 // If this allocation is traced, program will jump to failure path | 3415 // If this allocation is traced, program will jump to failure path |
3416 // (i.e. the allocation stub) which will allocate the object and trace the | 3416 // (i.e. the allocation stub) which will allocate the object and trace the |
3417 // allocation call site. | 3417 // allocation call site. |
3418 NOT_IN_PRODUCT(MaybeTraceAllocation(cls.id(), failure, near_jump)); | 3418 NOT_IN_PRODUCT(MaybeTraceAllocation(cls.id(), failure, near_jump)); |
3419 const intptr_t instance_size = cls.instance_size(); | 3419 const intptr_t instance_size = cls.instance_size(); |
3420 Heap::Space space = Heap::kNew; | 3420 Heap::Space space = Heap::kNew; |
3421 movq(temp, Address(THR, Thread::heap_offset())); | 3421 movq(instance_reg, Address(THR, Thread::top_offset())); |
3422 movq(instance_reg, Address(temp, Heap::TopOffset(space))); | |
3423 addq(instance_reg, Immediate(instance_size)); | 3422 addq(instance_reg, Immediate(instance_size)); |
3424 // instance_reg: potential next object start. | 3423 // instance_reg: potential next object start. |
3425 cmpq(instance_reg, Address(temp, Heap::EndOffset(space))); | 3424 cmpq(instance_reg, Address(THR, Thread::end_offset())); |
3426 j(ABOVE_EQUAL, failure, near_jump); | 3425 j(ABOVE_EQUAL, failure, near_jump); |
3427 // Successfully allocated the object, now update top to point to | 3426 // Successfully allocated the object, now update top to point to |
3428 // next object start and store the class in the class field of object. | 3427 // next object start and store the class in the class field of object. |
3429 movq(Address(temp, Heap::TopOffset(space)), instance_reg); | 3428 movq(Address(THR, Thread::top_offset()), instance_reg); |
3430 NOT_IN_PRODUCT(UpdateAllocationStats(cls.id(), space)); | 3429 NOT_IN_PRODUCT(UpdateAllocationStats(cls.id(), space)); |
3431 ASSERT(instance_size >= kHeapObjectTag); | 3430 ASSERT(instance_size >= kHeapObjectTag); |
3432 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size)); | 3431 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size)); |
3433 uword tags = 0; | 3432 uword tags = 0; |
3434 tags = RawObject::SizeTag::update(instance_size, tags); | 3433 tags = RawObject::SizeTag::update(instance_size, tags); |
3435 ASSERT(cls.id() != kIllegalCid); | 3434 ASSERT(cls.id() != kIllegalCid); |
3436 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 3435 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
3437 MoveImmediate(FieldAddress(instance_reg, Object::tags_offset()), | 3436 MoveImmediate(FieldAddress(instance_reg, Object::tags_offset()), |
3438 Immediate(tags)); | 3437 Immediate(tags)); |
3439 } else { | 3438 } else { |
3440 jmp(failure); | 3439 jmp(failure); |
3441 } | 3440 } |
3442 } | 3441 } |
3443 | 3442 |
3444 | 3443 |
3445 void Assembler::TryAllocateArray(intptr_t cid, | 3444 void Assembler::TryAllocateArray(intptr_t cid, |
3446 intptr_t instance_size, | 3445 intptr_t instance_size, |
3447 Label* failure, | 3446 Label* failure, |
3448 bool near_jump, | 3447 bool near_jump, |
3449 Register instance, | 3448 Register instance, |
3450 Register end_address, | 3449 Register end_address, |
3451 Register temp) { | 3450 Register temp) { |
3452 ASSERT(failure != NULL); | 3451 ASSERT(failure != NULL); |
3453 if (FLAG_inline_alloc) { | 3452 if (FLAG_inline_alloc) { |
3454 // If this allocation is traced, program will jump to failure path | 3453 // If this allocation is traced, program will jump to failure path |
3455 // (i.e. the allocation stub) which will allocate the object and trace the | 3454 // (i.e. the allocation stub) which will allocate the object and trace the |
3456 // allocation call site. | 3455 // allocation call site. |
3457 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, failure, near_jump)); | 3456 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, failure, near_jump)); |
3458 Heap::Space space = Heap::kNew; | 3457 Heap::Space space = Heap::kNew; |
3459 movq(temp, Address(THR, Thread::heap_offset())); | 3458 movq(instance, Address(THR, Thread::top_offset())); |
3460 movq(instance, Address(temp, Heap::TopOffset(space))); | |
3461 movq(end_address, instance); | 3459 movq(end_address, instance); |
3462 | 3460 |
3463 addq(end_address, Immediate(instance_size)); | 3461 addq(end_address, Immediate(instance_size)); |
3464 j(CARRY, failure); | 3462 j(CARRY, failure); |
3465 | 3463 |
3466 // Check if the allocation fits into the remaining space. | 3464 // Check if the allocation fits into the remaining space. |
3467 // instance: potential new object start. | 3465 // instance: potential new object start. |
3468 // end_address: potential next object start. | 3466 // end_address: potential next object start. |
3469 cmpq(end_address, Address(temp, Heap::EndOffset(space))); | 3467 cmpq(end_address, Address(THR, Thread::end_offset())); |
3470 j(ABOVE_EQUAL, failure); | 3468 j(ABOVE_EQUAL, failure); |
3471 | 3469 |
3472 // Successfully allocated the object(s), now update top to point to | 3470 // Successfully allocated the object(s), now update top to point to |
3473 // next object start and initialize the object. | 3471 // next object start and initialize the object. |
3474 movq(Address(temp, Heap::TopOffset(space)), end_address); | 3472 movq(Address(THR, Thread::top_offset()), end_address); |
3475 addq(instance, Immediate(kHeapObjectTag)); | 3473 addq(instance, Immediate(kHeapObjectTag)); |
3476 NOT_IN_PRODUCT(UpdateAllocationStatsWithSize(cid, instance_size, space)); | 3474 NOT_IN_PRODUCT(UpdateAllocationStatsWithSize(cid, instance_size, space)); |
3477 | 3475 |
3478 // Initialize the tags. | 3476 // Initialize the tags. |
3479 // instance: new object start as a tagged pointer. | 3477 // instance: new object start as a tagged pointer. |
3480 uword tags = 0; | 3478 uword tags = 0; |
3481 tags = RawObject::ClassIdTag::update(cid, tags); | 3479 tags = RawObject::ClassIdTag::update(cid, tags); |
3482 tags = RawObject::SizeTag::update(instance_size, tags); | 3480 tags = RawObject::SizeTag::update(instance_size, tags); |
3483 movq(FieldAddress(instance, Array::tags_offset()), Immediate(tags)); | 3481 movq(FieldAddress(instance, Array::tags_offset()), Immediate(tags)); |
3484 } else { | 3482 } else { |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3798 | 3796 |
3799 | 3797 |
3800 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3798 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3801 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3799 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
3802 return xmm_reg_names[reg]; | 3800 return xmm_reg_names[reg]; |
3803 } | 3801 } |
3804 | 3802 |
3805 } // namespace dart | 3803 } // namespace dart |
3806 | 3804 |
3807 #endif // defined TARGET_ARCH_X64 | 3805 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |