Commit 734c34e5 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Move GetNextInlineAllocationStepSize() into AllocationCounter

Bug: v8:10315
Change-Id: I124642564d6644f864235c7fa89687e64b1e79c7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2315995Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69033}
parent 198deea2
......@@ -33,6 +33,16 @@ void AllocationObserver::AllocationStep(int bytes_allocated,
DCHECK_GE(bytes_to_next_step_, 0);
}
intptr_t AllocationCounter::GetNextInlineAllocationStepSize() {
intptr_t next_step = 0;
for (AllocationObserver* observer : allocation_observers_) {
next_step = next_step ? Min(next_step, observer->bytes_to_next_step())
: observer->bytes_to_next_step();
}
DCHECK(!HasAllocationObservers() || next_step > 0);
return next_step;
}
PauseAllocationObserversScope::PauseAllocationObserversScope(Heap* heap)
: heap_(heap) {
DCHECK_EQ(heap->gc_state(), Heap::NOT_IN_GC);
......
......@@ -39,6 +39,8 @@ class AllocationCounter {
paused_ = false;
}
intptr_t GetNextInlineAllocationStepSize();
private:
bool IsPaused() { return paused_; }
......@@ -86,7 +88,7 @@ class AllocationObserver {
intptr_t bytes_to_next_step_;
private:
friend class Space;
friend class AllocationCounter;
DISALLOW_COPY_AND_ASSIGN(AllocationObserver);
};
......
......@@ -289,16 +289,6 @@ void Space::AllocationStepAfterMerge(Address first_object_in_chunk, int size) {
heap()->set_allocation_step_in_progress(false);
}
intptr_t Space::GetNextInlineAllocationStepSize() {
intptr_t next_step = 0;
for (AllocationObserver* observer : allocation_counter_) {
next_step = next_step ? Min(next_step, observer->bytes_to_next_step())
: observer->bytes_to_next_step();
}
DCHECK(!allocation_counter_.HasAllocationObservers() || next_step > 0);
return next_step;
}
Address SpaceWithLinearArea::ComputeLimit(Address start, Address end,
size_t min_size) {
DCHECK_GE(end - start, min_size);
......@@ -309,7 +299,7 @@ Address SpaceWithLinearArea::ComputeLimit(Address start, Address end,
} else if (SupportsInlineAllocation() && allocation_counter_.IsActive()) {
// Generated code may allocate inline from the linear allocation area for.
// To make sure we can observe these allocations, we use a lower limit.
size_t step = GetNextInlineAllocationStepSize();
size_t step = allocation_counter_.GetNextInlineAllocationStepSize();
size_t rounded_step =
RoundSizeDownToObjectAlignment(static_cast<int>(step - 1));
return Min(static_cast<Address>(start + min_size + rounded_step), end);
......
......@@ -191,8 +191,6 @@ class V8_EXPORT_PRIVATE Space : public BaseSpace {
#endif
protected:
intptr_t GetNextInlineAllocationStepSize();
AllocationCounter allocation_counter_;
// The List manages the pages that belong to the given space.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment