| 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_ARM) | 6 #if defined(TARGET_ARCH_ARM) |
| 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/longjump.h" | 10 #include "vm/longjump.h" |
| (...skipping 3459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3470 Register temp_reg) { | 3470 Register temp_reg) { |
| 3471 ASSERT(failure != NULL); | 3471 ASSERT(failure != NULL); |
| 3472 if (FLAG_inline_alloc) { | 3472 if (FLAG_inline_alloc) { |
| 3473 ASSERT(instance_reg != temp_reg); | 3473 ASSERT(instance_reg != temp_reg); |
| 3474 ASSERT(temp_reg != IP); | 3474 ASSERT(temp_reg != IP); |
| 3475 const intptr_t instance_size = cls.instance_size(); | 3475 const intptr_t instance_size = cls.instance_size(); |
| 3476 ASSERT(instance_size != 0); | 3476 ASSERT(instance_size != 0); |
| 3477 // If this allocation is traced, program will jump to failure path | 3477 // If this allocation is traced, program will jump to failure path |
| 3478 // (i.e. the allocation stub) which will allocate the object and trace the | 3478 // (i.e. the allocation stub) which will allocate the object and trace the |
| 3479 // allocation call site. | 3479 // allocation call site. |
| 3480 MaybeTraceAllocation(cls.id(), temp_reg, failure); | 3480 NOT_IN_PRODUCT( |
| 3481 MaybeTraceAllocation(cls.id(), temp_reg, failure)); |
| 3481 Heap::Space space = Heap::SpaceForAllocation(cls.id()); | 3482 Heap::Space space = Heap::SpaceForAllocation(cls.id()); |
| 3482 ldr(temp_reg, Address(THR, Thread::heap_offset())); | 3483 ldr(temp_reg, Address(THR, Thread::heap_offset())); |
| 3483 ldr(instance_reg, Address(temp_reg, Heap::TopOffset(space))); | 3484 ldr(instance_reg, Address(temp_reg, Heap::TopOffset(space))); |
| 3484 // TODO(koda): Protect against unsigned overflow here. | 3485 // TODO(koda): Protect against unsigned overflow here. |
| 3485 AddImmediateSetFlags(instance_reg, instance_reg, instance_size); | 3486 AddImmediateSetFlags(instance_reg, instance_reg, instance_size); |
| 3486 | 3487 |
| 3487 // instance_reg: potential next object start. | 3488 // instance_reg: potential next object start. |
| 3488 ldr(IP, Address(temp_reg, Heap::EndOffset(space))); | 3489 ldr(IP, Address(temp_reg, Heap::EndOffset(space))); |
| 3489 cmp(IP, Operand(instance_reg)); | 3490 cmp(IP, Operand(instance_reg)); |
| 3490 // fail if heap end unsigned less than or equal to instance_reg. | 3491 // fail if heap end unsigned less than or equal to instance_reg. |
| 3491 b(failure, LS); | 3492 b(failure, LS); |
| 3492 | 3493 |
| 3493 // Successfully allocated the object, now update top to point to | 3494 // Successfully allocated the object, now update top to point to |
| 3494 // next object start and store the class in the class field of object. | 3495 // next object start and store the class in the class field of object. |
| 3495 str(instance_reg, Address(temp_reg, Heap::TopOffset(space))); | 3496 str(instance_reg, Address(temp_reg, Heap::TopOffset(space))); |
| 3496 | 3497 |
| 3497 LoadAllocationStatsAddress(temp_reg, cls.id()); | 3498 NOT_IN_PRODUCT(LoadAllocationStatsAddress(temp_reg, cls.id())); |
| 3498 | 3499 |
| 3499 ASSERT(instance_size >= kHeapObjectTag); | 3500 ASSERT(instance_size >= kHeapObjectTag); |
| 3500 AddImmediate(instance_reg, -instance_size + kHeapObjectTag); | 3501 AddImmediate(instance_reg, -instance_size + kHeapObjectTag); |
| 3501 | 3502 |
| 3502 uword tags = 0; | 3503 uword tags = 0; |
| 3503 tags = RawObject::SizeTag::update(instance_size, tags); | 3504 tags = RawObject::SizeTag::update(instance_size, tags); |
| 3504 ASSERT(cls.id() != kIllegalCid); | 3505 ASSERT(cls.id() != kIllegalCid); |
| 3505 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 3506 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 3506 LoadImmediate(IP, tags); | 3507 LoadImmediate(IP, tags); |
| 3507 str(IP, FieldAddress(instance_reg, Object::tags_offset())); | 3508 str(IP, FieldAddress(instance_reg, Object::tags_offset())); |
| 3508 | 3509 |
| 3509 IncrementAllocationStats(temp_reg, cls.id(), space); | 3510 NOT_IN_PRODUCT(IncrementAllocationStats(temp_reg, cls.id(), space)); |
| 3510 } else { | 3511 } else { |
| 3511 b(failure); | 3512 b(failure); |
| 3512 } | 3513 } |
| 3513 } | 3514 } |
| 3514 | 3515 |
| 3515 | 3516 |
| 3516 void Assembler::TryAllocateArray(intptr_t cid, | 3517 void Assembler::TryAllocateArray(intptr_t cid, |
| 3517 intptr_t instance_size, | 3518 intptr_t instance_size, |
| 3518 Label* failure, | 3519 Label* failure, |
| 3519 Register instance, | 3520 Register instance, |
| 3520 Register end_address, | 3521 Register end_address, |
| 3521 Register temp1, | 3522 Register temp1, |
| 3522 Register temp2) { | 3523 Register temp2) { |
| 3523 if (FLAG_inline_alloc) { | 3524 if (FLAG_inline_alloc) { |
| 3524 // If this allocation is traced, program will jump to failure path | 3525 // If this allocation is traced, program will jump to failure path |
| 3525 // (i.e. the allocation stub) which will allocate the object and trace the | 3526 // (i.e. the allocation stub) which will allocate the object and trace the |
| 3526 // allocation call site. | 3527 // allocation call site. |
| 3527 MaybeTraceAllocation(cid, temp1, failure); | 3528 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, temp1, failure)); |
| 3528 Heap::Space space = Heap::SpaceForAllocation(cid); | 3529 Heap::Space space = Heap::SpaceForAllocation(cid); |
| 3529 ldr(temp1, Address(THR, Thread::heap_offset())); | 3530 ldr(temp1, Address(THR, Thread::heap_offset())); |
| 3530 // Potential new object start. | 3531 // Potential new object start. |
| 3531 ldr(instance, Address(temp1, Heap::TopOffset(space))); | 3532 ldr(instance, Address(temp1, Heap::TopOffset(space))); |
| 3532 AddImmediateSetFlags(end_address, instance, instance_size); | 3533 AddImmediateSetFlags(end_address, instance, instance_size); |
| 3533 b(failure, CS); // Branch if unsigned overflow. | 3534 b(failure, CS); // Branch if unsigned overflow. |
| 3534 | 3535 |
| 3535 // Check if the allocation fits into the remaining space. | 3536 // Check if the allocation fits into the remaining space. |
| 3536 // instance: potential new object start. | 3537 // instance: potential new object start. |
| 3537 // end_address: potential next object start. | 3538 // end_address: potential next object start. |
| 3538 ldr(temp2, Address(temp1, Heap::EndOffset(space))); | 3539 ldr(temp2, Address(temp1, Heap::EndOffset(space))); |
| 3539 cmp(end_address, Operand(temp2)); | 3540 cmp(end_address, Operand(temp2)); |
| 3540 b(failure, CS); | 3541 b(failure, CS); |
| 3541 | 3542 |
| 3542 LoadAllocationStatsAddress(temp2, cid); | 3543 NOT_IN_PRODUCT(LoadAllocationStatsAddress(temp2, cid)); |
| 3543 | 3544 |
| 3544 // Successfully allocated the object(s), now update top to point to | 3545 // Successfully allocated the object(s), now update top to point to |
| 3545 // next object start and initialize the object. | 3546 // next object start and initialize the object. |
| 3546 str(end_address, Address(temp1, Heap::TopOffset(space))); | 3547 str(end_address, Address(temp1, Heap::TopOffset(space))); |
| 3547 add(instance, instance, Operand(kHeapObjectTag)); | 3548 add(instance, instance, Operand(kHeapObjectTag)); |
| 3548 | 3549 |
| 3549 // Initialize the tags. | 3550 // Initialize the tags. |
| 3550 // instance: new object start as a tagged pointer. | 3551 // instance: new object start as a tagged pointer. |
| 3551 uword tags = 0; | 3552 uword tags = 0; |
| 3552 tags = RawObject::ClassIdTag::update(cid, tags); | 3553 tags = RawObject::ClassIdTag::update(cid, tags); |
| 3553 tags = RawObject::SizeTag::update(instance_size, tags); | 3554 tags = RawObject::SizeTag::update(instance_size, tags); |
| 3554 LoadImmediate(temp1, tags); | 3555 LoadImmediate(temp1, tags); |
| 3555 str(temp1, FieldAddress(instance, Array::tags_offset())); // Store tags. | 3556 str(temp1, FieldAddress(instance, Array::tags_offset())); // Store tags. |
| 3556 | 3557 |
| 3557 LoadImmediate(temp1, instance_size); | 3558 LoadImmediate(temp1, instance_size); |
| 3558 IncrementAllocationStatsWithSize(temp2, temp1, space); | 3559 NOT_IN_PRODUCT(IncrementAllocationStatsWithSize(temp2, temp1, space)); |
| 3559 } else { | 3560 } else { |
| 3560 b(failure); | 3561 b(failure); |
| 3561 } | 3562 } |
| 3562 } | 3563 } |
| 3563 | 3564 |
| 3564 | 3565 |
| 3565 void Assembler::Stop(const char* message) { | 3566 void Assembler::Stop(const char* message) { |
| 3566 if (FLAG_print_stop_message) { | 3567 if (FLAG_print_stop_message) { |
| 3567 PushList((1 << R0) | (1 << IP) | (1 << LR)); // Preserve R0, IP, LR. | 3568 PushList((1 << R0) | (1 << IP) | (1 << LR)); // Preserve R0, IP, LR. |
| 3568 LoadImmediate(R0, reinterpret_cast<int32_t>(message)); | 3569 LoadImmediate(R0, reinterpret_cast<int32_t>(message)); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3669 | 3670 |
| 3670 | 3671 |
| 3671 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3672 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
| 3672 ASSERT((0 <= reg) && (reg < kNumberOfFpuRegisters)); | 3673 ASSERT((0 <= reg) && (reg < kNumberOfFpuRegisters)); |
| 3673 return fpu_reg_names[reg]; | 3674 return fpu_reg_names[reg]; |
| 3674 } | 3675 } |
| 3675 | 3676 |
| 3676 } // namespace dart | 3677 } // namespace dart |
| 3677 | 3678 |
| 3678 #endif // defined TARGET_ARCH_ARM | 3679 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |