Commit 4e5883c5 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Rename mode to tier where it makes sense

Variables of type {ExecutionTier} should be called "tier", not "mode".

R=ahaas@chromium.org

Bug: v8:8238
Change-Id: I09c640398ab8ad34ac6591d42ea7b0f9ba83d620
Reviewed-on: https://chromium-review.googlesource.com/c/1335688Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57502}
parent 3858368d
......@@ -16,8 +16,8 @@ namespace wasm {
namespace {
const char* GetExecutionTierAsString(ExecutionTier mode) {
switch (mode) {
const char* GetExecutionTierAsString(ExecutionTier tier) {
switch (tier) {
case ExecutionTier::kBaseline:
return "liftoff";
case ExecutionTier::kOptimized:
......@@ -37,23 +37,23 @@ ExecutionTier WasmCompilationUnit::GetDefaultExecutionTier() {
WasmCompilationUnit::WasmCompilationUnit(WasmEngine* wasm_engine,
NativeModule* native_module, int index,
ExecutionTier mode)
ExecutionTier tier)
: wasm_engine_(wasm_engine),
func_index_(index),
native_module_(native_module),
mode_(mode) {
tier_(tier) {
const WasmModule* module = native_module->module();
DCHECK_GE(index, module->num_imported_functions);
DCHECK_LT(index, module->functions.size());
// Always disable Liftoff for asm.js, for two reasons:
// 1) asm-specific opcodes are not implemented, and
// 2) tier-up does not work with lazy compilation.
if (module->origin == kAsmJsOrigin) mode = ExecutionTier::kOptimized;
if (module->origin == kAsmJsOrigin) tier = ExecutionTier::kOptimized;
if (V8_UNLIKELY(FLAG_wasm_tier_mask_for_testing) && index < 32 &&
(FLAG_wasm_tier_mask_for_testing & (1 << index))) {
mode = ExecutionTier::kOptimized;
tier = ExecutionTier::kOptimized;
}
SwitchMode(mode);
SwitchTier(tier);
}
// Declared here such that {LiftoffCompilationUnit} and
......@@ -80,17 +80,17 @@ void WasmCompilationUnit::ExecuteCompilation(
if (FLAG_trace_wasm_compiler) {
PrintF("Compiling wasm function %d with %s\n\n", func_index_,
GetExecutionTierAsString(mode_));
GetExecutionTierAsString(tier_));
}
switch (mode_) {
switch (tier_) {
case ExecutionTier::kBaseline:
if (liftoff_unit_->ExecuteCompilation(env, func_body, counters,
detected)) {
break;
}
// Otherwise, fall back to turbofan.
SwitchMode(ExecutionTier::kOptimized);
SwitchTier(ExecutionTier::kOptimized);
V8_FALLTHROUGH;
case ExecutionTier::kOptimized:
turbofan_unit_->ExecuteCompilation(env, func_body, counters, detected);
......@@ -100,12 +100,12 @@ void WasmCompilationUnit::ExecuteCompilation(
}
}
void WasmCompilationUnit::SwitchMode(ExecutionTier new_mode) {
void WasmCompilationUnit::SwitchTier(ExecutionTier new_tier) {
// This method is being called in the constructor, where neither
// {liftoff_unit_} nor {turbofan_unit_} are set, or to switch mode from
// {liftoff_unit_} nor {turbofan_unit_} are set, or to switch tier from
// kLiftoff to kTurbofan, in which case {liftoff_unit_} is already set.
mode_ = new_mode;
switch (new_mode) {
tier_ = new_tier;
switch (new_tier) {
case ExecutionTier::kBaseline:
DCHECK(!turbofan_unit_);
DCHECK(!liftoff_unit_);
......@@ -127,14 +127,14 @@ bool WasmCompilationUnit::CompileWasmFunction(Isolate* isolate,
NativeModule* native_module,
WasmFeatures* detected,
const WasmFunction* function,
ExecutionTier mode) {
ExecutionTier tier) {
ModuleWireBytes wire_bytes(native_module->wire_bytes());
FunctionBody function_body{function->sig, function->code.offset(),
wire_bytes.start() + function->code.offset(),
wire_bytes.start() + function->code.end_offset()};
WasmCompilationUnit unit(isolate->wasm_engine(), native_module,
function->func_index, mode);
function->func_index, tier);
CompilationEnv env = native_module->CreateCompilationEnv();
unit.ExecuteCompilation(
&env, native_module->compilation_state()->GetWireBytesStorage(),
......
......@@ -46,7 +46,7 @@ class WasmCompilationUnit final {
Counters*, WasmFeatures* detected);
NativeModule* native_module() const { return native_module_; }
ExecutionTier mode() const { return mode_; }
ExecutionTier tier() const { return tier_; }
bool failed() const { return result_ == nullptr; } // TODO(clemensh): Remove.
WasmCode* result() const { return result_; }
......@@ -62,15 +62,15 @@ class WasmCompilationUnit final {
WasmEngine* const wasm_engine_;
const int func_index_;
NativeModule* const native_module_;
ExecutionTier mode_;
ExecutionTier tier_;
WasmCode* result_ = nullptr;
// LiftoffCompilationUnit, set if {mode_ == kLiftoff}.
// LiftoffCompilationUnit, set if {tier_ == kLiftoff}.
std::unique_ptr<LiftoffCompilationUnit> liftoff_unit_;
// TurbofanWasmCompilationUnit, set if {mode_ == kTurbofan}.
// TurbofanWasmCompilationUnit, set if {tier_ == kTurbofan}.
std::unique_ptr<compiler::TurbofanWasmCompilationUnit> turbofan_unit_;
void SwitchMode(ExecutionTier new_mode);
void SwitchTier(ExecutionTier new_tier);
// Called from {ExecuteCompilation} to set the result of compilation.
void SetResult(WasmCode*, Counters*);
......
......@@ -100,7 +100,7 @@ class CompilationStateImpl {
void OnFinishedUnit();
void ScheduleUnitForFinishing(std::unique_ptr<WasmCompilationUnit> unit,
ExecutionTier mode);
ExecutionTier tier);
void ScheduleCodeLogging(WasmCode*);
void OnBackgroundTaskStopped(const WasmFeatures& detected);
......@@ -584,9 +584,9 @@ class CompilationUnitBuilder {
private:
std::unique_ptr<WasmCompilationUnit> CreateUnit(uint32_t func_index,
ExecutionTier mode) {
ExecutionTier tier) {
return base::make_unique<WasmCompilationUnit>(wasm_engine_, native_module_,
func_index, mode);
func_index, tier);
}
CompilationStateImpl* compilation_state() const {
......@@ -639,16 +639,16 @@ bool FetchAndExecuteCompilationUnit(CompilationEnv* env,
compilation_state->GetNextCompilationUnit();
if (unit == nullptr) return false;
// TODO(kimanh): We need to find out in which mode the unit
// TODO(kimanh): We need to find out in which tier the unit
// should be compiled in before compiling it, as it might fallback
// to Turbofan if it cannot be compiled using Liftoff. This can be removed
// later as soon as Liftoff can compile any function. Then, we can directly
// access {unit->mode()} within {ScheduleUnitForFinishing()}.
ExecutionTier mode = unit->mode();
// access {unit->tier()} within {ScheduleUnitForFinishing()}.
ExecutionTier tier = unit->tier();
unit->ExecuteCompilation(env, compilation_state->GetSharedWireBytesStorage(),
counters, detected);
if (!unit->failed()) compilation_state->ScheduleCodeLogging(unit->result());
compilation_state->ScheduleUnitForFinishing(std::move(unit), mode);
compilation_state->ScheduleUnitForFinishing(std::move(unit), tier);
return true;
}
......@@ -3018,7 +3018,7 @@ void CompilationStateImpl::AddCompilationUnits(
if (compile_mode_ == CompileMode::kTiering) {
DCHECK_EQ(baseline_units.size(), tiering_units.size());
DCHECK_EQ(tiering_units.back()->mode(), ExecutionTier::kOptimized);
DCHECK_EQ(tiering_units.back()->tier(), ExecutionTier::kOptimized);
tiering_compilation_units_.insert(
tiering_compilation_units_.end(),
std::make_move_iterator(tiering_units.begin()),
......@@ -3099,10 +3099,10 @@ void CompilationStateImpl::OnFinishedUnit() {
}
void CompilationStateImpl::ScheduleUnitForFinishing(
std::unique_ptr<WasmCompilationUnit> unit, ExecutionTier mode) {
std::unique_ptr<WasmCompilationUnit> unit, ExecutionTier tier) {
base::MutexGuard guard(&mutex_);
if (compile_mode_ == CompileMode::kTiering &&
mode == ExecutionTier::kOptimized) {
tier == ExecutionTier::kOptimized) {
tiering_finish_units_.push_back(std::move(unit));
} else {
baseline_finish_units_.push_back(std::move(unit));
......
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