Revert "[heap] Add missing steps for Add/Remove observers"
This reverts commit e770879eee
.
Reason for revert: broke on this build: https://build.chromium.org/p/client.v8/builders/V8%20Mac%20-%20debug/builds/16703
Original change's description:
> [heap] Add missing steps for Add/Remove observers
>
> Change-Id: I9935ff4debc623af674e606c006085258b685ced
> Reviewed-on: https://chromium-review.googlesource.com/715118
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Commit-Queue: Ali Ijaz Sheikh <ofrobots@google.com>
> Cr-Commit-Position: refs/heads/master@{#48513}
TBR=ulan@chromium.org,mlippautz@chromium.org,ofrobots@google.com
Change-Id: Idc53870cbcb692e79764dfe0984ff765ed2458f3
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/717318
Reviewed-by: Ali Ijaz Sheikh <ofrobots@google.com>
Commit-Queue: Ali Ijaz Sheikh <ofrobots@google.com>
Cr-Commit-Position: refs/heads/master@{#48515}
This commit is contained in:
parent
ae32e6e121
commit
1cedda2510
@ -6372,16 +6372,5 @@ void Heap::CreateObjectStats() {
|
||||
}
|
||||
}
|
||||
|
||||
void AllocationObserver::AllocationStep(int bytes_allocated,
|
||||
Address soon_object, size_t size) {
|
||||
DCHECK_GE(bytes_allocated, 0);
|
||||
bytes_to_next_step_ -= bytes_allocated;
|
||||
if (bytes_to_next_step_ <= 0) {
|
||||
Step(static_cast<int>(step_size_ - bytes_to_next_step_), soon_object, size);
|
||||
step_size_ = GetNextStepSize();
|
||||
bytes_to_next_step_ = step_size_;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -2648,7 +2648,15 @@ class AllocationObserver {
|
||||
// Called each time the observed space does an allocation step. This may be
|
||||
// more frequently than the step_size we are monitoring (e.g. when there are
|
||||
// multiple observers, or when page or space boundary is encountered.)
|
||||
void AllocationStep(int bytes_allocated, Address soon_object, size_t size);
|
||||
void AllocationStep(int bytes_allocated, Address soon_object, size_t size) {
|
||||
bytes_to_next_step_ -= bytes_allocated;
|
||||
if (bytes_to_next_step_ <= 0) {
|
||||
Step(static_cast<int>(step_size_ - bytes_to_next_step_), soon_object,
|
||||
size);
|
||||
step_size_ = GetNextStepSize();
|
||||
bytes_to_next_step_ = step_size_;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
intptr_t step_size() const { return step_size_; }
|
||||
|
@ -103,7 +103,7 @@ void ScavengeJob::ScheduleIdleTaskIfNeeded(Heap* heap, int bytes_allocated) {
|
||||
|
||||
|
||||
void ScavengeJob::ScheduleIdleTask(Heap* heap) {
|
||||
if (!idle_task_pending_ && heap->use_tasks()) {
|
||||
if (!idle_task_pending_) {
|
||||
v8::Isolate* isolate = reinterpret_cast<v8::Isolate*>(heap->isolate());
|
||||
if (V8::GetCurrentPlatform()->IdleTasksEnabled(isolate)) {
|
||||
idle_task_pending_ = true;
|
||||
|
@ -1696,7 +1696,12 @@ void PagedSpace::EmptyAllocationInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
InlineAllocationStep(current_top, nullptr, nullptr, 0);
|
||||
if (top_on_previous_step_) {
|
||||
DCHECK(current_top >= top_on_previous_step_);
|
||||
AllocationStep(static_cast<int>(current_top - top_on_previous_step_),
|
||||
nullptr, 0);
|
||||
top_on_previous_step_ = 0;
|
||||
}
|
||||
SetTopAndLimit(NULL, NULL);
|
||||
DCHECK_GE(current_limit, current_top);
|
||||
Free(current_top, current_limit - current_top);
|
||||
@ -2145,30 +2150,6 @@ void NewSpace::StartNextInlineAllocationStep() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(ofrobots): refactor into SpaceWithLinearArea
|
||||
void NewSpace::AddAllocationObserver(AllocationObserver* observer) {
|
||||
InlineAllocationStep(top(), top(), nullptr, 0);
|
||||
Space::AddAllocationObserver(observer);
|
||||
}
|
||||
|
||||
// TODO(ofrobots): refactor into SpaceWithLinearArea
|
||||
void PagedSpace::AddAllocationObserver(AllocationObserver* observer) {
|
||||
InlineAllocationStep(top(), top(), nullptr, 0);
|
||||
Space::AddAllocationObserver(observer);
|
||||
}
|
||||
|
||||
// TODO(ofrobots): refactor into SpaceWithLinearArea
|
||||
void NewSpace::RemoveAllocationObserver(AllocationObserver* observer) {
|
||||
InlineAllocationStep(top(), top(), nullptr, 0);
|
||||
Space::RemoveAllocationObserver(observer);
|
||||
}
|
||||
|
||||
// TODO(ofrobots): refactor into SpaceWithLinearArea
|
||||
void PagedSpace::RemoveAllocationObserver(AllocationObserver* observer) {
|
||||
InlineAllocationStep(top(), top(), nullptr, 0);
|
||||
Space::RemoveAllocationObserver(observer);
|
||||
}
|
||||
|
||||
void NewSpace::PauseAllocationObservers() {
|
||||
// Do a step to account for memory allocated so far.
|
||||
InlineAllocationStep(top(), top(), nullptr, 0);
|
||||
@ -2179,7 +2160,10 @@ void NewSpace::PauseAllocationObservers() {
|
||||
|
||||
void PagedSpace::PauseAllocationObservers() {
|
||||
// Do a step to account for memory allocated so far.
|
||||
InlineAllocationStep(top(), nullptr, nullptr, 0);
|
||||
if (top_on_previous_step_) {
|
||||
int bytes_allocated = static_cast<int>(top() - top_on_previous_step_);
|
||||
AllocationStep(bytes_allocated, nullptr, 0);
|
||||
}
|
||||
Space::PauseAllocationObservers();
|
||||
top_on_previous_step_ = 0;
|
||||
}
|
||||
@ -2197,21 +2181,13 @@ void PagedSpace::ResumeAllocationObservers() {
|
||||
StartNextInlineAllocationStep();
|
||||
}
|
||||
|
||||
// TODO(ofrobots): refactor into SpaceWithLinearArea
|
||||
void PagedSpace::InlineAllocationStep(Address top, Address new_top,
|
||||
Address soon_object, size_t size) {
|
||||
if (top_on_previous_step_) {
|
||||
int bytes_allocated = static_cast<int>(top - top_on_previous_step_);
|
||||
AllocationStep(bytes_allocated, soon_object, static_cast<int>(size));
|
||||
top_on_previous_step_ = new_top;
|
||||
}
|
||||
}
|
||||
|
||||
void NewSpace::InlineAllocationStep(Address top, Address new_top,
|
||||
Address soon_object, size_t size) {
|
||||
if (top_on_previous_step_) {
|
||||
int bytes_allocated = static_cast<int>(top - top_on_previous_step_);
|
||||
AllocationStep(bytes_allocated, soon_object, static_cast<int>(size));
|
||||
for (AllocationObserver* observer : allocation_observers_) {
|
||||
observer->AllocationStep(bytes_allocated, soon_object, size);
|
||||
}
|
||||
top_on_previous_step_ = new_top;
|
||||
}
|
||||
}
|
||||
|
@ -903,11 +903,9 @@ class Space : public Malloced {
|
||||
// Identity used in error reporting.
|
||||
AllocationSpace identity() { return id_; }
|
||||
|
||||
V8_EXPORT_PRIVATE virtual void AddAllocationObserver(
|
||||
AllocationObserver* observer);
|
||||
void AddAllocationObserver(AllocationObserver* observer);
|
||||
|
||||
V8_EXPORT_PRIVATE virtual void RemoveAllocationObserver(
|
||||
AllocationObserver* observer);
|
||||
void RemoveAllocationObserver(AllocationObserver* observer);
|
||||
|
||||
V8_EXPORT_PRIVATE virtual void PauseAllocationObservers();
|
||||
|
||||
@ -2080,14 +2078,9 @@ class V8_EXPORT_PRIVATE PagedSpace : NON_EXPORTED_BASE(public Space) {
|
||||
|
||||
void ResetFreeList() { free_list_.Reset(); }
|
||||
|
||||
void AddAllocationObserver(AllocationObserver* observer) override;
|
||||
void RemoveAllocationObserver(AllocationObserver* observer) override;
|
||||
void PauseAllocationObservers() override;
|
||||
void ResumeAllocationObservers() override;
|
||||
|
||||
void InlineAllocationStep(Address top, Address new_top, Address soon_object,
|
||||
size_t size);
|
||||
|
||||
// Empty space allocation info, returning unused area to free list.
|
||||
void EmptyAllocationInfo();
|
||||
|
||||
@ -2737,8 +2730,6 @@ class NewSpace : public Space {
|
||||
|
||||
SemiSpace* active_space() { return &to_space_; }
|
||||
|
||||
void AddAllocationObserver(AllocationObserver* observer) override;
|
||||
void RemoveAllocationObserver(AllocationObserver* observer) override;
|
||||
void PauseAllocationObservers() override;
|
||||
void ResumeAllocationObservers() override;
|
||||
|
||||
|
@ -3137,28 +3137,3 @@ TEST(SamplingHeapProfilerPretenuredInlineAllocations) {
|
||||
|
||||
CHECK_GE(count, 9000);
|
||||
}
|
||||
|
||||
TEST(SamplingHeapProfilerLargeInterval) {
|
||||
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
||||
LocalContext env;
|
||||
v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
|
||||
|
||||
// Suppress randomness to avoid flakiness in tests.
|
||||
v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true;
|
||||
|
||||
heap_profiler->StartSamplingHeapProfiler(512 * 1024);
|
||||
|
||||
for (int i = 0; i < 8 * 1024; ++i) {
|
||||
CcTest::i_isolate()->factory()->NewFixedArray(1024);
|
||||
}
|
||||
|
||||
std::unique_ptr<v8::AllocationProfile> profile(
|
||||
heap_profiler->GetAllocationProfile());
|
||||
CHECK(profile);
|
||||
const char* names[] = {"(EXTERNAL)"};
|
||||
auto node = FindAllocationProfileNode(env->GetIsolate(), *profile,
|
||||
ArrayVector(names));
|
||||
CHECK(node);
|
||||
|
||||
heap_profiler->StopSamplingHeapProfiler();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user