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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 167 |
161 // Associate a peer with an object. A non-existent peer is equal to NULL. | 168 // Associate a peer with an object. A non-existent peer is equal to NULL. |
162 void SetPeer(RawObject* raw_obj, void* peer) { | 169 void SetPeer(RawObject* raw_obj, void* peer) { |
163 SetWeakEntry(raw_obj, kPeers, reinterpret_cast<intptr_t>(peer)); | 170 SetWeakEntry(raw_obj, kPeers, reinterpret_cast<intptr_t>(peer)); |
164 } | 171 } |
165 void* GetPeer(RawObject* raw_obj) const { | 172 void* GetPeer(RawObject* raw_obj) const { |
166 return reinterpret_cast<void*>(GetWeakEntry(raw_obj, kPeers)); | 173 return reinterpret_cast<void*>(GetWeakEntry(raw_obj, kPeers)); |
167 } | 174 } |
168 int64_t PeerCount() const; | 175 int64_t PeerCount() const; |
169 | 176 |
| 177 #if !defined(HASH_IN_OBJECT_HEADER) |
170 // Associate an identity hashCode with an object. An non-existent hashCode | 178 // Associate an identity hashCode with an object. An non-existent hashCode |
171 // is equal to 0. | 179 // is equal to 0. |
172 void SetHash(RawObject* raw_obj, intptr_t hash) { | 180 void SetHash(RawObject* raw_obj, intptr_t hash) { |
173 SetWeakEntry(raw_obj, kHashes, hash); | 181 SetWeakEntry(raw_obj, kHashes, hash); |
174 } | 182 } |
175 intptr_t GetHash(RawObject* raw_obj) const { | 183 intptr_t GetHash(RawObject* raw_obj) const { |
176 return GetWeakEntry(raw_obj, kHashes); | 184 return GetWeakEntry(raw_obj, kHashes); |
177 } | 185 } |
| 186 #endif |
178 int64_t HashCount() const; | 187 int64_t HashCount() const; |
179 | 188 |
180 // Associate an id with an object (used when serializing an object). | 189 // Associate an id with an object (used when serializing an object). |
181 // A non-existant id is equal to 0. | 190 // A non-existant id is equal to 0. |
182 void SetObjectId(RawObject* raw_obj, intptr_t object_id) { | 191 void SetObjectId(RawObject* raw_obj, intptr_t object_id) { |
183 ASSERT(Thread::Current()->IsMutatorThread()); | 192 ASSERT(Thread::Current()->IsMutatorThread()); |
184 SetWeakEntry(raw_obj, kObjectIds, object_id); | 193 SetWeakEntry(raw_obj, kObjectIds, object_id); |
185 } | 194 } |
186 intptr_t GetObjectId(RawObject* raw_obj) const { | 195 intptr_t GetObjectId(RawObject* raw_obj) const { |
187 ASSERT(Thread::Current()->IsMutatorThread()); | 196 ASSERT(Thread::Current()->IsMutatorThread()); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 // Note: During this scope, the code pages are non-executable. | 396 // Note: During this scope, the code pages are non-executable. |
388 class WritableVMIsolateScope : StackResource { | 397 class WritableVMIsolateScope : StackResource { |
389 public: | 398 public: |
390 explicit WritableVMIsolateScope(Thread* thread); | 399 explicit WritableVMIsolateScope(Thread* thread); |
391 ~WritableVMIsolateScope(); | 400 ~WritableVMIsolateScope(); |
392 }; | 401 }; |
393 | 402 |
394 } // namespace dart | 403 } // namespace dart |
395 | 404 |
396 #endif // RUNTIME_VM_HEAP_H_ | 405 #endif // RUNTIME_VM_HEAP_H_ |
OLD | NEW |