Browse Source

deps: cherry-pick 22858cb from V8 upstream

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: https://github.com/nodejs/node/pull/11998
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
v7.x
Ali Ijaz Sheikh 8 years ago
committed by Italo A. Casas
parent
commit
9f73df5910
No known key found for this signature in database GPG Key ID: 23EFEFE93C4CFFFE
  1. 18
      deps/v8/src/compiler-dispatcher/optimizing-compile-dispatcher.cc
  2. 4
      deps/v8/src/compiler-dispatcher/optimizing-compile-dispatcher.h
  3. 3
      deps/v8/src/debug/debug.cc
  4. 9
      deps/v8/src/heap/heap.cc

18
deps/v8/src/compiler-dispatcher/optimizing-compile-dispatcher.cc

@ -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();
{

4
deps/v8/src/compiler-dispatcher/optimizing-compile-dispatcher.h

@ -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),
@ -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();

3
deps/v8/src/debug/debug.cc

@ -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;

9
deps/v8/src/heap/heap.cc

@ -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);
@ -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();
@ -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) {

Loading…
Cancel
Save