From ae45472b6c7e5cce7c0979bbeafbf5c098b77221 Mon Sep 17 00:00:00 2001 From: Michael Lippautz Date: Fri, 26 Oct 2018 10:15:10 +0200 Subject: [PATCH] AdjustAmountOfExternalAllocatedMemory: Do not trigger GCs when reducing amount GCs should only trigger only trigger when growing external memory but not when removing it. - The limit is already lowered when removing memory, so possible future allocations check against a lowered limit. - Memory pressure signals are already handled via an explicit V8 API. Bug: chromium:899035 Change-Id: I96da5862400e06edb8c9fa47357070b3b48560a1 Reviewed-on: https://chromium-review.googlesource.com/c/1301473 Reviewed-by: Hannes Payer Reviewed-by: Ulan Degenbaev Commit-Queue: Michael Lippautz Cr-Commit-Position: refs/heads/master@{#57024} --- include/v8.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/v8.h b/include/v8.h index d840a447aa..fb30bdd5c0 100644 --- a/include/v8.h +++ b/include/v8.h @@ -10391,7 +10391,7 @@ MaybeLocal Isolate::GetDataFromSnapshotOnce(size_t index) { int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( int64_t change_in_bytes) { typedef internal::Internals I; - const int64_t kMemoryReducerActivationLimit = 32 * 1024 * 1024; + constexpr int64_t kMemoryReducerActivationLimit = 32 * 1024 * 1024; int64_t* external_memory = reinterpret_cast( reinterpret_cast(this) + I::kExternalMemoryOffset); int64_t* external_memory_limit = reinterpret_cast( @@ -10399,15 +10399,12 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( int64_t* external_memory_at_last_mc = reinterpret_cast(reinterpret_cast(this) + I::kExternalMemoryAtLastMarkCompactOffset); - const int64_t amount = *external_memory + change_in_bytes; + const int64_t amount = *external_memory + change_in_bytes; *external_memory = amount; int64_t allocation_diff_since_last_mc = *external_memory_at_last_mc - *external_memory; - allocation_diff_since_last_mc = allocation_diff_since_last_mc < 0 - ? -allocation_diff_since_last_mc - : allocation_diff_since_last_mc; if (allocation_diff_since_last_mc > kMemoryReducerActivationLimit) { CheckMemoryPressure(); }