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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
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 2612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2623 Register temp_reg) { | 2623 Register temp_reg) { |
2624 ASSERT(failure != NULL); | 2624 ASSERT(failure != NULL); |
2625 ASSERT(temp_reg != kNoRegister); | 2625 ASSERT(temp_reg != kNoRegister); |
2626 if (FLAG_inline_alloc) { | 2626 if (FLAG_inline_alloc) { |
2627 // If this allocation is traced, program will jump to failure path | 2627 // If this allocation is traced, program will jump to failure path |
2628 // (i.e. the allocation stub) which will allocate the object and trace the | 2628 // (i.e. the allocation stub) which will allocate the object and trace the |
2629 // allocation call site. | 2629 // allocation call site. |
2630 NOT_IN_PRODUCT( | 2630 NOT_IN_PRODUCT( |
2631 MaybeTraceAllocation(cls.id(), temp_reg, failure, near_jump)); | 2631 MaybeTraceAllocation(cls.id(), temp_reg, failure, near_jump)); |
2632 const intptr_t instance_size = cls.instance_size(); | 2632 const intptr_t instance_size = cls.instance_size(); |
2633 Heap::Space space = Heap::kNew; | 2633 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
2634 movl(temp_reg, Address(THR, Thread::heap_offset())); | 2634 movl(instance_reg, Address(THR, Thread::top_offset())); |
2635 movl(instance_reg, Address(temp_reg, Heap::TopOffset(space))); | |
2636 addl(instance_reg, Immediate(instance_size)); | 2635 addl(instance_reg, Immediate(instance_size)); |
2637 // instance_reg: potential next object start. | 2636 // instance_reg: potential next object start. |
2638 cmpl(instance_reg, Address(temp_reg, Heap::EndOffset(space))); | 2637 cmpl(instance_reg, Address(THR, Thread::end_offset())); |
2639 j(ABOVE_EQUAL, failure, near_jump); | 2638 j(ABOVE_EQUAL, failure, near_jump); |
2640 // Successfully allocated the object, now update top to point to | 2639 // Successfully allocated the object, now update top to point to |
2641 // next object start and store the class in the class field of object. | 2640 // next object start and store the class in the class field of object. |
2642 movl(Address(temp_reg, Heap::TopOffset(space)), instance_reg); | 2641 movl(Address(THR, Thread::top_offset()), instance_reg); |
2643 NOT_IN_PRODUCT(UpdateAllocationStats(cls.id(), temp_reg, space)); | 2642 NOT_IN_PRODUCT(UpdateAllocationStats(cls.id(), temp_reg, space)); |
2644 ASSERT(instance_size >= kHeapObjectTag); | 2643 ASSERT(instance_size >= kHeapObjectTag); |
2645 subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); | 2644 subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); |
2646 uint32_t tags = 0; | 2645 uint32_t tags = 0; |
2647 tags = RawObject::SizeTag::update(instance_size, tags); | 2646 tags = RawObject::SizeTag::update(instance_size, tags); |
2648 ASSERT(cls.id() != kIllegalCid); | 2647 ASSERT(cls.id() != kIllegalCid); |
2649 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 2648 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
2650 movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); | 2649 movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); |
2651 } else { | 2650 } else { |
2652 jmp(failure); | 2651 jmp(failure); |
2653 } | 2652 } |
2654 } | 2653 } |
2655 | 2654 |
2656 | 2655 |
2657 void Assembler::TryAllocateArray(intptr_t cid, | 2656 void Assembler::TryAllocateArray(intptr_t cid, |
2658 intptr_t instance_size, | 2657 intptr_t instance_size, |
2659 Label* failure, | 2658 Label* failure, |
2660 bool near_jump, | 2659 bool near_jump, |
2661 Register instance, | 2660 Register instance, |
2662 Register end_address, | 2661 Register end_address, |
2663 Register temp_reg) { | 2662 Register temp_reg) { |
2664 ASSERT(failure != NULL); | 2663 ASSERT(failure != NULL); |
2665 ASSERT(temp_reg != kNoRegister); | 2664 ASSERT(temp_reg != kNoRegister); |
2666 if (FLAG_inline_alloc) { | 2665 if (FLAG_inline_alloc) { |
2667 // If this allocation is traced, program will jump to failure path | 2666 // If this allocation is traced, program will jump to failure path |
2668 // (i.e. the allocation stub) which will allocate the object and trace the | 2667 // (i.e. the allocation stub) which will allocate the object and trace the |
2669 // allocation call site. | 2668 // allocation call site. |
2670 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, temp_reg, failure, near_jump)); | 2669 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, temp_reg, failure, near_jump)); |
2671 Heap::Space space = Heap::kNew; | 2670 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
2672 movl(temp_reg, Address(THR, Thread::heap_offset())); | 2671 movl(instance, Address(THR, Thread::top_offset())); |
2673 movl(instance, Address(temp_reg, Heap::TopOffset(space))); | |
2674 movl(end_address, instance); | 2672 movl(end_address, instance); |
2675 | 2673 |
2676 addl(end_address, Immediate(instance_size)); | 2674 addl(end_address, Immediate(instance_size)); |
2677 j(CARRY, failure); | 2675 j(CARRY, failure); |
2678 | 2676 |
2679 // Check if the allocation fits into the remaining space. | 2677 // Check if the allocation fits into the remaining space. |
2680 // EAX: potential new object start. | 2678 // EAX: potential new object start. |
2681 // EBX: potential next object start. | 2679 // EBX: potential next object start. |
2682 cmpl(end_address, Address(temp_reg, Heap::EndOffset(space))); | 2680 cmpl(end_address, Address(THR, Thread::end_offset())); |
2683 j(ABOVE_EQUAL, failure); | 2681 j(ABOVE_EQUAL, failure); |
2684 | 2682 |
2685 // Successfully allocated the object(s), now update top to point to | 2683 // Successfully allocated the object(s), now update top to point to |
2686 // next object start and initialize the object. | 2684 // next object start and initialize the object. |
2687 movl(Address(temp_reg, Heap::TopOffset(space)), end_address); | 2685 movl(Address(THR, Thread::top_offset()), end_address); |
2688 addl(instance, Immediate(kHeapObjectTag)); | 2686 addl(instance, Immediate(kHeapObjectTag)); |
2689 NOT_IN_PRODUCT( | 2687 NOT_IN_PRODUCT( |
2690 UpdateAllocationStatsWithSize(cid, instance_size, temp_reg, space)); | 2688 UpdateAllocationStatsWithSize(cid, instance_size, temp_reg, space)); |
2691 | 2689 |
2692 // Initialize the tags. | 2690 // Initialize the tags. |
2693 uint32_t tags = 0; | 2691 uint32_t tags = 0; |
2694 tags = RawObject::ClassIdTag::update(cid, tags); | 2692 tags = RawObject::ClassIdTag::update(cid, tags); |
2695 tags = RawObject::SizeTag::update(instance_size, tags); | 2693 tags = RawObject::SizeTag::update(instance_size, tags); |
2696 movl(FieldAddress(instance, Object::tags_offset()), Immediate(tags)); | 2694 movl(FieldAddress(instance, Object::tags_offset()), Immediate(tags)); |
2697 } else { | 2695 } else { |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3022 | 3020 |
3023 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3021 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3024 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3022 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
3025 return xmm_reg_names[reg]; | 3023 return xmm_reg_names[reg]; |
3026 } | 3024 } |
3027 | 3025 |
3028 | 3026 |
3029 } // namespace dart | 3027 } // namespace dart |
3030 | 3028 |
3031 #endif // defined TARGET_ARCH_IA32 | 3029 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |