[wasm] Fix non-determinism with --predictable

For invalid modules, the {kFinishedExportWrappers} event and the
validation error can happen in any order. Make the order deterministic
for predictable mode.

R=clemensb@chromium.org

Bug: v8:10936
Change-Id: Ib5b1e5a1a3af901a81bc37919b5aff4e5c237579
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2424134
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70086}
This commit is contained in:
Thibaud Michaud 2020-09-23 12:26:47 +02:00 committed by Commit Bot
parent cb758969dd
commit 043193187f

View File

@ -1614,9 +1614,12 @@ void CompileNativeModule(Isolate* isolate,
return;
}
Impl(native_module->compilation_state())
->FinalizeJSToWasmWrappers(isolate, native_module->module(),
export_wrappers_out);
if (!FLAG_predictable) {
// For predictable mode, do not finalize wrappers yet to make sure we catch
// validation errors first.
compilation_state->FinalizeJSToWasmWrappers(
isolate, native_module->module(), export_wrappers_out);
}
compilation_state->WaitForCompilationEvent(
CompilationEvent::kFinishedBaselineCompilation);
@ -1628,6 +1631,9 @@ void CompileNativeModule(Isolate* isolate,
ValidateSequentially(wasm_module, native_module.get(), isolate->counters(),
isolate->allocator(), thrower, lazy_module);
CHECK(thrower->error());
} else if (FLAG_predictable) {
compilation_state->FinalizeJSToWasmWrappers(
isolate, native_module->module(), export_wrappers_out);
}
}