Commit 22858cb0 authored by jochen's avatar jochen Committed by Commit bot

Only flush not yet started and finished compile jobs from gc

We shouldn't block during GC for arbitrarily long intervals.

BUG=chromium:686153,chromium:642532
R=verwaest@chromium.org,hpayer@chromium.org

Review-Url: https://codereview.chromium.org/2658313002
Cr-Commit-Position: refs/heads/master@{#42761}
parent 82204eac
...@@ -134,7 +134,23 @@ void OptimizingCompileDispatcher::FlushOutputQueue(bool restore_function_code) { ...@@ -134,7 +134,23 @@ void OptimizingCompileDispatcher::FlushOutputQueue(bool restore_function_code) {
} }
} }
void OptimizingCompileDispatcher::Flush() { void OptimizingCompileDispatcher::Flush(BlockingBehavior blocking_behavior) {
if (FLAG_block_concurrent_recompilation) Unblock();
if (blocking_behavior == BlockingBehavior::kDontBlock) {
base::LockGuard<base::Mutex> access_input_queue_(&input_queue_mutex_);
while (input_queue_length_ > 0) {
CompilationJob* job = input_queue_[InputQueueIndex(0)];
DCHECK_NOT_NULL(job);
input_queue_shift_ = InputQueueIndex(1);
input_queue_length_--;
DisposeCompilationJob(job, true);
}
FlushOutputQueue(true);
if (FLAG_trace_concurrent_recompilation) {
PrintF(" ** Flushed concurrent recompilation queues (not blocking).\n");
}
return;
}
base::Release_Store(&mode_, static_cast<base::AtomicWord>(FLUSH)); base::Release_Store(&mode_, static_cast<base::AtomicWord>(FLUSH));
if (FLAG_block_concurrent_recompilation) Unblock(); if (FLAG_block_concurrent_recompilation) Unblock();
{ {
......
...@@ -22,6 +22,8 @@ class SharedFunctionInfo; ...@@ -22,6 +22,8 @@ class SharedFunctionInfo;
class OptimizingCompileDispatcher { class OptimizingCompileDispatcher {
public: public:
enum class BlockingBehavior { kBlock, kDontBlock };
explicit OptimizingCompileDispatcher(Isolate* isolate) explicit OptimizingCompileDispatcher(Isolate* isolate)
: isolate_(isolate), : isolate_(isolate),
input_queue_capacity_(FLAG_concurrent_recompilation_queue_length), input_queue_capacity_(FLAG_concurrent_recompilation_queue_length),
...@@ -38,7 +40,7 @@ class OptimizingCompileDispatcher { ...@@ -38,7 +40,7 @@ class OptimizingCompileDispatcher {
void Run(); void Run();
void Stop(); void Stop();
void Flush(); void Flush(BlockingBehavior blocking_behavior);
void QueueForOptimization(CompilationJob* job); void QueueForOptimization(CompilationJob* job);
void Unblock(); void Unblock();
void InstallOptimizedFunctions(); void InstallOptimizedFunctions();
......
...@@ -1268,7 +1268,8 @@ bool Debug::PrepareFunctionForBreakPoints(Handle<SharedFunctionInfo> shared) { ...@@ -1268,7 +1268,8 @@ bool Debug::PrepareFunctionForBreakPoints(Handle<SharedFunctionInfo> shared) {
DCHECK(shared->is_compiled()); DCHECK(shared->is_compiled());
if (isolate_->concurrent_recompilation_enabled()) { if (isolate_->concurrent_recompilation_enabled()) {
isolate_->optimizing_compile_dispatcher()->Flush(); isolate_->optimizing_compile_dispatcher()->Flush(
OptimizingCompileDispatcher::BlockingBehavior::kBlock);
} }
List<Handle<JSFunction> > functions; List<Handle<JSFunction> > functions;
......
...@@ -876,7 +876,8 @@ void Heap::CollectAllAvailableGarbage(GarbageCollectionReason gc_reason) { ...@@ -876,7 +876,8 @@ void Heap::CollectAllAvailableGarbage(GarbageCollectionReason gc_reason) {
if (isolate()->concurrent_recompilation_enabled()) { if (isolate()->concurrent_recompilation_enabled()) {
// The optimizing compiler may be unnecessarily holding on to memory. // The optimizing compiler may be unnecessarily holding on to memory.
DisallowHeapAllocation no_recursive_gc; DisallowHeapAllocation no_recursive_gc;
isolate()->optimizing_compile_dispatcher()->Flush(); isolate()->optimizing_compile_dispatcher()->Flush(
OptimizingCompileDispatcher::BlockingBehavior::kDontBlock);
} }
isolate()->ClearSerializerData(); isolate()->ClearSerializerData();
set_current_gc_flags(kMakeHeapIterableMask | kReduceMemoryFootprintMask); set_current_gc_flags(kMakeHeapIterableMask | kReduceMemoryFootprintMask);
...@@ -1075,7 +1076,8 @@ int Heap::NotifyContextDisposed(bool dependant_context) { ...@@ -1075,7 +1076,8 @@ int Heap::NotifyContextDisposed(bool dependant_context) {
} }
if (isolate()->concurrent_recompilation_enabled()) { if (isolate()->concurrent_recompilation_enabled()) {
// Flush the queued recompilation tasks. // Flush the queued recompilation tasks.
isolate()->optimizing_compile_dispatcher()->Flush(); isolate()->optimizing_compile_dispatcher()->Flush(
OptimizingCompileDispatcher::BlockingBehavior::kDontBlock);
} }
AgeInlineCaches(); AgeInlineCaches();
number_of_disposed_maps_ = retained_maps()->Length(); number_of_disposed_maps_ = retained_maps()->Length();
...@@ -4490,7 +4492,8 @@ void Heap::CheckMemoryPressure() { ...@@ -4490,7 +4492,8 @@ void Heap::CheckMemoryPressure() {
if (isolate()->concurrent_recompilation_enabled()) { if (isolate()->concurrent_recompilation_enabled()) {
// The optimizing compiler may be unnecessarily holding on to memory. // The optimizing compiler may be unnecessarily holding on to memory.
DisallowHeapAllocation no_recursive_gc; DisallowHeapAllocation no_recursive_gc;
isolate()->optimizing_compile_dispatcher()->Flush(); isolate()->optimizing_compile_dispatcher()->Flush(
OptimizingCompileDispatcher::BlockingBehavior::kDontBlock);
} }
} }
if (memory_pressure_level_.Value() == MemoryPressureLevel::kCritical) { if (memory_pressure_level_.Value() == MemoryPressureLevel::kCritical) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment