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

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

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

Powered by Google App Engine
This is Rietveld 408576698