[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/582008
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46835}
This commit is contained in:
Ulan Degenbaev 2017-07-24 10:52:40 +02:00 committed by Commit Bot
parent d07365f9de
commit 5ea58bde1c
3 changed files with 11 additions and 5 deletions

View File

@ -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) {

View File

@ -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_ =

View File

@ -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();