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

[init] Use v8_flags for accessing flag values

Avoid the deprecated FLAG_* syntax, access flag values via the
{v8_flags} struct instead.

R=jkummerow@chromium.org

Bug: v8:12887
Change-Id: I5bd5faaac89185c5f40b0eabb01f9b678f791498
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3898934
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83225}
parent 23d1a10d
......@@ -134,13 +134,13 @@ void Bootstrapper::Initialize(bool create_heap_objects) {
static const char* GCFunctionName() {
bool flag_given =
FLAG_expose_gc_as != nullptr && strlen(FLAG_expose_gc_as) != 0;
return flag_given ? FLAG_expose_gc_as : "gc";
v8_flags.expose_gc_as != nullptr && strlen(v8_flags.expose_gc_as) != 0;
return flag_given ? v8_flags.expose_gc_as : "gc";
}
static bool isValidCpuTraceMarkFunctionName() {
return FLAG_expose_cputracemark_as != nullptr &&
strlen(FLAG_expose_cputracemark_as) != 0;
return v8_flags.expose_cputracemark_as != nullptr &&
strlen(v8_flags.expose_cputracemark_as) != 0;
}
void Bootstrapper::InitializeOncePerProcess() {
......@@ -150,8 +150,8 @@ void Bootstrapper::InitializeOncePerProcess() {
v8::RegisterExtension(std::make_unique<TriggerFailureExtension>());
v8::RegisterExtension(std::make_unique<IgnitionStatisticsExtension>());
if (isValidCpuTraceMarkFunctionName()) {
v8::RegisterExtension(
std::make_unique<CpuTraceMarkExtension>(FLAG_expose_cputracemark_as));
v8::RegisterExtension(std::make_unique<CpuTraceMarkExtension>(
v8_flags.expose_cputracemark_as));
}
#ifdef ENABLE_VTUNE_TRACEMARK
v8::RegisterExtension(
......@@ -360,7 +360,7 @@ Handle<JSGlobalProxy> Bootstrapper::NewRemoteContext(
}
void Bootstrapper::LogAllMaps() {
if (!FLAG_log_maps || isolate_->initialized_from_snapshot()) return;
if (!v8_flags.log_maps || isolate_->initialized_from_snapshot()) return;
// Log all created Map objects that are on the heap. For snapshots the Map
// logging happens during deserialization in order to avoid printing Maps
// multiple times during partial deserialization.
......@@ -3921,7 +3921,7 @@ void Genesis::InitializeGlobal(Handle<JSGlobalObject> global_object,
// The cleanupSome function is created but not exposed, as it is used
// internally by InvokeFinalizationRegistryCleanupFromTask.
//
// It is exposed by FLAG_harmony_weak_refs_with_cleanup_some.
// It is exposed by v8_flags.harmony_weak_refs_with_cleanup_some.
Handle<JSFunction> cleanup_some_fun = SimpleCreateFunction(
isolate_, factory->InternalizeUtf8String("cleanupSome"),
Builtin::kFinalizationRegistryPrototypeCleanupSome, 0, false);
......@@ -4514,7 +4514,7 @@ EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE(harmony_intl_best_fit_matcher)
#undef EMPTY_INITIALIZE_GLOBAL_FOR_FEATURE
void Genesis::InitializeGlobal_harmony_change_array_by_copy() {
if (!FLAG_harmony_change_array_by_copy) return;
if (!v8_flags.harmony_change_array_by_copy) return;
{
Handle<JSFunction> array_function(native_context()->array_function(),
......@@ -4552,7 +4552,7 @@ void Genesis::InitializeGlobal_harmony_change_array_by_copy() {
}
void Genesis::InitializeGlobal_harmony_regexp_unicode_sets() {
if (!FLAG_harmony_regexp_unicode_sets) return;
if (!v8_flags.harmony_regexp_unicode_sets) return;
Handle<JSFunction> regexp_fun(native_context()->regexp_function(), isolate());
Handle<JSObject> regexp_prototype(
......@@ -4566,7 +4566,7 @@ void Genesis::InitializeGlobal_harmony_regexp_unicode_sets() {
}
void Genesis::InitializeGlobal_harmony_shadow_realm() {
if (!FLAG_harmony_shadow_realm) return;
if (!v8_flags.harmony_shadow_realm) return;
Factory* factory = isolate()->factory();
// -- S h a d o w R e a l m
// #sec-shadowrealm-objects
......@@ -4638,7 +4638,7 @@ void Genesis::InitializeGlobal_harmony_shadow_realm() {
}
void Genesis::InitializeGlobal_harmony_struct() {
if (!FLAG_harmony_struct) return;
if (!v8_flags.harmony_struct) return;
Handle<JSGlobalObject> global(native_context()->global_object(), isolate());
Handle<String> name =
......@@ -4728,7 +4728,7 @@ void Genesis::InitializeGlobal_harmony_struct() {
}
void Genesis::InitializeGlobal_harmony_array_find_last() {
if (!FLAG_harmony_array_find_last) return;
if (!v8_flags.harmony_array_find_last) return;
{
Handle<JSFunction> array_function(native_context()->array_function(),
......@@ -4761,7 +4761,7 @@ void Genesis::InitializeGlobal_harmony_array_find_last() {
}
void Genesis::InitializeGlobal_harmony_array_grouping() {
if (!FLAG_harmony_array_grouping) return;
if (!v8_flags.harmony_array_grouping) return;
Handle<JSFunction> array_function(native_context()->array_function(),
isolate());
......@@ -4783,8 +4783,8 @@ void Genesis::InitializeGlobal_harmony_array_grouping() {
}
void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
if (!FLAG_harmony_sharedarraybuffer ||
FLAG_enable_sharedarraybuffer_per_context) {
if (!v8_flags.harmony_sharedarraybuffer ||
v8_flags.enable_sharedarraybuffer_per_context) {
return;
}
......@@ -4795,7 +4795,7 @@ void Genesis::InitializeGlobal_harmony_sharedarraybuffer() {
}
void Genesis::InitializeGlobal_harmony_atomics() {
if (!FLAG_harmony_atomics) return;
if (!v8_flags.harmony_atomics) return;
Handle<JSGlobalObject> global(native_context()->global_object(), isolate());
......@@ -4805,7 +4805,7 @@ void Genesis::InitializeGlobal_harmony_atomics() {
}
void Genesis::InitializeGlobal_harmony_weak_refs_with_cleanup_some() {
if (!FLAG_harmony_weak_refs_with_cleanup_some) return;
if (!v8_flags.harmony_weak_refs_with_cleanup_some) return;
Handle<JSFunction> finalization_registry_fun =
isolate()->js_finalization_registry_fun();
......@@ -4820,7 +4820,7 @@ void Genesis::InitializeGlobal_harmony_weak_refs_with_cleanup_some() {
}
void Genesis::InitializeGlobal_regexp_linear_flag() {
if (!FLAG_enable_experimental_regexp_engine) return;
if (!v8_flags.enable_experimental_regexp_engine) return;
Handle<JSFunction> regexp_fun(native_context()->regexp_function(), isolate());
Handle<JSObject> regexp_prototype(
......@@ -4834,7 +4834,7 @@ void Genesis::InitializeGlobal_regexp_linear_flag() {
}
void Genesis::InitializeGlobal_harmony_rab_gsab() {
if (!FLAG_harmony_rab_gsab) return;
if (!v8_flags.harmony_rab_gsab) return;
Handle<JSObject> array_buffer_prototype(
JSObject::cast(native_context()->array_buffer_fun().instance_prototype()),
isolate());
......@@ -4865,7 +4865,7 @@ void Genesis::InitializeGlobal_harmony_rab_gsab() {
}
void Genesis::InitializeGlobal_harmony_temporal() {
if (!FLAG_harmony_temporal) return;
if (!v8_flags.harmony_temporal) return;
// -- T e m p o r a l
// #sec-temporal-objects
Handle<JSObject> temporal =
......@@ -5508,7 +5508,7 @@ void Genesis::InitializeGlobal_harmony_temporal() {
#ifdef V8_INTL_SUPPORT
void Genesis::InitializeGlobal_harmony_intl_number_format_v3() {
if (!FLAG_harmony_intl_number_format_v3) return;
if (!v8_flags.harmony_intl_number_format_v3) return;
{
Handle<JSFunction> number_format_constructor =
......@@ -5538,7 +5538,7 @@ void Genesis::InitializeGlobal_harmony_intl_number_format_v3() {
#endif // V8_INTL_SUPPORT
void Genesis::InitializeGlobal_experimental_web_snapshots() {
if (!FLAG_experimental_web_snapshots) return;
if (!v8_flags.experimental_web_snapshots) return;
Handle<JSGlobalObject> global(native_context()->global_object(), isolate());
Handle<JSObject> web_snapshot_object =
......@@ -6000,15 +6000,16 @@ bool Genesis::InstallSpecialObjects(Isolate* isolate,
Handle<JSObject> Error = isolate->error_function();
Handle<String> name = isolate->factory()->stackTraceLimit_string();
Handle<Smi> stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), isolate);
Handle<Smi> stack_trace_limit(Smi::FromInt(v8_flags.stack_trace_limit),
isolate);
JSObject::AddProperty(isolate, Error, name, stack_trace_limit, NONE);
#if V8_ENABLE_WEBASSEMBLY
if (FLAG_expose_wasm) {
if (v8_flags.expose_wasm) {
// Install the internal data structures into the isolate and expose on
// the global object.
WasmJs::Install(isolate, true);
} else if (FLAG_validate_asm) {
} else if (v8_flags.validate_asm) {
// Install the internal data structures only; these are needed for asm.js
// translated to Wasm to work correctly.
WasmJs::Install(isolate, false);
......@@ -6051,21 +6052,22 @@ bool Genesis::InstallExtensions(Isolate* isolate,
v8::ExtensionConfiguration* extensions) {
ExtensionStates extension_states; // All extensions have state UNVISITED.
return InstallAutoExtensions(isolate, &extension_states) &&
(!FLAG_expose_gc ||
(!v8_flags.expose_gc ||
InstallExtension(isolate, "v8/gc", &extension_states)) &&
(!FLAG_expose_externalize_string ||
(!v8_flags.expose_externalize_string ||
InstallExtension(isolate, "v8/externalize", &extension_states)) &&
(!(FLAG_expose_statistics || TracingFlags::is_gc_stats_enabled()) ||
(!(v8_flags.expose_statistics ||
TracingFlags::is_gc_stats_enabled()) ||
InstallExtension(isolate, "v8/statistics", &extension_states)) &&
(!FLAG_expose_trigger_failure ||
(!v8_flags.expose_trigger_failure ||
InstallExtension(isolate, "v8/trigger-failure", &extension_states)) &&
(!FLAG_expose_ignition_statistics ||
(!v8_flags.expose_ignition_statistics ||
InstallExtension(isolate, "v8/ignition-statistics",
&extension_states)) &&
(!isValidCpuTraceMarkFunctionName() ||
InstallExtension(isolate, "v8/cpumark", &extension_states)) &&
#ifdef ENABLE_VTUNE_TRACEMARK
(!FLAG_enable_vtune_domain_support ||
(!v8_flags.enable_vtune_domain_support ||
InstallExtension(isolate, "v8/vtunedomain", &extension_states)) &&
#endif // ENABLE_VTUNE_TRACEMARK
InstallRequestedExtensions(isolate, extensions, &extension_states);
......@@ -6465,7 +6467,7 @@ Genesis::Genesis(
DCHECK(native_context().is_null());
base::ElapsedTimer timer;
if (FLAG_profile_deserialization) timer.Start();
if (v8_flags.profile_deserialization) timer.Start();
DCHECK_EQ(0u, context_snapshot_index);
// We get here if there was no context snapshot.
CreateRoots();
......@@ -6488,7 +6490,7 @@ Genesis::Genesis(
if (!InstallExtrasBindings()) return;
if (!ConfigureGlobalObject(global_proxy_template)) return;
if (FLAG_profile_deserialization) {
if (v8_flags.profile_deserialization) {
double ms = timer.Elapsed().InMillisecondsF();
PrintF("[Initializing context from scratch took %0.3f ms]\n", ms);
}
......@@ -6515,7 +6517,7 @@ Genesis::Genesis(
string_function_prototype.map());
}
if (FLAG_disallow_code_generation_from_strings) {
if (v8_flags.disallow_code_generation_from_strings) {
native_context()->set_allow_code_gen_from_strings(
ReadOnlyRoots(isolate).false_value());
}
......
......@@ -99,7 +99,7 @@ void V8::InitializePlatform(v8::Platform* platform) {
v8::base::SetPrintStackTrace(platform_->GetStackTracePrinter());
v8::tracing::TracingCategoryObserver::SetUp();
#if defined(V8_OS_WIN) && defined(V8_ENABLE_ETW_STACK_WALKING)
if (FLAG_enable_etw_stack_walking) {
if (v8_flags.enable_etw_stack_walking) {
// TODO(sartang@microsoft.com): Move to platform specific diagnostics object
v8::internal::ETWJITInterface::Register();
}
......@@ -114,10 +114,10 @@ void V8::InitializePlatform(v8::Platform* platform) {
}
#define DISABLE_FLAG(flag) \
if (FLAG_##flag) { \
if (v8_flags.flag) { \
PrintF(stderr, \
"Warning: disabling flag --" #flag " due to conflicting flags\n"); \
FLAG_##flag = false; \
v8_flags.flag = false; \
}
void V8::Initialize() {
......@@ -125,52 +125,53 @@ void V8::Initialize() {
CHECK(platform_);
// Update logging information before enforcing flag implications.
FlagValue<bool>* log_all_flags[] = {&FLAG_log_all,
&FLAG_log_code,
&FLAG_log_code_disassemble,
&FLAG_log_source_code,
&FLAG_log_source_position,
&FLAG_log_feedback_vector,
FlagValue<bool>* log_all_flags[] = {&v8_flags.log_all,
&v8_flags.log_code,
&v8_flags.log_code_disassemble,
&v8_flags.log_source_code,
&v8_flags.log_source_position,
&v8_flags.log_feedback_vector,
&v8_flags.log_function_events,
&FLAG_log_internal_timer_events,
&FLAG_log_deopt,
&FLAG_log_ic,
&FLAG_log_maps};
if (FLAG_log_all) {
&v8_flags.log_internal_timer_events,
&v8_flags.log_deopt,
&v8_flags.log_ic,
&v8_flags.log_maps};
if (v8_flags.log_all) {
// Enable all logging flags
for (auto* flag : log_all_flags) {
*flag = true;
}
FLAG_log = true;
} else if (!FLAG_log) {
v8_flags.log = true;
} else if (!v8_flags.log) {
// Enable --log if any log flag is set.
for (const auto* flag : log_all_flags) {
if (!*flag) continue;
FLAG_log = true;
v8_flags.log = true;
break;
}
// Profiling flags depend on logging.
FLAG_log = FLAG_log || FLAG_perf_prof || FLAG_perf_basic_prof ||
FLAG_ll_prof || FLAG_prof || FLAG_prof_cpp || FLAG_gdbjit;
v8_flags.log = v8_flags.log || v8_flags.perf_prof ||
v8_flags.perf_basic_prof || v8_flags.ll_prof ||
v8_flags.prof || v8_flags.prof_cpp || v8_flags.gdbjit;
#if defined(V8_OS_WIN) && defined(V8_ENABLE_ETW_STACK_WALKING)
FLAG_log = FLAG_log || FLAG_enable_etw_stack_walking;
v8_flags.log = v8_flags.log || v8_flags.enable_etw_stack_walking;
#endif
}
FlagList::EnforceFlagImplications();
if (FLAG_predictable && FLAG_random_seed == 0) {
if (v8_flags.predictable && v8_flags.random_seed == 0) {
// Avoid random seeds in predictable mode.
FLAG_random_seed = 12347;
v8_flags.random_seed = 12347;
}
if (FLAG_stress_compaction) {
FLAG_force_marking_deque_overflows = true;
FLAG_gc_global = true;
FLAG_max_semi_space_size = 1;
if (v8_flags.stress_compaction) {
v8_flags.force_marking_deque_overflows = true;
v8_flags.gc_global = true;
v8_flags.max_semi_space_size = 1;
}
if (FLAG_trace_turbo) {
if (v8_flags.trace_turbo) {
// Create an empty file shared by the process (e.g. the wasm engine).
std::ofstream(Isolate::GetTurboCfgFileName(nullptr).c_str(),
std::ios_base::trunc);
......@@ -187,7 +188,7 @@ void V8::Initialize() {
// TODO(jgruber): Remove this once / if wasm can run without executable
// memory.
#if V8_ENABLE_WEBASSEMBLY
if (FLAG_jitless && !FLAG_correctness_fuzzer_suppressions) {
if (v8_flags.jitless && !v8_flags.correctness_fuzzer_suppressions) {
DISABLE_FLAG(expose_wasm);
}
#endif
......@@ -197,7 +198,7 @@ void V8::Initialize() {
// leads to false positives on TSAN bots.
// TODO(chromium:1205289): Teach relevant fuzzers to not pass TF tracing
// flags instead, and remove this section.
if (FLAG_fuzzing && FLAG_concurrent_recompilation) {
if (v8_flags.fuzzing && v8_flags.concurrent_recompilation) {
DISABLE_FLAG(trace_turbo);
DISABLE_FLAG(trace_turbo_graph);
DISABLE_FLAG(trace_turbo_scheduled);
......@@ -215,16 +216,16 @@ void V8::Initialize() {
// The --jitless and --interpreted-frames-native-stack flags are incompatible
// since the latter requires code generation while the former prohibits code
// generation.
CHECK(!FLAG_interpreted_frames_native_stack || !FLAG_jitless);
CHECK(!v8_flags.interpreted_frames_native_stack || !v8_flags.jitless);
base::OS::Initialize(FLAG_hard_abort, FLAG_gc_fake_mmap);
base::OS::Initialize(v8_flags.hard_abort, v8_flags.gc_fake_mmap);
if (FLAG_random_seed) {
GetPlatformPageAllocator()->SetRandomMmapSeed(FLAG_random_seed);
GetPlatformVirtualAddressSpace()->SetRandomSeed(FLAG_random_seed);
if (v8_flags.random_seed) {
GetPlatformPageAllocator()->SetRandomMmapSeed(v8_flags.random_seed);
GetPlatformVirtualAddressSpace()->SetRandomSeed(v8_flags.random_seed);
}
if (FLAG_print_flag_values) FlagList::PrintValues();
if (v8_flags.print_flag_values) FlagList::PrintValues();
// Initialize the default FlagList::Hash.
FlagList::Hash();
......@@ -232,7 +233,7 @@ void V8::Initialize() {
// Before initializing internals, freeze the flags such that further changes
// are not allowed. Global initialization of the Isolate or the WasmEngine
// already reads flags, so they should not be changed afterwards.
if (FLAG_freeze_flags_after_init) FlagList::FreezeFlags();
if (v8_flags.freeze_flags_after_init) FlagList::FreezeFlags();
#if defined(V8_ENABLE_SANDBOX)
// If enabled, the sandbox must be initialized first.
......@@ -291,7 +292,7 @@ void V8::DisposePlatform() {
AdvanceStartupState(V8StartupState::kPlatformDisposing);
CHECK(platform_);
#if defined(V8_OS_WIN) && defined(V8_ENABLE_ETW_STACK_WALKING)
if (FLAG_enable_etw_stack_walking) {
if (v8_flags.enable_etw_stack_walking) {
v8::internal::ETWJITInterface::Unregister();
}
#endif
......
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