Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/V8GCForContextDispose.cpp |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/V8GCForContextDispose.cpp b/third_party/WebKit/Source/bindings/core/v8/V8GCForContextDispose.cpp |
| index deca64c5ee5773498a32c574de0a5dbd4732bfce..4fb2a494db3604a854687809cd1801d80b2bb83b 100644 |
| --- a/third_party/WebKit/Source/bindings/core/v8/V8GCForContextDispose.cpp |
| +++ b/third_party/WebKit/Source/bindings/core/v8/V8GCForContextDispose.cpp |
| @@ -30,12 +30,26 @@ |
| #include "bindings/core/v8/V8GCForContextDispose.h" |
| +#include "platform/Histogram.h" |
| +#include "platform/MemoryCoordinator.h" |
| #include "platform/bindings/V8PerIsolateData.h" |
| #include "platform/wtf/CurrentTime.h" |
| +#include "platform/wtf/ProcessMetrics.h" |
| #include "platform/wtf/StdLibExtras.h" |
| #include "public/platform/Platform.h" |
| #include "v8/include/v8.h" |
| +size_t GetMemoryUsage() { |
| + size_t usage = WTF::GetMallocUsage() + WTF::Partitions::TotalActiveBytes() + |
| + blink::ProcessHeap::TotalAllocatedObjectSize() + |
| + blink::ProcessHeap::TotalMarkedObjectSize(); |
| + v8::HeapStatistics v8_heap_statistics; |
| + blink::V8PerIsolateData::MainThreadIsolate()->GetHeapStatistics( |
| + &v8_heap_statistics); |
| + usage = v8_heap_statistics.total_heap_size(); |
| + return usage; |
| +} |
| + |
| namespace blink { |
| V8GCForContextDispose::V8GCForContextDispose() |
| @@ -43,9 +57,22 @@ V8GCForContextDispose::V8GCForContextDispose() |
| Reset(); |
| } |
| -void V8GCForContextDispose::NotifyContextDisposed(bool is_main_frame) { |
| +void V8GCForContextDispose::NotifyContextDisposed(bool is_main_frame, |
| + bool reusing_frame) { |
| did_dispose_context_for_main_frame_ = is_main_frame; |
| last_context_disposal_time_ = WTF::CurrentTime(); |
| + if (is_main_frame && reusing_frame && MemoryCoordinator::IsLowEndDevice() && |
| + MemoryCoordinator::IsCurrentlyLowMemory()) { |
|
haraken
2017/06/23 04:17:00
Add a comment and explain what this is doing.
keishi
2017/06/23 06:25:03
Done.
|
| + size_t pre_gc_memory_usage = GetMemoryUsage(); |
| + V8PerIsolateData::MainThreadIsolate()->MemoryPressureNotification( |
| + v8::MemoryPressureLevel::kCritical); |
|
haraken
2017/06/23 04:17:00
Does this force an Oilpan conservative GC inside t
keishi
2017/06/23 06:25:03
V8GController will run a conservative ForcedGC syn
|
| + size_t post_gc_memory_usage = GetMemoryUsage(); |
| + int reduction = static_cast<int>(pre_gc_memory_usage) - |
| + static_cast<int>(post_gc_memory_usage); |
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, reduction_histogram, |
| + ("LowMemoryPageNavigationGC.Reduction", 0, 512, 50)); |
| + reduction_histogram.Count(reduction / 1024 / 1024); |
| + } |
| V8PerIsolateData::MainThreadIsolate()->ContextDisposedNotification( |
| !is_main_frame); |
| pseudo_idle_timer_.Stop(); |