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" | 5 #include "vm/globals.h" |
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/heap.h" | 9 #include "vm/heap.h" |
10 #include "vm/memory_region.h" | 10 #include "vm/memory_region.h" |
(...skipping 2877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2888 } | 2888 } |
2889 | 2889 |
2890 | 2890 |
2891 void Assembler::LeaveStubFrame() { | 2891 void Assembler::LeaveStubFrame() { |
2892 // Restore caller's PP register that was pushed in EnterStubFrame. | 2892 // Restore caller's PP register that was pushed in EnterStubFrame. |
2893 movq(PP, Address(RBP, (kSavedCallerPpSlotFromFp * kWordSize))); | 2893 movq(PP, Address(RBP, (kSavedCallerPpSlotFromFp * kWordSize))); |
2894 LeaveFrame(); | 2894 LeaveFrame(); |
2895 } | 2895 } |
2896 | 2896 |
2897 | 2897 |
| 2898 void Assembler::UpdateAllocationStats(intptr_t cid, |
| 2899 Heap::Space space) { |
| 2900 Register temp_reg = TMP; |
| 2901 ASSERT(cid > 0); |
| 2902 Isolate* isolate = Isolate::Current(); |
| 2903 ClassTable* class_table = isolate->class_table(); |
| 2904 if (cid < kNumPredefinedCids) { |
| 2905 const uword class_heap_stats_table_address = |
| 2906 class_table->PredefinedClassHeapStatsTableAddress(); |
| 2907 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 2908 const uword count_field_offset = (space == Heap::kNew) ? |
| 2909 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 2910 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 2911 movq(temp_reg, Immediate(class_heap_stats_table_address + class_offset)); |
| 2912 const Address& count_address = Address(temp_reg, count_field_offset); |
| 2913 incq(count_address); |
| 2914 } else { |
| 2915 ASSERT(temp_reg != kNoRegister); |
| 2916 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 2917 const uword count_field_offset = (space == Heap::kNew) ? |
| 2918 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 2919 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 2920 movq(temp_reg, Immediate(class_table->ClassStatsTableAddress())); |
| 2921 movq(temp_reg, Address(temp_reg, 0)); |
| 2922 incq(Address(temp_reg, class_offset + count_field_offset)); |
| 2923 } |
| 2924 } |
| 2925 |
| 2926 |
| 2927 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid, |
| 2928 Register size_reg, |
| 2929 Heap::Space space) { |
| 2930 Register temp_reg = TMP; |
| 2931 ASSERT(cid > 0); |
| 2932 Isolate* isolate = Isolate::Current(); |
| 2933 ClassTable* class_table = isolate->class_table(); |
| 2934 if (cid < kNumPredefinedCids) { |
| 2935 const uword class_heap_stats_table_address = |
| 2936 class_table->PredefinedClassHeapStatsTableAddress(); |
| 2937 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 2938 const uword count_field_offset = (space == Heap::kNew) ? |
| 2939 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 2940 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 2941 const uword size_field_offset = (space == Heap::kNew) ? |
| 2942 ClassHeapStats::allocated_size_since_gc_new_space_offset() : |
| 2943 ClassHeapStats::allocated_size_since_gc_old_space_offset(); |
| 2944 movq(temp_reg, Immediate(class_heap_stats_table_address + class_offset)); |
| 2945 const Address& count_address = Address(temp_reg, count_field_offset); |
| 2946 const Address& size_address = Address(temp_reg, size_field_offset); |
| 2947 incq(count_address); |
| 2948 addq(size_address, size_reg); |
| 2949 } else { |
| 2950 ASSERT(temp_reg != kNoRegister); |
| 2951 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 2952 const uword count_field_offset = (space == Heap::kNew) ? |
| 2953 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 2954 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 2955 const uword size_field_offset = (space == Heap::kNew) ? |
| 2956 ClassHeapStats::allocated_size_since_gc_new_space_offset() : |
| 2957 ClassHeapStats::allocated_size_since_gc_old_space_offset(); |
| 2958 movq(temp_reg, Immediate(class_table->ClassStatsTableAddress())); |
| 2959 movq(temp_reg, Address(temp_reg, 0)); |
| 2960 incq(Address(temp_reg, class_offset + count_field_offset)); |
| 2961 addq(Address(temp_reg, class_offset + size_field_offset), size_reg); |
| 2962 } |
| 2963 } |
| 2964 |
| 2965 |
2898 void Assembler::TryAllocate(const Class& cls, | 2966 void Assembler::TryAllocate(const Class& cls, |
2899 Label* failure, | 2967 Label* failure, |
2900 bool near_jump, | 2968 bool near_jump, |
2901 Register instance_reg, | 2969 Register instance_reg, |
2902 Register pp) { | 2970 Register pp) { |
2903 ASSERT(failure != NULL); | 2971 ASSERT(failure != NULL); |
2904 if (FLAG_inline_alloc) { | 2972 if (FLAG_inline_alloc) { |
2905 Heap* heap = Isolate::Current()->heap(); | 2973 Heap* heap = Isolate::Current()->heap(); |
2906 const intptr_t instance_size = cls.instance_size(); | 2974 const intptr_t instance_size = cls.instance_size(); |
2907 LoadImmediate(TMP, Immediate(heap->TopAddress()), pp); | 2975 LoadImmediate(TMP, Immediate(heap->TopAddress()), pp); |
2908 movq(instance_reg, Address(TMP, 0)); | 2976 movq(instance_reg, Address(TMP, 0)); |
2909 AddImmediate(instance_reg, Immediate(instance_size), pp); | 2977 AddImmediate(instance_reg, Immediate(instance_size), pp); |
2910 // instance_reg: potential next object start. | 2978 // instance_reg: potential next object start. |
2911 LoadImmediate(TMP, Immediate(heap->EndAddress()), pp); | 2979 LoadImmediate(TMP, Immediate(heap->EndAddress()), pp); |
2912 cmpq(instance_reg, Address(TMP, 0)); | 2980 cmpq(instance_reg, Address(TMP, 0)); |
2913 j(ABOVE_EQUAL, failure, near_jump); | 2981 j(ABOVE_EQUAL, failure, near_jump); |
2914 // Successfully allocated the object, now update top to point to | 2982 // Successfully allocated the object, now update top to point to |
2915 // next object start and store the class in the class field of object. | 2983 // next object start and store the class in the class field of object. |
2916 LoadImmediate(TMP, Immediate(heap->TopAddress()), pp); | 2984 LoadImmediate(TMP, Immediate(heap->TopAddress()), pp); |
2917 movq(Address(TMP, 0), instance_reg); | 2985 movq(Address(TMP, 0), instance_reg); |
| 2986 UpdateAllocationStats(cls.id()); |
2918 ASSERT(instance_size >= kHeapObjectTag); | 2987 ASSERT(instance_size >= kHeapObjectTag); |
2919 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size), pp); | 2988 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size), pp); |
2920 uword tags = 0; | 2989 uword tags = 0; |
2921 tags = RawObject::SizeTag::update(instance_size, tags); | 2990 tags = RawObject::SizeTag::update(instance_size, tags); |
2922 ASSERT(cls.id() != kIllegalCid); | 2991 ASSERT(cls.id() != kIllegalCid); |
2923 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 2992 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
2924 LoadImmediate(FieldAddress(instance_reg, Object::tags_offset()), | 2993 LoadImmediate(FieldAddress(instance_reg, Object::tags_offset()), |
2925 Immediate(tags), pp); | 2994 Immediate(tags), pp); |
2926 } else { | 2995 } else { |
2927 jmp(failure); | 2996 jmp(failure); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3115 | 3184 |
3116 | 3185 |
3117 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3186 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3118 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3187 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
3119 return xmm_reg_names[reg]; | 3188 return xmm_reg_names[reg]; |
3120 } | 3189 } |
3121 | 3190 |
3122 } // namespace dart | 3191 } // namespace dart |
3123 | 3192 |
3124 #endif // defined TARGET_ARCH_X64 | 3193 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |