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 3403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3414 Register instance_reg, | 3414 Register instance_reg, |
3415 Register temp) { | 3415 Register temp) { |
3416 ASSERT(failure != NULL); | 3416 ASSERT(failure != NULL); |
3417 if (FLAG_inline_alloc) { | 3417 if (FLAG_inline_alloc) { |
3418 // If this allocation is traced, program will jump to failure path | 3418 // If this allocation is traced, program will jump to failure path |
3419 // (i.e. the allocation stub) which will allocate the object and trace the | 3419 // (i.e. the allocation stub) which will allocate the object and trace the |
3420 // allocation call site. | 3420 // allocation call site. |
3421 NOT_IN_PRODUCT(MaybeTraceAllocation(cls.id(), failure, near_jump)); | 3421 NOT_IN_PRODUCT(MaybeTraceAllocation(cls.id(), failure, near_jump)); |
3422 const intptr_t instance_size = cls.instance_size(); | 3422 const intptr_t instance_size = cls.instance_size(); |
3423 Heap::Space space = Heap::kNew; | 3423 Heap::Space space = Heap::kNew; |
3424 movq(temp, Address(THR, Thread::heap_offset())); | 3424 movq(instance_reg, Address(THR, Thread::top_offset())); |
3425 movq(instance_reg, Address(temp, Heap::TopOffset(space))); | |
3426 addq(instance_reg, Immediate(instance_size)); | 3425 addq(instance_reg, Immediate(instance_size)); |
3427 // instance_reg: potential next object start. | 3426 // instance_reg: potential next object start. |
3428 cmpq(instance_reg, Address(temp, Heap::EndOffset(space))); | 3427 cmpq(instance_reg, Address(THR, Thread::end_offset())); |
3429 j(ABOVE_EQUAL, failure, near_jump); | 3428 j(ABOVE_EQUAL, failure, near_jump); |
3430 // Successfully allocated the object, now update top to point to | 3429 // Successfully allocated the object, now update top to point to |
3431 // next object start and store the class in the class field of object. | 3430 // next object start and store the class in the class field of object. |
3432 movq(Address(temp, Heap::TopOffset(space)), instance_reg); | 3431 movq(Address(THR, Thread::top_offset()), instance_reg); |
3433 NOT_IN_PRODUCT(UpdateAllocationStats(cls.id(), space)); | 3432 NOT_IN_PRODUCT(UpdateAllocationStats(cls.id(), space)); |
3434 ASSERT(instance_size >= kHeapObjectTag); | 3433 ASSERT(instance_size >= kHeapObjectTag); |
3435 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size)); | 3434 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size)); |
3436 uword tags = 0; | 3435 uword tags = 0; |
3437 tags = RawObject::SizeTag::update(instance_size, tags); | 3436 tags = RawObject::SizeTag::update(instance_size, tags); |
3438 ASSERT(cls.id() != kIllegalCid); | 3437 ASSERT(cls.id() != kIllegalCid); |
3439 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 3438 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
3440 MoveImmediate(FieldAddress(instance_reg, Object::tags_offset()), | 3439 MoveImmediate(FieldAddress(instance_reg, Object::tags_offset()), |
3441 Immediate(tags)); | 3440 Immediate(tags)); |
3442 } else { | 3441 } else { |
3443 jmp(failure); | 3442 jmp(failure); |
3444 } | 3443 } |
3445 } | 3444 } |
3446 | 3445 |
3447 | 3446 |
3448 void Assembler::TryAllocateArray(intptr_t cid, | 3447 void Assembler::TryAllocateArray(intptr_t cid, |
3449 intptr_t instance_size, | 3448 intptr_t instance_size, |
3450 Label* failure, | 3449 Label* failure, |
3451 bool near_jump, | 3450 bool near_jump, |
3452 Register instance, | 3451 Register instance, |
3453 Register end_address, | 3452 Register end_address, |
3454 Register temp) { | 3453 Register temp) { |
3455 ASSERT(failure != NULL); | 3454 ASSERT(failure != NULL); |
3456 if (FLAG_inline_alloc) { | 3455 if (FLAG_inline_alloc) { |
3457 // If this allocation is traced, program will jump to failure path | 3456 // If this allocation is traced, program will jump to failure path |
3458 // (i.e. the allocation stub) which will allocate the object and trace the | 3457 // (i.e. the allocation stub) which will allocate the object and trace the |
3459 // allocation call site. | 3458 // allocation call site. |
3460 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, failure, near_jump)); | 3459 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, failure, near_jump)); |
3461 Heap::Space space = Heap::kNew; | 3460 Heap::Space space = Heap::kNew; |
3462 movq(temp, Address(THR, Thread::heap_offset())); | 3461 movq(instance, Address(THR, Thread::top_offset())); |
3463 movq(instance, Address(temp, Heap::TopOffset(space))); | |
3464 movq(end_address, instance); | 3462 movq(end_address, instance); |
3465 | 3463 |
3466 addq(end_address, Immediate(instance_size)); | 3464 addq(end_address, Immediate(instance_size)); |
3467 j(CARRY, failure); | 3465 j(CARRY, failure); |
3468 | 3466 |
3469 // Check if the allocation fits into the remaining space. | 3467 // Check if the allocation fits into the remaining space. |
3470 // instance: potential new object start. | 3468 // instance: potential new object start. |
3471 // end_address: potential next object start. | 3469 // end_address: potential next object start. |
3472 cmpq(end_address, Address(temp, Heap::EndOffset(space))); | 3470 cmpq(end_address, Address(THR, Thread::end_offset())); |
3473 j(ABOVE_EQUAL, failure); | 3471 j(ABOVE_EQUAL, failure); |
3474 | 3472 |
3475 // Successfully allocated the object(s), now update top to point to | 3473 // Successfully allocated the object(s), now update top to point to |
3476 // next object start and initialize the object. | 3474 // next object start and initialize the object. |
3477 movq(Address(temp, Heap::TopOffset(space)), end_address); | 3475 movq(Address(THR, Thread::top_offset()), end_address); |
3478 addq(instance, Immediate(kHeapObjectTag)); | 3476 addq(instance, Immediate(kHeapObjectTag)); |
3479 NOT_IN_PRODUCT(UpdateAllocationStatsWithSize(cid, instance_size, space)); | 3477 NOT_IN_PRODUCT(UpdateAllocationStatsWithSize(cid, instance_size, space)); |
3480 | 3478 |
3481 // Initialize the tags. | 3479 // Initialize the tags. |
3482 // instance: new object start as a tagged pointer. | 3480 // instance: new object start as a tagged pointer. |
3483 uword tags = 0; | 3481 uword tags = 0; |
3484 tags = RawObject::ClassIdTag::update(cid, tags); | 3482 tags = RawObject::ClassIdTag::update(cid, tags); |
3485 tags = RawObject::SizeTag::update(instance_size, tags); | 3483 tags = RawObject::SizeTag::update(instance_size, tags); |
3486 movq(FieldAddress(instance, Array::tags_offset()), Immediate(tags)); | 3484 movq(FieldAddress(instance, Array::tags_offset()), Immediate(tags)); |
3487 } else { | 3485 } else { |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3801 | 3799 |
3802 | 3800 |
3803 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3801 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3804 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3802 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
3805 return xmm_reg_names[reg]; | 3803 return xmm_reg_names[reg]; |
3806 } | 3804 } |
3807 | 3805 |
3808 } // namespace dart | 3806 } // namespace dart |
3809 | 3807 |
3810 #endif // defined TARGET_ARCH_X64 | 3808 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |