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

Unified Diff: runtime/vm/scavenger.cc

Issue 498363003: - Simplify from containment check. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/scavenger.cc
===================================================================
--- runtime/vm/scavenger.cc (revision 39533)
+++ runtime/vm/scavenger.cc (working copy)
@@ -79,6 +79,8 @@
explicit ScavengerVisitor(Isolate* isolate, Scavenger* scavenger)
: ObjectPointerVisitor(isolate),
scavenger_(scavenger),
+ from_start_(scavenger_->from_->start()),
koda 2014/08/25 22:49:26 It would be nice to somehow assert here that the "
Ivan Posva 2014/08/25 22:56:23 The "assertion" is the fact that from_ is NULL if
+ from_size_(scavenger_->from_->end() - scavenger_->from_->start()),
heap_(scavenger->heap_),
vm_heap_(Dart::vm_isolate()->heap()),
page_space_(scavenger->heap_->old_space()),
@@ -152,15 +154,20 @@
return;
}
- uword raw_addr = RawObject::ToAddr(raw_obj);
// Objects should be contained in the heap.
// TODO(iposva): Add an appropriate assert here or in the return block
// below.
+
// The scavenger is only interested in objects located in the from space.
- if (!scavenger_->from_->Contains(raw_addr)) {
+ //
+ // We are using address math here and relying on the unsigned underflow
+ // in the code below to avoid having two checks.
+ uword obj_offset = reinterpret_cast<uword>(raw_obj) - from_start_;
+ if (obj_offset > from_size_) {
return;
}
+ uword raw_addr = RawObject::ToAddr(raw_obj);
// Read the header word of the object and determine if the object has
// already been copied.
uword header = *reinterpret_cast<uword*>(raw_addr);
@@ -233,6 +240,8 @@
}
Scavenger* scavenger_;
+ uword from_start_;
+ uword from_size_;
Heap* heap_;
Heap* vm_heap_;
PageSpace* page_space_;
@@ -780,13 +789,15 @@
OS::PrintErr(" done.\n");
}
- // Setup the visitor and run a scavenge.
- ScavengerVisitor visitor(isolate, this);
+ // Prepare for a scavenge.
SpaceUsage usage_before = GetCurrentUsage();
intptr_t promo_candidate_words =
(survivor_end_ - FirstObjectStart()) / kWordSize;
Prologue(isolate, invoke_api_callbacks);
const bool prologue_weak_are_strong = !invoke_api_callbacks;
+
+ // Setup the visitor and run the scavenge.
+ ScavengerVisitor visitor(isolate, this);
page_space->AcquireDataLock();
IterateRoots(isolate, &visitor, prologue_weak_are_strong);
int64_t start = OS::GetCurrentTimeMicros();
@@ -800,6 +811,8 @@
visitor.Finalize();
ProcessWeakTables();
page_space->ReleaseDataLock();
+
+ // Scavenge finished. Run accounting and epilogue.
int64_t end = OS::GetCurrentTimeMicros();
heap_->RecordTime(kProcessToSpace, middle - start);
heap_->RecordTime(kIterateWeaks, end - middle);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698