From 906cb204d069de8d1a27f2039d0c1c1509a6ad89 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 13 Jul 2016 10:44:41 -0700 Subject: [PATCH] Flush the optimizing compilejob queue when doing memory pressure GCs R=ulan@chromium.org,hpayer@chromium.org BUG= Review-Url: https://codereview.chromium.org/2145683003 Cr-Commit-Position: refs/heads/master@{#37726} --- src/compiler.cc | 10 ++++++++++ src/heap/heap.cc | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/compiler.cc b/src/compiler.cc index 8fac53e970..992ed4e82d 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -23,6 +23,7 @@ #include "src/frames-inl.h" #include "src/full-codegen/full-codegen.h" #include "src/globals.h" +#include "src/heap/heap.h" #include "src/interpreter/interpreter.h" #include "src/isolate-inl.h" #include "src/log-inl.h" @@ -705,6 +706,15 @@ bool GetOptimizedCodeLater(CompilationJob* job) { return false; } + if (isolate->heap()->HighMemoryPressure()) { + if (FLAG_trace_concurrent_recompilation) { + PrintF(" ** High memory pressure, will retry optimizing "); + info->closure()->ShortPrint(); + PrintF(" later.\n"); + } + return false; + } + // All handles below this point will be allocated in a deferred handle scope // that is detached and handed off to the background thread when we return. CompilationHandleScope handle_scope(info); diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 57be4fa023..60875dd9fa 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -4373,6 +4373,13 @@ class MemoryPressureInterruptTask : public CancelableTask { }; void Heap::CheckMemoryPressure() { + if (HighMemoryPressure()) { + if (isolate()->concurrent_recompilation_enabled()) { + // The optimizing compiler may be unnecessarily holding on to memory. + DisallowHeapAllocation no_recursive_gc; + isolate()->optimizing_compile_dispatcher()->Flush(); + } + } if (memory_pressure_level_.Value() == MemoryPressureLevel::kCritical) { CollectGarbageOnMemoryPressure("memory pressure"); } else if (memory_pressure_level_.Value() == MemoryPressureLevel::kModerate) {