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

Unified Diff: runtime/vm/scavenger.cc

Issue 2951333002: Moves the top_ and end_ words of the Scavenger into mutator thread. (Closed)
Patch Set: Created 3 years, 6 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
Index: runtime/vm/scavenger.cc
diff --git a/runtime/vm/scavenger.cc b/runtime/vm/scavenger.cc
index 2309e6ca2aa3bb5c5b08cdf062cc4556206060b5..10b07c8ed9cf76c149a8b43fdff1c37e473e804e 100644
--- a/runtime/vm/scavenger.cc
+++ b/runtime/vm/scavenger.cc
@@ -337,7 +337,8 @@ Scavenger::Scavenger(Heap* heap,
delayed_weak_properties_(NULL),
gc_time_micros_(0),
collections_(0),
- external_size_(0) {
+ external_size_(0),
+ space_lock_(new Mutex()) {
// Verify assumptions about the first word in objects which the scavenger is
// going to use for forwarding pointers.
ASSERT(Object::tags_offset() == 0);
@@ -365,6 +366,7 @@ Scavenger::Scavenger(Heap* heap,
Scavenger::~Scavenger() {
ASSERT(!scavenging_);
to_->Delete();
+ delete space_lock_;
}
@@ -387,6 +389,9 @@ SemiSpace* Scavenger::Prologue(Isolate* isolate, bool invoke_api_callbacks) {
(isolate->gc_prologue_callback())();
}
isolate->PrepareForGC();
+
+ ASSERT(isolate->mutator_thread()->top() == top_);
+
// Flip the two semi-spaces so that to_ is always the space for allocating
// objects.
SemiSpace* from = to_;
@@ -400,6 +405,10 @@ SemiSpace* Scavenger::Prologue(Isolate* isolate, bool invoke_api_callbacks) {
top_ = FirstObjectStart();
resolved_top_ = top_;
end_ = to_->end();
+
+ isolate->mutator_thread()->set_top_offset(top_);
+ isolate->mutator_thread()->set_end_offset(end_);
+
return from;
}
@@ -409,6 +418,10 @@ void Scavenger::Epilogue(Isolate* isolate,
bool invoke_api_callbacks) {
// All objects in the to space have been copied from the from space at this
// moment.
+
+ isolate->mutator_thread()->set_top_offset(top_);
+ isolate->mutator_thread()->set_end_offset(end_);
+
double avg_frac = stats_history_.Get(0).PromoCandidatesSuccessFraction();
if (stats_history_.Size() >= 2) {
// Previous scavenge is only given half as much weight.
@@ -545,6 +558,9 @@ void Scavenger::IterateWeakRoots(Isolate* isolate, HandleVisitor* visitor) {
void Scavenger::ProcessToSpace(ScavengerVisitor* visitor) {
// Iterate until all work has been drained.
+
+ ASSERT(Isolate::Current()->mutator_thread()->top() == top_);
+
while ((resolved_top_ < top_) || PromotedStackHasMore()) {
while (resolved_top_ < top_) {
RawObject* raw_obj = RawObject::FromAddr(resolved_top_);

Powered by Google App Engine
This is Rietveld 408576698