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

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

Issue 18051007: - Revert r24564 and r24563 due to unexplained malloc corruption. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/gc_marker.cc ('k') | runtime/vm/heap.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_HEAP_H_ 5 #ifndef VM_HEAP_H_
6 #define VM_HEAP_H_ 6 #define VM_HEAP_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/allocation.h" 9 #include "vm/allocation.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
11 #include "vm/globals.h" 11 #include "vm/globals.h"
12 #include "vm/pages.h" 12 #include "vm/pages.h"
13 #include "vm/scavenger.h" 13 #include "vm/scavenger.h"
14 #include "vm/weak_table.h"
15 14
16 namespace dart { 15 namespace dart {
17 16
18 // Forward declarations. 17 // Forward declarations.
19 class Isolate; 18 class Isolate;
20 class ObjectPointerVisitor; 19 class ObjectPointerVisitor;
21 class ObjectSet; 20 class ObjectSet;
22 class VirtualMemory; 21 class VirtualMemory;
23 22
24 DECLARE_FLAG(bool, verbose_gc); 23 DECLARE_FLAG(bool, verbose_gc);
25 DECLARE_FLAG(bool, verify_before_gc); 24 DECLARE_FLAG(bool, verify_before_gc);
26 DECLARE_FLAG(bool, verify_after_gc); 25 DECLARE_FLAG(bool, verify_after_gc);
27 DECLARE_FLAG(bool, gc_at_alloc); 26 DECLARE_FLAG(bool, gc_at_alloc);
28 27
29 class Heap { 28 class Heap {
30 public: 29 public:
31 enum Space { 30 enum Space {
32 kNew, 31 kNew,
33 kOld, 32 kOld,
34 kCode, 33 kCode,
35 }; 34 };
36 35
37 enum WeakSelector {
38 kPeers = 0,
39 kHashes,
40 kNumWeakSelectors
41 };
42
43 enum ApiCallbacks { 36 enum ApiCallbacks {
44 kIgnoreApiCallbacks, 37 kIgnoreApiCallbacks,
45 kInvokeApiCallbacks 38 kInvokeApiCallbacks
46 }; 39 };
47 40
48 enum GCReason { 41 enum GCReason {
49 kNewSpace, 42 kNewSpace,
50 kPromotionFailure, 43 kPromotionFailure,
51 kOldSpace, 44 kOldSpace,
52 kFull, 45 kFull,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 void StartEndAddress(uword* start, uword* end) const; 161 void StartEndAddress(uword* start, uword* end) const;
169 162
170 ObjectSet* CreateAllocatedObjectSet() const; 163 ObjectSet* CreateAllocatedObjectSet() const;
171 164
172 // Generates a profile of the current and VM isolate heaps. 165 // Generates a profile of the current and VM isolate heaps.
173 void Profile(Dart_FileWriteCallback callback, void* stream) const; 166 void Profile(Dart_FileWriteCallback callback, void* stream) const;
174 void ProfileToFile(const char* reason) const; 167 void ProfileToFile(const char* reason) const;
175 168
176 static const char* GCReasonToString(GCReason gc_reason); 169 static const char* GCReasonToString(GCReason gc_reason);
177 170
178 // Associate a peer with an object. A non-existent peer is equal to NULL. 171 // Associates a peer with an object. If an object has a peer, it is
179 void SetPeer(RawObject* raw_obj, void* peer) { 172 // replaced. A value of NULL disassociate an object from its peer.
180 SetWeakEntry(raw_obj, kPeers, reinterpret_cast<intptr_t>(peer)); 173 void SetPeer(RawObject* raw_obj, void* peer);
181 } 174
182 void* GetPeer(RawObject* raw_obj) const { 175 // Retrieves the peer associated with an object. Returns NULL if
183 return reinterpret_cast<void*>(GetWeakEntry(raw_obj, kPeers)); 176 // there is no association.
184 } 177 void* GetPeer(RawObject* raw_obj);
178
179 // Returns the number of objects with a peer.
185 int64_t PeerCount() const; 180 int64_t PeerCount() const;
186 181
187 // Associate an identity hashCode with an object. An non-existent hashCode
188 // is equal to 0.
189 void SetHash(RawObject* raw_obj, intptr_t hash) {
190 SetWeakEntry(raw_obj, kHashes, hash);
191 }
192 intptr_t GetHash(RawObject* raw_obj) const {
193 return GetWeakEntry(raw_obj, kHashes);
194 }
195 int64_t HashCount() const;
196
197 // Used by the GC algorithms to propagate weak entries.
198 intptr_t GetWeakEntry(RawObject* raw_obj, WeakSelector sel) const;
199 void SetWeakEntry(RawObject* raw_obj, WeakSelector sel, intptr_t val);
200
201 WeakTable* GetWeakTable(Space space, WeakSelector selector) const {
202 if (space == kNew) {
203 return new_weak_tables_[selector];
204 }
205 ASSERT(space ==kOld);
206 return old_weak_tables_[selector];
207 }
208 void SetWeakTable(Space space, WeakSelector selector, WeakTable* value) {
209 if (space == kNew) {
210 new_weak_tables_[selector] = value;
211 } else {
212 ASSERT(space == kOld);
213 old_weak_tables_[selector] = value;
214 }
215 }
216
217 // Stats collection. 182 // Stats collection.
218 void RecordTime(int id, int64_t micros) { 183 void RecordTime(int id, int64_t micros) {
219 ASSERT((id >= 0) && (id < GCStats::kDataEntries)); 184 ASSERT((id >= 0) && (id < GCStats::kDataEntries));
220 stats_.times_[id] = micros; 185 stats_.times_[id] = micros;
221 } 186 }
222 187
223 void RecordData(int id, intptr_t value) { 188 void RecordData(int id, intptr_t value) {
224 ASSERT((id >= 0) && (id < GCStats::kDataEntries)); 189 ASSERT((id >= 0) && (id < GCStats::kDataEntries));
225 stats_.data_[id] = value; 190 stats_.data_[id] = value;
226 } 191 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // GC stats collection. 239 // GC stats collection.
275 void RecordBeforeGC(Space space, GCReason reason); 240 void RecordBeforeGC(Space space, GCReason reason);
276 void RecordAfterGC(); 241 void RecordAfterGC();
277 void PrintStats(); 242 void PrintStats();
278 void UpdateObjectHistogram(); 243 void UpdateObjectHistogram();
279 244
280 // The different spaces used for allocation. 245 // The different spaces used for allocation.
281 Scavenger* new_space_; 246 Scavenger* new_space_;
282 PageSpace* old_space_; 247 PageSpace* old_space_;
283 248
284 WeakTable* new_weak_tables_[kNumWeakSelectors];
285 WeakTable* old_weak_tables_[kNumWeakSelectors];
286
287 // GC stats collection. 249 // GC stats collection.
288 GCStats stats_; 250 GCStats stats_;
289 251
290 // This heap is in read-only mode: No allocation is allowed. 252 // This heap is in read-only mode: No allocation is allowed.
291 bool read_only_; 253 bool read_only_;
292 254
293 // GC on the heap is in progress. 255 // GC on the heap is in progress.
294 bool gc_in_progress_; 256 bool gc_in_progress_;
295 257
296 friend class GCTestHelper; 258 friend class GCTestHelper;
(...skipping 24 matching lines...) Expand all
321 NoHeapGrowthControlScope(); 283 NoHeapGrowthControlScope();
322 ~NoHeapGrowthControlScope(); 284 ~NoHeapGrowthControlScope();
323 private: 285 private:
324 bool current_growth_controller_state_; 286 bool current_growth_controller_state_;
325 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); 287 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope);
326 }; 288 };
327 289
328 } // namespace dart 290 } // namespace dart
329 291
330 #endif // VM_HEAP_H_ 292 #endif // VM_HEAP_H_
OLDNEW
« no previous file with comments | « runtime/vm/gc_marker.cc ('k') | runtime/vm/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698