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 RUNTIME_VM_HEAP_H_ | 5 #ifndef RUNTIME_VM_HEAP_H_ |
6 #define RUNTIME_VM_HEAP_H_ | 6 #define RUNTIME_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 15 matching lines...) Expand all Loading... |
26 class VirtualMemory; | 26 class VirtualMemory; |
27 | 27 |
28 class Heap { | 28 class Heap { |
29 public: | 29 public: |
30 enum Space { | 30 enum Space { |
31 kNew, | 31 kNew, |
32 kOld, | 32 kOld, |
33 kCode, | 33 kCode, |
34 }; | 34 }; |
35 | 35 |
36 enum WeakSelector { kPeers = 0, kHashes, kObjectIds, kNumWeakSelectors }; | 36 enum WeakSelector { |
| 37 kPeers = 0, |
| 38 #if !defined(HASH_IN_OBJECT_HEADER) |
| 39 kHashes, |
| 40 #endif |
| 41 kObjectIds, |
| 42 kNumWeakSelectors |
| 43 }; |
37 | 44 |
38 enum ApiCallbacks { kIgnoreApiCallbacks, kInvokeApiCallbacks }; | 45 enum ApiCallbacks { kIgnoreApiCallbacks, kInvokeApiCallbacks }; |
39 | 46 |
40 enum GCReason { | 47 enum GCReason { |
41 kNewSpace, | 48 kNewSpace, |
42 kPromotion, | 49 kPromotion, |
43 kOldSpace, | 50 kOldSpace, |
44 kFull, | 51 kFull, |
45 kGCAtAlloc, | 52 kGCAtAlloc, |
46 kGCTestCase, | 53 kGCTestCase, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 173 |
167 // Associate a peer with an object. A non-existent peer is equal to NULL. | 174 // Associate a peer with an object. A non-existent peer is equal to NULL. |
168 void SetPeer(RawObject* raw_obj, void* peer) { | 175 void SetPeer(RawObject* raw_obj, void* peer) { |
169 SetWeakEntry(raw_obj, kPeers, reinterpret_cast<intptr_t>(peer)); | 176 SetWeakEntry(raw_obj, kPeers, reinterpret_cast<intptr_t>(peer)); |
170 } | 177 } |
171 void* GetPeer(RawObject* raw_obj) const { | 178 void* GetPeer(RawObject* raw_obj) const { |
172 return reinterpret_cast<void*>(GetWeakEntry(raw_obj, kPeers)); | 179 return reinterpret_cast<void*>(GetWeakEntry(raw_obj, kPeers)); |
173 } | 180 } |
174 int64_t PeerCount() const; | 181 int64_t PeerCount() const; |
175 | 182 |
| 183 #if !defined(HASH_IN_OBJECT_HEADER) |
176 // Associate an identity hashCode with an object. An non-existent hashCode | 184 // Associate an identity hashCode with an object. An non-existent hashCode |
177 // is equal to 0. | 185 // is equal to 0. |
178 void SetHash(RawObject* raw_obj, intptr_t hash) { | 186 void SetHash(RawObject* raw_obj, intptr_t hash) { |
179 SetWeakEntry(raw_obj, kHashes, hash); | 187 SetWeakEntry(raw_obj, kHashes, hash); |
180 } | 188 } |
181 intptr_t GetHash(RawObject* raw_obj) const { | 189 intptr_t GetHash(RawObject* raw_obj) const { |
182 return GetWeakEntry(raw_obj, kHashes); | 190 return GetWeakEntry(raw_obj, kHashes); |
183 } | 191 } |
| 192 #endif |
184 int64_t HashCount() const; | 193 int64_t HashCount() const; |
185 | 194 |
186 // Associate an id with an object (used when serializing an object). | 195 // Associate an id with an object (used when serializing an object). |
187 // A non-existant id is equal to 0. | 196 // A non-existant id is equal to 0. |
188 void SetObjectId(RawObject* raw_obj, intptr_t object_id) { | 197 void SetObjectId(RawObject* raw_obj, intptr_t object_id) { |
189 ASSERT(Thread::Current()->IsMutatorThread()); | 198 ASSERT(Thread::Current()->IsMutatorThread()); |
190 SetWeakEntry(raw_obj, kObjectIds, object_id); | 199 SetWeakEntry(raw_obj, kObjectIds, object_id); |
191 } | 200 } |
192 intptr_t GetObjectId(RawObject* raw_obj) const { | 201 intptr_t GetObjectId(RawObject* raw_obj) const { |
193 ASSERT(Thread::Current()->IsMutatorThread()); | 202 ASSERT(Thread::Current()->IsMutatorThread()); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 // Note: During this scope, the code pages are non-executable. | 402 // Note: During this scope, the code pages are non-executable. |
394 class WritableVMIsolateScope : StackResource { | 403 class WritableVMIsolateScope : StackResource { |
395 public: | 404 public: |
396 explicit WritableVMIsolateScope(Thread* thread); | 405 explicit WritableVMIsolateScope(Thread* thread); |
397 ~WritableVMIsolateScope(); | 406 ~WritableVMIsolateScope(); |
398 }; | 407 }; |
399 | 408 |
400 } // namespace dart | 409 } // namespace dart |
401 | 410 |
402 #endif // RUNTIME_VM_HEAP_H_ | 411 #endif // RUNTIME_VM_HEAP_H_ |
OLD | NEW |