Commit e7fa1fbf authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Avoid adding callback that will never be called

In {InitializeRecompilationProgress}, we already have logic in place to
call the callback (all callbacks really) if no compilation units were
added.
In that case, the callback in fact does not need to be added to the list
of callbacks. Instead, it's enough to just call this one callback and
then discard it.

R=ahaas@chromium.org

Bug: v8:9654
Change-Id: I60bab2d67d67d10964404d897d13ffd628ff9964
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2071861
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66450}
parent 51022eb8
......@@ -2550,9 +2550,6 @@ std::vector<int> CompilationStateImpl::InitializeRecompilationProgress(
std::vector<int> recompilation_functions;
base::MutexGuard guard(&callbacks_mutex_);
// Add callback.
callbacks_.emplace_back(std::move(recompilation_finished_callback));
// Ensure that we don't trigger recompilation if another recompilation is
// already happening.
DCHECK_EQ(0, outstanding_recompilation_functions_);
......@@ -2582,11 +2579,12 @@ std::vector<int> CompilationStateImpl::InitializeRecompilationProgress(
native_module_->module()->num_declared_functions);
}
// Trigger callbacks if module needs no recompilation.
// Trigger callback if module needs no recompilation. Add to the list of
// callbacks (to be called later) otherwise.
if (outstanding_recompilation_functions_ == 0) {
for (auto& callback : callbacks_) {
callback(CompilationEvent::kFinishedRecompilation);
}
recompilation_finished_callback(CompilationEvent::kFinishedRecompilation);
} else {
callbacks_.emplace_back(std::move(recompilation_finished_callback));
}
return recompilation_functions;
......
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