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 <hpayer@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57024}
This commit is contained in:
Michael Lippautz 2018-10-26 10:15:10 +02:00 committed by Commit Bot
parent 6f39ab8911
commit ae45472b6c

View File

@ -10391,7 +10391,7 @@ MaybeLocal<T> 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<int64_t*>(
reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset);
int64_t* external_memory_limit = reinterpret_cast<int64_t*>(
@ -10399,15 +10399,12 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory(
int64_t* external_memory_at_last_mc =
reinterpret_cast<int64_t*>(reinterpret_cast<uint8_t*>(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();
}