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

[wasm] Release compilation time callback earlier

As the {CompilationTimeCallback} does not react to
{kFinishedCompilationChunk}, it does not need to stay alive after a
"final" compilation event.

Drive-by: Make the enum a boolean enum.

R=jkummerow@chromium.org

Bug: v8:12899
Change-Id: Iffacd6e3d9a0f2474a51f07cf01419b2badf98c6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3667083
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80940}
parent 2d5c7a15
......@@ -127,14 +127,17 @@ class V8_EXPORT_PRIVATE CompilationEventCallback {
virtual void call(CompilationEvent event) = 0;
enum class ReleaseAfterFinalEvent { kRelease, kKeep };
enum ReleaseAfterFinalEvent : bool {
kReleaseAfterFinalEvent = true,
kKeepAfterFinalEvent = false
};
// Tells the module compiler whether to keep or to release a callback when the
// compilation state finishes all compilation units. Most callbacks should be
// released, that's why there is a default implementation, but the callback
// for code caching with dynamic tiering has to stay alive.
virtual ReleaseAfterFinalEvent release_after_final_event() {
return ReleaseAfterFinalEvent::kRelease;
return kReleaseAfterFinalEvent;
}
};
......
......@@ -1777,11 +1777,6 @@ class CompilationTimeCallback : public CompilationEventCallback {
native_module_(std::move(native_module)),
compile_mode_(compile_mode) {}
// Keep this callback alive to be able to record caching metrics.
ReleaseAfterFinalEvent release_after_final_event() override {
return CompilationEventCallback::ReleaseAfterFinalEvent::kKeep;
}
void call(CompilationEvent compilation_event) override {
DCHECK(base::TimeTicks::IsHighResolution());
std::shared_ptr<NativeModule> native_module = native_module_.lock();
......@@ -3635,8 +3630,7 @@ void CompilationStateImpl::TriggerCallbacks(
outstanding_recompilation_functions_ == 0) {
auto new_end = std::remove_if(
callbacks_.begin(), callbacks_.end(), [](const auto& callback) {
return callback->release_after_final_event() ==
CompilationEventCallback::ReleaseAfterFinalEvent::kRelease;
return callback->release_after_final_event();
});
callbacks_.erase(new_end, callbacks_.end());
}
......
......@@ -342,7 +342,7 @@ class CompilationChunkFinishedCallback : public CompilationEventCallback {
}
ReleaseAfterFinalEvent release_after_final_event() override {
return CompilationEventCallback::ReleaseAfterFinalEvent::kKeep;
return kKeepAfterFinalEvent;
}
private:
......
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