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/code_generator.h" | 9 #include "vm/code_generator.h" |
10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
(...skipping 2665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2676 const uword size_field_offset = (space == Heap::kNew) ? | 2676 const uword size_field_offset = (space == Heap::kNew) ? |
2677 ClassHeapStats::allocated_size_since_gc_new_space_offset() : | 2677 ClassHeapStats::allocated_size_since_gc_new_space_offset() : |
2678 ClassHeapStats::allocated_size_since_gc_old_space_offset(); | 2678 ClassHeapStats::allocated_size_since_gc_old_space_offset(); |
2679 *count_address = Address::Absolute( | 2679 *count_address = Address::Absolute( |
2680 class_heap_stats_table_address + class_offset + count_field_offset); | 2680 class_heap_stats_table_address + class_offset + count_field_offset); |
2681 *size_address = Address::Absolute( | 2681 *size_address = Address::Absolute( |
2682 class_heap_stats_table_address + class_offset + size_field_offset); | 2682 class_heap_stats_table_address + class_offset + size_field_offset); |
2683 } | 2683 } |
2684 | 2684 |
2685 | 2685 |
2686 static void ComputeHeapStatsStateAddressForCid(intptr_t cid, | |
2687 Address* state_address) { | |
2688 ASSERT(cid < kNumPredefinedCids); | |
2689 Isolate* isolate = Isolate::Current(); | |
2690 ClassTable* class_table = isolate->class_table(); | |
2691 const uword class_heap_stats_table_address = | |
2692 class_table->PredefinedClassHeapStatsTableAddress(); | |
2693 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT | |
2694 const uword state_offset = ClassHeapStats::state_offset(); | |
2695 *state_address = Address::Absolute(class_heap_stats_table_address + | |
2696 class_offset + | |
2697 state_offset); | |
2698 } | |
2699 | |
2700 | |
2701 void Assembler::MaybeTraceAllocation(intptr_t cid, | |
2702 Register temp_reg, | |
2703 Label* failure, | |
2704 bool near_jump) { | |
2705 ASSERT(cid > 0); | |
2706 Address state_address(kNoRegister, 0); | |
2707 if (cid < kNumPredefinedCids) { | |
2708 ComputeHeapStatsStateAddressForCid(cid, &state_address); | |
2709 } else { | |
2710 ASSERT(temp_reg != kNoRegister); | |
2711 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT | |
2712 const uword state_offset = ClassHeapStats::state_offset(); | |
2713 // temp_reg gets address of class table pointer. | |
2714 ClassTable* class_table = Isolate::Current()->class_table(); | |
2715 movl(temp_reg, Address::Absolute(class_table->ClassStatsTableAddress())); | |
2716 state_address = Address(temp_reg, class_offset + state_offset); | |
2717 } | |
2718 testb(state_address, Immediate(ClassHeapStats::TraceAllocationMask())); | |
Florian Schneider
2015/07/07 12:43:21
state_ is a intptr_t, and you're using testb. Even
Cutch
2015/07/09 23:37:33
I'd rather not change the size of the state_ field
| |
2719 // We are tracing for this class, jump to the failure case which will use | |
2720 // the allocation stub. | |
2721 j(NOT_ZERO, failure, near_jump); | |
2722 } | |
2723 | |
2724 | |
2686 void Assembler::UpdateAllocationStats(intptr_t cid, | 2725 void Assembler::UpdateAllocationStats(intptr_t cid, |
2687 Register temp_reg, | 2726 Register temp_reg, |
2688 Heap::Space space) { | 2727 Heap::Space space) { |
2689 ASSERT(cid > 0); | 2728 ASSERT(cid > 0); |
2690 if (cid < kNumPredefinedCids) { | 2729 if (cid < kNumPredefinedCids) { |
2691 Address count_address(kNoRegister, 0), size_address(kNoRegister, 0); | 2730 Address count_address(kNoRegister, 0), size_address(kNoRegister, 0); |
2692 ComputeCounterAddressesForCid(cid, space, &count_address, &size_address); | 2731 ComputeCounterAddressesForCid(cid, space, &count_address, &size_address); |
2693 incl(count_address); | 2732 incl(count_address); |
2694 } else { | 2733 } else { |
2695 ASSERT(temp_reg != kNoRegister); | 2734 ASSERT(temp_reg != kNoRegister); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2732 } | 2771 } |
2733 | 2772 |
2734 | 2773 |
2735 void Assembler::TryAllocate(const Class& cls, | 2774 void Assembler::TryAllocate(const Class& cls, |
2736 Label* failure, | 2775 Label* failure, |
2737 bool near_jump, | 2776 bool near_jump, |
2738 Register instance_reg, | 2777 Register instance_reg, |
2739 Register temp_reg) { | 2778 Register temp_reg) { |
2740 ASSERT(failure != NULL); | 2779 ASSERT(failure != NULL); |
2741 if (FLAG_inline_alloc) { | 2780 if (FLAG_inline_alloc) { |
2781 // If this allocation is traced, program will jump to failure path | |
2782 // (i.e. the allocation stub) which will allocate the object and trace the | |
2783 // allocation call site. | |
2784 MaybeTraceAllocation(cls.id(), temp_reg, failure, near_jump); | |
2742 Heap* heap = Isolate::Current()->heap(); | 2785 Heap* heap = Isolate::Current()->heap(); |
2743 const intptr_t instance_size = cls.instance_size(); | 2786 const intptr_t instance_size = cls.instance_size(); |
2744 Heap::Space space = heap->SpaceForAllocation(cls.id()); | 2787 Heap::Space space = heap->SpaceForAllocation(cls.id()); |
2745 movl(instance_reg, Address::Absolute(heap->TopAddress(space))); | 2788 movl(instance_reg, Address::Absolute(heap->TopAddress(space))); |
2746 addl(instance_reg, Immediate(instance_size)); | 2789 addl(instance_reg, Immediate(instance_size)); |
2747 // instance_reg: potential next object start. | 2790 // instance_reg: potential next object start. |
2748 cmpl(instance_reg, Address::Absolute(heap->EndAddress(space))); | 2791 cmpl(instance_reg, Address::Absolute(heap->EndAddress(space))); |
2749 j(ABOVE_EQUAL, failure, near_jump); | 2792 j(ABOVE_EQUAL, failure, near_jump); |
2750 // Successfully allocated the object, now update top to point to | 2793 // Successfully allocated the object, now update top to point to |
2751 // next object start and store the class in the class field of object. | 2794 // next object start and store the class in the class field of object. |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3150 | 3193 |
3151 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3194 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3152 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3195 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
3153 return xmm_reg_names[reg]; | 3196 return xmm_reg_names[reg]; |
3154 } | 3197 } |
3155 | 3198 |
3156 | 3199 |
3157 } // namespace dart | 3200 } // namespace dart |
3158 | 3201 |
3159 #endif // defined TARGET_ARCH_IA32 | 3202 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |