Commit f6a559e2 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Make DynamicTiering a boolean enum

This makes usages less verbose, and is consistent with other existing
enums.
Also, we can use brace initialization to avoid boilerplate when creating
a DynamicTiering value.

Drive-by: Rename a 'kIncludeLiftoff' variable to 'include_liftoff'
because it is not a static constant.

R=jkummerow@chromium.org

Bug: v8:12281
Change-Id: Ie45fdb550241a8b9ca4e2a31b7c27500939fa247
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3585566Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79993}
parent 302e5408
...@@ -7999,7 +7999,7 @@ wasm::WasmCompilationResult CompileWasmMathIntrinsic( ...@@ -7999,7 +7999,7 @@ wasm::WasmCompilationResult CompileWasmMathIntrinsic(
wasm::CompilationEnv env( wasm::CompilationEnv env(
nullptr, wasm::kNoBoundsChecks, nullptr, wasm::kNoBoundsChecks,
wasm::RuntimeExceptionSupport::kNoRuntimeExceptionSupport, wasm::RuntimeExceptionSupport::kNoRuntimeExceptionSupport,
wasm::WasmFeatures::All(), wasm::DynamicTiering::kDisabled); wasm::WasmFeatures::All(), wasm::kNoDynamicTiering);
WasmGraphBuilder builder(&env, mcgraph->zone(), mcgraph, sig, WasmGraphBuilder builder(&env, mcgraph->zone(), mcgraph, sig,
source_positions); source_positions);
......
...@@ -790,8 +790,7 @@ class LiftoffCompiler { ...@@ -790,8 +790,7 @@ class LiftoffCompiler {
} }
bool dynamic_tiering() { bool dynamic_tiering() {
return env_->dynamic_tiering == DynamicTiering::kEnabled && return env_->dynamic_tiering && for_debugging_ == kNoDebugging &&
for_debugging_ == kNoDebugging &&
(FLAG_wasm_tier_up_filter == -1 || (FLAG_wasm_tier_up_filter == -1 ||
FLAG_wasm_tier_up_filter == func_index_); FLAG_wasm_tier_up_filter == func_index_);
} }
......
...@@ -45,7 +45,10 @@ enum BoundsCheckStrategy : int8_t { ...@@ -45,7 +45,10 @@ enum BoundsCheckStrategy : int8_t {
kNoBoundsChecks kNoBoundsChecks
}; };
enum class DynamicTiering { kEnabled, kDisabled }; enum DynamicTiering : bool {
kDynamicTiering = true,
kNoDynamicTiering = false
};
// The {CompilationEnv} encapsulates the module data that is used during // The {CompilationEnv} encapsulates the module data that is used during
// compilation. CompilationEnvs are shareable across multiple compilations. // compilation. CompilationEnvs are shareable across multiple compilations.
......
...@@ -952,8 +952,7 @@ ExecutionTierPair GetRequestedExecutionTiers( ...@@ -952,8 +952,7 @@ ExecutionTierPair GetRequestedExecutionTiers(
result.baseline_tier = WasmCompilationUnit::GetBaselineExecutionTier(module); result.baseline_tier = WasmCompilationUnit::GetBaselineExecutionTier(module);
bool dynamic_tiering = bool dynamic_tiering =
Impl(native_module->compilation_state())->dynamic_tiering() == Impl(native_module->compilation_state())->dynamic_tiering();
DynamicTiering::kEnabled;
bool tier_up_enabled = !dynamic_tiering && FLAG_wasm_tier_up; bool tier_up_enabled = !dynamic_tiering && FLAG_wasm_tier_up;
if (module->origin != kWasmOrigin || !tier_up_enabled || if (module->origin != kWasmOrigin || !tier_up_enabled ||
V8_UNLIKELY(FLAG_wasm_tier_up_filter >= 0 && V8_UNLIKELY(FLAG_wasm_tier_up_filter >= 0 &&
...@@ -1930,9 +1929,7 @@ std::shared_ptr<NativeModule> CompileToNativeModule( ...@@ -1930,9 +1929,7 @@ std::shared_ptr<NativeModule> CompileToNativeModule(
// Create a new {NativeModule} first. // Create a new {NativeModule} first.
const bool include_liftoff = module->origin == kWasmOrigin && FLAG_liftoff; const bool include_liftoff = module->origin == kWasmOrigin && FLAG_liftoff;
DynamicTiering dynamic_tiering = isolate->IsWasmDynamicTieringEnabled() DynamicTiering dynamic_tiering{isolate->IsWasmDynamicTieringEnabled()};
? DynamicTiering::kEnabled
: DynamicTiering::kDisabled;
size_t code_size_estimate = size_t code_size_estimate =
wasm::WasmCodeManager::EstimateNativeModuleCodeSize( wasm::WasmCodeManager::EstimateNativeModuleCodeSize(
module.get(), include_liftoff, dynamic_tiering); module.get(), include_liftoff, dynamic_tiering);
...@@ -2006,9 +2003,7 @@ AsyncCompileJob::AsyncCompileJob( ...@@ -2006,9 +2003,7 @@ AsyncCompileJob::AsyncCompileJob(
: isolate_(isolate), : isolate_(isolate),
api_method_name_(api_method_name), api_method_name_(api_method_name),
enabled_features_(enabled), enabled_features_(enabled),
dynamic_tiering_(isolate_->IsWasmDynamicTieringEnabled() dynamic_tiering_(DynamicTiering{isolate_->IsWasmDynamicTieringEnabled()}),
? DynamicTiering::kEnabled
: DynamicTiering::kDisabled),
wasm_lazy_compilation_(FLAG_wasm_lazy_compilation), wasm_lazy_compilation_(FLAG_wasm_lazy_compilation),
start_time_(base::TimeTicks::Now()), start_time_(base::TimeTicks::Now()),
bytes_copy_(std::move(bytes_copy)), bytes_copy_(std::move(bytes_copy)),
...@@ -3610,15 +3605,13 @@ void CompilationStateImpl::TriggerCallbacks( ...@@ -3610,15 +3605,13 @@ void CompilationStateImpl::TriggerCallbacks(
triggered_events.Add(CompilationEvent::kFinishedExportWrappers); triggered_events.Add(CompilationEvent::kFinishedExportWrappers);
if (outstanding_baseline_units_ == 0) { if (outstanding_baseline_units_ == 0) {
triggered_events.Add(CompilationEvent::kFinishedBaselineCompilation); triggered_events.Add(CompilationEvent::kFinishedBaselineCompilation);
if (dynamic_tiering_ == DynamicTiering::kDisabled && if (!dynamic_tiering_ && outstanding_top_tier_functions_ == 0) {
outstanding_top_tier_functions_ == 0) {
triggered_events.Add(CompilationEvent::kFinishedTopTierCompilation); triggered_events.Add(CompilationEvent::kFinishedTopTierCompilation);
} }
} }
} }
if (dynamic_tiering_ == DynamicTiering::kEnabled && if (dynamic_tiering_ && static_cast<size_t>(FLAG_wasm_caching_threshold) <
static_cast<size_t>(FLAG_wasm_caching_threshold) <
bytes_since_last_chunk_) { bytes_since_last_chunk_) {
triggered_events.Add(CompilationEvent::kFinishedCompilationChunk); triggered_events.Add(CompilationEvent::kFinishedCompilationChunk);
bytes_since_last_chunk_ = 0; bytes_since_last_chunk_ = 0;
......
...@@ -2110,7 +2110,7 @@ size_t WasmCodeManager::EstimateNativeModuleCodeSize( ...@@ -2110,7 +2110,7 @@ size_t WasmCodeManager::EstimateNativeModuleCodeSize(
// With dynamic tiering we don't expect to compile more than 25% with // With dynamic tiering we don't expect to compile more than 25% with
// TurboFan. If there is no liftoff though then all code will get generated // TurboFan. If there is no liftoff though then all code will get generated
// by TurboFan. // by TurboFan.
if (include_liftoff && dynamic_tiering == DynamicTiering::kEnabled) { if (include_liftoff && dynamic_tiering) {
size_of_turbofan /= 4; size_of_turbofan /= 4;
} }
...@@ -2233,11 +2233,10 @@ std::shared_ptr<NativeModule> WasmCodeManager::NewNativeModule( ...@@ -2233,11 +2233,10 @@ std::shared_ptr<NativeModule> WasmCodeManager::NewNativeModule(
size_t size = code_space.size(); size_t size = code_space.size();
Address end = code_space.end(); Address end = code_space.end();
std::shared_ptr<NativeModule> ret; std::shared_ptr<NativeModule> ret;
DynamicTiering dynamic_tiering = isolate->IsWasmDynamicTieringEnabled() new NativeModule(enabled,
? DynamicTiering::kEnabled DynamicTiering{isolate->IsWasmDynamicTieringEnabled()},
: DynamicTiering::kDisabled; std::move(code_space), std::move(module),
new NativeModule(enabled, dynamic_tiering, std::move(code_space), isolate->async_counters(), &ret);
std::move(module), isolate->async_counters(), &ret);
// The constructor initialized the shared_ptr. // The constructor initialized the shared_ptr.
DCHECK_NOT_NULL(ret); DCHECK_NOT_NULL(ret);
TRACE_HEAP("New NativeModule %p: Mem: 0x%" PRIxPTR ",+%zu\n", ret.get(), TRACE_HEAP("New NativeModule %p: Mem: 0x%" PRIxPTR ",+%zu\n", ret.get(),
......
...@@ -2240,7 +2240,7 @@ Handle<AsmWasmData> AsmWasmData::New( ...@@ -2240,7 +2240,7 @@ Handle<AsmWasmData> AsmWasmData::New(
const bool kUsesLiftoff = false; const bool kUsesLiftoff = false;
size_t memory_estimate = size_t memory_estimate =
wasm::WasmCodeManager::EstimateNativeModuleCodeSize( wasm::WasmCodeManager::EstimateNativeModuleCodeSize(
module, kUsesLiftoff, wasm::DynamicTiering::kDisabled) + module, kUsesLiftoff, wasm::kNoDynamicTiering) +
wasm::WasmCodeManager::EstimateNativeModuleMetaDataSize(module); wasm::WasmCodeManager::EstimateNativeModuleMetaDataSize(module);
Handle<Managed<wasm::NativeModule>> managed_native_module = Handle<Managed<wasm::NativeModule>> managed_native_module =
Managed<wasm::NativeModule>::FromSharedPtr(isolate, memory_estimate, Managed<wasm::NativeModule>::FromSharedPtr(isolate, memory_estimate,
......
...@@ -868,13 +868,11 @@ MaybeHandle<WasmModuleObject> DeserializeNativeModule( ...@@ -868,13 +868,11 @@ MaybeHandle<WasmModuleObject> DeserializeNativeModule(
auto shared_native_module = wasm_engine->MaybeGetNativeModule( auto shared_native_module = wasm_engine->MaybeGetNativeModule(
module->origin, owned_wire_bytes.as_vector(), isolate); module->origin, owned_wire_bytes.as_vector(), isolate);
if (shared_native_module == nullptr) { if (shared_native_module == nullptr) {
DynamicTiering dynamic_tiering = isolate->IsWasmDynamicTieringEnabled() bool dynamic_tiering = isolate->IsWasmDynamicTieringEnabled();
? DynamicTiering::kEnabled const bool include_liftoff = !dynamic_tiering;
: DynamicTiering::kDisabled;
const bool kIncludeLiftoff = dynamic_tiering == DynamicTiering::kDisabled;
size_t code_size_estimate = size_t code_size_estimate =
wasm::WasmCodeManager::EstimateNativeModuleCodeSize( wasm::WasmCodeManager::EstimateNativeModuleCodeSize(
module.get(), kIncludeLiftoff, dynamic_tiering); module.get(), include_liftoff, DynamicTiering{dynamic_tiering});
shared_native_module = wasm_engine->NewNativeModule( shared_native_module = wasm_engine->NewNativeModule(
isolate, enabled_features, std::move(module), code_size_estimate); isolate, enabled_features, std::move(module), code_size_estimate);
// We have to assign a compilation ID here, as it is required for a // We have to assign a compilation ID here, as it is required for a
......
...@@ -343,8 +343,7 @@ uint32_t TestingModuleBuilder::AddPassiveElementSegment( ...@@ -343,8 +343,7 @@ uint32_t TestingModuleBuilder::AddPassiveElementSegment(
CompilationEnv TestingModuleBuilder::CreateCompilationEnv() { CompilationEnv TestingModuleBuilder::CreateCompilationEnv() {
return {test_module_.get(), native_module_->bounds_checks(), return {test_module_.get(), native_module_->bounds_checks(),
runtime_exception_support_, enabled_features_, runtime_exception_support_, enabled_features_, kNoDynamicTiering};
DynamicTiering::kDisabled};
} }
const WasmGlobal* TestingModuleBuilder::AddGlobal(ValueType type) { const WasmGlobal* TestingModuleBuilder::AddGlobal(ValueType type) {
...@@ -360,12 +359,10 @@ const WasmGlobal* TestingModuleBuilder::AddGlobal(ValueType type) { ...@@ -360,12 +359,10 @@ const WasmGlobal* TestingModuleBuilder::AddGlobal(ValueType type) {
Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() { Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() {
const bool kUsesLiftoff = true; const bool kUsesLiftoff = true;
DynamicTiering dynamic_tiering = FLAG_wasm_dynamic_tiering
? DynamicTiering::kEnabled
: DynamicTiering::kDisabled;
size_t code_size_estimate = size_t code_size_estimate =
wasm::WasmCodeManager::EstimateNativeModuleCodeSize( wasm::WasmCodeManager::EstimateNativeModuleCodeSize(
test_module_.get(), kUsesLiftoff, dynamic_tiering); test_module_.get(), kUsesLiftoff,
DynamicTiering{FLAG_wasm_dynamic_tiering});
auto native_module = GetWasmEngine()->NewNativeModule( auto native_module = GetWasmEngine()->NewNativeModule(
isolate_, enabled_features_, test_module_, code_size_estimate); isolate_, enabled_features_, test_module_, code_size_estimate);
native_module->SetWireBytes(base::OwnedVector<const uint8_t>()); native_module->SetWireBytes(base::OwnedVector<const uint8_t>());
......
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