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

Unified Diff: src/heap/incremental-marking.cc

Issue 2464393002: [heap] Invoke incremental marking step before allocation. (Closed)
Patch Set: Created 4 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 | « src/heap/incremental-marking.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/incremental-marking.cc
diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc
index 185cb1b53780f4b9982fef2dabc2e1170f3715e7..9a5733bc06610841a22c15b74b922c9eeb4f9ebb 100644
--- a/src/heap/incremental-marking.cc
+++ b/src/heap/incremental-marking.cc
@@ -32,9 +32,7 @@ IncrementalMarking::IncrementalMarking(Heap* heap)
was_activated_(false),
black_allocation_(false),
finalize_marking_completed_(false),
- request_type_(NONE),
- new_generation_observer_(*this, kAllocatedThreshold),
- old_generation_observer_(*this, kAllocatedThreshold) {}
+ request_type_(NONE) {}
bool IncrementalMarking::BaseRecordWrite(HeapObject* obj, Object* value) {
HeapObject* value_heap_obj = HeapObject::cast(value);
@@ -489,16 +487,6 @@ void IncrementalMarking::Start(GarbageCollectionReason gc_reason) {
state_ = SWEEPING;
}
- SpaceIterator it(heap_);
- while (it.has_next()) {
- Space* space = it.next();
- if (space == heap_->new_space()) {
- space->AddAllocationObserver(&new_generation_observer_);
- } else {
- space->AddAllocationObserver(&old_generation_observer_);
- }
- }
-
incremental_marking_job()->Start(heap_);
}
@@ -957,16 +945,6 @@ void IncrementalMarking::Stop() {
Max(0, old_generation_size_mb - old_generation_limit_mb));
}
- SpaceIterator it(heap_);
- while (it.has_next()) {
- Space* space = it.next();
- if (space == heap_->new_space()) {
- space->RemoveAllocationObserver(&new_generation_observer_);
- } else {
- space->RemoveAllocationObserver(&old_generation_observer_);
- }
- }
-
IncrementalMarking::set_should_hurry(false);
if (IsMarking()) {
PatchIncrementalMarkingRecordWriteStubs(heap_,
@@ -1085,30 +1063,33 @@ void IncrementalMarking::AdvanceIncrementalMarkingOnAllocation() {
return;
}
- size_t bytes_to_process =
- StepSizeToKeepUpWithAllocations() + StepSizeToMakeProgress();
-
- if (bytes_to_process >= IncrementalMarking::kAllocatedThreshold) {
- // The first step after Scavenge will see many allocated bytes.
- // Cap the step size to distribute the marking work more uniformly.
- size_t max_step_size = GCIdleTimeHandler::EstimateMarkingStepSize(
- kMaxStepSizeInMs,
- heap()->tracer()->IncrementalMarkingSpeedInBytesPerMillisecond());
- bytes_to_process = Min(bytes_to_process, max_step_size);
-
- size_t bytes_processed = 0;
- if (bytes_marked_ahead_of_schedule_ >= bytes_to_process) {
- // Steps performed in tasks have put us ahead of schedule.
- // We skip processing of marking dequeue here and thus
- // shift marking time from inside V8 to standalone tasks.
- bytes_marked_ahead_of_schedule_ -= bytes_to_process;
- bytes_processed = bytes_to_process;
- } else {
- bytes_processed = Step(bytes_to_process, GC_VIA_STACK_GUARD,
- FORCE_COMPLETION, StepOrigin::kV8);
- }
- bytes_allocated_ -= Min(bytes_allocated_, bytes_processed);
+ size_t bytes_to_process = StepSizeToKeepUpWithAllocations();
+
+ if (bytes_to_process < IncrementalMarking::kAllocatedThreshold) {
+ return;
+ }
+
+ bytes_to_process += StepSizeToMakeProgress();
+
+ // The first step after Scavenge will see many allocated bytes.
+ // Cap the step size to distribute the marking work more uniformly.
+ size_t max_step_size = GCIdleTimeHandler::EstimateMarkingStepSize(
+ kMaxStepSizeInMs,
+ heap()->tracer()->IncrementalMarkingSpeedInBytesPerMillisecond());
+ bytes_to_process = Min(bytes_to_process, max_step_size);
+
+ size_t bytes_processed = 0;
+ if (bytes_marked_ahead_of_schedule_ >= bytes_to_process) {
+ // Steps performed in tasks have put us ahead of schedule.
+ // We skip processing of marking dequeue here and thus
+ // shift marking time from inside V8 to standalone tasks.
+ bytes_marked_ahead_of_schedule_ -= bytes_to_process;
+ bytes_processed = bytes_to_process;
+ } else {
+ bytes_processed = Step(bytes_to_process, GC_VIA_STACK_GUARD,
+ FORCE_COMPLETION, StepOrigin::kV8);
}
+ bytes_allocated_ -= Min(bytes_allocated_, bytes_processed);
}
size_t IncrementalMarking::Step(size_t bytes_to_process,
« no previous file with comments | « src/heap/incremental-marking.h ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698