Commit a849c595 authored by Shu-yu Guo's avatar Shu-yu Guo Committed by V8 LUCI CQ

Revert "[wasm] Refactor compilation tier computations"

This reverts commit e50472d6.

Reason for revert: compilation-hints-decoder breakage
https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Linux64%20ASAN/45708/overview

Original change's description:
> [wasm] Refactor compilation tier computations
>
> The way we initialized the "compilation progress" was pretty convoluted,
> with multiple levels of functions being called for initializing every
> single slot.
>
> This CL refactors this to compute one default value for the whole
> module, and only modifies those slots that need special handling (e.g.
> because of compilation hints, or lazy/eager compilation after
> deserialization).
>
> We also rename "liftoff_functions" to "eager_functions" in the
> deserialization path; the idea is that those functions should get
> eagerly compiled because we expect them to be needed during execution.
> Usually they would be Liftoff-compiled, but it's more consistent to use
> the existing logic to choose the baseline tier. In the default
> configuration, this will still use Liftoff, but if Liftoff is disabled
> we will use TurboFan instead.
>
> R=​jkummerow@chromium.org, ahaas@chromium.org
>
> Bug: v8:12425
> Change-Id: Ie58840b19efd0b1e98f1b02d5f1d4369410ed8e1
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3829606
> Commit-Queue: Clemens Backes <clemensb@chromium.org>
> Reviewed-by: Andreas Haas <ahaas@chromium.org>
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#82521}

Bug: v8:12425
Change-Id: I45cef01ea40c50c3b86fbceca9b482a9bded535e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3835290
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Owners-Override: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82541}
parent 2b2e4e42
......@@ -167,8 +167,9 @@ class V8_EXPORT_PRIVATE CompilationState {
void AddCallback(std::unique_ptr<CompilationEventCallback> callback);
void InitializeAfterDeserialization(base::Vector<const int> lazy_functions,
base::Vector<const int> eager_functions);
void InitializeAfterDeserialization(
base::Vector<const int> lazy_functions,
base::Vector<const int> liftoff_functions);
// Set a higher priority for the compilation job.
void SetHighPriority();
......
......@@ -16,7 +16,18 @@
#include "src/wasm/wasm-debug.h"
#include "src/wasm/wasm-engine.h"
namespace v8::internal::wasm {
namespace v8 {
namespace internal {
namespace wasm {
// static
ExecutionTier WasmCompilationUnit::GetBaselineExecutionTier(
const WasmModule* module) {
// Liftoff does not support the special asm.js opcodes, thus always compile
// asm.js modules with TurboFan.
if (is_asmjs_module(module)) return ExecutionTier::kTurbofan;
return FLAG_liftoff ? ExecutionTier::kLiftoff : ExecutionTier::kTurbofan;
}
WasmCompilationResult WasmCompilationUnit::ExecuteCompilation(
CompilationEnv* env, const WireBytesStorage* wire_bytes_storage,
......@@ -264,4 +275,6 @@ Handle<CodeT> JSToWasmWrapperCompilationUnit::CompileSpecificJSToWasmWrapper(
return unit.Finalize();
}
} // namespace v8::internal::wasm
} // namespace wasm
} // namespace internal
} // namespace v8
......@@ -62,6 +62,8 @@ struct WasmCompilationResult {
class V8_EXPORT_PRIVATE WasmCompilationUnit final {
public:
static ExecutionTier GetBaselineExecutionTier(const WasmModule*);
WasmCompilationUnit(int index, ExecutionTier tier, ForDebugging for_debugging)
: func_index_(index), tier_(tier), for_debugging_(for_debugging) {}
......
This diff is collapsed.
......@@ -28,7 +28,7 @@ namespace wasm {
namespace {
constexpr uint8_t kLazyFunction = 2;
constexpr uint8_t kEagerFunction = 3;
constexpr uint8_t kLiftoffFunction = 3;
constexpr uint8_t kTurboFanFunction = 4;
// TODO(bbudge) Try to unify the various implementations of readers and writers
......@@ -340,17 +340,17 @@ void NativeModuleSerializer::WriteCode(const WasmCode* code, Writer* writer) {
// non-relocatable constants.
if (code->tier() != ExecutionTier::kTurbofan) {
// We check if the function has been executed already. If so, we serialize
// it as {kEagerFunction} so that upon deserialization the function will
// get eagerly compiled with Liftoff (if enabled). If the function has not
// been executed yet, we serialize it as {kLazyFunction}, and the function
// will not get compiled upon deserialization.
// it as {kLiftoffFunction} so that upon deserialization the function will
// get compiled with Liftoff eagerly. If the function has not been executed
// yet, we serialize it as {kLazyFunction}, and the function will not get
// compiled upon deserialization.
NativeModule* native_module = code->native_module();
uint32_t budget =
native_module->tiering_budget_array()[declared_function_index(
native_module->module(), code->index())];
writer->Write(budget == static_cast<uint32_t>(FLAG_wasm_tiering_budget)
? kLazyFunction
: kEagerFunction);
: kLiftoffFunction);
return;
}
......@@ -552,8 +552,8 @@ class V8_EXPORT_PRIVATE NativeModuleDeserializer {
return base::VectorOf(lazy_functions_);
}
base::Vector<const int> eager_functions() {
return base::VectorOf(eager_functions_);
base::Vector<const int> liftoff_functions() {
return base::VectorOf(liftoff_functions_);
}
private:
......@@ -574,7 +574,7 @@ class V8_EXPORT_PRIVATE NativeModuleDeserializer {
base::Vector<byte> current_code_space_;
NativeModule::JumpTablesRef current_jump_tables_;
std::vector<int> lazy_functions_;
std::vector<int> eager_functions_;
std::vector<int> liftoff_functions_;
};
class DeserializeCodeTask : public JobTask {
......@@ -714,8 +714,8 @@ DeserializationUnit NativeModuleDeserializer::ReadCode(int fn_index,
lazy_functions_.push_back(fn_index);
return {};
}
if (code_kind == kEagerFunction) {
eager_functions_.push_back(fn_index);
if (code_kind == kLiftoffFunction) {
liftoff_functions_.push_back(fn_index);
return {};
}
......@@ -896,7 +896,7 @@ MaybeHandle<WasmModuleObject> DeserializeNativeModule(
return {};
}
shared_native_module->compilation_state()->InitializeAfterDeserialization(
deserializer.lazy_functions(), deserializer.eager_functions());
deserializer.lazy_functions(), deserializer.liftoff_functions());
wasm_engine->UpdateNativeModuleCache(error, &shared_native_module, 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