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

Unified Diff: runtime/vm/scavenger.cc

Issue 11363226: Fail new space promotions only when old space is truly exhausted. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/heap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scavenger.cc
diff --git a/runtime/vm/scavenger.cc b/runtime/vm/scavenger.cc
index e1b4326d03e6f63e5d76c6d7a4c2771634363322..de4ff2cc5a13e543e0dfb8d2c46f583b1bf3cb22 100644
--- a/runtime/vm/scavenger.cc
+++ b/runtime/vm/scavenger.cc
@@ -73,6 +73,8 @@ class ScavengerVisitor : public ObjectPointerVisitor {
heap_(scavenger->heap_),
vm_heap_(Dart::vm_isolate()->heap()),
delayed_weak_stack_(),
+ growth_policy_(PageSpace::kControlGrowth),
+ bytes_promoted_(0),
visiting_old_pointers_(false),
in_scavenge_pointer_(false) {}
@@ -107,6 +109,8 @@ class ScavengerVisitor : public ObjectPointerVisitor {
}
}
+ intptr_t bytes_promoted() { return bytes_promoted_; }
+
private:
void UpdateStoreBuffer(RawObject** p, RawObject* obj) {
uword ptr = reinterpret_cast<uword>(p);
@@ -175,14 +179,28 @@ class ScavengerVisitor : public ObjectPointerVisitor {
//
// This object is a survivor of a previous scavenge. Attempt to promote
// the object.
- new_addr = heap_->TryAllocate(size, Heap::kOld);
+ new_addr = heap_->old_space()->TryAllocate(size,
+ HeapPage::kData,
+ growth_policy_);
if (new_addr != 0) {
// If promotion succeeded then we need to remember it so that it can
// be traversed later.
+ bytes_promoted_ += size;
Ivan Posva 2012/11/14 21:07:18 Comment above has been separated from the code it
cshapiro 2012/11/14 22:47:36 I do not follow. Do you want me to transpose line
scavenger_->PushToPromotedStack(new_addr);
+ } else if (!scavenger_->had_promotion_failure_) {
+ // Retry.
Ivan Posva 2012/11/14 21:07:18 Please expand on the "Retry." comment by briefly e
+ scavenger_->had_promotion_failure_ = true;
+ growth_policy_ = PageSpace::kForceGrowth;
+ new_addr = heap_->old_space()->TryAllocate(size,
+ HeapPage::kData,
+ growth_policy_);
+ if (new_addr != 0) {
+ bytes_promoted_ += size;
+ scavenger_->PushToPromotedStack(new_addr);
+ }
Ivan Posva 2012/11/14 21:07:18 What if new_addr is 0?
cshapiro 2012/11/14 22:47:36 Same thing that always happens. We trip the asser
} else {
+ ASSERT(growth_policy_ == PageSpace::kForceGrowth);
// Promotion did not succeed. Copy into the to space instead.
- scavenger_->had_promotion_failure_ = true;
new_addr = scavenger_->TryAllocate(size);
}
}
@@ -211,6 +229,8 @@ class ScavengerVisitor : public ObjectPointerVisitor {
typedef std::multimap<RawObject*, RawWeakProperty*> DelaySet;
DelaySet delay_set_;
GrowableArray<RawObject*> delayed_weak_stack_;
+ PageSpace::GrowthPolicy growth_policy_;
+ intptr_t bytes_promoted_;
bool visiting_old_pointers_;
bool in_scavenge_pointer_;
@@ -615,6 +635,9 @@ void Scavenger::Scavenge(bool invoke_api_callbacks, const char* gc_reason) {
}
Timer timer(FLAG_verbose_gc, "Scavenge");
timer.Start();
+
+ intptr_t in_use_before = in_use();
+
// Setup the visitor and run a scavenge.
ScavengerVisitor visitor(isolate, this);
Prologue(isolate, invoke_api_callbacks);
@@ -627,10 +650,17 @@ void Scavenger::Scavenge(bool invoke_api_callbacks, const char* gc_reason) {
ProcessPeerReferents();
Epilogue(isolate, invoke_api_callbacks);
timer.Stop();
+
if (FLAG_verbose_gc) {
- OS::PrintErr("Scavenge[%d]: %"Pd64"us\n",
+ const intptr_t KB2 = KB / 2;
+ OS::PrintErr("Scavenge[%d]: %"Pd64"us (%"Pd"K -> %"Pd"K, %"Pd"K)\n"
+ "Promoted %"Pd"K\n",
count_,
- timer.TotalElapsedTime());
+ timer.TotalElapsedTime(),
+ (in_use_before + KB2) / KB,
+ (in_use() + KB2) / KB,
+ (capacity() + KB2) / KB,
+ (visitor.bytes_promoted() + KB2) / KB);
}
if (FLAG_verify_after_gc) {
« no previous file with comments | « runtime/vm/heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698