[wasm] Publish Liftoff code before starting TurboFan

The previous logic published whenever a TurboFan function was
*finished*. Since we compile big functions first, the first TurboFan
compilation can take quite some time, and we will only publish
previously compiled Liftoff functions once that first TurboFan
compilation is done.
This CL changes that logic to publish all previous results *before*
starting a TurboFan compilation.

Drive-by: Add some trace events for interesting events.

R=ahaas@chromium.org

Bug: v8:8916, chromium:966351, chromium:944755
Change-Id: I669d6ea16bdc3f29685df153a7ed45875c28a843
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1627532
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61791}
This commit is contained in:
Clemens Hammacher 2019-05-23 15:03:02 +02:00 committed by Commit Bot
parent dec3298d9c
commit be62dcc2c0

View File

@ -936,6 +936,7 @@ bool ExecuteCompilationUnits(
auto publish_results = [&results_to_publish](
BackgroundCompileScope* compile_scope) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "PublishResults");
if (results_to_publish.empty()) return;
WasmCodeRefScope code_ref_scope;
std::vector<WasmCode*> code_vector =
@ -963,10 +964,6 @@ bool ExecuteCompilationUnits(
compilation_failed = true;
break;
}
// Publish TurboFan units immediately to reduce peak memory consumption.
if (result.requested_tier == ExecutionTier::kTurbofan) {
publish_results(&compile_scope);
}
// Get next unit.
if (deadline < platform->MonotonicallyIncreasingTime()) {
@ -980,6 +977,12 @@ bool ExecuteCompilationUnits(
publish_results(&compile_scope);
stop(compile_scope);
return true;
} else if (unit->tier() == ExecutionTier::kTurbofan) {
// Before executing a TurboFan unit, ensure to publish all previous
// units. If we compiled Liftoff before, we need to publish them anyway
// to ensure fast completion of baseline compilation, if we compiled
// TurboFan before, we publish to reduce peak memory consumption.
publish_results(&compile_scope);
}
}
}
@ -2080,6 +2083,8 @@ CompilationStateImpl::GetNextCompilationUnit(
}
void CompilationStateImpl::OnFinishedUnits(Vector<WasmCode*> code_vector) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "OnFinishedUnits");
base::MutexGuard guard(&callbacks_mutex_);
// In case of no outstanding functions we can return early.
@ -2148,11 +2153,13 @@ void CompilationStateImpl::OnFinishedUnits(Vector<WasmCode*> code_vector) {
// Trigger callbacks.
if (completes_baseline_compilation) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "BaselineFinished");
for (auto& callback : callbacks_) {
callback(CompilationEvent::kFinishedBaselineCompilation);
}
}
if (completes_top_tier_compilation) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "TopTierFinished");
for (auto& callback : callbacks_) {
callback(CompilationEvent::kFinishedTopTierCompilation);
}