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

Side by Side Diff: vm/heap.h

Issue 11265026: - Consolidate code into the old generation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 static const intptr_t kCodeHeapSizeInMB = 18; 53 static const intptr_t kCodeHeapSizeInMB = 18;
54 54
55 ~Heap(); 55 ~Heap();
56 56
57 uword Allocate(intptr_t size, Space space) { 57 uword Allocate(intptr_t size, Space space) {
58 ASSERT(!read_only_); 58 ASSERT(!read_only_);
59 switch (space) { 59 switch (space) {
60 case kNew: 60 case kNew:
61 // Do not attempt to allocate very large objects in new space. 61 // Do not attempt to allocate very large objects in new space.
62 if (!PageSpace::IsPageAllocatableSize(size)) { 62 if (!PageSpace::IsPageAllocatableSize(size)) {
63 return AllocateOld(size); 63 return AllocateOld(size, HeapPage::kData);
64 } 64 }
65 return AllocateNew(size); 65 return AllocateNew(size);
66 case kOld: 66 case kOld:
67 return AllocateOld(size); 67 return AllocateOld(size, HeapPage::kData);
68 case kCode: 68 case kCode:
69 return AllocateCode(code_space_, size); 69 return AllocateOld(size, HeapPage::kExecutable);
70 default: 70 default:
71 UNREACHABLE(); 71 UNREACHABLE();
72 } 72 }
73 return 0; 73 return 0;
74 } 74 }
75 75
76 uword TryAllocate(intptr_t size, Space space) { 76 uword TryAllocate(intptr_t size, Space space) {
77 ASSERT(!read_only_); 77 ASSERT(!read_only_);
78 switch (space) { 78 switch (space) {
79 case kNew: 79 case kNew:
80 return new_space_->TryAllocate(size); 80 return new_space_->TryAllocate(size);
81 case kOld: 81 case kOld:
82 return old_space_->TryAllocate(size); 82 return old_space_->TryAllocate(size, HeapPage::kData);
83 case kCode: 83 case kCode:
84 return code_space_->TryAllocate(size); 84 return old_space_->TryAllocate(size, HeapPage::kExecutable);
85 default: 85 default:
86 UNREACHABLE(); 86 UNREACHABLE();
87 } 87 }
88 return 0; 88 return 0;
89 } 89 }
90 90
91 // Heap contains the specified address. 91 // Heap contains the specified address.
92 bool Contains(uword addr) const; 92 bool Contains(uword addr) const;
93 bool NewContains(uword addr) const; 93 bool NewContains(uword addr) const;
94 bool OldContains(uword addr) const; 94 bool OldContains(uword addr) const;
95 bool CodeContains(uword addr) const; 95 bool CodeContains(uword addr) const;
96 bool StubCodeContains(uword addr) const; 96 bool StubCodeContains(uword addr) const;
97 97
98 // Visit all pointers. 98 // Visit all pointers.
99 void IteratePointers(ObjectPointerVisitor* visitor); 99 void IteratePointers(ObjectPointerVisitor* visitor);
100 100
101 // Visit all pointers in the space. 101 // Visit all pointers in the space.
102 void IterateNewPointers(ObjectPointerVisitor* visitor); 102 void IterateNewPointers(ObjectPointerVisitor* visitor);
103 void IterateOldPointers(ObjectPointerVisitor* visitor); 103 void IterateOldPointers(ObjectPointerVisitor* visitor);
104 void IterateCodePointers(ObjectPointerVisitor* visitor);
105 104
106 // Visit all objects. 105 // Visit all objects.
107 void IterateObjects(ObjectVisitor* visitor); 106 void IterateObjects(ObjectVisitor* visitor);
108 107
109 // Visit all object in the space. 108 // Visit all object in the space.
110 void IterateNewObjects(ObjectVisitor* visitor); 109 void IterateNewObjects(ObjectVisitor* visitor);
111 void IterateOldObjects(ObjectVisitor* visitor); 110 void IterateOldObjects(ObjectVisitor* visitor);
112 void IterateCodeObjects(ObjectVisitor* visitor);
113 111
114 // Find an object by visiting all pointers in the specified heap space, 112 // Find an object by visiting all pointers in the specified heap space,
115 // the 'visitor' is used to determine if an object is found or not. 113 // the 'visitor' is used to determine if an object is found or not.
116 // The 'visitor' function should be set up to return true if the 114 // The 'visitor' function should be set up to return true if the
117 // object is found, traversal through the heap space stops at that 115 // object is found, traversal through the heap space stops at that
118 // point. 116 // point.
119 // The 'visitor' function should return false if the object is not found, 117 // The 'visitor' function should return false if the object is not found,
120 // traversal through the heap space continues. 118 // traversal through the heap space continues.
121 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor); 119 RawInstructions* FindObjectInOldSpace(FindObjectVisitor* visitor);
122 RawInstructions* FindObjectInStubCodeSpace(FindObjectVisitor* visitor); 120 RawInstructions* FindObjectInStubCodeSpace(FindObjectVisitor* visitor);
123 121
124 void CollectGarbage(Space space); 122 void CollectGarbage(Space space);
125 void CollectGarbage(Space space, ApiCallbacks api_callbacks); 123 void CollectGarbage(Space space, ApiCallbacks api_callbacks);
126 void CollectAllGarbage(); 124 void CollectAllGarbage();
127 125
128 // Enables growth control on the page space heaps. This should be 126 // Enables growth control on the page space heaps. This should be
129 // called before any user code is executed. 127 // called before any user code is executed.
130 void EnableGrowthControl(); 128 void EnableGrowthControl();
131 129
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // there is no association. 162 // there is no association.
165 void* GetPeer(RawObject* raw_obj); 163 void* GetPeer(RawObject* raw_obj);
166 164
167 // Returns the number of objects with a peer. 165 // Returns the number of objects with a peer.
168 int64_t PeerCount() const; 166 int64_t PeerCount() const;
169 167
170 private: 168 private:
171 Heap(); 169 Heap();
172 170
173 uword AllocateNew(intptr_t size); 171 uword AllocateNew(intptr_t size);
174 uword AllocateOld(intptr_t size); 172 uword AllocateOld(intptr_t size, HeapPage::PageType type);
175 uword AllocateCode(PageSpace* space, intptr_t size);
176 173
177 // The different spaces used for allocation. 174 // The different spaces used for allocation.
178 Scavenger* new_space_; 175 Scavenger* new_space_;
179 PageSpace* old_space_; 176 PageSpace* old_space_;
180 PageSpace* code_space_;
181 177
182 // This heap is in read-only mode: No allocation is allowed. 178 // This heap is in read-only mode: No allocation is allowed.
183 bool read_only_; 179 bool read_only_;
184 180
185 friend class GCTestHelper; 181 friend class GCTestHelper;
186 DISALLOW_COPY_AND_ASSIGN(Heap); 182 DISALLOW_COPY_AND_ASSIGN(Heap);
187 }; 183 };
188 184
189 185
190 #if defined(DEBUG) 186 #if defined(DEBUG)
191 class NoGCScope : public StackResource { 187 class NoGCScope : public StackResource {
192 public: 188 public:
193 NoGCScope(); 189 NoGCScope();
194 ~NoGCScope(); 190 ~NoGCScope();
195 private: 191 private:
196 DISALLOW_COPY_AND_ASSIGN(NoGCScope); 192 DISALLOW_COPY_AND_ASSIGN(NoGCScope);
197 }; 193 };
198 #else // defined(DEBUG) 194 #else // defined(DEBUG)
199 class NoGCScope : public ValueObject { 195 class NoGCScope : public ValueObject {
200 public: 196 public:
201 NoGCScope() {} 197 NoGCScope() {}
202 private: 198 private:
203 DISALLOW_COPY_AND_ASSIGN(NoGCScope); 199 DISALLOW_COPY_AND_ASSIGN(NoGCScope);
204 }; 200 };
205 #endif // defined(DEBUG) 201 #endif // defined(DEBUG)
206 202
207 } // namespace dart 203 } // namespace dart
208 204
209 #endif // VM_HEAP_H_ 205 #endif // VM_HEAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698