Commit bc2c2542 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

Revert "[wasm] Initialize compilation progress before compilation units"

This reverts commit 3161106e.

Reason for revert: Breaks layout tests (missing handle scope): https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Blink%20Linux/12278/overview

Original change's description:
> [wasm] Initialize compilation progress before compilation units
>
> Initializing the compilation progress first, and making it an explicit
> step, allows us to share the wrapper compilation code between async
> compilation and streaming compilation. In the future it will also allow
> us to initialize compilation units based on the compilation progress,
> which will allow us to share more code between async compilation and
> deserialization.
>
> R=​clemensb@chromium.org
>
> Bug: v8:11862
> Change-Id: If8394f3068840f759b8325ba806549dbd208f195
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2978258
> Commit-Queue: Andreas Haas <ahaas@chromium.org>
> Reviewed-by: Clemens Backes <clemensb@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#75380}

Bug: v8:11862
Change-Id: I05fa906a86ba8d3226356bcda99786a4a82e6374
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2988416
Auto-Submit: Clemens Backes <clemensb@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/master@{#75393}
parent 35f774c7
......@@ -1424,28 +1424,13 @@ int AddImportWrapperUnits(NativeModule* native_module,
return static_cast<int>(keys.size());
}
std::unique_ptr<CompilationUnitBuilder> InitializeCompilation(
Isolate* isolate, NativeModule* native_module) {
void InitializeCompilationUnits(Isolate* isolate, NativeModule* native_module) {
CompilationStateImpl* compilation_state =
Impl(native_module->compilation_state());
const bool lazy_module = IsLazyModule(native_module->module());
auto builder = std::make_unique<CompilationUnitBuilder>(native_module);
int num_import_wrappers = AddImportWrapperUnits(native_module, builder.get());
int num_export_wrappers =
AddExportWrapperUnits(isolate, native_module, builder.get(),
WasmFeatures::FromIsolate(isolate));
compilation_state->InitializeCompilationProgress(
lazy_module, num_import_wrappers, num_export_wrappers);
return builder;
}
void InitializeCompilationUnits(
NativeModule* native_module,
std::unique_ptr<CompilationUnitBuilder> builder) {
const bool lazy_module = IsLazyModule(native_module->module());
ModuleWireBytes wire_bytes(native_module->wire_bytes());
CompilationUnitBuilder builder(native_module);
auto* module = native_module->module();
const bool prefer_liftoff = native_module->IsTieredDown();
uint32_t start = module->num_imported_functions;
......@@ -1453,13 +1438,13 @@ void InitializeCompilationUnits(
base::Optional<CodeSpaceWriteScope> lazy_code_space_write_scope;
for (uint32_t func_index = start; func_index < end; func_index++) {
if (prefer_liftoff) {
builder->AddRecompilationUnit(func_index, ExecutionTier::kLiftoff);
builder.AddRecompilationUnit(func_index, ExecutionTier::kLiftoff);
continue;
}
CompileStrategy strategy = GetCompileStrategy(
module, native_module->enabled_features(), func_index, lazy_module);
if (strategy == CompileStrategy::kEager) {
builder->AddUnits(func_index);
builder.AddUnits(func_index);
} else {
// Open a single scope for all following calls to {UseLazyStub()}, instead
// of flipping page permissions for each {func_index} individually.
......@@ -1470,12 +1455,17 @@ void InitializeCompilationUnits(
native_module->UseLazyStub(func_index);
} else {
DCHECK_EQ(strategy, CompileStrategy::kLazyBaselineEagerTopTier);
builder->AddTopTierUnit(func_index);
builder.AddTopTierUnit(func_index);
native_module->UseLazyStub(func_index);
}
}
}
builder->Commit();
int num_import_wrappers = AddImportWrapperUnits(native_module, &builder);
int num_export_wrappers = AddExportWrapperUnits(
isolate, native_module, &builder, WasmFeatures::FromIsolate(isolate));
compilation_state->InitializeCompilationProgress(
lazy_module, num_import_wrappers, num_export_wrappers);
builder.Commit();
}
bool MayCompriseLazyFunctions(const WasmModule* module,
......@@ -1607,9 +1597,7 @@ void CompileNativeModule(Isolate* isolate,
}
// Initialize the compilation units and kick off background compile tasks.
std::unique_ptr<CompilationUnitBuilder> builder =
InitializeCompilation(isolate, native_module.get());
InitializeCompilationUnits(native_module.get(), std::move(builder));
InitializeCompilationUnits(isolate, native_module.get());
compilation_state->WaitForCompilationEvent(
CompilationEvent::kFinishedExportWrappers);
......@@ -2380,9 +2368,7 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
// then DoAsync would do the same as NextStep already.
// Add compilation units and kick off compilation.
std::unique_ptr<CompilationUnitBuilder> builder =
InitializeCompilation(job->isolate(), job->native_module_.get());
InitializeCompilationUnits(job->native_module_.get(), std::move(builder));
InitializeCompilationUnits(job->isolate(), job->native_module_.get());
// We are in single-threaded mode, so there are no worker tasks that will
// do the compilation. We call {WaitForCompilationEvent} here so that the
// main thread paticipates and finishes the compilation.
......@@ -2613,12 +2599,23 @@ bool AsyncStreamingProcessor::ProcessCodeSectionHeader(
auto* compilation_state = Impl(job_->native_module_->compilation_state());
compilation_state->SetWireBytesStorage(std::move(wire_bytes_storage));
DCHECK_EQ(job_->native_module_->module()->origin, kWasmOrigin);
const bool lazy_module = job_->wasm_lazy_compilation_;
// Set outstanding_finishers_ to 2, because both the AsyncCompileJob and the
// AsyncStreamingProcessor have to finish.
job_->outstanding_finishers_.store(2);
compilation_unit_builder_ =
InitializeCompilation(job_->isolate(), job_->native_module_.get());
compilation_unit_builder_.reset(
new CompilationUnitBuilder(job_->native_module_.get()));
NativeModule* native_module = job_->native_module_.get();
int num_import_wrappers =
AddImportWrapperUnits(native_module, compilation_unit_builder_.get());
int num_export_wrappers = AddExportWrapperUnits(
job_->isolate_, native_module, compilation_unit_builder_.get(),
job_->enabled_features_);
compilation_state->InitializeCompilationProgress(
lazy_module, num_import_wrappers, num_export_wrappers);
return true;
}
......
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