Chromium Code Reviews| Index: src/heap/incremental-marking.cc |
| diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc |
| index 3e5e6c0697cd505bf49880d407891ef8f938458a..4064b46700b92b715ffa0aad4c80e0e1f4048e60 100644 |
| --- a/src/heap/incremental-marking.cc |
| +++ b/src/heap/incremental-marking.cc |
| @@ -17,6 +17,22 @@ |
| namespace v8 { |
| namespace internal { |
| +class IncrementalMarkingObserver : public InlineAllocationObserver { |
| + public: |
| + IncrementalMarkingObserver(IncrementalMarking& incremental_marking, |
| + intptr_t step_size) |
| + : InlineAllocationObserver(step_size), |
| + incremental_marking_(incremental_marking) {} |
| + |
| + virtual void Step(int bytes_allocated) { |
| + incremental_marking_.Step(bytes_allocated, |
| + IncrementalMarking::GC_VIA_STACK_GUARD); |
| + } |
| + |
| + private: |
| + IncrementalMarking& incremental_marking_; |
| +}; |
| + |
| IncrementalMarking::StepActions IncrementalMarking::IdleStepActions() { |
| return StepActions(IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
| @@ -27,6 +43,7 @@ IncrementalMarking::StepActions IncrementalMarking::IdleStepActions() { |
| IncrementalMarking::IncrementalMarking(Heap* heap) |
| : heap_(heap), |
| + observer_(nullptr), |
| state_(STOPPED), |
| is_compacting_(false), |
| steps_count_(0), |
| @@ -569,7 +586,9 @@ void IncrementalMarking::Start(const char* reason) { |
| state_ = SWEEPING; |
| } |
| - heap_->LowerInlineAllocationLimit(kAllocatedThreshold); |
| + observer_ = new IncrementalMarkingObserver(*this, kAllocatedThreshold); |
|
ulan
2015/10/22 09:02:22
I think we can bind the lifetime of the observer t
ofrobots
2015/10/26 21:55:01
Done.
|
| + heap_->new_space()->AddInlineAllocationObserver(observer_); |
| + |
| incremental_marking_job()->Start(heap_); |
| } |
| @@ -821,7 +840,13 @@ void IncrementalMarking::Stop() { |
| if (FLAG_trace_incremental_marking) { |
| PrintF("[IncrementalMarking] Stopping.\n"); |
| } |
| - heap_->ResetInlineAllocationLimit(); |
| + |
| + if (observer_) { |
| + heap_->new_space()->RemoveInlineAllocationObserver(observer_); |
| + delete observer_; |
|
Hannes Payer (out of office)
2015/10/22 09:14:14
Let's allocate/delete the observer at heap setup/s
ofrobots
2015/10/26 21:55:01
Done as per Ulan's suggestion above.
|
| + observer_ = nullptr; |
| + } |
| + |
| IncrementalMarking::set_should_hurry(false); |
| ResetStepCounters(); |
| if (IsMarking()) { |
| @@ -849,7 +874,12 @@ void IncrementalMarking::Finalize() { |
| Hurry(); |
| state_ = STOPPED; |
| is_compacting_ = false; |
| - heap_->ResetInlineAllocationLimit(); |
| + |
| + if (observer_) { |
| + heap_->new_space()->RemoveInlineAllocationObserver(observer_); |
| + delete observer_; |
| + observer_ = nullptr; |
| + } |
| IncrementalMarking::set_should_hurry(false); |
| ResetStepCounters(); |
| PatchIncrementalMarkingRecordWriteStubs(heap_, |