OLD | NEW |
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" |
(...skipping 24 matching lines...) Expand all Loading... |
35 kNew, | 35 kNew, |
36 kOld, | 36 kOld, |
37 kCode, | 37 kCode, |
38 // TODO(koda): Harmonize all old-space allocation and get rid of this. | 38 // TODO(koda): Harmonize all old-space allocation and get rid of this. |
39 kPretenured, | 39 kPretenured, |
40 }; | 40 }; |
41 | 41 |
42 enum WeakSelector { | 42 enum WeakSelector { |
43 kPeers = 0, | 43 kPeers = 0, |
44 kHashes, | 44 kHashes, |
| 45 kObjectIds, |
45 kNumWeakSelectors | 46 kNumWeakSelectors |
46 }; | 47 }; |
47 | 48 |
48 enum ApiCallbacks { | 49 enum ApiCallbacks { |
49 kIgnoreApiCallbacks, | 50 kIgnoreApiCallbacks, |
50 kInvokeApiCallbacks | 51 kInvokeApiCallbacks |
51 }; | 52 }; |
52 | 53 |
53 enum GCReason { | 54 enum GCReason { |
54 kNewSpace, | 55 kNewSpace, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // Associate an identity hashCode with an object. An non-existent hashCode | 183 // Associate an identity hashCode with an object. An non-existent hashCode |
183 // is equal to 0. | 184 // is equal to 0. |
184 void SetHash(RawObject* raw_obj, intptr_t hash) { | 185 void SetHash(RawObject* raw_obj, intptr_t hash) { |
185 SetWeakEntry(raw_obj, kHashes, hash); | 186 SetWeakEntry(raw_obj, kHashes, hash); |
186 } | 187 } |
187 intptr_t GetHash(RawObject* raw_obj) const { | 188 intptr_t GetHash(RawObject* raw_obj) const { |
188 return GetWeakEntry(raw_obj, kHashes); | 189 return GetWeakEntry(raw_obj, kHashes); |
189 } | 190 } |
190 int64_t HashCount() const; | 191 int64_t HashCount() const; |
191 | 192 |
| 193 // Associate an id with an object (used when serializing an object). |
| 194 // A non-existant id is equal to 0. |
| 195 void SetObjectId(RawObject* raw_obj, intptr_t object_id) { |
| 196 SetWeakEntry(raw_obj, kObjectIds, object_id); |
| 197 } |
| 198 intptr_t GetObjectId(RawObject* raw_obj) const { |
| 199 return GetWeakEntry(raw_obj, kObjectIds); |
| 200 } |
| 201 int64_t ObjectIdCount() const; |
| 202 void ResetObjectIdTable(); |
| 203 |
192 // Used by the GC algorithms to propagate weak entries. | 204 // Used by the GC algorithms to propagate weak entries. |
193 intptr_t GetWeakEntry(RawObject* raw_obj, WeakSelector sel) const; | 205 intptr_t GetWeakEntry(RawObject* raw_obj, WeakSelector sel) const; |
194 void SetWeakEntry(RawObject* raw_obj, WeakSelector sel, intptr_t val); | 206 void SetWeakEntry(RawObject* raw_obj, WeakSelector sel, intptr_t val); |
195 | 207 |
196 WeakTable* GetWeakTable(Space space, WeakSelector selector) const { | 208 WeakTable* GetWeakTable(Space space, WeakSelector selector) const { |
197 if (space == kNew) { | 209 if (space == kNew) { |
198 return new_weak_tables_[selector]; | 210 return new_weak_tables_[selector]; |
199 } | 211 } |
200 ASSERT(space ==kOld); | 212 ASSERT(space ==kOld); |
201 return old_weak_tables_[selector]; | 213 return old_weak_tables_[selector]; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 // Note: During this scope, the code pages are non-executable. | 377 // Note: During this scope, the code pages are non-executable. |
366 class WritableVMIsolateScope : StackResource { | 378 class WritableVMIsolateScope : StackResource { |
367 public: | 379 public: |
368 explicit WritableVMIsolateScope(Thread* thread); | 380 explicit WritableVMIsolateScope(Thread* thread); |
369 ~WritableVMIsolateScope(); | 381 ~WritableVMIsolateScope(); |
370 }; | 382 }; |
371 | 383 |
372 } // namespace dart | 384 } // namespace dart |
373 | 385 |
374 #endif // VM_HEAP_H_ | 386 #endif // VM_HEAP_H_ |
OLD | NEW |