Commit 7dd85c1d authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Make compilation more predictable

If predictable compilation is requested (via --predictable,
--single-threaded, or --wasm-num-compilation-tasks=0), do compile and
commit one function at a time. This makes function allocation
independent of the timing.

R=ahaas@chromium.org

Bug: v8:9751, v8:9752
Change-Id: I451a436800c19574caa5e03901bd900d80e53eee
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1809371Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63884}
parent 55c48820
...@@ -964,6 +964,10 @@ bool ExecuteJSToWasmWrapperCompilationUnits( ...@@ -964,6 +964,10 @@ bool ExecuteJSToWasmWrapperCompilationUnits(
return true; return true;
} }
bool NeedsDeterministicCompile() {
return FLAG_trace_wasm_decoder || FLAG_wasm_num_compilation_tasks <= 1;
}
// Run by the main thread and background tasks to take part in compilation. // Run by the main thread and background tasks to take part in compilation.
// Returns whether any units were executed. // Returns whether any units were executed.
bool ExecuteCompilationUnits( bool ExecuteCompilationUnits(
...@@ -991,6 +995,7 @@ bool ExecuteCompilationUnits( ...@@ -991,6 +995,7 @@ bool ExecuteCompilationUnits(
// These fields are initialized in a {BackgroundCompileScope} before // These fields are initialized in a {BackgroundCompileScope} before
// starting compilation. // starting compilation.
double deadline = 0; double deadline = 0;
const bool deterministic = NeedsDeterministicCompile();
base::Optional<CompilationEnv> env; base::Optional<CompilationEnv> env;
std::shared_ptr<WireBytesStorage> wire_bytes; std::shared_ptr<WireBytesStorage> wire_bytes;
std::shared_ptr<const WasmModule> module; std::shared_ptr<const WasmModule> module;
...@@ -1084,7 +1089,7 @@ bool ExecuteCompilationUnits( ...@@ -1084,7 +1089,7 @@ bool ExecuteCompilationUnits(
} }
// Get next unit. // Get next unit.
if (deadline < platform->MonotonicallyIncreasingTime()) { if (deterministic || deadline < platform->MonotonicallyIncreasingTime()) {
unit = {}; unit = {};
} else { } else {
unit = compile_scope.compilation_state()->GetNextCompilationUnit( unit = compile_scope.compilation_state()->GetNextCompilationUnit(
...@@ -1196,10 +1201,6 @@ void InitializeCompilationUnits(Isolate* isolate, NativeModule* native_module) { ...@@ -1196,10 +1201,6 @@ void InitializeCompilationUnits(Isolate* isolate, NativeModule* native_module) {
builder.Commit(); builder.Commit();
} }
bool NeedsDeterministicCompile() {
return FLAG_trace_wasm_decoder || FLAG_wasm_num_compilation_tasks <= 1;
}
bool MayCompriseLazyFunctions(const WasmModule* module, bool MayCompriseLazyFunctions(const WasmModule* module,
const WasmFeatures& enabled_features, const WasmFeatures& enabled_features,
bool lazy_module) { bool lazy_module) {
......
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