Skip to content

Commit

Permalink
Revert of Remove support for thread-based recompilation (patchset nwjs#1
Browse files Browse the repository at this point in the history
 id:1 of https://codereview.chromium.org/966653002/)

Reason for revert:
speculative revert due to gc-stress timeouts.

Original issue's description:
> Remove support for thread-based recompilation
>
> BUG=v8:3608
> R=yangguo@chromium.org
> LOG=y
>
> Committed: https://crrev.com/ed5db223a19dfe126af012e894582251aa3635d7
> Cr-Commit-Position: refs/heads/master@{#27619}

TBR=jochen@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
BUG=v8:3608
LOG=N

Review URL: https://codereview.chromium.org/1063383004

Cr-Commit-Position: refs/heads/master@{#27654}
  • Loading branch information
hashseed authored and Commit bot committed Apr 8, 2015
1 parent a54f22d commit c4081d2
Show file tree
Hide file tree
Showing 17 changed files with 254 additions and 109 deletions.
4 changes: 2 additions & 2 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -892,8 +892,8 @@ source_set("v8_base") {
"src/objects-printer.cc",
"src/objects.cc",
"src/objects.h",
"src/optimizing-compile-dispatcher.cc",
"src/optimizing-compile-dispatcher.h",
"src/optimizing-compiler-thread.cc",
"src/optimizing-compiler-thread.h",
"src/ostreams.cc",
"src/ostreams.h",
"src/parser.cc",
Expand Down
4 changes: 2 additions & 2 deletions src/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ static bool GetOptimizedCodeNow(CompilationInfo* info) {

static bool GetOptimizedCodeLater(CompilationInfo* info) {
Isolate* isolate = info->isolate();
if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) {
if (!isolate->optimizing_compiler_thread()->IsQueueAvailable()) {
if (FLAG_trace_concurrent_recompilation) {
PrintF(" ** Compilation queue full, will retry optimizing ");
info->closure()->ShortPrint();
Expand All @@ -840,7 +840,7 @@ static bool GetOptimizedCodeLater(CompilationInfo* info) {
OptimizedCompileJob* job = new (info->zone()) OptimizedCompileJob(info);
OptimizedCompileJob::Status status = job->CreateGraph();
if (status != OptimizedCompileJob::SUCCEEDED) return false;
isolate->optimizing_compile_dispatcher()->QueueForOptimization(job);
isolate->optimizing_compiler_thread()->QueueForOptimization(job);

if (FLAG_trace_concurrent_recompilation) {
PrintF(" ** Queued ");
Expand Down
2 changes: 2 additions & 0 deletions src/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,12 @@ class CompilationInfo {
}

void AbortDueToDependencyChange() {
DCHECK(!OptimizingCompilerThread::IsOptimizerThread(isolate()));
aborted_due_to_dependency_change_ = true;
}

bool HasAbortedDueToDependencyChange() const {
DCHECK(!OptimizingCompilerThread::IsOptimizerThread(isolate()));
return aborted_due_to_dependency_change_;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cpu-profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "src/circular-queue.h"
#include "src/compiler.h"
#include "src/sampler.h"
#include "src/unbound-queue-inl.h"
#include "src/unbound-queue.h"

namespace v8 {
namespace internal {
Expand Down
2 changes: 1 addition & 1 deletion src/debug.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,7 @@ void Debug::PrepareForBreakPoints() {
// functions as debugging does not work with optimized code.
if (!has_break_points_) {
if (isolate_->concurrent_recompilation_enabled()) {
isolate_->optimizing_compile_dispatcher()->Flush();
isolate_->optimizing_compiler_thread()->Flush();
}

Deoptimizer::DeoptimizeAll(isolate_);
Expand Down
2 changes: 1 addition & 1 deletion src/execution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ Object* StackGuard::HandleInterrupts() {

if (CheckAndClearInterrupt(INSTALL_CODE)) {
DCHECK(isolate_->concurrent_recompilation_enabled());
isolate_->optimizing_compile_dispatcher()->InstallOptimizedFunctions();
isolate_->optimizing_compiler_thread()->InstallOptimizedFunctions();
}

if (CheckAndClearInterrupt(API_INTERRUPT)) {
Expand Down
3 changes: 3 additions & 0 deletions src/flag-definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ DEFINE_BOOL(optimize_for_in, true, "optimize functions containing for-in loops")

DEFINE_BOOL(concurrent_recompilation, true,
"optimizing hot functions asynchronously on a separate thread")
DEFINE_BOOL(job_based_recompilation, true,
"post tasks to v8::Platform instead of using a thread for "
"concurrent recompilation")
DEFINE_BOOL(trace_concurrent_recompilation, false,
"track concurrent recompilation")
DEFINE_INT(concurrent_recompilation_queue_length, 8,
Expand Down
6 changes: 3 additions & 3 deletions src/heap/heap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void Heap::GarbageCollectionPrologue() {
store_buffer()->GCPrologue();

if (isolate()->concurrent_osr_enabled()) {
isolate()->optimizing_compile_dispatcher()->AgeBufferedOsrJobs();
isolate()->optimizing_compiler_thread()->AgeBufferedOsrJobs();
}

if (new_space_.IsAtMaximumCapacity()) {
Expand Down Expand Up @@ -784,7 +784,7 @@ void Heap::CollectAllAvailableGarbage(const char* 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_compiler_thread()->Flush();
}
isolate()->ClearSerializerData();
mark_compact_collector()->SetFlags(kMakeHeapIterableMask |
Expand Down Expand Up @@ -902,7 +902,7 @@ int Heap::NotifyContextDisposed(bool dependant_context) {
}
if (isolate()->concurrent_recompilation_enabled()) {
// Flush the queued recompilation tasks.
isolate()->optimizing_compile_dispatcher()->Flush();
isolate()->optimizing_compiler_thread()->Flush();
}
AgeInlineCaches();
set_retained_maps(ArrayList::cast(empty_fixed_array()));
Expand Down
1 change: 1 addition & 0 deletions src/hydrogen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3473,6 +3473,7 @@ HBasicBlock* HGraph::CreateBasicBlock() {

void HGraph::FinalizeUniqueness() {
DisallowHeapAllocation no_gc;
DCHECK(!OptimizingCompilerThread::IsOptimizerThread(isolate()));
for (int i = 0; i < blocks()->length(); ++i) {
for (HInstructionIterator it(blocks()->at(i)); !it.Done(); it.Advance()) {
it.Current()->FinalizeUniqueness();
Expand Down
13 changes: 7 additions & 6 deletions src/isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,7 @@ Isolate::Isolate(bool enable_serializer)
heap_profiler_(NULL),
function_entry_hook_(NULL),
deferred_handles_head_(NULL),
optimizing_compile_dispatcher_(NULL),
optimizing_compiler_thread_(NULL),
stress_deopt_count_(0),
next_optimization_id_(0),
#if TRACE_MAPS
Expand Down Expand Up @@ -1833,9 +1833,9 @@ void Isolate::Deinit() {
FreeThreadResources();

if (concurrent_recompilation_enabled()) {
optimizing_compile_dispatcher_->Stop();
delete optimizing_compile_dispatcher_;
optimizing_compile_dispatcher_ = NULL;
optimizing_compiler_thread_->Stop();
delete optimizing_compiler_thread_;
optimizing_compiler_thread_ = NULL;
}

if (heap_.mark_compact_collector()->sweeping_in_progress()) {
Expand Down Expand Up @@ -2133,8 +2133,9 @@ bool Isolate::Init(Deserializer* des) {

if (FLAG_trace_hydrogen || FLAG_trace_hydrogen_stubs) {
PrintF("Concurrent recompilation has been disabled for tracing.\n");
} else if (OptimizingCompileDispatcher::Enabled(max_available_threads_)) {
optimizing_compile_dispatcher_ = new OptimizingCompileDispatcher(this);
} else if (OptimizingCompilerThread::Enabled(max_available_threads_)) {
optimizing_compiler_thread_ = new OptimizingCompilerThread(this);
optimizing_compiler_thread_->Start();
}

// Initialize runtime profiler before deserialization, because collections may
Expand Down
18 changes: 9 additions & 9 deletions src/isolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "src/handles.h"
#include "src/hashmap.h"
#include "src/heap/heap.h"
#include "src/optimizing-compile-dispatcher.h"
#include "src/optimizing-compiler-thread.h"
#include "src/regexp-stack.h"
#include "src/runtime/runtime.h"
#include "src/runtime-profiler.h"
Expand Down Expand Up @@ -1028,20 +1028,20 @@ class Isolate {

bool concurrent_recompilation_enabled() {
// Thread is only available with flag enabled.
DCHECK(optimizing_compile_dispatcher_ == NULL ||
DCHECK(optimizing_compiler_thread_ == NULL ||
FLAG_concurrent_recompilation);
return optimizing_compile_dispatcher_ != NULL;
return optimizing_compiler_thread_ != NULL;
}

bool concurrent_osr_enabled() const {
// Thread is only available with flag enabled.
DCHECK(optimizing_compile_dispatcher_ == NULL ||
DCHECK(optimizing_compiler_thread_ == NULL ||
FLAG_concurrent_recompilation);
return optimizing_compile_dispatcher_ != NULL && FLAG_concurrent_osr;
return optimizing_compiler_thread_ != NULL && FLAG_concurrent_osr;
}

OptimizingCompileDispatcher* optimizing_compile_dispatcher() {
return optimizing_compile_dispatcher_;
OptimizingCompilerThread* optimizing_compiler_thread() {
return optimizing_compiler_thread_;
}

int id() const { return static_cast<int>(id_); }
Expand Down Expand Up @@ -1329,7 +1329,7 @@ class Isolate {
#endif

DeferredHandles* deferred_handles_head_;
OptimizingCompileDispatcher* optimizing_compile_dispatcher_;
OptimizingCompilerThread* optimizing_compiler_thread_;

// Counts deopt points if deopt_every_n_times is enabled.
unsigned int stress_deopt_count_;
Expand All @@ -1350,7 +1350,7 @@ class Isolate {

friend class ExecutionAccess;
friend class HandleScopeImplementer;
friend class OptimizingCompileDispatcher;
friend class OptimizingCompilerThread;
friend class SweeperThread;
friend class ThreadManager;
friend class Simulator;
Expand Down
2 changes: 1 addition & 1 deletion src/objects.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9706,7 +9706,7 @@ void JSFunction::AttemptConcurrentOptimization() {
return;
}
if (isolate->concurrent_osr_enabled() &&
isolate->optimizing_compile_dispatcher()->IsQueuedForOSR(this)) {
isolate->optimizing_compiler_thread()->IsQueuedForOSR(this)) {
// Do not attempt regular recompilation if we already queued this for OSR.
// TODO(yangguo): This is necessary so that we don't install optimized
// code on a function that is already optimized, since OSR and regular
Expand Down
Loading

0 comments on commit c4081d2

Please sign in to comment.