Commit 83cb73f3 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

Revert "[wasm] Compile JS to WASM wrappers asynchronously"

This reverts commit 9a9aa71f.

Reason for revert: https://ci.chromium.org/p/v8/builders/ci/V8-Blink%20Linux%2064/33101

Original change's description:
> [wasm] Compile JS to WASM wrappers asynchronously
> 
> R=​mstarzinger@chromium.org, ahaas@chromium.org
> 
> Bug: v8:9231
> Change-Id: I9e18073bbe25bf8c9c5f9ace102316e6209d0459
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1669699
> Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
> Reviewed-by: Andreas Haas <ahaas@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#62672}

TBR=mstarzinger@chromium.org,ahaas@chromium.org,thibaudm@chromium.org

Change-Id: I4c66663ca8a3f12f578c451f3c25705cebc753a7
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:9231
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1700066Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62680}
parent 0ce30904
...@@ -173,12 +173,12 @@ class PipelineData { ...@@ -173,12 +173,12 @@ class PipelineData {
// For CodeStubAssembler and machine graph testing entry point. // For CodeStubAssembler and machine graph testing entry point.
PipelineData(ZoneStats* zone_stats, OptimizedCompilationInfo* info, PipelineData(ZoneStats* zone_stats, OptimizedCompilationInfo* info,
Isolate* isolate, AccountingAllocator* allocator, Graph* graph, Isolate* isolate, Graph* graph, Schedule* schedule,
Schedule* schedule, SourcePositionTable* source_positions, SourcePositionTable* source_positions,
NodeOriginTable* node_origins, JumpOptimizationInfo* jump_opt, NodeOriginTable* node_origins, JumpOptimizationInfo* jump_opt,
const AssemblerOptions& assembler_options) const AssemblerOptions& assembler_options)
: isolate_(isolate), : isolate_(isolate),
allocator_(allocator), allocator_(isolate->allocator()),
info_(info), info_(info),
debug_name_(info_->GetDebugName()), debug_name_(info_->GetDebugName()),
zone_stats_(zone_stats), zone_stats_(zone_stats),
...@@ -1056,19 +1056,16 @@ class WasmHeapStubCompilationJob final : public OptimizedCompilationJob { ...@@ -1056,19 +1056,16 @@ class WasmHeapStubCompilationJob final : public OptimizedCompilationJob {
// we pass it to the CompilationJob constructor, but it is not // we pass it to the CompilationJob constructor, but it is not
// dereferenced there. // dereferenced there.
: OptimizedCompilationJob(isolate->stack_guard()->real_climit(), &info_, : OptimizedCompilationJob(isolate->stack_guard()->real_climit(), &info_,
"TurboFan", State::kReadyToExecute), "TurboFan"),
debug_name_(std::move(debug_name)), debug_name_(std::move(debug_name)),
info_(CStrVector(debug_name_.get()), graph->zone(), kind), info_(CStrVector(debug_name_.get()), graph->zone(), kind),
call_descriptor_(call_descriptor), call_descriptor_(call_descriptor),
zone_stats_(isolate->wasm_engine()->allocator()), zone_stats_(isolate->allocator()),
zone_(std::move(zone)), zone_(std::move(zone)),
graph_(graph), graph_(graph),
data_(&zone_stats_, &info_, isolate, data_(&zone_stats_, &info_, isolate, graph_, nullptr, source_positions,
isolate->wasm_engine()->allocator(), graph_, nullptr, new (zone_.get()) NodeOriginTable(graph_), nullptr, options),
source_positions, new (zone_.get()) NodeOriginTable(graph_), pipeline_(&data_) {}
nullptr, options),
pipeline_(&data_),
wasm_engine_(isolate->wasm_engine()) {}
~WasmHeapStubCompilationJob() = default; ~WasmHeapStubCompilationJob() = default;
...@@ -1086,7 +1083,6 @@ class WasmHeapStubCompilationJob final : public OptimizedCompilationJob { ...@@ -1086,7 +1083,6 @@ class WasmHeapStubCompilationJob final : public OptimizedCompilationJob {
Graph* graph_; Graph* graph_;
PipelineData data_; PipelineData data_;
PipelineImpl pipeline_; PipelineImpl pipeline_;
wasm::WasmEngine* wasm_engine_;
DISALLOW_COPY_AND_ASSIGN(WasmHeapStubCompilationJob); DISALLOW_COPY_AND_ASSIGN(WasmHeapStubCompilationJob);
}; };
...@@ -1107,14 +1103,10 @@ Pipeline::NewWasmHeapStubCompilationJob(Isolate* isolate, ...@@ -1107,14 +1103,10 @@ Pipeline::NewWasmHeapStubCompilationJob(Isolate* isolate,
CompilationJob::Status WasmHeapStubCompilationJob::PrepareJobImpl( CompilationJob::Status WasmHeapStubCompilationJob::PrepareJobImpl(
Isolate* isolate) { Isolate* isolate) {
return CompilationJob::SUCCEEDED;
}
CompilationJob::Status WasmHeapStubCompilationJob::ExecuteJobImpl() {
std::unique_ptr<PipelineStatistics> pipeline_statistics; std::unique_ptr<PipelineStatistics> pipeline_statistics;
if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) {
pipeline_statistics.reset(new PipelineStatistics( pipeline_statistics.reset(new PipelineStatistics(
&info_, wasm_engine_->GetOrCreateTurboStatistics(), &zone_stats_)); &info_, isolate->GetTurboStatistics(), &zone_stats_));
pipeline_statistics->BeginPhaseKind("V8.WasmStubCodegen"); pipeline_statistics->BeginPhaseKind("V8.WasmStubCodegen");
} }
if (info_.trace_turbo_json_enabled() || info_.trace_turbo_graph_enabled()) { if (info_.trace_turbo_json_enabled() || info_.trace_turbo_graph_enabled()) {
...@@ -1136,6 +1128,10 @@ CompilationJob::Status WasmHeapStubCompilationJob::ExecuteJobImpl() { ...@@ -1136,6 +1128,10 @@ CompilationJob::Status WasmHeapStubCompilationJob::ExecuteJobImpl() {
<< "\", \"source\":\"\",\n\"phases\":["; << "\", \"source\":\"\",\n\"phases\":[";
} }
pipeline_.RunPrintAndVerify("V8.WasmMachineCode", true); pipeline_.RunPrintAndVerify("V8.WasmMachineCode", true);
return CompilationJob::SUCCEEDED;
}
CompilationJob::Status WasmHeapStubCompilationJob::ExecuteJobImpl() {
pipeline_.ComputeScheduledGraph(); pipeline_.ComputeScheduledGraph();
if (pipeline_.SelectInstructionsAndAssemble(call_descriptor_)) { if (pipeline_.SelectInstructionsAndAssemble(call_descriptor_)) {
return CompilationJob::SUCCEEDED; return CompilationJob::SUCCEEDED;
...@@ -2336,8 +2332,8 @@ MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub( ...@@ -2336,8 +2332,8 @@ MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub(
JumpOptimizationInfo jump_opt; JumpOptimizationInfo jump_opt;
bool should_optimize_jumps = bool should_optimize_jumps =
isolate->serializer_enabled() && FLAG_turbo_rewrite_far_jumps; isolate->serializer_enabled() && FLAG_turbo_rewrite_far_jumps;
PipelineData data(&zone_stats, &info, isolate, isolate->allocator(), graph, PipelineData data(&zone_stats, &info, isolate, graph, nullptr,
nullptr, source_positions, &node_origins, source_positions, &node_origins,
should_optimize_jumps ? &jump_opt : nullptr, options); should_optimize_jumps ? &jump_opt : nullptr, options);
data.set_verify_graph(FLAG_verify_csa); data.set_verify_graph(FLAG_verify_csa);
std::unique_ptr<PipelineStatistics> pipeline_statistics; std::unique_ptr<PipelineStatistics> pipeline_statistics;
...@@ -2382,10 +2378,10 @@ MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub( ...@@ -2382,10 +2378,10 @@ MaybeHandle<Code> Pipeline::GenerateCodeForCodeStub(
// First run code generation on a copy of the pipeline, in order to be able to // First run code generation on a copy of the pipeline, in order to be able to
// repeat it for jump optimization. The first run has to happen on a temporary // repeat it for jump optimization. The first run has to happen on a temporary
// pipeline to avoid deletion of zones on the main pipeline. // pipeline to avoid deletion of zones on the main pipeline.
PipelineData second_data(&zone_stats, &info, isolate, isolate->allocator(), PipelineData second_data(&zone_stats, &info, isolate, data.graph(),
data.graph(), data.schedule(), data.schedule(), data.source_positions(),
data.source_positions(), data.node_origins(), data.node_origins(), data.jump_optimization_info(),
data.jump_optimization_info(), options); options);
second_data.set_verify_graph(FLAG_verify_csa); second_data.set_verify_graph(FLAG_verify_csa);
PipelineImpl second_pipeline(&second_data); PipelineImpl second_pipeline(&second_data);
second_pipeline.SelectInstructionsAndAssemble(call_descriptor); second_pipeline.SelectInstructionsAndAssemble(call_descriptor);
...@@ -2531,8 +2527,8 @@ MaybeHandle<Code> Pipeline::GenerateCodeForTesting( ...@@ -2531,8 +2527,8 @@ MaybeHandle<Code> Pipeline::GenerateCodeForTesting(
// Construct a pipeline for scheduling and code generation. // Construct a pipeline for scheduling and code generation.
ZoneStats zone_stats(isolate->allocator()); ZoneStats zone_stats(isolate->allocator());
NodeOriginTable* node_positions = new (info->zone()) NodeOriginTable(graph); NodeOriginTable* node_positions = new (info->zone()) NodeOriginTable(graph);
PipelineData data(&zone_stats, info, isolate, isolate->allocator(), graph, PipelineData data(&zone_stats, info, isolate, graph, schedule, nullptr,
schedule, nullptr, node_positions, nullptr, options); node_positions, nullptr, options);
std::unique_ptr<PipelineStatistics> pipeline_statistics; std::unique_ptr<PipelineStatistics> pipeline_statistics;
if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) { if (FLAG_turbo_stats || FLAG_turbo_stats_nvp) {
pipeline_statistics.reset(new PipelineStatistics( pipeline_statistics.reset(new PipelineStatistics(
......
...@@ -5954,7 +5954,7 @@ std::unique_ptr<OptimizedCompilationJob> NewJSToWasmCompilationJob( ...@@ -5954,7 +5954,7 @@ std::unique_ptr<OptimizedCompilationJob> NewJSToWasmCompilationJob(
// Create the Graph. // Create the Graph.
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::unique_ptr<Zone> zone = std::unique_ptr<Zone> zone =
base::make_unique<Zone>(isolate->wasm_engine()->allocator(), ZONE_NAME); base::make_unique<Zone>(isolate->allocator(), ZONE_NAME);
Graph* graph = new (zone.get()) Graph(zone.get()); Graph* graph = new (zone.get()) Graph(zone.get());
CommonOperatorBuilder common(zone.get()); CommonOperatorBuilder common(zone.get());
MachineOperatorBuilder machine( MachineOperatorBuilder machine(
...@@ -6417,7 +6417,8 @@ MaybeHandle<Code> CompileCWasmEntry(Isolate* isolate, wasm::FunctionSig* sig) { ...@@ -6417,7 +6417,8 @@ MaybeHandle<Code> CompileCWasmEntry(Isolate* isolate, wasm::FunctionSig* sig) {
isolate, incoming, std::move(zone), graph, Code::C_WASM_ENTRY, isolate, incoming, std::move(zone), graph, Code::C_WASM_ENTRY,
std::move(debug_name), AssemblerOptions::Default(isolate))); std::move(debug_name), AssemblerOptions::Default(isolate)));
if (job->ExecuteJob() == CompilationJob::FAILED || if (job->PrepareJob(isolate) == CompilationJob::FAILED ||
job->ExecuteJob() == CompilationJob::FAILED ||
job->FinalizeJob(isolate) == CompilationJob::FAILED) { job->FinalizeJob(isolate) == CompilationJob::FAILED) {
return {}; return {};
} }
......
...@@ -265,12 +265,15 @@ void WasmCompilationUnit::CompileWasmFunction(Isolate* isolate, ...@@ -265,12 +265,15 @@ void WasmCompilationUnit::CompileWasmFunction(Isolate* isolate,
JSToWasmWrapperCompilationUnit::JSToWasmWrapperCompilationUnit(Isolate* isolate, JSToWasmWrapperCompilationUnit::JSToWasmWrapperCompilationUnit(Isolate* isolate,
FunctionSig* sig, FunctionSig* sig,
bool is_import) bool is_import)
: is_import_(is_import), : job_(compiler::NewJSToWasmCompilationJob(isolate, sig, is_import)) {}
sig_(sig),
job_(compiler::NewJSToWasmCompilationJob(isolate, sig, is_import)) {}
JSToWasmWrapperCompilationUnit::~JSToWasmWrapperCompilationUnit() = default; JSToWasmWrapperCompilationUnit::~JSToWasmWrapperCompilationUnit() = default;
void JSToWasmWrapperCompilationUnit::Prepare(Isolate* isolate) {
CompilationJob::Status status = job_->PrepareJob(isolate);
CHECK_EQ(status, CompilationJob::SUCCEEDED);
}
void JSToWasmWrapperCompilationUnit::Execute() { void JSToWasmWrapperCompilationUnit::Execute() {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "CompileJSToWasmWrapper"); TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "CompileJSToWasmWrapper");
DCHECK_EQ(job_->state(), CompilationJob::State::kReadyToExecute); DCHECK_EQ(job_->state(), CompilationJob::State::kReadyToExecute);
...@@ -294,6 +297,7 @@ Handle<Code> JSToWasmWrapperCompilationUnit::CompileJSToWasmWrapper( ...@@ -294,6 +297,7 @@ Handle<Code> JSToWasmWrapperCompilationUnit::CompileJSToWasmWrapper(
Isolate* isolate, FunctionSig* sig, bool is_import) { Isolate* isolate, FunctionSig* sig, bool is_import) {
// Run the compilation unit synchronously. // Run the compilation unit synchronously.
JSToWasmWrapperCompilationUnit unit(isolate, sig, is_import); JSToWasmWrapperCompilationUnit unit(isolate, sig, is_import);
unit.Prepare(isolate);
unit.Execute(); unit.Execute();
return unit.Finalize(isolate); return unit.Finalize(isolate);
} }
......
...@@ -108,19 +108,15 @@ class V8_EXPORT_PRIVATE JSToWasmWrapperCompilationUnit final { ...@@ -108,19 +108,15 @@ class V8_EXPORT_PRIVATE JSToWasmWrapperCompilationUnit final {
bool is_import); bool is_import);
~JSToWasmWrapperCompilationUnit(); ~JSToWasmWrapperCompilationUnit();
void Prepare(Isolate* isolate);
void Execute(); void Execute();
Handle<Code> Finalize(Isolate* isolate); Handle<Code> Finalize(Isolate* isolate);
bool is_import() const { return is_import_; }
FunctionSig* sig() const { return sig_; }
// Run a compilation unit synchronously. // Run a compilation unit synchronously.
static Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, FunctionSig* sig, static Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, FunctionSig* sig,
bool is_import); bool is_import);
private: private:
bool is_import_;
FunctionSig* sig_;
std::unique_ptr<OptimizedCompilationJob> job_; std::unique_ptr<OptimizedCompilationJob> job_;
}; };
......
This diff is collapsed.
...@@ -153,6 +153,8 @@ class AsyncCompileJob { ...@@ -153,6 +153,8 @@ class AsyncCompileJob {
void AsyncCompileSucceeded(Handle<WasmModuleObject> result); void AsyncCompileSucceeded(Handle<WasmModuleObject> result);
void CompileWrappers();
void FinishModule(); void FinishModule();
void StartForegroundTask(); void StartForegroundTask();
......
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