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

Side by Side Diff: runtime/vm/class_table.h

Issue 1213013002: Update Assembler::TryAllocate to support inline allocation tracing (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | runtime/vm/class_table.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #ifndef VM_CLASS_TABLE_H_ 5 #ifndef VM_CLASS_TABLE_H_
6 #define VM_CLASS_TABLE_H_ 6 #define VM_CLASS_TABLE_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/bitfield.h"
9 #include "vm/globals.h" 10 #include "vm/globals.h"
10 11
11 namespace dart { 12 namespace dart {
12 13
13 class Class; 14 class Class;
14 class ClassStats; 15 class ClassStats;
15 class JSONArray; 16 class JSONArray;
16 class JSONObject; 17 class JSONObject;
17 class JSONStream; 18 class JSONStream;
18 template<typename T> class MallocGrowableArray; 19 template<typename T> class MallocGrowableArray;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 OFFSET_OF(AllocStats<intptr_t>, old_count); 96 OFFSET_OF(AllocStats<intptr_t>, old_count);
96 } 97 }
97 static intptr_t allocated_size_since_gc_new_space_offset() { 98 static intptr_t allocated_size_since_gc_new_space_offset() {
98 return OFFSET_OF(ClassHeapStats, recent) + 99 return OFFSET_OF(ClassHeapStats, recent) +
99 OFFSET_OF(AllocStats<intptr_t>, new_size); 100 OFFSET_OF(AllocStats<intptr_t>, new_size);
100 } 101 }
101 static intptr_t allocated_size_since_gc_old_space_offset() { 102 static intptr_t allocated_size_since_gc_old_space_offset() {
102 return OFFSET_OF(ClassHeapStats, recent) + 103 return OFFSET_OF(ClassHeapStats, recent) +
103 OFFSET_OF(AllocStats<intptr_t>, old_size); 104 OFFSET_OF(AllocStats<intptr_t>, old_size);
104 } 105 }
106 static intptr_t state_offset() {
107 return OFFSET_OF(ClassHeapStats, state_);
108 }
109 static intptr_t TraceAllocationMask() {
110 return (1 << kTraceAllocationBit);
111 }
105 112
106 void Initialize(); 113 void Initialize();
107 void ResetAtNewGC(); 114 void ResetAtNewGC();
108 void ResetAtOldGC(); 115 void ResetAtOldGC();
109 void ResetAccumulator(); 116 void ResetAccumulator();
110 void UpdatePromotedAfterNewGC(); 117 void UpdatePromotedAfterNewGC();
111 void UpdateSize(intptr_t instance_size); 118 void UpdateSize(intptr_t instance_size);
112 void PrintToJSONObject(const Class& cls, JSONObject* obj) const; 119 void PrintToJSONObject(const Class& cls, JSONObject* obj) const;
113 void Verify(); 120 void Verify();
114 121
122 bool trace_allocation() const {
123 return TraceAllocationBit::decode(state_);
124 }
125
126 void set_trace_allocation(bool trace_allocation) {
127 state_ = TraceAllocationBit::update(trace_allocation, state_);
128 }
129
115 private: 130 private:
131 enum StateBits {
132 kTraceAllocationBit = 0,
133 };
134
135 class TraceAllocationBit : public BitField<bool, kTraceAllocationBit, 1> {};
136
116 // Recent old at start of last new GC (used to compute promoted_*). 137 // Recent old at start of last new GC (used to compute promoted_*).
117 intptr_t old_pre_new_gc_count_; 138 intptr_t old_pre_new_gc_count_;
118 intptr_t old_pre_new_gc_size_; 139 intptr_t old_pre_new_gc_size_;
140 intptr_t state_;
119 }; 141 };
120 142
121 143
122 class ClassTable { 144 class ClassTable {
123 public: 145 public:
124 ClassTable(); 146 ClassTable();
125 // Creates a shallow copy of the original class table for some read-only 147 // Creates a shallow copy of the original class table for some read-only
126 // access, without support for stats data. 148 // access, without support for stats data.
127 explicit ClassTable(ClassTable* original); 149 explicit ClassTable(ClassTable* original);
128 ~ClassTable(); 150 ~ClassTable();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 209 }
188 210
189 ClassHeapStats* StatsWithUpdatedSize(intptr_t cid); 211 ClassHeapStats* StatsWithUpdatedSize(intptr_t cid);
190 212
191 void AllocationProfilePrintJSON(JSONStream* stream); 213 void AllocationProfilePrintJSON(JSONStream* stream);
192 void ResetAllocationAccumulators(); 214 void ResetAllocationAccumulators();
193 215
194 // Deallocates table copies. Do not call during concurrent access to table. 216 // Deallocates table copies. Do not call during concurrent access to table.
195 void FreeOldTables(); 217 void FreeOldTables();
196 218
219 void TraceAllocationsFor(intptr_t cid, bool trace);
220
197 private: 221 private:
198 friend class MarkingVisitor; 222 friend class MarkingVisitor;
199 friend class ScavengerVisitor; 223 friend class ScavengerVisitor;
200 friend class ClassHeapStatsTestHelper; 224 friend class ClassHeapStatsTestHelper;
201 static const int initial_capacity_ = 512; 225 static const int initial_capacity_ = 512;
202 static const int capacity_increment_ = 256; 226 static const int capacity_increment_ = 256;
203 227
204 static bool ShouldUpdateSizeForClassId(intptr_t cid); 228 static bool ShouldUpdateSizeForClassId(intptr_t cid);
205 229
206 intptr_t top_; 230 intptr_t top_;
(...skipping 11 matching lines...) Expand all
218 ClassHeapStats* PreliminaryStatsAt(intptr_t cid); 242 ClassHeapStats* PreliminaryStatsAt(intptr_t cid);
219 void UpdateLiveOld(intptr_t cid, intptr_t size); 243 void UpdateLiveOld(intptr_t cid, intptr_t size);
220 void UpdateLiveNew(intptr_t cid, intptr_t size); 244 void UpdateLiveNew(intptr_t cid, intptr_t size);
221 245
222 DISALLOW_COPY_AND_ASSIGN(ClassTable); 246 DISALLOW_COPY_AND_ASSIGN(ClassTable);
223 }; 247 };
224 248
225 } // namespace dart 249 } // namespace dart
226 250
227 #endif // VM_CLASS_TABLE_H_ 251 #endif // VM_CLASS_TABLE_H_
OLDNEW
« no previous file with comments | « runtime/vm/assembler_x64.cc ('k') | runtime/vm/class_table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698