Chromium Code Reviews| Index: src/heap/heap.h |
| diff --git a/src/heap/heap.h b/src/heap/heap.h |
| index 44a080b1e0914ddbd9c40772bcd7d2cc03c3b393..4694ffb459d46acb9862a9ab0ec31955c123b343 100644 |
| --- a/src/heap/heap.h |
| +++ b/src/heap/heap.h |
| @@ -10,6 +10,7 @@ |
| // Clients of this interface shouldn't depend on lots of heap internals. |
| // Do not include anything from src/heap here! |
| +#include "include/v8.h" |
| #include "src/allocation.h" |
| #include "src/assert-scope.h" |
| #include "src/atomic-utils.h" |
| @@ -23,6 +24,8 @@ |
| namespace v8 { |
| namespace internal { |
| +using v8::MemoryPressureLevel; |
| + |
| // Defines all the roots in Heap. |
| #define STRONG_ROOT_LIST(V) \ |
| V(Map, byte_array_map, ByteArrayMap) \ |
| @@ -736,6 +739,9 @@ class Heap { |
| bool IdleNotification(double deadline_in_seconds); |
| bool IdleNotification(int idle_time_in_ms); |
| + void MemoryPressureNotification(MemoryPressureLevel level, |
| + bool is_isolate_locked); |
| + |
| double MonotonicallyIncreasingTimeInMs(); |
| void RecordStats(HeapStats* stats, bool take_snapshot = false); |
| @@ -750,6 +756,9 @@ class Heap { |
| if (PromotedTotalSize() >= adjusted_allocation_limit) return true; |
| + if (memory_pressure_level_.Value() != MemoryPressureLevel::kNone) |
| + return true; |
| + |
| return false; |
| } |
| @@ -833,7 +842,10 @@ class Heap { |
| void SetOptimizeForLatency() { optimize_for_memory_usage_ = false; } |
| void SetOptimizeForMemoryUsage(); |
| - bool ShouldOptimizeForMemoryUsage() { return optimize_for_memory_usage_; } |
| + bool ShouldOptimizeForMemoryUsage() { |
| + return optimize_for_memory_usage_ || |
| + memory_pressure_level_.Value() != MemoryPressureLevel::kNone; |
| + } |
| // =========================================================================== |
| // Initialization. =========================================================== |
| @@ -1996,6 +2008,8 @@ class Heap { |
| // count, as scopes can be acquired from multiple tasks (read: threads). |
| AtomicNumber<size_t> always_allocate_scope_count_; |
| + AtomicValue<MemoryPressureLevel> memory_pressure_level_; |
|
Hannes Payer (out of office)
2016/03/18 13:27:26
For completeness, add a comment to describe that f
ulan
2016/03/18 16:10:00
Done.
|
| + |
| // For keeping track of context disposals. |
| int contexts_disposed_; |