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

[wasm][gc] Fix rare never-ending code GCs

Sometimes we were triggering a wasm code GC at a time where all native
modules just died. Thus, no isolates took part in that GC, and it never
finished (because no isolate would ever call {ReportLiveCodeForGC}).
This never-ending GC would then block all other GCs for the rest of the
life of this wasm engine.

This CL fixes this by just finishing the GC immediately if no isolates
are outstanding.

R=ahaas@chromium.org

Change-Id: I4c25dd6ba4132cf9f72de39c30da5d5cba0526ad
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2150588
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67154}
parent db7c21e4
......@@ -1235,6 +1235,7 @@ Handle<Script> WasmEngine::GetOrCreateScript(
}
void WasmEngine::TriggerGC(int8_t gc_sequence_index) {
DCHECK(!mutex_.TryLock());
DCHECK_NULL(current_gc_info_);
DCHECK(FLAG_wasm_code_gc);
new_potentially_dead_code_size_ = 0;
......@@ -1262,6 +1263,11 @@ void WasmEngine::TriggerGC(int8_t gc_sequence_index) {
TRACE_CODE_GC(
"Starting GC. Total number of potentially dead code objects: %zu\n",
current_gc_info_->dead_code.size());
// Ensure that there are outstanding isolates that will eventually finish this
// GC. If there are no outstanding isolates, we finish the GC immediately.
PotentiallyFinishCurrentGC();
DCHECK(current_gc_info_ == nullptr ||
!current_gc_info_->outstanding_isolates.empty());
}
bool WasmEngine::RemoveIsolateFromCurrentGC(Isolate* isolate) {
......
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