[wasm] Allow TurboFan compilation of arbitrarily sized functions

We added a stop-gap workaround for excessive TurboFan compilation times,
by just not compiling functions bigger than 500k by TurboFan.
This code is only used when WasmGC is enabled and lazy compilation is
disabled.
Since lazy compilation is the default now, this code is not needed any
more. We remove it to simplify the code by avoiding late updates of the
compilation progress.

R=jkummerow@chromium.org

Change-Id: I32c63b24417e6f44e8ec4496caba20b10bfd78b0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4161754
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85247}
This commit is contained in:
Clemens Backes 2023-01-12 10:59:34 +01:00 committed by V8 LUCI CQ
parent 77de44e1c4
commit 25005c142c

View File

@ -669,10 +669,9 @@ class CompilationStateImpl {
}
private:
// Returns the potentially-updated {function_progress}.
uint8_t AddCompilationUnitInternal(CompilationUnitBuilder* builder,
int function_index,
uint8_t function_progress);
void AddCompilationUnitInternal(CompilationUnitBuilder* builder,
int function_index,
uint8_t function_progress);
// Trigger callbacks according to the internal counters below
// (outstanding_...), plus the given events.
@ -3133,7 +3132,7 @@ void CompilationStateImpl::InitializeCompilationProgress(
TriggerCallbacks();
}
uint8_t CompilationStateImpl::AddCompilationUnitInternal(
void CompilationStateImpl::AddCompilationUnitInternal(
CompilationUnitBuilder* builder, int function_index,
uint8_t function_progress) {
ExecutionTier required_baseline_tier =
@ -3144,26 +3143,6 @@ uint8_t CompilationStateImpl::AddCompilationUnitInternal(
ExecutionTier reached_tier =
CompilationStateImpl::ReachedTierField::decode(function_progress);
if (v8_flags.experimental_wasm_gc && !v8_flags.wasm_lazy_compilation) {
// The Turbofan optimizations we enable for WasmGC code can (for now)
// take a very long time, so skip Turbofan compilation for super-large
// functions.
// Besides, module serialization currently requires that all functions
// have been TF-compiled. By enabling this limit only for WasmGC, we
// make sure that non-experimental modules can be serialize as usual.
// TODO(jkummerow): This is a stop-gap solution to avoid excessive
// compile times. We would like to replace this hard threshold with
// a better solution (TBD) eventually.
constexpr uint32_t kMaxWasmFunctionSizeForTurbofan = 500 * KB;
uint32_t size = builder->module()->functions[function_index].code.length();
if (size > kMaxWasmFunctionSizeForTurbofan) {
required_baseline_tier = ExecutionTier::kLiftoff;
if (required_top_tier == ExecutionTier::kTurbofan) {
required_top_tier = ExecutionTier::kLiftoff;
}
}
}
if (reached_tier < required_baseline_tier) {
builder->AddBaselineUnit(function_index, required_baseline_tier);
}
@ -3171,10 +3150,6 @@ uint8_t CompilationStateImpl::AddCompilationUnitInternal(
required_baseline_tier != required_top_tier) {
builder->AddTopTierUnit(function_index, required_top_tier);
}
return CompilationStateImpl::RequiredBaselineTierField::encode(
required_baseline_tier) |
CompilationStateImpl::RequiredTopTierField::encode(required_top_tier) |
CompilationStateImpl::ReachedTierField::encode(reached_tier);
}
void CompilationStateImpl::InitializeCompilationUnits(
@ -3188,11 +3163,10 @@ void CompilationStateImpl::InitializeCompilationUnits(
} else {
base::MutexGuard guard(&callbacks_mutex_);
for (size_t i = 0; i < compilation_progress_.size(); ++i) {
for (size_t i = 0, e = compilation_progress_.size(); i < e; ++i) {
uint8_t function_progress = compilation_progress_[i];
int func_index = offset + static_cast<int>(i);
compilation_progress_[i] = AddCompilationUnitInternal(
builder.get(), func_index, function_progress);
AddCompilationUnitInternal(builder.get(), func_index, function_progress);
}
}
builder->Commit();
@ -3213,14 +3187,7 @@ void CompilationStateImpl::AddCompilationUnit(CompilationUnitBuilder* builder,
base::MutexGuard guard(&callbacks_mutex_);
function_progress = compilation_progress_[progress_index];
}
uint8_t updated_function_progress =
AddCompilationUnitInternal(builder, func_index, function_progress);
if (updated_function_progress != function_progress) {
// This should happen very rarely (only for super-large functions), so we're
// not worried about overhead.
base::MutexGuard guard(&callbacks_mutex_);
compilation_progress_[progress_index] = updated_function_progress;
}
AddCompilationUnitInternal(builder, func_index, function_progress);
}
void CompilationStateImpl::InitializeCompilationProgressAfterDeserialization(