Chromium Code Reviews| Index: include/v8.h |
| diff --git a/include/v8.h b/include/v8.h |
| index 30445457c20638b5cd2512e29649ae370ab7f97f..7fde7e3d1b24f256a9f06b97b246984113163a36 100644 |
| --- a/include/v8.h |
| +++ b/include/v8.h |
| @@ -7589,6 +7589,7 @@ class V8_EXPORT Isolate { |
| friend class PersistentValueMapBase; |
| void ReportExternalAllocationLimitReached(); |
| + void CheckMemoryPressure(); |
| }; |
| class V8_EXPORT StartupData { |
| @@ -8816,6 +8817,8 @@ class Internals { |
| static const int kExternalMemoryOffset = 4 * kApiPointerSize; |
| static const int kExternalMemoryLimitOffset = |
| kExternalMemoryOffset + kApiInt64Size; |
| + static const int kExternalMemoryAtLastMarkCompactOffset = |
| + kExternalMemoryLimitOffset + kApiInt64Size; |
| static const int kIsolateRootsOffset = kExternalMemoryLimitOffset + |
| kApiInt64Size + kApiInt64Size + |
| kApiPointerSize + kApiPointerSize; |
| @@ -10038,8 +10041,23 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( |
| reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset); |
| const int64_t external_memory_limit = *reinterpret_cast<int64_t*>( |
| reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryLimitOffset); |
| + 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 memory_reducer_activation_limit = 1024 * 1024; |
|
Michael Lippautz
2017/06/01 18:47:05
kMemoryReducerActivationLimit and move to top of f
Hannes Payer (out of office)
2017/06/02 06:59:04
Done.
|
| + |
| *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 > memory_reducer_activation_limit) { |
| + CheckMemoryPressure(); |
| + } |
| + |
| if (change_in_bytes > 0 && amount > external_memory_limit) { |
| ReportExternalAllocationLimitReached(); |
| } |