Commit 5ea58bde authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Use AdjustAmountOfExternalMemory to account freed array buffers.

Currently GC decrements the external memory counter directly bypassing
the AdjustAmountOfExternalMemory. This is inconsistent with array
buffer allocation, which actually uses the API to increment the counter.

Change-Id: I401087872213fdd60f1a40c99c8f459c14dc0608
Reviewed-on: https://chromium-review.googlesource.com/582008Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46835}
parent d07365f9
......@@ -44,7 +44,8 @@ void ArrayBufferTracker::Unregister(Heap* heap, JSArrayBuffer* buffer) {
DCHECK_NOT_NULL(tracker);
tracker->Remove(buffer, length);
}
heap->update_external_memory(-static_cast<intptr_t>(length));
reinterpret_cast<v8::Isolate*>(heap->isolate())
->AdjustAmountOfExternalAllocatedMemory(-static_cast<int64_t>(length));
}
void LocalArrayBufferTracker::Add(JSArrayBuffer* buffer, size_t length) {
......
......@@ -2255,6 +2255,14 @@ void Heap::UnregisterArrayBuffer(JSArrayBuffer* buffer) {
ArrayBufferTracker::Unregister(this, buffer);
}
void Heap::account_external_memory_concurrently_freed() {
DCHECK_NE(gc_state_, NOT_IN_GC);
uint64_t delta = external_memory_concurrently_freed_.Value();
external_memory_concurrently_freed_.SetValue(0);
reinterpret_cast<v8::Isolate*>(isolate())
->AdjustAmountOfExternalAllocatedMemory(delta);
}
void Heap::ConfigureInitialOldGenerationSize() {
if (!old_generation_size_configured_ && tracer()->SurvivalEventsRecorded()) {
old_generation_allocation_limit_ =
......
......@@ -855,10 +855,7 @@ class Heap {
external_memory_concurrently_freed_.Increment(freed);
}
void account_external_memory_concurrently_freed() {
external_memory_ -= external_memory_concurrently_freed_.Value();
external_memory_concurrently_freed_.SetValue(0);
}
void account_external_memory_concurrently_freed();
void DeoptMarkedAllocationSites();
......
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