Index: src/heap/spaces.cc |
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc |
index 457fd19c111fa0271e1d9f76f5491b5de5339c1c..c568199ef030a1171d34e8e6f3d45c099213e059 100644 |
--- a/src/heap/spaces.cc |
+++ b/src/heap/spaces.cc |
@@ -1509,7 +1509,7 @@ void NewSpace::UpdateInlineAllocationLimit(int size_in_bytes) { |
Address high = to_space_.page_high(); |
Address new_top = allocation_info_.top() + size_in_bytes; |
allocation_info_.set_limit(Min(new_top, high)); |
- } else if (inline_allocation_limit_step_ == 0) { |
+ } else if (top_on_previous_step_ == 0) { |
// Normal limit is the end of the current page. |
allocation_info_.set_limit(to_space_.page_high()); |
} else { |
@@ -1601,12 +1601,40 @@ bool NewSpace::EnsureAllocation(int size_in_bytes, |
} |
+void NewSpace::UpdateInlineAllocationLimitStep() { |
+ intptr_t step = 0; |
+ for (int i = 0; i < inline_allocation_observers_.length(); ++i) { |
+ InlineAllocationObserver* observer = inline_allocation_observers_[i]; |
+ step = step ? Min(step, observer->step_size()) : observer->step_size(); |
+ } |
+ inline_allocation_limit_step_ = step; |
+ top_on_previous_step_ = step ? allocation_info_.top() : 0; |
+ UpdateInlineAllocationLimit(0); |
+} |
+ |
+ |
+void NewSpace::AddInlineAllocationObserver(InlineAllocationObserver* observer) { |
+ inline_allocation_observers_.Add(observer); |
+ UpdateInlineAllocationLimitStep(); |
+} |
+ |
+ |
+void NewSpace::RemoveInlineAllocationObserver( |
+ InlineAllocationObserver* observer) { |
+ bool removed = inline_allocation_observers_.RemoveElement(observer); |
+ // Only used in assertion. Suppress unused variable warning. |
+ static_cast<void>(removed); |
+ DCHECK(removed); |
+ UpdateInlineAllocationLimitStep(); |
+} |
+ |
+ |
void NewSpace::InlineAllocationStep(Address top, Address new_top) { |
if (top_on_previous_step_) { |
int bytes_allocated = static_cast<int>(top - top_on_previous_step_); |
- heap()->ScheduleIdleScavengeIfNeeded(bytes_allocated); |
- heap()->incremental_marking()->Step(bytes_allocated, |
- IncrementalMarking::GC_VIA_STACK_GUARD); |
+ for (int i = 0; i < inline_allocation_observers_.length(); ++i) { |
+ inline_allocation_observers_[i]->InlineAllocationStep(bytes_allocated); |
+ } |
top_on_previous_step_ = new_top; |
} |
} |