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" |
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 | 14 |
15 namespace dart { | 15 namespace dart { |
16 | 16 |
17 // Forward declarations. | 17 // Forward declarations. |
18 class HeapTrace; | |
18 class Isolate; | 19 class Isolate; |
19 class ObjectPointerVisitor; | 20 class ObjectPointerVisitor; |
20 class ObjectSet; | 21 class ObjectSet; |
21 class VirtualMemory; | 22 class VirtualMemory; |
22 | 23 |
23 DECLARE_FLAG(bool, verbose_gc); | 24 DECLARE_FLAG(bool, verbose_gc); |
24 DECLARE_FLAG(bool, verify_before_gc); | 25 DECLARE_FLAG(bool, verify_before_gc); |
25 DECLARE_FLAG(bool, verify_after_gc); | 26 DECLARE_FLAG(bool, verify_after_gc); |
26 DECLARE_FLAG(bool, gc_at_alloc); | 27 DECLARE_FLAG(bool, gc_at_alloc); |
27 | 28 |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 uword TopAddress(); | 142 uword TopAddress(); |
142 uword EndAddress(); | 143 uword EndAddress(); |
143 static intptr_t new_space_offset() { return OFFSET_OF(Heap, new_space_); } | 144 static intptr_t new_space_offset() { return OFFSET_OF(Heap, new_space_); } |
144 | 145 |
145 // Initialize the heap and register it with the isolate. | 146 // Initialize the heap and register it with the isolate. |
146 static void Init(Isolate* isolate); | 147 static void Init(Isolate* isolate); |
147 | 148 |
148 // Verify that all pointers in the heap point to the heap. | 149 // Verify that all pointers in the heap point to the heap. |
149 bool Verify() const; | 150 bool Verify() const; |
150 | 151 |
152 // Accessor function to get the HeapTrace used for tracing. There | |
153 // should only ever be one of these per isolate | |
154 HeapTrace* trace() { return heap_trace_; } | |
siva
2012/12/05 16:06:40
const
cshapiro
2012/12/08 03:23:08
Fixed.
| |
155 | |
151 // Print heap sizes. | 156 // Print heap sizes. |
152 void PrintSizes() const; | 157 void PrintSizes() const; |
153 | 158 |
154 // Returns the [lowest, highest) addresses in the heap. | 159 // Returns the [lowest, highest) addresses in the heap. |
155 void StartEndAddress(uword* start, uword* end) const; | 160 void StartEndAddress(uword* start, uword* end) const; |
156 | 161 |
157 ObjectSet* CreateAllocatedObjectSet() const; | 162 ObjectSet* CreateAllocatedObjectSet() const; |
158 | 163 |
159 // Generates a profile of the current and VM isolate heaps. | 164 // Generates a profile of the current and VM isolate heaps. |
160 void Profile(Dart_HeapProfileWriteCallback callback, void* stream) const; | 165 void Profile(Dart_FileWriteCallback callback, void* stream) const; |
161 | 166 |
162 static const char* GCReasonToString(GCReason gc_reason); | 167 static const char* GCReasonToString(GCReason gc_reason); |
163 | 168 |
164 // Associates a peer with an object. If an object has a peer, it is | 169 // Associates a peer with an object. If an object has a peer, it is |
165 // replaced. A value of NULL disassociate an object from its peer. | 170 // replaced. A value of NULL disassociate an object from its peer. |
166 void SetPeer(RawObject* raw_obj, void* peer); | 171 void SetPeer(RawObject* raw_obj, void* peer); |
167 | 172 |
168 // Retrieves the peer associated with an object. Returns NULL if | 173 // Retrieves the peer associated with an object. Returns NULL if |
169 // there is no association. | 174 // there is no association. |
170 void* GetPeer(RawObject* raw_obj); | 175 void* GetPeer(RawObject* raw_obj); |
171 | 176 |
172 // Returns the number of objects with a peer. | 177 // Returns the number of objects with a peer. |
173 int64_t PeerCount() const; | 178 int64_t PeerCount() const; |
174 | 179 |
175 private: | 180 private: |
176 Heap(); | 181 Heap(); |
177 | 182 |
178 uword AllocateNew(intptr_t size); | 183 uword AllocateNew(intptr_t size); |
179 uword AllocateOld(intptr_t size, HeapPage::PageType type); | 184 uword AllocateOld(intptr_t size, HeapPage::PageType type); |
180 | 185 |
181 // The different spaces used for allocation. | 186 // The different spaces used for allocation. |
182 Scavenger* new_space_; | 187 Scavenger* new_space_; |
183 PageSpace* old_space_; | 188 PageSpace* old_space_; |
184 | 189 |
190 // The active trace for this heap. NULL if tracing is not enabled. | |
191 HeapTrace* heap_trace_; | |
192 | |
185 // This heap is in read-only mode: No allocation is allowed. | 193 // This heap is in read-only mode: No allocation is allowed. |
186 bool read_only_; | 194 bool read_only_; |
187 | 195 |
188 friend class GCTestHelper; | 196 friend class GCTestHelper; |
189 DISALLOW_COPY_AND_ASSIGN(Heap); | 197 DISALLOW_COPY_AND_ASSIGN(Heap); |
190 }; | 198 }; |
191 | 199 |
192 | 200 |
193 #if defined(DEBUG) | 201 #if defined(DEBUG) |
194 class NoGCScope : public StackResource { | 202 class NoGCScope : public StackResource { |
195 public: | 203 public: |
196 NoGCScope(); | 204 NoGCScope(); |
197 ~NoGCScope(); | 205 ~NoGCScope(); |
198 private: | 206 private: |
199 DISALLOW_COPY_AND_ASSIGN(NoGCScope); | 207 DISALLOW_COPY_AND_ASSIGN(NoGCScope); |
200 }; | 208 }; |
201 #else // defined(DEBUG) | 209 #else // defined(DEBUG) |
202 class NoGCScope : public ValueObject { | 210 class NoGCScope : public ValueObject { |
203 public: | 211 public: |
204 NoGCScope() {} | 212 NoGCScope() {} |
205 private: | 213 private: |
206 DISALLOW_COPY_AND_ASSIGN(NoGCScope); | 214 DISALLOW_COPY_AND_ASSIGN(NoGCScope); |
207 }; | 215 }; |
208 #endif // defined(DEBUG) | 216 #endif // defined(DEBUG) |
209 | 217 |
210 } // namespace dart | 218 } // namespace dart |
211 | 219 |
212 #endif // VM_HEAP_H_ | 220 #endif // VM_HEAP_H_ |
OLD | NEW |