Skip to content

Commit

Permalink
deps: cherry-pick 22858cb from V8 upstream
Browse files Browse the repository at this point in the history
Original commit message:
  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}

PR-URL: #11998
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
ofrobots authored and italoacasas committed Apr 10, 2017
1 parent 211dd16 commit 9f73df5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
18 changes: 17 additions & 1 deletion deps/v8/src/compiler-dispatcher/optimizing-compile-dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
if (FLAG_block_concurrent_recompilation) Unblock();
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class SharedFunctionInfo;

class OptimizingCompileDispatcher {
public:
enum class BlockingBehavior { kBlock, kDontBlock };

explicit OptimizingCompileDispatcher(Isolate* isolate)
: isolate_(isolate),
input_queue_capacity_(FLAG_concurrent_recompilation_queue_length),
Expand All @@ -38,7 +40,7 @@ class OptimizingCompileDispatcher {

void Run();
void Stop();
void Flush();
void Flush(BlockingBehavior blocking_behavior);
void QueueForOptimization(CompilationJob* job);
void Unblock();
void InstallOptimizedFunctions();
Expand Down
3 changes: 2 additions & 1 deletion deps/v8/src/debug/debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,8 @@ bool Debug::PrepareFunctionForBreakPoints(Handle<SharedFunctionInfo> shared) {
DCHECK(shared->is_compiled());

if (isolate_->concurrent_recompilation_enabled()) {
isolate_->optimizing_compile_dispatcher()->Flush();
isolate_->optimizing_compile_dispatcher()->Flush(
OptimizingCompileDispatcher::BlockingBehavior::kBlock);
}

List<Handle<JSFunction> > functions;
Expand Down
9 changes: 6 additions & 3 deletions deps/v8/src/heap/heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,8 @@ void Heap::CollectAllAvailableGarbage(GarbageCollectionReason gc_reason) {
if (isolate()->concurrent_recompilation_enabled()) {
// The optimizing compiler may be unnecessarily holding on to memory.
DisallowHeapAllocation no_recursive_gc;
isolate()->optimizing_compile_dispatcher()->Flush();
isolate()->optimizing_compile_dispatcher()->Flush(
OptimizingCompileDispatcher::BlockingBehavior::kDontBlock);
}
isolate()->ClearSerializerData();
set_current_gc_flags(kMakeHeapIterableMask | kReduceMemoryFootprintMask);
Expand Down Expand Up @@ -1056,7 +1057,8 @@ int Heap::NotifyContextDisposed(bool dependant_context) {
}
if (isolate()->concurrent_recompilation_enabled()) {
// Flush the queued recompilation tasks.
isolate()->optimizing_compile_dispatcher()->Flush();
isolate()->optimizing_compile_dispatcher()->Flush(
OptimizingCompileDispatcher::BlockingBehavior::kDontBlock);
}
AgeInlineCaches();
number_of_disposed_maps_ = retained_maps()->Length();
Expand Down Expand Up @@ -4457,7 +4459,8 @@ void Heap::CheckMemoryPressure() {
if (isolate()->concurrent_recompilation_enabled()) {
// The optimizing compiler may be unnecessarily holding on to memory.
DisallowHeapAllocation no_recursive_gc;
isolate()->optimizing_compile_dispatcher()->Flush();
isolate()->optimizing_compile_dispatcher()->Flush(
OptimizingCompileDispatcher::BlockingBehavior::kDontBlock);
}
}
if (memory_pressure_level_.Value() == MemoryPressureLevel::kCritical) {
Expand Down

0 comments on commit 9f73df5

Please sign in to comment.