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

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

Issue 864843002: Remove default heap size limit and add separate limit for externals. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/pages.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "vm/freelist.h" 8 #include "vm/freelist.h"
9 #include "vm/globals.h" 9 #include "vm/globals.h"
10 #include "vm/lockers.h" 10 #include "vm/lockers.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 class PageSpace { 189 class PageSpace {
190 public: 190 public:
191 // TODO(iposva): Determine heap sizes and tune the page size accordingly. 191 // TODO(iposva): Determine heap sizes and tune the page size accordingly.
192 static const intptr_t kPageSizeInWords = 256 * KBInWords; 192 static const intptr_t kPageSizeInWords = 256 * KBInWords;
193 193
194 enum GrowthPolicy { 194 enum GrowthPolicy {
195 kControlGrowth, 195 kControlGrowth,
196 kForceGrowth 196 kForceGrowth
197 }; 197 };
198 198
199 PageSpace(Heap* heap, intptr_t max_capacity_in_words); 199 PageSpace(Heap* heap,
200 intptr_t max_capacity_in_words,
201 intptr_t max_external_in_words);
200 ~PageSpace(); 202 ~PageSpace();
201 203
202 uword TryAllocate(intptr_t size, 204 uword TryAllocate(intptr_t size,
203 HeapPage::PageType type = HeapPage::kData, 205 HeapPage::PageType type = HeapPage::kData,
204 GrowthPolicy growth_policy = kControlGrowth) { 206 GrowthPolicy growth_policy = kControlGrowth) {
205 bool is_protected = 207 bool is_protected =
206 (type == HeapPage::kExecutable) && FLAG_write_protect_code; 208 (type == HeapPage::kExecutable) && FLAG_write_protect_code;
207 bool is_locked = false; 209 bool is_locked = false;
208 return TryAllocateInternal( 210 return TryAllocateInternal(
209 size, type, growth_policy, is_protected, is_locked); 211 size, type, growth_policy, is_protected, is_locked);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } else { 264 } else {
263 page_space_controller_.Disable(); 265 page_space_controller_.Disable();
264 } 266 }
265 } 267 }
266 268
267 bool GrowthControlState() { 269 bool GrowthControlState() {
268 return page_space_controller_.is_enabled(); 270 return page_space_controller_.is_enabled();
269 } 271 }
270 272
271 bool NeedsExternalGC() const { 273 bool NeedsExternalGC() const {
272 return UsedInWords() + ExternalInWords() > max_capacity_in_words_; 274 return (max_external_in_words_ != 0) &&
275 (ExternalInWords() > max_external_in_words_);
273 } 276 }
274 277
275 // TODO(koda): Unify protection handling. 278 // TODO(koda): Unify protection handling.
276 void WriteProtect(bool read_only); 279 void WriteProtect(bool read_only);
277 void WriteProtectCode(bool read_only); 280 void WriteProtectCode(bool read_only);
278 281
279 void AddGCTime(int64_t micros) { 282 void AddGCTime(int64_t micros) {
280 gc_time_micros_ += micros; 283 gc_time_micros_ += micros;
281 } 284 }
282 285
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 ASSERT((exec_pages_tail_ == NULL) || (exec_pages_tail_->next() == NULL)); 378 ASSERT((exec_pages_tail_ == NULL) || (exec_pages_tail_->next() == NULL));
376 if (page == pages_tail_) { 379 if (page == pages_tail_) {
377 return (exec_pages_ != NULL) ? exec_pages_ : large_pages_; 380 return (exec_pages_ != NULL) ? exec_pages_ : large_pages_;
378 } 381 }
379 return page == exec_pages_tail_ ? large_pages_ : page->next(); 382 return page == exec_pages_tail_ ? large_pages_ : page->next();
380 } 383 }
381 384
382 static intptr_t LargePageSizeInWordsFor(intptr_t size); 385 static intptr_t LargePageSizeInWordsFor(intptr_t size);
383 386
384 bool CanIncreaseCapacityInWords(intptr_t increase_in_words) { 387 bool CanIncreaseCapacityInWords(intptr_t increase_in_words) {
388 if (max_capacity_in_words_ == 0) {
389 // Unlimited.
390 return true;
391 }
385 ASSERT(CapacityInWords() <= max_capacity_in_words_); 392 ASSERT(CapacityInWords() <= max_capacity_in_words_);
386 return increase_in_words <= (max_capacity_in_words_ - CapacityInWords()); 393 return increase_in_words <= (max_capacity_in_words_ - CapacityInWords());
387 } 394 }
388 395
389 FreeList freelist_[HeapPage::kNumPageTypes]; 396 FreeList freelist_[HeapPage::kNumPageTypes];
390 397
391 Heap* heap_; 398 Heap* heap_;
392 399
393 // Use ExclusivePageIterator for safe access to these. 400 // Use ExclusivePageIterator for safe access to these.
394 Mutex* pages_lock_; 401 Mutex* pages_lock_;
395 HeapPage* pages_; 402 HeapPage* pages_;
396 HeapPage* pages_tail_; 403 HeapPage* pages_tail_;
397 HeapPage* exec_pages_; 404 HeapPage* exec_pages_;
398 HeapPage* exec_pages_tail_; 405 HeapPage* exec_pages_tail_;
399 HeapPage* large_pages_; 406 HeapPage* large_pages_;
400 407
401 // A block of memory in a data page, managed by bump allocation. The remainder 408 // A block of memory in a data page, managed by bump allocation. The remainder
402 // is kept formatted as a FreeListElement, but is not in any freelist. 409 // is kept formatted as a FreeListElement, but is not in any freelist.
403 uword bump_top_; 410 uword bump_top_;
404 uword bump_end_; 411 uword bump_end_;
405 412
406 // Various sizes being tracked for this generation. 413 // Various sizes being tracked for this generation.
407 intptr_t max_capacity_in_words_; 414 intptr_t max_capacity_in_words_;
415 intptr_t max_external_in_words_;
408 // NOTE: The capacity component of usage_ is updated by the concurrent 416 // NOTE: The capacity component of usage_ is updated by the concurrent
409 // sweeper. Use (Increase)CapacityInWords(Locked) for thread-safe access. 417 // sweeper. Use (Increase)CapacityInWords(Locked) for thread-safe access.
410 SpaceUsage usage_; 418 SpaceUsage usage_;
411 419
412 // Keep track of running MarkSweep tasks. 420 // Keep track of running MarkSweep tasks.
413 Monitor* tasks_lock_; 421 Monitor* tasks_lock_;
414 intptr_t tasks_; 422 intptr_t tasks_;
415 423
416 PageSpaceController page_space_controller_; 424 PageSpaceController page_space_controller_;
417 425
418 int64_t gc_time_micros_; 426 int64_t gc_time_micros_;
419 intptr_t collections_; 427 intptr_t collections_;
420 428
421 friend class ExclusivePageIterator; 429 friend class ExclusivePageIterator;
422 friend class ExclusiveCodePageIterator; 430 friend class ExclusiveCodePageIterator;
423 friend class ExclusiveLargePageIterator; 431 friend class ExclusiveLargePageIterator;
424 friend class PageSpaceController; 432 friend class PageSpaceController;
425 friend class SweeperTask; 433 friend class SweeperTask;
426 434
427 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); 435 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace);
428 }; 436 };
429 437
430 } // namespace dart 438 } // namespace dart
431 439
432 #endif // VM_PAGES_H_ 440 #endif // VM_PAGES_H_
OLDNEW
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/pages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698