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(
wasm::CompilationEnv env(
nullptr, wasm::kNoBoundsChecks,
wasm::RuntimeExceptionSupport::kNoRuntimeExceptionSupport,
wasm::WasmFeatures::All(), wasm::DynamicTiering::kDisabled);
wasm::WasmFeatures::All(), wasm::kNoDynamicTiering);
WasmGraphBuilder builder(&env, mcgraph->zone(), mcgraph, sig,
source_positions);
......
......@@ -790,8 +790,7 @@ class LiftoffCompiler {
}
bool dynamic_tiering() {
return env_->dynamic_tiering == DynamicTiering::kEnabled &&
for_debugging_ == kNoDebugging &&
return env_->dynamic_tiering && for_debugging_ == kNoDebugging &&
(FLAG_wasm_tier_up_filter == -1 ||
FLAG_wasm_tier_up_filter == func_index_);
}
......
......@@ -45,7 +45,10 @@ enum BoundsCheckStrategy : int8_t {
kNoBoundsChecks
};
enum class DynamicTiering { kEnabled, kDisabled };
enum DynamicTiering : bool {
kDynamicTiering = true,
kNoDynamicTiering = false
};
// The {CompilationEnv} encapsulates the module data that is used during
// compilation. CompilationEnvs are shareable across multiple compilations.
......
......@@ -952,8 +952,7 @@ ExecutionTierPair GetRequestedExecutionTiers(
result.baseline_tier = WasmCompilationUnit::GetBaselineExecutionTier(module);
bool dynamic_tiering =
Impl(native_module->compilation_state())->dynamic_tiering() ==
DynamicTiering::kEnabled;
Impl(native_module->compilation_state())->dynamic_tiering();
bool tier_up_enabled = !dynamic_tiering && FLAG_wasm_tier_up;
if (module->origin != kWasmOrigin || !tier_up_enabled ||
V8_UNLIKELY(FLAG_wasm_tier_up_filter >= 0 &&
......@@ -1930,9 +1929,7 @@ std::shared_ptr<NativeModule> CompileToNativeModule(
// Create a new {NativeModule} first.
const bool include_liftoff = module->origin == kWasmOrigin && FLAG_liftoff;
DynamicTiering dynamic_tiering = isolate->IsWasmDynamicTieringEnabled()
? DynamicTiering::kEnabled
: DynamicTiering::kDisabled;
DynamicTiering dynamic_tiering{isolate->IsWasmDynamicTieringEnabled()};
size_t code_size_estimate =
wasm::WasmCodeManager::EstimateNativeModuleCodeSize(
module.get(), include_liftoff, dynamic_tiering);
......@@ -2006,9 +2003,7 @@ AsyncCompileJob::AsyncCompileJob(
: isolate_(isolate),
api_method_name_(api_method_name),
enabled_features_(enabled),
dynamic_tiering_(isolate_->IsWasmDynamicTieringEnabled()
? DynamicTiering::kEnabled
: DynamicTiering::kDisabled),
dynamic_tiering_(DynamicTiering{isolate_->IsWasmDynamicTieringEnabled()}),
wasm_lazy_compilation_(FLAG_wasm_lazy_compilation),
start_time_(base::TimeTicks::Now()),
bytes_copy_(std::move(bytes_copy)),
......@@ -3610,16 +3605,14 @@ void CompilationStateImpl::TriggerCallbacks(
triggered_events.Add(CompilationEvent::kFinishedExportWrappers);
if (outstanding_baseline_units_ == 0) {
triggered_events.Add(CompilationEvent::kFinishedBaselineCompilation);
if (dynamic_tiering_ == DynamicTiering::kDisabled &&
outstanding_top_tier_functions_ == 0) {
if (!dynamic_tiering_ && outstanding_top_tier_functions_ == 0) {
triggered_events.Add(CompilationEvent::kFinishedTopTierCompilation);
}
}
}
if (dynamic_tiering_ == DynamicTiering::kEnabled &&
static_cast<size_t>(FLAG_wasm_caching_threshold) <
bytes_since_last_chunk_) {
if (dynamic_tiering_ && static_cast<size_t>(FLAG_wasm_caching_threshold) <
bytes_since_last_chunk_) {
triggered_events.Add(CompilationEvent::kFinishedCompilationChunk);
bytes_since_last_chunk_ = 0;
}
......
......@@ -2110,7 +2110,7 @@ size_t WasmCodeManager::EstimateNativeModuleCodeSize(
// 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
// by TurboFan.
if (include_liftoff && dynamic_tiering == DynamicTiering::kEnabled) {
if (include_liftoff && dynamic_tiering) {
size_of_turbofan /= 4;
}
......@@ -2233,11 +2233,10 @@ std::shared_ptr<NativeModule> WasmCodeManager::NewNativeModule(
size_t size = code_space.size();
Address end = code_space.end();
std::shared_ptr<NativeModule> ret;
DynamicTiering dynamic_tiering = isolate->IsWasmDynamicTieringEnabled()
? DynamicTiering::kEnabled
: DynamicTiering::kDisabled;
new NativeModule(enabled, dynamic_tiering, std::move(code_space),
std::move(module), isolate->async_counters(), &ret);
new NativeModule(enabled,
DynamicTiering{isolate->IsWasmDynamicTieringEnabled()},
std::move(code_space), std::move(module),
isolate->async_counters(), &ret);
// The constructor initialized the shared_ptr.
DCHECK_NOT_NULL(ret);
TRACE_HEAP("New NativeModule %p: Mem: 0x%" PRIxPTR ",+%zu\n", ret.get(),
......
......@@ -2240,7 +2240,7 @@ Handle<AsmWasmData> AsmWasmData::New(
const bool kUsesLiftoff = false;
size_t memory_estimate =
wasm::WasmCodeManager::EstimateNativeModuleCodeSize(
module, kUsesLiftoff, wasm::DynamicTiering::kDisabled) +
module, kUsesLiftoff, wasm::kNoDynamicTiering) +
wasm::WasmCodeManager::EstimateNativeModuleMetaDataSize(module);
Handle<Managed<wasm::NativeModule>> managed_native_module =
Managed<wasm::NativeModule>::FromSharedPtr(isolate, memory_estimate,
......
......@@ -868,13 +868,11 @@ MaybeHandle<WasmModuleObject> DeserializeNativeModule(
auto shared_native_module = wasm_engine->MaybeGetNativeModule(
module->origin, owned_wire_bytes.as_vector(), isolate);
if (shared_native_module == nullptr) {
DynamicTiering dynamic_tiering = isolate->IsWasmDynamicTieringEnabled()
? DynamicTiering::kEnabled
: DynamicTiering::kDisabled;
const bool kIncludeLiftoff = dynamic_tiering == DynamicTiering::kDisabled;
bool dynamic_tiering = isolate->IsWasmDynamicTieringEnabled();
const bool include_liftoff = !dynamic_tiering;
size_t code_size_estimate =
wasm::WasmCodeManager::EstimateNativeModuleCodeSize(
module.get(), kIncludeLiftoff, dynamic_tiering);
module.get(), include_liftoff, DynamicTiering{dynamic_tiering});
shared_native_module = wasm_engine->NewNativeModule(
isolate, enabled_features, std::move(module), code_size_estimate);
// We have to assign a compilation ID here, as it is required for a
......
......@@ -343,8 +343,7 @@ uint32_t TestingModuleBuilder::AddPassiveElementSegment(
CompilationEnv TestingModuleBuilder::CreateCompilationEnv() {
return {test_module_.get(), native_module_->bounds_checks(),
runtime_exception_support_, enabled_features_,
DynamicTiering::kDisabled};
runtime_exception_support_, enabled_features_, kNoDynamicTiering};
}
const WasmGlobal* TestingModuleBuilder::AddGlobal(ValueType type) {
......@@ -360,12 +359,10 @@ const WasmGlobal* TestingModuleBuilder::AddGlobal(ValueType type) {
Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() {
const bool kUsesLiftoff = true;
DynamicTiering dynamic_tiering = FLAG_wasm_dynamic_tiering
? DynamicTiering::kEnabled
: DynamicTiering::kDisabled;
size_t code_size_estimate =
wasm::WasmCodeManager::EstimateNativeModuleCodeSize(
test_module_.get(), kUsesLiftoff, dynamic_tiering);
test_module_.get(), kUsesLiftoff,
DynamicTiering{FLAG_wasm_dynamic_tiering});
auto native_module = GetWasmEngine()->NewNativeModule(
isolate_, enabled_features_, test_module_, code_size_estimate);
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