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

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

Issue 10905251: Lazy peer API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebased Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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_PAGES_H_ 5 #ifndef VM_PAGES_H_
6 #define VM_PAGES_H_ 6 #define VM_PAGES_H_
7 7
8 #include <map>
9
8 #include "vm/freelist.h" 10 #include "vm/freelist.h"
9 #include "vm/globals.h" 11 #include "vm/globals.h"
10 #include "vm/virtual_memory.h" 12 #include "vm/virtual_memory.h"
11 13
12 namespace dart { 14 namespace dart {
13 15
14 // Forward declarations. 16 // Forward declarations.
15 class Heap; 17 class Heap;
16 class ObjectPointerVisitor; 18 class ObjectPointerVisitor;
17 19
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 196 }
195 197
196 void StartEndAddress(uword* start, uword* end) const; 198 void StartEndAddress(uword* start, uword* end) const;
197 199
198 void EnableGrowthControl() { 200 void EnableGrowthControl() {
199 page_space_controller_.Enable(); 201 page_space_controller_.Enable();
200 } 202 }
201 203
202 void WriteProtect(bool read_only); 204 void WriteProtect(bool read_only);
203 205
206 typedef std::map<RawObject*, void*> PeerTable;
207
208 void SetPeer(RawObject* raw_obj, void* peer);
209
210 void* GetPeer(RawObject* raw_obj);
211
212 int64_t PeerCount() const;
213
214 PeerTable* GetPeerTable() { return &peer_table_; }
215
204 private: 216 private:
205 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage); 217 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage);
206 218
207 void AllocatePage(); 219 void AllocatePage();
208 void FreePage(HeapPage* page, HeapPage* previous_page); 220 void FreePage(HeapPage* page, HeapPage* previous_page);
209 HeapPage* AllocateLargePage(intptr_t size); 221 HeapPage* AllocateLargePage(intptr_t size);
210 void FreeLargePage(HeapPage* page, HeapPage* previous_page); 222 void FreeLargePage(HeapPage* page, HeapPage* previous_page);
211 void FreePages(HeapPage* pages); 223 void FreePages(HeapPage* pages);
212 224
213 static intptr_t LargePageSizeFor(intptr_t size); 225 static intptr_t LargePageSizeFor(intptr_t size);
214 226
215 bool CanIncreaseCapacity(intptr_t increase) { 227 bool CanIncreaseCapacity(intptr_t increase) {
216 ASSERT(capacity_ <= max_capacity_); 228 ASSERT(capacity_ <= max_capacity_);
217 return increase <= (max_capacity_ - capacity_); 229 return increase <= (max_capacity_ - capacity_);
218 } 230 }
219 231
220 uword TryBumpAllocate(intptr_t size); 232 uword TryBumpAllocate(intptr_t size);
221 233
222 FreeList freelist_; 234 FreeList freelist_;
223 235
224 Heap* heap_; 236 Heap* heap_;
225 237
226 HeapPage* pages_; 238 HeapPage* pages_;
227 HeapPage* pages_tail_; 239 HeapPage* pages_tail_;
228 HeapPage* large_pages_; 240 HeapPage* large_pages_;
229 241
242 PeerTable peer_table_;
243
230 // Page being used for bump allocation. 244 // Page being used for bump allocation.
231 // The value has different meanings: 245 // The value has different meanings:
232 // NULL: Still bump allocating from last allocated fresh page. 246 // NULL: Still bump allocating from last allocated fresh page.
233 // !NULL: Last page that had enough room to bump allocate, when we reach the 247 // !NULL: Last page that had enough room to bump allocate, when we reach the
234 // tail page, we give up bump allocating. 248 // tail page, we give up bump allocating.
235 HeapPage* bump_page_; 249 HeapPage* bump_page_;
236 250
237 // Various sizes being tracked for this generation. 251 // Various sizes being tracked for this generation.
238 intptr_t max_capacity_; 252 intptr_t max_capacity_;
239 intptr_t capacity_; 253 intptr_t capacity_;
240 intptr_t in_use_; 254 intptr_t in_use_;
241 255
242 // Old-gen GC cycle count. 256 // Old-gen GC cycle count.
243 int count_; 257 int count_;
244 258
245 bool is_executable_; 259 bool is_executable_;
246 260
247 // Keep track whether a MarkSweep is currently running. 261 // Keep track whether a MarkSweep is currently running.
248 bool sweeping_; 262 bool sweeping_;
249 263
250 PageSpaceController page_space_controller_; 264 PageSpaceController page_space_controller_;
251 265
252 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); 266 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace);
253 }; 267 };
254 268
255 } // namespace dart 269 } // namespace dart
256 270
257 #endif // VM_PAGES_H_ 271 #endif // VM_PAGES_H_
OLDNEW
« runtime/vm/dart_api_impl.cc ('K') | « runtime/vm/heap.cc ('k') | runtime/vm/pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698