Revert of [Interpreter] Introduce InterpreterCompilationJob (patchset #7 id:140001 of https://codereview.chromium.org/2240463002/ )
Reason for revert: Failing on Win64 bot: https://build.chromium.org/p/client.v8/builders/V8%20Win64/builds/12061/steps/Check/logs/regress-635429 Original issue's description: > [Interpreter] Introduce InterpreterCompilationJob > > Adds InterpreterCompilationJob as a sub-class of > CompilationJob, to enable off-thread bytecode > generation. Currently only used in > Interpreter::MakeBytecode. > > As part of this change, CompilationJob is modified > to make it less specific to optimized compilation, > renaming the phases as follows: > - CreateGraph -> PrepareJob > - OptimizeGraph -> ExecuteJob > - GenerateCode -> FinalizeJob > > RegisterWeakObjectsInOptimizedCode is also moved out > of CompilationJob and instead becomes a static function > on Compiler. > > BUG=v8:5203 > > Committed: https://crrev.com/1fb6a7e697e8bc5b4af51647553741f966e00cdc > Cr-Commit-Position: refs/heads/master@{#38662} TBR=mstarzinger@chromium.org,jkummerow@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=v8:5203 Review-Url: https://codereview.chromium.org/2249153002 Cr-Commit-Position: refs/heads/master@{#38663}
This commit is contained in:
parent
1fb6a7e697
commit
ce65e10597
@ -107,7 +107,7 @@ void OptimizingCompileDispatcher::CompileNext(CompilationJob* job) {
|
||||
if (!job) return;
|
||||
|
||||
// The function may have already been optimized by OSR. Simply continue.
|
||||
CompilationJob::Status status = job->ExecuteJob();
|
||||
CompilationJob::Status status = job->OptimizeGraph();
|
||||
USE(status); // Prevent an unused-variable error.
|
||||
|
||||
// The function may have already been optimized by OSR. Simply continue.
|
||||
|
114
src/compiler.cc
114
src/compiler.cc
@ -240,11 +240,11 @@ bool CompilationInfo::ExpectsJSReceiverAsReceiver() {
|
||||
// ----------------------------------------------------------------------------
|
||||
// Implementation of CompilationJob
|
||||
|
||||
CompilationJob::Status CompilationJob::PrepareJob() {
|
||||
DCHECK(ThreadId::Current().Equals(info()->isolate()->thread_id()));
|
||||
CompilationJob::Status CompilationJob::CreateGraph() {
|
||||
DisallowJavascriptExecution no_js(isolate());
|
||||
DCHECK(info()->IsOptimizing());
|
||||
|
||||
if (FLAG_trace_opt && info()->IsOptimizing()) {
|
||||
if (FLAG_trace_opt) {
|
||||
OFStream os(stdout);
|
||||
os << "[compiling method " << Brief(*info()->closure()) << " using "
|
||||
<< compiler_name_;
|
||||
@ -253,69 +253,34 @@ CompilationJob::Status CompilationJob::PrepareJob() {
|
||||
}
|
||||
|
||||
// Delegate to the underlying implementation.
|
||||
DCHECK(state() == State::kReadyToPrepare);
|
||||
ScopedTimer t(&time_taken_to_prepare_);
|
||||
return UpdateState(PrepareJobImpl(), State::kReadyToExecute);
|
||||
DCHECK_EQ(SUCCEEDED, last_status());
|
||||
ScopedTimer t(&time_taken_to_create_graph_);
|
||||
return SetLastStatus(CreateGraphImpl());
|
||||
}
|
||||
|
||||
CompilationJob::Status CompilationJob::ExecuteJob() {
|
||||
CompilationJob::Status CompilationJob::OptimizeGraph() {
|
||||
DisallowHeapAllocation no_allocation;
|
||||
DisallowHandleAllocation no_handles;
|
||||
DisallowHandleDereference no_deref;
|
||||
DisallowCodeDependencyChange no_dependency_change;
|
||||
|
||||
// Delegate to the underlying implementation.
|
||||
DCHECK(state() == State::kReadyToExecute);
|
||||
ScopedTimer t(&time_taken_to_execute_);
|
||||
return UpdateState(ExecuteJobImpl(), State::kReadyToFinalize);
|
||||
DCHECK_EQ(SUCCEEDED, last_status());
|
||||
ScopedTimer t(&time_taken_to_optimize_);
|
||||
return SetLastStatus(OptimizeGraphImpl());
|
||||
}
|
||||
|
||||
CompilationJob::Status CompilationJob::FinalizeJob() {
|
||||
DCHECK(ThreadId::Current().Equals(info()->isolate()->thread_id()));
|
||||
CompilationJob::Status CompilationJob::GenerateCode() {
|
||||
DisallowCodeDependencyChange no_dependency_change;
|
||||
DisallowJavascriptExecution no_js(isolate());
|
||||
DCHECK(!info()->dependencies()->HasAborted());
|
||||
|
||||
// Delegate to the underlying implementation.
|
||||
DCHECK(state() == State::kReadyToFinalize);
|
||||
ScopedTimer t(&time_taken_to_finalize_);
|
||||
return UpdateState(FinalizeJobImpl(), State::kSucceeded);
|
||||
DCHECK_EQ(SUCCEEDED, last_status());
|
||||
ScopedTimer t(&time_taken_to_codegen_);
|
||||
return SetLastStatus(GenerateCodeImpl());
|
||||
}
|
||||
|
||||
void CompilationJob::RecordOptimizationStats() {
|
||||
DCHECK(info()->IsOptimizing());
|
||||
Handle<JSFunction> function = info()->closure();
|
||||
if (!function->IsOptimized()) {
|
||||
// Concurrent recompilation and OSR may race. Increment only once.
|
||||
int opt_count = function->shared()->opt_count();
|
||||
function->shared()->set_opt_count(opt_count + 1);
|
||||
}
|
||||
double ms_creategraph = time_taken_to_prepare_.InMillisecondsF();
|
||||
double ms_optimize = time_taken_to_execute_.InMillisecondsF();
|
||||
double ms_codegen = time_taken_to_finalize_.InMillisecondsF();
|
||||
if (FLAG_trace_opt) {
|
||||
PrintF("[optimizing ");
|
||||
function->ShortPrint();
|
||||
PrintF(" - took %0.3f, %0.3f, %0.3f ms]\n", ms_creategraph, ms_optimize,
|
||||
ms_codegen);
|
||||
}
|
||||
if (FLAG_trace_opt_stats) {
|
||||
static double compilation_time = 0.0;
|
||||
static int compiled_functions = 0;
|
||||
static int code_size = 0;
|
||||
|
||||
compilation_time += (ms_creategraph + ms_optimize + ms_codegen);
|
||||
compiled_functions++;
|
||||
code_size += function->shared()->SourceSize();
|
||||
PrintF("Compiled: %d functions with %d byte source size in %fms.\n",
|
||||
compiled_functions, code_size, compilation_time);
|
||||
}
|
||||
if (FLAG_hydrogen_stats) {
|
||||
isolate()->GetHStatistics()->IncrementSubtotals(time_taken_to_prepare_,
|
||||
time_taken_to_execute_,
|
||||
time_taken_to_finalize_);
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
@ -335,7 +300,6 @@ void AddWeakObjectToCodeDependency(Isolate* isolate, Handle<HeapObject> object,
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
void CompilationJob::RegisterWeakObjectsInOptimizedCode(Handle<Code> code) {
|
||||
// TODO(turbofan): Move this to pipeline.cc once Crankshaft dies.
|
||||
Isolate* const isolate = code->GetIsolate();
|
||||
@ -376,6 +340,42 @@ void CompilationJob::RegisterWeakObjectsInOptimizedCode(Handle<Code> code) {
|
||||
code->set_can_have_weak_objects(true);
|
||||
}
|
||||
|
||||
void CompilationJob::RecordOptimizationStats() {
|
||||
Handle<JSFunction> function = info()->closure();
|
||||
if (!function->IsOptimized()) {
|
||||
// Concurrent recompilation and OSR may race. Increment only once.
|
||||
int opt_count = function->shared()->opt_count();
|
||||
function->shared()->set_opt_count(opt_count + 1);
|
||||
}
|
||||
double ms_creategraph = time_taken_to_create_graph_.InMillisecondsF();
|
||||
double ms_optimize = time_taken_to_optimize_.InMillisecondsF();
|
||||
double ms_codegen = time_taken_to_codegen_.InMillisecondsF();
|
||||
if (FLAG_trace_opt) {
|
||||
PrintF("[optimizing ");
|
||||
function->ShortPrint();
|
||||
PrintF(" - took %0.3f, %0.3f, %0.3f ms]\n", ms_creategraph, ms_optimize,
|
||||
ms_codegen);
|
||||
}
|
||||
if (FLAG_trace_opt_stats) {
|
||||
static double compilation_time = 0.0;
|
||||
static int compiled_functions = 0;
|
||||
static int code_size = 0;
|
||||
|
||||
compilation_time += (ms_creategraph + ms_optimize + ms_codegen);
|
||||
compiled_functions++;
|
||||
code_size += function->shared()->SourceSize();
|
||||
PrintF("Compiled: %d functions with %d byte source size in %fms.\n",
|
||||
compiled_functions,
|
||||
code_size,
|
||||
compilation_time);
|
||||
}
|
||||
if (FLAG_hydrogen_stats) {
|
||||
isolate()->GetHStatistics()->IncrementSubtotals(time_taken_to_create_graph_,
|
||||
time_taken_to_optimize_,
|
||||
time_taken_to_codegen_);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Local helper methods that make up the compilation pipeline.
|
||||
|
||||
@ -672,9 +672,9 @@ bool GetOptimizedCodeNow(CompilationJob* job) {
|
||||
TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
|
||||
isolate, &tracing::TraceEventStatsTable::RecompileSynchronous);
|
||||
|
||||
if (job->PrepareJob() != CompilationJob::SUCCEEDED ||
|
||||
job->ExecuteJob() != CompilationJob::SUCCEEDED ||
|
||||
job->FinalizeJob() != CompilationJob::SUCCEEDED) {
|
||||
if (job->CreateGraph() != CompilationJob::SUCCEEDED ||
|
||||
job->OptimizeGraph() != CompilationJob::SUCCEEDED ||
|
||||
job->GenerateCode() != CompilationJob::SUCCEEDED) {
|
||||
if (FLAG_trace_opt) {
|
||||
PrintF("[aborted optimizing ");
|
||||
info->closure()->ShortPrint();
|
||||
@ -735,7 +735,7 @@ bool GetOptimizedCodeLater(CompilationJob* job) {
|
||||
TRACE_EVENT_RUNTIME_CALL_STATS_TRACING_SCOPED(
|
||||
isolate, &tracing::TraceEventStatsTable::RecompileSynchronous);
|
||||
|
||||
if (job->PrepareJob() != CompilationJob::SUCCEEDED) return false;
|
||||
if (job->CreateGraph() != CompilationJob::SUCCEEDED) return false;
|
||||
isolate->optimizing_compile_dispatcher()->QueueForOptimization(job);
|
||||
|
||||
if (FLAG_trace_concurrent_recompilation) {
|
||||
@ -1907,12 +1907,12 @@ void Compiler::FinalizeCompilationJob(CompilationJob* raw_job) {
|
||||
// Except when OSR already disabled optimization for some reason.
|
||||
// 3) The code may have already been invalidated due to dependency change.
|
||||
// 4) Code generation may have failed.
|
||||
if (job->state() == CompilationJob::State::kReadyToFinalize) {
|
||||
if (job->last_status() == CompilationJob::SUCCEEDED) {
|
||||
if (shared->optimization_disabled()) {
|
||||
job->RetryOptimization(kOptimizationDisabled);
|
||||
} else if (info->dependencies()->HasAborted()) {
|
||||
job->RetryOptimization(kBailedOutDueToDependencyChange);
|
||||
} else if (job->FinalizeJob() == CompilationJob::SUCCEEDED) {
|
||||
} else if (job->GenerateCode() == CompilationJob::SUCCEEDED) {
|
||||
job->RecordOptimizationStats();
|
||||
RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, info);
|
||||
if (shared->SearchOptimizedCodeMap(info->context()->native_context(),
|
||||
@ -1929,7 +1929,7 @@ void Compiler::FinalizeCompilationJob(CompilationJob* raw_job) {
|
||||
}
|
||||
}
|
||||
|
||||
DCHECK(job->state() == CompilationJob::State::kFailed);
|
||||
DCHECK(job->last_status() != CompilationJob::SUCCEEDED);
|
||||
if (FLAG_trace_opt) {
|
||||
PrintF("[aborted optimizing ");
|
||||
info->closure()->ShortPrint();
|
||||
|
@ -537,86 +537,62 @@ class CompilationInfo final {
|
||||
// A base class for compilation jobs intended to run concurrent to the main
|
||||
// thread. The job is split into three phases which are called in sequence on
|
||||
// different threads and with different limitations:
|
||||
// 1) PrepareJob: Runs on main thread. No major limitations.
|
||||
// 2) ExecuteJob: Runs concurrently. No heap allocation or handle derefs.
|
||||
// 3) FinalizeJob: Runs on main thread. No dependency changes.
|
||||
// 1) CreateGraph: Runs on main thread. No major limitations.
|
||||
// 2) OptimizeGraph: Runs concurrently. No heap allocation or handle derefs.
|
||||
// 3) GenerateCode: Runs on main thread. No dependency changes.
|
||||
//
|
||||
// Each of the three phases can either fail or succeed. The current state of
|
||||
// the job can be checked using {state()}.
|
||||
// Each of the three phases can either fail or succeed. Apart from their return
|
||||
// value, the status of the phase last run can be checked using {last_status()}
|
||||
// as well. When failing we distinguish between the following levels:
|
||||
// a) AbortOptimization: Persistent failure, disable future optimization.
|
||||
// b) RetryOptimzation: Transient failure, try again next time.
|
||||
class CompilationJob {
|
||||
public:
|
||||
enum Status { SUCCEEDED, FAILED };
|
||||
enum class State {
|
||||
kReadyToPrepare,
|
||||
kReadyToExecute,
|
||||
kReadyToFinalize,
|
||||
kSucceeded,
|
||||
kFailed,
|
||||
};
|
||||
|
||||
explicit CompilationJob(CompilationInfo* info, const char* compiler_name,
|
||||
State initial_state = State::kReadyToPrepare)
|
||||
: info_(info), compiler_name_(compiler_name), state_(initial_state) {}
|
||||
explicit CompilationJob(CompilationInfo* info, const char* compiler_name)
|
||||
: info_(info), compiler_name_(compiler_name), last_status_(SUCCEEDED) {}
|
||||
virtual ~CompilationJob() {}
|
||||
|
||||
// Prepare the compile job. Must be called on the main thread.
|
||||
MUST_USE_RESULT Status PrepareJob();
|
||||
enum Status { FAILED, SUCCEEDED };
|
||||
|
||||
// Executes the compile job. Can be called off the main thread.
|
||||
MUST_USE_RESULT Status ExecuteJob();
|
||||
MUST_USE_RESULT Status CreateGraph();
|
||||
MUST_USE_RESULT Status OptimizeGraph();
|
||||
MUST_USE_RESULT Status GenerateCode();
|
||||
|
||||
// Finalizes the compile job. Must be called on the main thread.
|
||||
MUST_USE_RESULT Status FinalizeJob();
|
||||
Status last_status() const { return last_status_; }
|
||||
CompilationInfo* info() const { return info_; }
|
||||
Isolate* isolate() const { return info()->isolate(); }
|
||||
|
||||
// Report a transient failure, try again next time. Should only be called on
|
||||
// optimization compilation jobs.
|
||||
Status RetryOptimization(BailoutReason reason) {
|
||||
DCHECK(info_->IsOptimizing());
|
||||
info_->RetryOptimization(reason);
|
||||
state_ = State::kFailed;
|
||||
return FAILED;
|
||||
return SetLastStatus(FAILED);
|
||||
}
|
||||
|
||||
// Report a persistent failure, disable future optimization on the function.
|
||||
// Should only be called on optimization compilation jobs.
|
||||
Status AbortOptimization(BailoutReason reason) {
|
||||
DCHECK(info_->IsOptimizing());
|
||||
info_->AbortOptimization(reason);
|
||||
state_ = State::kFailed;
|
||||
return FAILED;
|
||||
return SetLastStatus(FAILED);
|
||||
}
|
||||
|
||||
void RecordOptimizationStats();
|
||||
|
||||
// Registers weak object to optimized code dependencies.
|
||||
// TODO(turbofan): Move this to pipeline.cc once Crankshaft dies.
|
||||
static void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
|
||||
|
||||
State state() const { return state_; }
|
||||
CompilationInfo* info() const { return info_; }
|
||||
Isolate* isolate() const { return info()->isolate(); }
|
||||
|
||||
protected:
|
||||
void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
|
||||
|
||||
// Overridden by the actual implementation.
|
||||
virtual Status PrepareJobImpl() = 0;
|
||||
virtual Status ExecuteJobImpl() = 0;
|
||||
virtual Status FinalizeJobImpl() = 0;
|
||||
virtual Status CreateGraphImpl() = 0;
|
||||
virtual Status OptimizeGraphImpl() = 0;
|
||||
virtual Status GenerateCodeImpl() = 0;
|
||||
|
||||
private:
|
||||
CompilationInfo* info_;
|
||||
base::TimeDelta time_taken_to_prepare_;
|
||||
base::TimeDelta time_taken_to_execute_;
|
||||
base::TimeDelta time_taken_to_finalize_;
|
||||
base::TimeDelta time_taken_to_create_graph_;
|
||||
base::TimeDelta time_taken_to_optimize_;
|
||||
base::TimeDelta time_taken_to_codegen_;
|
||||
const char* compiler_name_;
|
||||
State state_;
|
||||
Status last_status_;
|
||||
|
||||
MUST_USE_RESULT Status UpdateState(Status status, State next_state) {
|
||||
if (status == SUCCEEDED) {
|
||||
state_ = next_state;
|
||||
} else {
|
||||
state_ = State::kFailed;
|
||||
}
|
||||
return status;
|
||||
MUST_USE_RESULT Status SetLastStatus(Status status) {
|
||||
last_status_ = status;
|
||||
return last_status_;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -573,9 +573,9 @@ class PipelineCompilationJob final : public CompilationJob {
|
||||
linkage_(nullptr) {}
|
||||
|
||||
protected:
|
||||
Status PrepareJobImpl() final;
|
||||
Status ExecuteJobImpl() final;
|
||||
Status FinalizeJobImpl() final;
|
||||
Status CreateGraphImpl() final;
|
||||
Status OptimizeGraphImpl() final;
|
||||
Status GenerateCodeImpl() final;
|
||||
|
||||
private:
|
||||
Zone zone_;
|
||||
@ -590,7 +590,7 @@ class PipelineCompilationJob final : public CompilationJob {
|
||||
DISALLOW_COPY_AND_ASSIGN(PipelineCompilationJob);
|
||||
};
|
||||
|
||||
PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl() {
|
||||
PipelineCompilationJob::Status PipelineCompilationJob::CreateGraphImpl() {
|
||||
if (info()->shared_info()->asm_function()) {
|
||||
if (info()->osr_frame()) info()->MarkAsFrameSpecializing();
|
||||
info()->MarkAsFunctionContextSpecializing();
|
||||
@ -633,12 +633,12 @@ PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl() {
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
PipelineCompilationJob::Status PipelineCompilationJob::ExecuteJobImpl() {
|
||||
PipelineCompilationJob::Status PipelineCompilationJob::OptimizeGraphImpl() {
|
||||
if (!pipeline_.OptimizeGraph(linkage_)) return FAILED;
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
PipelineCompilationJob::Status PipelineCompilationJob::FinalizeJobImpl() {
|
||||
PipelineCompilationJob::Status PipelineCompilationJob::GenerateCodeImpl() {
|
||||
Handle<Code> code = pipeline_.GenerateCode(linkage_);
|
||||
if (code.is_null()) {
|
||||
if (info()->bailout_reason() == kNoReason) {
|
||||
@ -650,7 +650,7 @@ PipelineCompilationJob::Status PipelineCompilationJob::FinalizeJobImpl() {
|
||||
info()->SetCode(code);
|
||||
if (info()->is_deoptimization_enabled()) {
|
||||
info()->context()->native_context()->AddOptimizedCode(*code);
|
||||
CompilationJob::RegisterWeakObjectsInOptimizedCode(code);
|
||||
RegisterWeakObjectsInOptimizedCode(code);
|
||||
}
|
||||
return SUCCEEDED;
|
||||
}
|
||||
@ -660,16 +660,16 @@ class PipelineWasmCompilationJob final : public CompilationJob {
|
||||
explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph,
|
||||
CallDescriptor* descriptor,
|
||||
SourcePositionTable* source_positions)
|
||||
: CompilationJob(info, "TurboFan", State::kReadyToExecute),
|
||||
: CompilationJob(info, "TurboFan"),
|
||||
zone_pool_(info->isolate()->allocator()),
|
||||
data_(&zone_pool_, info, graph, source_positions),
|
||||
pipeline_(&data_),
|
||||
linkage_(descriptor) {}
|
||||
|
||||
protected:
|
||||
Status PrepareJobImpl() final;
|
||||
Status ExecuteJobImpl() final;
|
||||
Status FinalizeJobImpl() final;
|
||||
Status CreateGraphImpl() final;
|
||||
Status OptimizeGraphImpl() final;
|
||||
Status GenerateCodeImpl() final;
|
||||
|
||||
private:
|
||||
ZonePool zone_pool_;
|
||||
@ -679,13 +679,12 @@ class PipelineWasmCompilationJob final : public CompilationJob {
|
||||
};
|
||||
|
||||
PipelineWasmCompilationJob::Status
|
||||
PipelineWasmCompilationJob::PrepareJobImpl() {
|
||||
UNREACHABLE(); // Prepare should always be skipped for WasmCompilationJob.
|
||||
PipelineWasmCompilationJob::CreateGraphImpl() {
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
PipelineWasmCompilationJob::Status
|
||||
PipelineWasmCompilationJob::ExecuteJobImpl() {
|
||||
PipelineWasmCompilationJob::OptimizeGraphImpl() {
|
||||
if (FLAG_trace_turbo) {
|
||||
TurboJsonFile json_of(info(), std::ios_base::trunc);
|
||||
json_of << "{\"function\":\"" << info()->GetDebugName().get()
|
||||
@ -699,7 +698,7 @@ PipelineWasmCompilationJob::ExecuteJobImpl() {
|
||||
}
|
||||
|
||||
PipelineWasmCompilationJob::Status
|
||||
PipelineWasmCompilationJob::FinalizeJobImpl() {
|
||||
PipelineWasmCompilationJob::GenerateCodeImpl() {
|
||||
pipeline_.GenerateCode(&linkage_);
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
@ -3165,7 +3165,11 @@ void WasmCompilationUnit::ExecuteCompilation() {
|
||||
}
|
||||
job_.reset(Pipeline::NewWasmCompilationJob(&info_, jsgraph_->graph(),
|
||||
descriptor, source_positions));
|
||||
ok_ = job_->ExecuteJob() == CompilationJob::SUCCEEDED;
|
||||
|
||||
// The function name {OptimizeGraph()} is misleading but necessary because we
|
||||
// want to use the CompilationJob interface. A better name would be
|
||||
// ScheduleGraphAndSelectInstructions.
|
||||
ok_ = job_->OptimizeGraph() == CompilationJob::SUCCEEDED;
|
||||
// TODO(bradnelson): Improve histogram handling of size_t.
|
||||
// TODO(ahaas): The counters are not thread-safe at the moment.
|
||||
// isolate_->counters()->wasm_compile_function_peak_memory_bytes()
|
||||
@ -3197,7 +3201,7 @@ Handle<Code> WasmCompilationUnit::FinishCompilation() {
|
||||
|
||||
return Handle<Code>::null();
|
||||
}
|
||||
if (job_->FinalizeJob() != CompilationJob::SUCCEEDED) {
|
||||
if (job_->GenerateCode() != CompilationJob::SUCCEEDED) {
|
||||
return Handle<Code>::null();
|
||||
}
|
||||
base::ElapsedTimer compile_timer;
|
||||
|
@ -114,7 +114,7 @@ class HOptimizedGraphBuilderWithPositions : public HOptimizedGraphBuilder {
|
||||
#undef DEF_VISIT
|
||||
};
|
||||
|
||||
HCompilationJob::Status HCompilationJob::PrepareJobImpl() {
|
||||
HCompilationJob::Status HCompilationJob::CreateGraphImpl() {
|
||||
if (!isolate()->use_crankshaft() ||
|
||||
info()->shared_info()->dont_crankshaft()) {
|
||||
// Crankshaft is entirely disabled.
|
||||
@ -203,7 +203,7 @@ HCompilationJob::Status HCompilationJob::PrepareJobImpl() {
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
HCompilationJob::Status HCompilationJob::ExecuteJobImpl() {
|
||||
HCompilationJob::Status HCompilationJob::OptimizeGraphImpl() {
|
||||
DCHECK(graph_ != NULL);
|
||||
BailoutReason bailout_reason = kNoReason;
|
||||
|
||||
@ -217,7 +217,7 @@ HCompilationJob::Status HCompilationJob::ExecuteJobImpl() {
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
HCompilationJob::Status HCompilationJob::FinalizeJobImpl() {
|
||||
HCompilationJob::Status HCompilationJob::GenerateCodeImpl() {
|
||||
DCHECK(chunk_ != NULL);
|
||||
DCHECK(graph_ != NULL);
|
||||
{
|
||||
@ -233,7 +233,7 @@ HCompilationJob::Status HCompilationJob::FinalizeJobImpl() {
|
||||
}
|
||||
return FAILED;
|
||||
}
|
||||
CompilationJob::RegisterWeakObjectsInOptimizedCode(optimized_code);
|
||||
RegisterWeakObjectsInOptimizedCode(optimized_code);
|
||||
info()->SetCode(optimized_code);
|
||||
}
|
||||
// Add to the weak list of optimized code objects.
|
||||
|
@ -44,9 +44,9 @@ class HCompilationJob final : public CompilationJob {
|
||||
chunk_(nullptr) {}
|
||||
|
||||
protected:
|
||||
virtual Status PrepareJobImpl();
|
||||
virtual Status ExecuteJobImpl();
|
||||
virtual Status FinalizeJobImpl();
|
||||
virtual Status CreateGraphImpl();
|
||||
virtual Status OptimizeGraphImpl();
|
||||
virtual Status GenerateCodeImpl();
|
||||
|
||||
private:
|
||||
Zone zone_;
|
||||
|
@ -54,6 +54,8 @@ class LCodeGenBase BASE_EMBEDDED {
|
||||
|
||||
int GetNextEmittedBlock() const;
|
||||
|
||||
void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
|
||||
|
||||
void WriteTranslationFrame(LEnvironment* environment,
|
||||
Translation* translation);
|
||||
int DefineDeoptimizationLiteral(Handle<Object> literal);
|
||||
|
@ -688,16 +688,20 @@ BytecodeGenerator::BytecodeGenerator(CompilationInfo* info)
|
||||
InitializeAstVisitor(isolate()->stack_guard()->real_climit());
|
||||
}
|
||||
|
||||
Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode() {
|
||||
Handle<BytecodeArray> BytecodeGenerator::MakeBytecode() {
|
||||
// Create an inner HandleScope to avoid unnecessarily canonicalizing handles
|
||||
// created as part of bytecode finalization.
|
||||
HandleScope scope(isolate());
|
||||
AllocateDeferredConstants();
|
||||
|
||||
GenerateBytecode();
|
||||
FinalizeBytecode();
|
||||
|
||||
if (HasStackOverflow()) return Handle<BytecodeArray>();
|
||||
|
||||
return scope.CloseAndEscape(builder()->ToBytecodeArray());
|
||||
}
|
||||
|
||||
void BytecodeGenerator::AllocateDeferredConstants() {
|
||||
void BytecodeGenerator::FinalizeBytecode() {
|
||||
// Build global declaration pair arrays.
|
||||
for (GlobalDeclarationsBuilder* globals_builder : global_declarations_) {
|
||||
Handle<FixedArray> declarations =
|
||||
|
@ -24,8 +24,7 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
|
||||
public:
|
||||
explicit BytecodeGenerator(CompilationInfo* info);
|
||||
|
||||
void GenerateBytecode();
|
||||
Handle<BytecodeArray> FinalizeBytecode();
|
||||
Handle<BytecodeArray> MakeBytecode();
|
||||
|
||||
#define DECLARE_VISIT(type) void Visit##type(type* node);
|
||||
AST_NODE_LIST(DECLARE_VISIT)
|
||||
@ -53,8 +52,9 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
|
||||
|
||||
enum class TestFallthrough { kThen, kElse, kNone };
|
||||
|
||||
void GenerateBytecode();
|
||||
void GenerateBytecodeBody();
|
||||
void AllocateDeferredConstants();
|
||||
void FinalizeBytecode();
|
||||
|
||||
DEFINE_AST_VISITOR_SUBCLASS_MEMBERS();
|
||||
|
||||
|
@ -30,23 +30,6 @@ typedef InterpreterAssembler::Arg Arg;
|
||||
|
||||
#define __ assembler->
|
||||
|
||||
class InterpreterCompilationJob final : public CompilationJob {
|
||||
public:
|
||||
explicit InterpreterCompilationJob(CompilationInfo* info);
|
||||
|
||||
protected:
|
||||
Status PrepareJobImpl() final;
|
||||
Status ExecuteJobImpl() final;
|
||||
Status FinalizeJobImpl() final;
|
||||
|
||||
private:
|
||||
BytecodeGenerator* generator() { return &generator_; }
|
||||
|
||||
BytecodeGenerator generator_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(InterpreterCompilationJob);
|
||||
};
|
||||
|
||||
Interpreter::Interpreter(Isolate* isolate) : isolate_(isolate) {
|
||||
memset(dispatch_table_, 0, sizeof(dispatch_table_));
|
||||
}
|
||||
@ -149,39 +132,6 @@ int Interpreter::InterruptBudget() {
|
||||
return FLAG_interrupt_budget * kCodeSizeMultiplier;
|
||||
}
|
||||
|
||||
InterpreterCompilationJob::InterpreterCompilationJob(CompilationInfo* info)
|
||||
: CompilationJob(info, "Ignition"), generator_(info) {}
|
||||
|
||||
InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl() {
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() {
|
||||
generator()->GenerateBytecode();
|
||||
|
||||
if (generator()->HasStackOverflow()) {
|
||||
return FAILED;
|
||||
}
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl() {
|
||||
Handle<BytecodeArray> bytecodes = generator()->FinalizeBytecode();
|
||||
if (generator()->HasStackOverflow()) {
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
if (FLAG_print_bytecode) {
|
||||
OFStream os(stdout);
|
||||
bytecodes->Print(os);
|
||||
os << std::flush;
|
||||
}
|
||||
|
||||
info()->SetBytecodeArray(bytecodes);
|
||||
info()->SetCode(info()->isolate()->builtins()->InterpreterEntryTrampoline());
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
bool Interpreter::MakeBytecode(CompilationInfo* info) {
|
||||
RuntimeCallTimerScope runtimeTimer(info->isolate(),
|
||||
&RuntimeCallStats::CompileIgnition);
|
||||
@ -206,10 +156,20 @@ bool Interpreter::MakeBytecode(CompilationInfo* info) {
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
InterpreterCompilationJob job(info);
|
||||
if (job.PrepareJob() != CompilationJob::SUCCEEDED) return false;
|
||||
if (job.ExecuteJob() != CompilationJob::SUCCEEDED) return false;
|
||||
return job.FinalizeJob() == CompilationJob::SUCCEEDED;
|
||||
BytecodeGenerator generator(info);
|
||||
Handle<BytecodeArray> bytecodes = generator.MakeBytecode();
|
||||
|
||||
if (generator.HasStackOverflow()) return false;
|
||||
|
||||
if (FLAG_print_bytecode) {
|
||||
OFStream os(stdout);
|
||||
bytecodes->Print(os);
|
||||
os << std::flush;
|
||||
}
|
||||
|
||||
info->SetBytecodeArray(bytecodes);
|
||||
info->SetCode(info->isolate()->builtins()->InterpreterEntryTrampoline());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Interpreter::IsDispatchTableInitialized() {
|
||||
|
@ -549,8 +549,8 @@ class WasmFunctionCompiler : public HandleAndZoneScope,
|
||||
Code::ComputeFlags(Code::WASM_FUNCTION));
|
||||
std::unique_ptr<CompilationJob> job(Pipeline::NewWasmCompilationJob(
|
||||
&info, graph(), desc, &source_position_table_));
|
||||
if (job->ExecuteJob() != CompilationJob::SUCCEEDED ||
|
||||
job->FinalizeJob() != CompilationJob::SUCCEEDED)
|
||||
if (job->OptimizeGraph() != CompilationJob::SUCCEEDED ||
|
||||
job->GenerateCode() != CompilationJob::SUCCEEDED)
|
||||
return Handle<Code>::null();
|
||||
|
||||
Handle<Code> code = info.code();
|
||||
|
Loading…
Reference in New Issue
Block a user