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

[wasm] Fix code size estimate for async compilation

When computing the code size estimate for {PrepareAndStartCompile}, we
did not consider Liftoff code in the async path. Other invocations
checked {FLAG_liftoff} to decide whether Liftoff code will be generated.
This CL fixes the async path to do the same, and renames {uses_liftoff}
to {include_liftoff} to match the name of the parameter in
{EstimateNativeModuleCodeSize}.

R=ahaas@chromium.org

Bug: v8:12520
Change-Id: Ic92237dc05ac96ddd88c3e8788cd443c83bd446f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3367624Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78492}
parent 139a2f51
......@@ -1879,10 +1879,10 @@ std::shared_ptr<NativeModule> CompileToNativeModule(
}
// Create a new {NativeModule} first.
const bool uses_liftoff = module->origin == kWasmOrigin && FLAG_liftoff;
const bool include_liftoff = module->origin == kWasmOrigin && FLAG_liftoff;
size_t code_size_estimate =
wasm::WasmCodeManager::EstimateNativeModuleCodeSize(module.get(),
uses_liftoff);
include_liftoff);
native_module =
engine->NewNativeModule(isolate, enabled, module, code_size_estimate);
native_module->SetWireBytes(std::move(wire_bytes_copy));
......@@ -2485,10 +2485,10 @@ class AsyncCompileJob::DecodeModule : public AsyncCompileJob::CompileStep {
} else {
// Decode passed.
std::shared_ptr<WasmModule> module = std::move(result).value();
const bool kUsesLiftoff = false;
const bool include_liftoff = FLAG_liftoff;
size_t code_size_estimate =
wasm::WasmCodeManager::EstimateNativeModuleCodeSize(module.get(),
kUsesLiftoff);
include_liftoff);
job->DoSync<PrepareAndStartCompile>(std::move(module), true,
code_size_estimate);
}
......@@ -2528,10 +2528,6 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
code_size_estimate_(code_size_estimate) {}
private:
const std::shared_ptr<const WasmModule> module_;
const bool start_compilation_;
const size_t code_size_estimate_;
void RunInForeground(AsyncCompileJob* job) override {
TRACE_COMPILE("(2) Prepare and start compile...\n");
......@@ -2575,6 +2571,10 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
}
}
}
const std::shared_ptr<const WasmModule> module_;
const bool start_compilation_;
const size_t code_size_estimate_;
};
//==========================================================================
......@@ -2785,11 +2785,11 @@ bool AsyncStreamingProcessor::ProcessCodeSectionHeader(
int num_imported_functions =
static_cast<int>(decoder_.module()->num_imported_functions);
DCHECK_EQ(kWasmOrigin, decoder_.module()->origin);
const bool uses_liftoff = FLAG_liftoff;
const bool include_liftoff = FLAG_liftoff;
size_t code_size_estimate =
wasm::WasmCodeManager::EstimateNativeModuleCodeSize(
num_functions, num_imported_functions, code_section_length,
uses_liftoff);
include_liftoff);
job_->DoImmediately<AsyncCompileJob::PrepareAndStartCompile>(
decoder_.shared_module(), false, code_size_estimate);
......@@ -2889,9 +2889,10 @@ void AsyncStreamingProcessor::OnFinishedStream(
if (prefix_cache_hit_) {
// Restart as an asynchronous, non-streaming compilation. Most likely
// {PrepareAndStartCompile} will get the native module from the cache.
const bool include_liftoff = FLAG_liftoff;
size_t code_size_estimate =
wasm::WasmCodeManager::EstimateNativeModuleCodeSize(
result.value().get(), FLAG_liftoff);
result.value().get(), include_liftoff);
job_->DoSync<AsyncCompileJob::PrepareAndStartCompile>(
std::move(result).value(), true, code_size_estimate);
return;
......
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