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

Unified Diff: runtime/vm/pages.h

Issue 225303006: Corrected resubmssion of r34736. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/pages.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/pages.h
===================================================================
--- runtime/vm/pages.h (revision 34741)
+++ runtime/vm/pages.h (working copy)
@@ -7,6 +7,7 @@
#include "vm/freelist.h"
#include "vm/globals.h"
+#include "vm/spaces.h"
#include "vm/virtual_memory.h"
namespace dart {
@@ -116,14 +117,18 @@
int garbage_collection_time_ratio);
~PageSpaceController();
- bool CanGrowPageSpace(intptr_t size_in_bytes);
+ // Returns whether growing to 'after' should trigger a GC.
+ // This method can be called before allocation (e.g., pretenuring) or after
+ // (e.g., promotion), as it does not change the state of the controller.
+ bool NeedsGarbageCollection(SpaceUsage after) const;
+ // Should be called after each collection to update the controller state.
// A garbage collection is considered as successful if more than
// heap_growth_ratio % of memory got deallocated by the garbage collector.
// In this case garbage collection will be performed next time. Otherwise
// the heap will grow.
- void EvaluateGarbageCollection(intptr_t used_before_in_words,
- intptr_t used_after_in_words,
+ void EvaluateGarbageCollection(SpaceUsage before,
+ SpaceUsage after,
int64_t start, int64_t end);
int64_t last_code_collection_in_us() { return last_code_collection_in_us_; }
@@ -141,6 +146,9 @@
private:
bool is_enabled_;
+ // Usage after last evaluated GC.
+ SpaceUsage last_usage_;
+
// Heap growth control variable.
intptr_t grow_heap_;
@@ -186,11 +194,16 @@
HeapPage::PageType type = HeapPage::kData,
GrowthPolicy growth_policy = kControlGrowth);
- intptr_t UsedInWords() const { return used_in_words_; }
- intptr_t CapacityInWords() const { return capacity_in_words_; }
+ bool NeedsGarbageCollection() const {
+ return page_space_controller_.NeedsGarbageCollection(usage_);
+ }
+
+ intptr_t UsedInWords() const { return usage_.used_in_words; }
+ intptr_t CapacityInWords() const { return usage_.capacity_in_words; }
intptr_t ExternalInWords() const {
- return external_in_words_;
+ return usage_.external_in_words;
}
+ SpaceUsage GetCurrentUsage() const { return usage_; }
bool Contains(uword addr) const;
bool Contains(uword addr, HeapPage::PageType type) const;
@@ -222,7 +235,7 @@
}
bool NeedExternalGC() {
- return used_in_words_ + ExternalInWords() > max_capacity_in_words_;
+ return UsedInWords() + ExternalInWords() > max_capacity_in_words_;
}
void WriteProtect(bool read_only);
@@ -275,8 +288,8 @@
static intptr_t LargePageSizeInWordsFor(intptr_t size);
bool CanIncreaseCapacityInWords(intptr_t increase_in_words) {
- ASSERT(capacity_in_words_ <= max_capacity_in_words_);
- return increase_in_words <= (max_capacity_in_words_ - capacity_in_words_);
+ ASSERT(CapacityInWords() <= max_capacity_in_words_);
+ return increase_in_words <= (max_capacity_in_words_ - CapacityInWords());
}
FreeList freelist_[HeapPage::kNumPageTypes];
@@ -289,9 +302,7 @@
// Various sizes being tracked for this generation.
intptr_t max_capacity_in_words_;
- intptr_t capacity_in_words_;
- intptr_t used_in_words_;
- intptr_t external_in_words_;
+ SpaceUsage usage_;
// Keep track whether a MarkSweep is currently running.
bool sweeping_;
« 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