Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: runtime/vm/assembler_ia32.cc

Issue 1263513002: VM: Load allocation-top and -end via Thread. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fixed cc tests Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 2663 matching lines...) Expand 10 before | Expand all | Expand 10 after
2674 state_address = Address::Absolute( 2674 state_address = Address::Absolute(
2675 reinterpret_cast<uword>(*table_ptr) + state_offset); 2675 reinterpret_cast<uword>(*table_ptr) + state_offset);
2676 } else { 2676 } else {
2677 ASSERT(temp_reg != kNoRegister); 2677 ASSERT(temp_reg != kNoRegister);
2678 // temp_reg gets address of class table pointer. 2678 // temp_reg gets address of class table pointer.
2679 movl(temp_reg, 2679 movl(temp_reg,
2680 Address::Absolute(reinterpret_cast<uword>(table_ptr))); 2680 Address::Absolute(reinterpret_cast<uword>(table_ptr)));
2681 state_address = Address(temp_reg, state_offset); 2681 state_address = Address(temp_reg, state_offset);
2682 } 2682 }
2683 } else { 2683 } else {
2684 ASSERT(temp_reg != kNoRegister);
2684 LoadIsolate(temp_reg); 2685 LoadIsolate(temp_reg);
2685 intptr_t table_offset = 2686 intptr_t table_offset =
2686 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid); 2687 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
2687 movl(temp_reg, Address(temp_reg, table_offset)); 2688 movl(temp_reg, Address(temp_reg, table_offset));
2688 state_address = Address(temp_reg, state_offset); 2689 state_address = Address(temp_reg, state_offset);
2689 } 2690 }
2690 testb(state_address, Immediate(ClassHeapStats::TraceAllocationMask())); 2691 testb(state_address, Immediate(ClassHeapStats::TraceAllocationMask()));
2691 // We are tracing for this class, jump to the trace label which will use 2692 // We are tracing for this class, jump to the trace label which will use
2692 // the allocation stub. 2693 // the allocation stub.
2693 j(NOT_ZERO, trace, near_jump); 2694 j(NOT_ZERO, trace, near_jump);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2763 } 2764 }
2764 } 2765 }
2765 2766
2766 2767
2767 void Assembler::TryAllocate(const Class& cls, 2768 void Assembler::TryAllocate(const Class& cls,
2768 Label* failure, 2769 Label* failure,
2769 bool near_jump, 2770 bool near_jump,
2770 Register instance_reg, 2771 Register instance_reg,
2771 Register temp_reg) { 2772 Register temp_reg) {
2772 ASSERT(failure != NULL); 2773 ASSERT(failure != NULL);
2774 ASSERT(temp_reg != kNoRegister);
2773 if (FLAG_inline_alloc) { 2775 if (FLAG_inline_alloc) {
2774 // If this allocation is traced, program will jump to failure path 2776 // If this allocation is traced, program will jump to failure path
2775 // (i.e. the allocation stub) which will allocate the object and trace the 2777 // (i.e. the allocation stub) which will allocate the object and trace the
2776 // allocation call site. 2778 // allocation call site.
2777 MaybeTraceAllocation(cls.id(), temp_reg, failure, near_jump); 2779 MaybeTraceAllocation(cls.id(), temp_reg, failure, near_jump,
2778 Heap* heap = Isolate::Current()->heap(); 2780 /* inline_isolate = */ false);
2779 const intptr_t instance_size = cls.instance_size(); 2781 const intptr_t instance_size = cls.instance_size();
2780 Heap::Space space = heap->SpaceForAllocation(cls.id()); 2782 Heap::Space space = Heap::SpaceForAllocation(cls.id());
2781 movl(instance_reg, Address::Absolute(heap->TopAddress(space))); 2783 movl(temp_reg, Address(THR, Thread::heap_offset()));
2784 movl(instance_reg, Address(temp_reg, Heap::TopOffset(space)));
2782 addl(instance_reg, Immediate(instance_size)); 2785 addl(instance_reg, Immediate(instance_size));
2783 // instance_reg: potential next object start. 2786 // instance_reg: potential next object start.
2784 cmpl(instance_reg, Address::Absolute(heap->EndAddress(space))); 2787 cmpl(instance_reg, Address(temp_reg, Heap::EndOffset(space)));
2785 j(ABOVE_EQUAL, failure, near_jump); 2788 j(ABOVE_EQUAL, failure, near_jump);
2786 // Successfully allocated the object, now update top to point to 2789 // Successfully allocated the object, now update top to point to
2787 // next object start and store the class in the class field of object. 2790 // next object start and store the class in the class field of object.
2788 movl(Address::Absolute(heap->TopAddress(space)), instance_reg); 2791 movl(Address(temp_reg, Heap::TopOffset(space)), instance_reg);
2789 UpdateAllocationStats(cls.id(), temp_reg, space); 2792 UpdateAllocationStats(cls.id(), temp_reg, space,
2793 /* inline_isolate = */ false);
2790 ASSERT(instance_size >= kHeapObjectTag); 2794 ASSERT(instance_size >= kHeapObjectTag);
2791 subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); 2795 subl(instance_reg, Immediate(instance_size - kHeapObjectTag));
2792 uword tags = 0; 2796 uword tags = 0;
2793 tags = RawObject::SizeTag::update(instance_size, tags); 2797 tags = RawObject::SizeTag::update(instance_size, tags);
2794 ASSERT(cls.id() != kIllegalCid); 2798 ASSERT(cls.id() != kIllegalCid);
2795 tags = RawObject::ClassIdTag::update(cls.id(), tags); 2799 tags = RawObject::ClassIdTag::update(cls.id(), tags);
2796 movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); 2800 movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags));
2797 } else { 2801 } else {
2798 jmp(failure); 2802 jmp(failure);
2799 } 2803 }
2800 } 2804 }
2801 2805
2802 2806
2803 void Assembler::TryAllocateArray(intptr_t cid, 2807 void Assembler::TryAllocateArray(intptr_t cid,
2804 intptr_t instance_size, 2808 intptr_t instance_size,
2805 Label* failure, 2809 Label* failure,
2806 bool near_jump, 2810 bool near_jump,
2807 Register instance, 2811 Register instance,
2808 Register end_address) { 2812 Register end_address,
2813 Register temp_reg) {
2809 ASSERT(failure != NULL); 2814 ASSERT(failure != NULL);
2815 ASSERT(temp_reg != kNoRegister);
2810 if (FLAG_inline_alloc) { 2816 if (FLAG_inline_alloc) {
2811 // If this allocation is traced, program will jump to failure path 2817 // If this allocation is traced, program will jump to failure path
2812 // (i.e. the allocation stub) which will allocate the object and trace the 2818 // (i.e. the allocation stub) which will allocate the object and trace the
2813 // allocation call site. 2819 // allocation call site.
2814 MaybeTraceAllocation(cid, kNoRegister, failure, near_jump); 2820 MaybeTraceAllocation(cid, temp_reg, failure, near_jump,
2815 Isolate* isolate = Isolate::Current(); 2821 /* inline_isolate = */ false);
2816 Heap* heap = isolate->heap(); 2822 Heap::Space space = Heap::SpaceForAllocation(cid);
2817 Heap::Space space = heap->SpaceForAllocation(cid); 2823 movl(temp_reg, Address(THR, Thread::heap_offset()));
2818 movl(instance, Address::Absolute(heap->TopAddress(space))); 2824 movl(instance, Address(temp_reg, Heap::TopOffset(space)));
2819 movl(end_address, instance); 2825 movl(end_address, instance);
2820 2826
2821 addl(end_address, Immediate(instance_size)); 2827 addl(end_address, Immediate(instance_size));
2822 j(CARRY, failure); 2828 j(CARRY, failure);
2823 2829
2824 // Check if the allocation fits into the remaining space. 2830 // Check if the allocation fits into the remaining space.
2825 // EAX: potential new object start. 2831 // EAX: potential new object start.
2826 // EBX: potential next object start. 2832 // EBX: potential next object start.
2827 cmpl(end_address, Address::Absolute(heap->EndAddress(space))); 2833 cmpl(end_address, Address(temp_reg, Heap::EndOffset(space)));
2828 j(ABOVE_EQUAL, failure); 2834 j(ABOVE_EQUAL, failure);
2829 2835
2830 // Successfully allocated the object(s), now update top to point to 2836 // Successfully allocated the object(s), now update top to point to
2831 // next object start and initialize the object. 2837 // next object start and initialize the object.
2832 movl(Address::Absolute(heap->TopAddress(space)), end_address); 2838 movl(Address(temp_reg, Heap::TopOffset(space)), end_address);
2833 addl(instance, Immediate(kHeapObjectTag)); 2839 addl(instance, Immediate(kHeapObjectTag));
2834 UpdateAllocationStatsWithSize(cid, instance_size, kNoRegister, space); 2840 UpdateAllocationStatsWithSize(cid, instance_size, temp_reg, space,
2841 /* inline_isolate = */ false);
2835 2842
2836 // Initialize the tags. 2843 // Initialize the tags.
2837 uword tags = 0; 2844 uword tags = 0;
2838 tags = RawObject::ClassIdTag::update(cid, tags); 2845 tags = RawObject::ClassIdTag::update(cid, tags);
2839 tags = RawObject::SizeTag::update(instance_size, tags); 2846 tags = RawObject::SizeTag::update(instance_size, tags);
2840 movl(FieldAddress(instance, Object::tags_offset()), Immediate(tags)); 2847 movl(FieldAddress(instance, Object::tags_offset()), Immediate(tags));
2841 } else { 2848 } else {
2842 jmp(failure); 2849 jmp(failure);
2843 } 2850 }
2844 } 2851 }
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
3191 3198
3192 const char* Assembler::FpuRegisterName(FpuRegister reg) { 3199 const char* Assembler::FpuRegisterName(FpuRegister reg) {
3193 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); 3200 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters));
3194 return xmm_reg_names[reg]; 3201 return xmm_reg_names[reg];
3195 } 3202 }
3196 3203
3197 3204
3198 } // namespace dart 3205 } // namespace dart
3199 3206
3200 #endif // defined TARGET_ARCH_IA32 3207 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/assembler_ia32.h ('k') | runtime/vm/assembler_mips.cc » ('j') | runtime/vm/isolate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698