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 2861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2872 } | 2872 } |
2873 | 2873 |
2874 | 2874 |
2875 void Assembler::LeaveStubFrame() { | 2875 void Assembler::LeaveStubFrame() { |
2876 // Restore caller's PP register that was pushed in EnterStubFrame. | 2876 // Restore caller's PP register that was pushed in EnterStubFrame. |
2877 movq(PP, Address(RBP, (kSavedCallerPpSlotFromFp * kWordSize))); | 2877 movq(PP, Address(RBP, (kSavedCallerPpSlotFromFp * kWordSize))); |
2878 LeaveFrame(); | 2878 LeaveFrame(); |
2879 } | 2879 } |
2880 | 2880 |
2881 | 2881 |
| 2882 void Assembler::UpdateAllocationStats(intptr_t cid, |
| 2883 Heap::Space space) { |
| 2884 Register temp_reg = TMP; |
| 2885 ASSERT(cid > 0); |
| 2886 Isolate* isolate = Isolate::Current(); |
| 2887 ClassTable* class_table = isolate->class_table(); |
| 2888 if (cid < kNumPredefinedCids) { |
| 2889 const uword class_heap_stats_table_address = |
| 2890 class_table->PredefinedClassHeapStatsTableAddress(); |
| 2891 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 2892 const uword count_field_offset = (space == Heap::kNew) ? |
| 2893 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 2894 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 2895 movq(temp_reg, Immediate(class_heap_stats_table_address + class_offset)); |
| 2896 const Address& count_address = Address(temp_reg, count_field_offset); |
| 2897 incq(count_address); |
| 2898 } else { |
| 2899 ASSERT(temp_reg != kNoRegister); |
| 2900 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 2901 const uword count_field_offset = (space == Heap::kNew) ? |
| 2902 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 2903 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 2904 movq(temp_reg, Immediate(class_table->ClassStatsTableAddress())); |
| 2905 movq(temp_reg, Address(temp_reg, 0)); |
| 2906 incq(Address(temp_reg, class_offset + count_field_offset)); |
| 2907 } |
| 2908 } |
| 2909 |
| 2910 |
| 2911 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid, |
| 2912 Register size_reg, |
| 2913 Heap::Space space) { |
| 2914 Register temp_reg = TMP; |
| 2915 ASSERT(cid > 0); |
| 2916 Isolate* isolate = Isolate::Current(); |
| 2917 ClassTable* class_table = isolate->class_table(); |
| 2918 if (cid < kNumPredefinedCids) { |
| 2919 const uword class_heap_stats_table_address = |
| 2920 class_table->PredefinedClassHeapStatsTableAddress(); |
| 2921 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 2922 const uword count_field_offset = (space == Heap::kNew) ? |
| 2923 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 2924 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 2925 const uword size_field_offset = (space == Heap::kNew) ? |
| 2926 ClassHeapStats::allocated_size_since_gc_new_space_offset() : |
| 2927 ClassHeapStats::allocated_size_since_gc_old_space_offset(); |
| 2928 movq(temp_reg, Immediate(class_heap_stats_table_address + class_offset)); |
| 2929 const Address& count_address = Address(temp_reg, count_field_offset); |
| 2930 const Address& size_address = Address(temp_reg, size_field_offset); |
| 2931 incq(count_address); |
| 2932 addq(size_address, size_reg); |
| 2933 } else { |
| 2934 ASSERT(temp_reg != kNoRegister); |
| 2935 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 2936 const uword count_field_offset = (space == Heap::kNew) ? |
| 2937 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 2938 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 2939 const uword size_field_offset = (space == Heap::kNew) ? |
| 2940 ClassHeapStats::allocated_size_since_gc_new_space_offset() : |
| 2941 ClassHeapStats::allocated_size_since_gc_old_space_offset(); |
| 2942 movq(temp_reg, Immediate(class_table->ClassStatsTableAddress())); |
| 2943 movq(temp_reg, Address(temp_reg, 0)); |
| 2944 incq(Address(temp_reg, class_offset + count_field_offset)); |
| 2945 addq(Address(temp_reg, class_offset + size_field_offset), size_reg); |
| 2946 } |
| 2947 } |
| 2948 |
| 2949 |
2882 void Assembler::TryAllocate(const Class& cls, | 2950 void Assembler::TryAllocate(const Class& cls, |
2883 Label* failure, | 2951 Label* failure, |
2884 bool near_jump, | 2952 bool near_jump, |
2885 Register instance_reg, | 2953 Register instance_reg, |
2886 Register pp) { | 2954 Register pp) { |
2887 ASSERT(failure != NULL); | 2955 ASSERT(failure != NULL); |
2888 if (FLAG_inline_alloc) { | 2956 if (FLAG_inline_alloc) { |
2889 Heap* heap = Isolate::Current()->heap(); | 2957 Heap* heap = Isolate::Current()->heap(); |
2890 const intptr_t instance_size = cls.instance_size(); | 2958 const intptr_t instance_size = cls.instance_size(); |
2891 LoadImmediate(TMP, Immediate(heap->TopAddress()), pp); | 2959 LoadImmediate(TMP, Immediate(heap->TopAddress()), pp); |
2892 movq(instance_reg, Address(TMP, 0)); | 2960 movq(instance_reg, Address(TMP, 0)); |
2893 AddImmediate(instance_reg, Immediate(instance_size), pp); | 2961 AddImmediate(instance_reg, Immediate(instance_size), pp); |
2894 // instance_reg: potential next object start. | 2962 // instance_reg: potential next object start. |
2895 LoadImmediate(TMP, Immediate(heap->EndAddress()), pp); | 2963 LoadImmediate(TMP, Immediate(heap->EndAddress()), pp); |
2896 cmpq(instance_reg, Address(TMP, 0)); | 2964 cmpq(instance_reg, Address(TMP, 0)); |
2897 j(ABOVE_EQUAL, failure, near_jump); | 2965 j(ABOVE_EQUAL, failure, near_jump); |
2898 // Successfully allocated the object, now update top to point to | 2966 // Successfully allocated the object, now update top to point to |
2899 // next object start and store the class in the class field of object. | 2967 // next object start and store the class in the class field of object. |
2900 LoadImmediate(TMP, Immediate(heap->TopAddress()), pp); | 2968 LoadImmediate(TMP, Immediate(heap->TopAddress()), pp); |
2901 movq(Address(TMP, 0), instance_reg); | 2969 movq(Address(TMP, 0), instance_reg); |
| 2970 UpdateAllocationStats(cls.id()); |
2902 ASSERT(instance_size >= kHeapObjectTag); | 2971 ASSERT(instance_size >= kHeapObjectTag); |
2903 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size), pp); | 2972 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size), pp); |
2904 uword tags = 0; | 2973 uword tags = 0; |
2905 tags = RawObject::SizeTag::update(instance_size, tags); | 2974 tags = RawObject::SizeTag::update(instance_size, tags); |
2906 ASSERT(cls.id() != kIllegalCid); | 2975 ASSERT(cls.id() != kIllegalCid); |
2907 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 2976 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
2908 LoadImmediate(FieldAddress(instance_reg, Object::tags_offset()), | 2977 LoadImmediate(FieldAddress(instance_reg, Object::tags_offset()), |
2909 Immediate(tags), pp); | 2978 Immediate(tags), pp); |
2910 } else { | 2979 } else { |
2911 jmp(failure); | 2980 jmp(failure); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3099 | 3168 |
3100 | 3169 |
3101 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3170 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3102 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3171 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
3103 return xmm_reg_names[reg]; | 3172 return xmm_reg_names[reg]; |
3104 } | 3173 } |
3105 | 3174 |
3106 } // namespace dart | 3175 } // namespace dart |
3107 | 3176 |
3108 #endif // defined TARGET_ARCH_X64 | 3177 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |