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

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

Issue 1235433004: VM: Inline Scavenger and PageSpace objects into Heap. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
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"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 #if defined(DEBUG) 62 #if defined(DEBUG)
63 // Pattern for unused new space and swept old space. 63 // Pattern for unused new space and swept old space.
64 static const uint64_t kZap64Bits = 0xf3f3f3f3f3f3f3f3; 64 static const uint64_t kZap64Bits = 0xf3f3f3f3f3f3f3f3;
65 static const uint32_t kZap32Bits = 0xf3f3f3f3; 65 static const uint32_t kZap32Bits = 0xf3f3f3f3;
66 static const uint8_t kZapByte = 0xf3; 66 static const uint8_t kZapByte = 0xf3;
67 #endif // DEBUG 67 #endif // DEBUG
68 68
69 ~Heap(); 69 ~Heap();
70 70
71 Scavenger* new_space() const { return new_space_; } 71 Scavenger* new_space() { return &new_space_; }
72 PageSpace* old_space() const { return old_space_; } 72 PageSpace* old_space() { return &old_space_; }
73 73
74 uword Allocate(intptr_t size, Space space) { 74 uword Allocate(intptr_t size, Space space) {
75 ASSERT(!read_only_); 75 ASSERT(!read_only_);
76 switch (space) { 76 switch (space) {
77 case kNew: 77 case kNew:
78 // Do not attempt to allocate very large objects in new space. 78 // Do not attempt to allocate very large objects in new space.
79 if (!IsAllocatableInNewSpace(size)) { 79 if (!IsAllocatableInNewSpace(size)) {
80 return AllocateOld(size, HeapPage::kData); 80 return AllocateOld(size, HeapPage::kData);
81 } 81 }
82 return AllocateNew(size); 82 return AllocateNew(size);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // Enables growth control on the page space heaps. This should be 129 // Enables growth control on the page space heaps. This should be
130 // called before any user code is executed. 130 // called before any user code is executed.
131 void EnableGrowthControl() { SetGrowthControlState(true); } 131 void EnableGrowthControl() { SetGrowthControlState(true); }
132 void DisableGrowthControl() { SetGrowthControlState(false); } 132 void DisableGrowthControl() { SetGrowthControlState(false); }
133 void SetGrowthControlState(bool state); 133 void SetGrowthControlState(bool state);
134 bool GrowthControlState(); 134 bool GrowthControlState();
135 135
136 // Protect access to the heap. 136 // Protect access to the heap.
137 void WriteProtect(bool read_only); 137 void WriteProtect(bool read_only);
138 void WriteProtectCode(bool read_only) { 138 void WriteProtectCode(bool read_only) {
139 old_space_->WriteProtectCode(read_only); 139 old_space_.WriteProtectCode(read_only);
140 } 140 }
141 141
142 // Accessors for inlined allocation in generated code. 142 // Accessors for inlined allocation in generated code.
143 uword TopAddress(Space space); 143 uword TopAddress(Space space);
144 uword EndAddress(Space space); 144 uword EndAddress(Space space);
145 Space SpaceForAllocation(intptr_t class_id) const; 145 Space SpaceForAllocation(intptr_t class_id) const;
146 146
147 // Initialize the heap and register it with the isolate. 147 // Initialize the heap and register it with the isolate.
148 static void Init(Isolate* isolate, 148 static void Init(Isolate* isolate,
149 intptr_t max_new_gen_words, 149 intptr_t max_new_gen_words,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 bool gc_in_progress() const { return gc_in_progress_; } 222 bool gc_in_progress() const { return gc_in_progress_; }
223 223
224 static bool IsAllocatableInNewSpace(intptr_t size) { 224 static bool IsAllocatableInNewSpace(intptr_t size) {
225 return size <= kNewAllocatableSize; 225 return size <= kNewAllocatableSize;
226 } 226 }
227 227
228 void PrintToJSONObject(Space space, JSONObject* object) const; 228 void PrintToJSONObject(Space space, JSONObject* object) const;
229 229
230 // The heap map contains the sizes and class ids for the objects in each page. 230 // The heap map contains the sizes and class ids for the objects in each page.
231 void PrintHeapMapToJSONStream(Isolate* isolate, JSONStream* stream) const { 231 void PrintHeapMapToJSONStream(Isolate* isolate, JSONStream* stream) {
232 return old_space_->PrintHeapMapToJSONStream(isolate, stream); 232 return old_space_.PrintHeapMapToJSONStream(isolate, stream);
233 } 233 }
234 234
235 Isolate* isolate() const { return isolate_; } 235 Isolate* isolate() const { return isolate_; }
236 236
237 bool ShouldPretenure(intptr_t class_id) const; 237 bool ShouldPretenure(intptr_t class_id) const;
238 238
239 private: 239 private:
240 class GCStats : public ValueObject { 240 class GCStats : public ValueObject {
241 public: 241 public:
242 GCStats() {} 242 GCStats() {}
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 void UpdatePretenurePolicy(); 298 void UpdatePretenurePolicy();
299 299
300 // If this heap is non-empty, updates start and end to the smallest range that 300 // If this heap is non-empty, updates start and end to the smallest range that
301 // contains both the original [start, end) and the [lowest, highest) addresses 301 // contains both the original [start, end) and the [lowest, highest) addresses
302 // of this heap. 302 // of this heap.
303 void GetMergedAddressRange(uword* start, uword* end) const; 303 void GetMergedAddressRange(uword* start, uword* end) const;
304 304
305 Isolate* isolate_; 305 Isolate* isolate_;
306 306
307 // The different spaces used for allocation. 307 // The different spaces used for allocation.
308 Scavenger* new_space_; 308 Scavenger new_space_;
309 PageSpace* old_space_; 309 PageSpace old_space_;
310 310
311 WeakTable* new_weak_tables_[kNumWeakSelectors]; 311 WeakTable* new_weak_tables_[kNumWeakSelectors];
312 WeakTable* old_weak_tables_[kNumWeakSelectors]; 312 WeakTable* old_weak_tables_[kNumWeakSelectors];
313 313
314 // GC stats collection. 314 // GC stats collection.
315 GCStats stats_; 315 GCStats stats_;
316 316
317 // This heap is in read-only mode: No allocation is allowed. 317 // This heap is in read-only mode: No allocation is allowed.
318 bool read_only_; 318 bool read_only_;
319 319
320 // GC on the heap is in progress. 320 // GC on the heap is in progress.
321 bool gc_in_progress_; 321 bool gc_in_progress_;
322 322
323 int pretenure_policy_; 323 int pretenure_policy_;
324 324
325 friend class ServiceEvent; 325 friend class ServiceEvent;
326 friend class GCTestHelper;
327 friend class PageSpace; // VerifyGC 326 friend class PageSpace; // VerifyGC
328 DISALLOW_COPY_AND_ASSIGN(Heap); 327 DISALLOW_COPY_AND_ASSIGN(Heap);
329 }; 328 };
330 329
331 330
332 // Within a NoSafepointScope, the thread must not reach any safepoint. Used 331 // Within a NoSafepointScope, the thread must not reach any safepoint. Used
333 // around code that manipulates raw object pointers directly without handles. 332 // around code that manipulates raw object pointers directly without handles.
334 #if defined(DEBUG) 333 #if defined(DEBUG)
335 class NoSafepointScope : public StackResource { 334 class NoSafepointScope : public StackResource {
336 public: 335 public:
(...skipping 29 matching lines...) Expand all
366 NoHeapGrowthControlScope(); 365 NoHeapGrowthControlScope();
367 ~NoHeapGrowthControlScope(); 366 ~NoHeapGrowthControlScope();
368 private: 367 private:
369 bool current_growth_controller_state_; 368 bool current_growth_controller_state_;
370 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); 369 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope);
371 }; 370 };
372 371
373 } // namespace dart 372 } // namespace dart
374 373
375 #endif // VM_HEAP_H_ 374 #endif // VM_HEAP_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/heap.cc » ('j') | runtime/vm/pages.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698