Commit caec0441 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Handle empty modules correctly

Instead of a hack in the {AsyncCompileJob}, handle empty modules by
just calling the callbacks for "baseline finished" and "top tier
finished" immediately, at the point where compilation would be started
usually.

R=mstarzinger@chromium.org

Bug: v8:8916
Change-Id: Id7b32fe2508e5a8902c60865f7f7d675a7a02610
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1564054
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60785}
parent 2780b9a4
...@@ -1467,15 +1467,6 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep { ...@@ -1467,15 +1467,6 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
job->CreateNativeModule(module_); job->CreateNativeModule(module_);
size_t num_functions =
module_->functions.size() - module_->num_imported_functions;
if (num_functions == 0) {
// Degenerate case of an empty module.
job->FinishCompile();
return;
}
CompilationStateImpl* compilation_state = CompilationStateImpl* compilation_state =
Impl(job->native_module_->compilation_state()); Impl(job->native_module_->compilation_state());
compilation_state->AddCallback(CompilationStateCallback{job}); compilation_state->AddCallback(CompilationStateCallback{job});
...@@ -1836,6 +1827,18 @@ void CompilationStateImpl::SetNumberOfFunctionsToCompile( ...@@ -1836,6 +1827,18 @@ void CompilationStateImpl::SetNumberOfFunctionsToCompile(
outstanding_baseline_functions_ = num_functions_to_compile; outstanding_baseline_functions_ = num_functions_to_compile;
outstanding_top_tier_functions_ = num_functions_to_compile; outstanding_top_tier_functions_ = num_functions_to_compile;
highest_execution_tier_.assign(num_functions, ExecutionTier::kNone); highest_execution_tier_.assign(num_functions, ExecutionTier::kNone);
// Degenerate case of an empty module. Trigger callbacks immediately.
if (num_functions_to_compile == 0) {
for (auto& callback : callbacks_) {
callback(CompilationEvent::kFinishedBaselineCompilation);
}
for (auto& callback : callbacks_) {
callback(CompilationEvent::kFinishedTopTierCompilation);
}
// Clear the callbacks because no more events will be delivered.
callbacks_.clear();
}
} }
void CompilationStateImpl::AddCallback(CompilationState::callback_t callback) { void CompilationStateImpl::AddCallback(CompilationState::callback_t callback) {
......
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