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

[d8] Use v8_flags for accessing flag values

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

R=marja@chromium.org

Bug: v8:12887
Change-Id: Ie0106ceb521a775c7660d369cdb15763e9264149
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3898932Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83224}
parent 604db85e
......@@ -73,7 +73,7 @@ void D8Console::Debug(const debug::ConsoleCallArguments& args,
void D8Console::Time(const debug::ConsoleCallArguments& args,
const v8::debug::ConsoleContext&) {
if (internal::FLAG_correctness_fuzzer_suppressions) return;
if (i::v8_flags.correctness_fuzzer_suppressions) return;
if (args.Length() == 0) {
default_timer_ = base::TimeTicks::Now();
} else {
......@@ -95,7 +95,7 @@ void D8Console::Time(const debug::ConsoleCallArguments& args,
void D8Console::TimeEnd(const debug::ConsoleCallArguments& args,
const v8::debug::ConsoleContext&) {
if (internal::FLAG_correctness_fuzzer_suppressions) return;
if (i::v8_flags.correctness_fuzzer_suppressions) return;
base::TimeDelta delta;
if (args.Length() == 0) {
delta = base::TimeTicks::Now() - default_timer_;
......@@ -119,7 +119,7 @@ void D8Console::TimeEnd(const debug::ConsoleCallArguments& args,
void D8Console::TimeStamp(const debug::ConsoleCallArguments& args,
const v8::debug::ConsoleContext&) {
if (internal::FLAG_correctness_fuzzer_suppressions) return;
if (i::v8_flags.correctness_fuzzer_suppressions) return;
base::TimeDelta delta = base::TimeTicks::Now() - default_timer_;
if (args.Length() == 0) {
printf("console.timeStamp: default, %f\n", delta.InMillisecondsF());
......@@ -136,7 +136,7 @@ void D8Console::TimeStamp(const debug::ConsoleCallArguments& args,
void D8Console::Trace(const debug::ConsoleCallArguments& args,
const v8::debug::ConsoleContext&) {
if (internal::FLAG_correctness_fuzzer_suppressions) return;
if (i::v8_flags.correctness_fuzzer_suppressions) return;
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate_);
i_isolate->PrintStack(stderr, i::Isolate::kPrintStackConcise);
}
......
......@@ -786,7 +786,7 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
ReportExceptions report_exceptions,
ProcessMessageQueue process_message_queue) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
if (i::FLAG_parse_only) {
if (i::v8_flags.parse_only) {
i::VMState<PARSER> state(i_isolate);
i::Handle<i::String> str = Utils::OpenHandle(*(source));
......@@ -796,8 +796,8 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
i::UnoptimizedCompileFlags flags =
i::UnoptimizedCompileFlags::ForToplevelCompile(
i_isolate, true, i::construct_language_mode(i::FLAG_use_strict),
i::REPLMode::kNo, ScriptType::kClassic, i::FLAG_lazy);
i_isolate, true, i::construct_language_mode(i::v8_flags.use_strict),
i::REPLMode::kNo, ScriptType::kClassic, i::v8_flags.lazy);
if (options.compile_options == v8::ScriptCompiler::kEagerCompile) {
flags.set_is_eager(true);
......@@ -1573,7 +1573,7 @@ bool Shell::LoadJSON(Isolate* isolate, const char* file_name) {
PerIsolateData::PerIsolateData(Isolate* isolate)
: isolate_(isolate), realms_(nullptr) {
isolate->SetData(0, this);
if (i::FLAG_expose_async_hooks) {
if (i::v8_flags.expose_async_hooks) {
async_hooks_wrapper_ = new AsyncHooks(isolate);
}
ignore_unhandled_promises_ = false;
......@@ -1585,7 +1585,7 @@ PerIsolateData::PerIsolateData(Isolate* isolate)
PerIsolateData::~PerIsolateData() {
isolate_->SetData(0, nullptr); // Not really needed, just to be sure...
if (i::FLAG_expose_async_hooks) {
if (i::v8_flags.expose_async_hooks) {
delete async_hooks_wrapper_; // This uses the isolate
}
#if defined(LEAK_SANITIZER)
......@@ -1749,10 +1749,10 @@ int PerIsolateData::RealmIndexOrThrow(
}
// performance.now() returns a time stamp as double, measured in milliseconds.
// When FLAG_verify_predictable mode is enabled it returns result of
// When v8_flags.verify_predictable mode is enabled it returns result of
// v8::Platform::MonotonicallyIncreasingTime().
void Shell::PerformanceNow(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (i::FLAG_verify_predictable) {
if (i::v8_flags.verify_predictable) {
args.GetReturnValue().Set(g_platform->MonotonicallyIncreasingTime());
} else {
base::TimeDelta delta = base::TimeTicks::Now() - kInitialTicks;
......@@ -2308,7 +2308,7 @@ void Shell::DisableDebugger(const v8::FunctionCallbackInfo<v8::Value>& args) {
void Shell::SetPromiseHooks(const v8::FunctionCallbackInfo<v8::Value>& args) {
Isolate* isolate = args.GetIsolate();
if (i::FLAG_correctness_fuzzer_suppressions) {
if (i::v8_flags.correctness_fuzzer_suppressions) {
// Setting promise hoooks dynamically has unexpected timing side-effects
// with certain promise optimizations. We might not get all callbacks for
// previously scheduled Promises or optimized code-paths that skip Promise
......@@ -3177,7 +3177,7 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
global_template->Set(isolate, "Worker", Shell::CreateWorkerTemplate(isolate));
// Prevent fuzzers from creating side effects.
if (!i::FLAG_fuzzing) {
if (!i::v8_flags.fuzzing) {
global_template->Set(isolate, "os", Shell::CreateOSTemplate(isolate));
}
global_template->Set(isolate, "d8", Shell::CreateD8Template(isolate));
......@@ -3189,7 +3189,7 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
FunctionTemplate::New(isolate, Fuzzilli), PropertyAttribute::DontEnum);
#endif // V8_FUZZILLI
if (i::FLAG_expose_async_hooks) {
if (i::v8_flags.expose_async_hooks) {
global_template->Set(isolate, "async_hooks",
Shell::CreateAsyncHookTemplate(isolate));
}
......@@ -3357,7 +3357,7 @@ Local<ObjectTemplate> Shell::CreateD8Template(Isolate* isolate) {
Local<ObjectTemplate> test_template = ObjectTemplate::New(isolate);
// For different runs of correctness fuzzing the bytecode of a function
// might get flushed, resulting in spurious errors.
if (!i::FLAG_correctness_fuzzer_suppressions) {
if (!i::v8_flags.correctness_fuzzer_suppressions) {
test_template->Set(
isolate, "verifySourcePositions",
FunctionTemplate::New(isolate, TestVerifySourcePositions));
......@@ -3365,8 +3365,8 @@ Local<ObjectTemplate> Shell::CreateD8Template(Isolate* isolate) {
// Correctness fuzzing will attempt to compare results of tests with and
// without turbo_fast_api_calls, so we don't expose the fast_c_api
// constructor when --correctness_fuzzer_suppressions is on.
if (options.expose_fast_api && i::FLAG_turbo_fast_api_calls &&
!i::FLAG_correctness_fuzzer_suppressions) {
if (options.expose_fast_api && i::v8_flags.turbo_fast_api_calls &&
!i::v8_flags.correctness_fuzzer_suppressions) {
test_template->Set(isolate, "FastCAPI",
Shell::CreateTestFastCApiTemplate(isolate));
test_template->Set(isolate, "LeafInterfaceType",
......@@ -3496,8 +3496,8 @@ void Shell::Initialize(Isolate* isolate, D8Console* console,
isolate->SetPromiseRejectCallback(PromiseRejectCallback);
if (isOnMainThread) {
// Set up counters
if (i::FLAG_map_counters[0] != '\0') {
MapCounters(isolate, i::FLAG_map_counters);
if (i::v8_flags.map_counters[0] != '\0') {
MapCounters(isolate, i::v8_flags.map_counters);
}
// Disable default message reporting.
isolate->AddMessageListenerWithErrorLevel(
......@@ -3559,7 +3559,8 @@ Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) {
Local<Context> context = Context::New(isolate, nullptr, global_template);
DCHECK_IMPLIES(context.IsEmpty(), isolate->IsExecutionTerminating());
if (context.IsEmpty()) return {};
if (i::FLAG_perf_prof_annotate_wasm || i::FLAG_vtune_prof_annotate_wasm) {
if (i::v8_flags.perf_prof_annotate_wasm ||
i::v8_flags.vtune_prof_annotate_wasm) {
isolate->SetWasmLoadSourceMapCallback(Shell::WasmLoadSourceMapCallback);
}
InitializeModuleEmbedderData(context);
......@@ -3600,7 +3601,7 @@ void Shell::WriteIgnitionDispatchCountersFile(v8::Isolate* isolate) {
->interpreter()
->GetDispatchCountersObject();
std::ofstream dispatch_counters_stream(
i::FLAG_trace_ignition_dispatches_output_file);
i::v8_flags.trace_ignition_dispatches_output_file);
dispatch_counters_stream << *String::Utf8Value(
isolate, JSON::Stringify(context, Utils::ToLocal(dispatch_counters))
.ToLocalChecked());
......@@ -3777,7 +3778,7 @@ void Dummy(char* arg) {}
V8_NOINLINE void FuzzerMonitor::SimulateErrors() {
// Initialize a fresh RNG to not interfere with JS execution.
std::unique_ptr<base::RandomNumberGenerator> rng;
int64_t seed = internal::FLAG_random_seed;
int64_t seed = i::v8_flags.random_seed;
if (seed != 0) {
rng = std::make_unique<base::RandomNumberGenerator>(seed);
} else {
......@@ -3944,7 +3945,7 @@ MaybeLocal<String> Shell::ReadFile(Isolate* isolate, const char* name,
int size = static_cast<int>(file->size());
char* chars = static_cast<char*>(file->memory());
if (i::FLAG_use_external_strings && i::String::IsAscii(chars, size)) {
if (i::v8_flags.use_external_strings && i::String::IsAscii(chars, size)) {
String::ExternalOneByteStringResource* resource =
new ExternalOwningOneByteStringResource(std::move(file));
return String::NewExternalOneByte(isolate, resource);
......@@ -4721,11 +4722,11 @@ bool Shell::SetOptions(int argc, char* argv[]) {
options.no_fail = true;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--dump-counters") == 0) {
i::FLAG_slow_histograms = true;
i::v8_flags.slow_histograms = true;
options.dump_counters = true;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--dump-counters-nvp") == 0) {
i::FLAG_slow_histograms = true;
i::v8_flags.slow_histograms = true;
options.dump_counters_nvp = true;
argv[i] = nullptr;
} else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) {
......@@ -4846,7 +4847,7 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strcmp(argv[i], "--enable-etw-stack-walking") == 0) {
options.enable_etw_stack_walking = true;
// This needs to be manually triggered for JIT ETW events to work.
i::FLAG_enable_etw_stack_walking = true;
i::v8_flags.enable_etw_stack_walking = true;
#if defined(V8_ENABLE_SYSTEM_INSTRUMENTATION)
} else if (strcmp(argv[i], "--enable-system-instrumentation") == 0) {
options.enable_system_instrumentation = true;
......@@ -4855,7 +4856,7 @@ bool Shell::SetOptions(int argc, char* argv[]) {
#if defined(V8_OS_WIN)
// Guard this bc the flag has a lot of overhead and is not currently used
// by macos
i::FLAG_interpreted_frames_native_stack = true;
i::v8_flags.interpreted_frames_native_stack = true;
#endif
argv[i] = nullptr;
#endif
......@@ -4905,17 +4906,17 @@ bool Shell::SetOptions(int argc, char* argv[]) {
" --module execute a file as a JavaScript module\n"
" --web-snapshot execute a file as a web snapshot\n\n";
using HelpOptions = i::FlagList::HelpOptions;
i::FLAG_abort_on_contradictory_flags = true;
i::v8_flags.abort_on_contradictory_flags = true;
i::FlagList::SetFlagsFromCommandLine(&argc, argv, true,
HelpOptions(HelpOptions::kExit, usage));
options.mock_arraybuffer_allocator = i::FLAG_mock_arraybuffer_allocator;
options.mock_arraybuffer_allocator = i::v8_flags.mock_arraybuffer_allocator;
options.mock_arraybuffer_allocator_limit =
i::FLAG_mock_arraybuffer_allocator_limit;
i::v8_flags.mock_arraybuffer_allocator_limit;
#if MULTI_MAPPED_ALLOCATOR_AVAILABLE
options.multi_mapped_mock_allocator = i::FLAG_multi_mapped_mock_allocator;
options.multi_mapped_mock_allocator = i::v8_flags.multi_mapped_mock_allocator;
#endif
if (i::FLAG_stress_snapshot && options.expose_fast_api &&
if (i::v8_flags.stress_snapshot && options.expose_fast_api &&
check_d8_flag_contradictions) {
FATAL("Flag --expose-fast-api is incompatible with --stress-snapshot.");
}
......@@ -4935,7 +4936,7 @@ bool Shell::SetOptions(int argc, char* argv[]) {
strcmp(str, "--json") == 0) {
// Pass on to SourceGroup, which understands these options.
} else if (strncmp(str, "--", 2) == 0) {
if (!i::FLAG_correctness_fuzzer_suppressions) {
if (!i::v8_flags.correctness_fuzzer_suppressions) {
printf("Warning: unknown flag %s.\nTry --help for options\n", str);
}
} else if (strcmp(str, "-e") == 0 && i + 1 < argc) {
......@@ -4980,7 +4981,7 @@ int Shell::RunMain(Isolate* isolate, bool last_run) {
if (!CompleteMessageLoop(isolate)) success = false;
}
WriteLcovData(isolate, options.lcov_file);
if (last_run && i::FLAG_stress_snapshot) {
if (last_run && i::v8_flags.stress_snapshot) {
static constexpr bool kClearRecompilableData = true;
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::Handle<i::Context> i_context = Utils::OpenHandle(*context);
......@@ -5089,7 +5090,7 @@ bool ProcessMessages(
// task queue of the {kProcessGlobalPredictablePlatformWorkerTaskQueue}
// isolate. We execute all background tasks after running one foreground
// task.
if (i::FLAG_verify_predictable) {
if (i::v8_flags.verify_predictable) {
while (v8::platform::PumpMessageLoop(
g_default_platform,
kProcessGlobalPredictablePlatformWorkerTaskQueue,
......@@ -5120,7 +5121,7 @@ bool Shell::CompleteMessageLoop(Isolate* isolate) {
return should_wait ? platform::MessageLoopBehavior::kWaitForWork
: platform::MessageLoopBehavior::kDoNotWait;
};
if (i::FLAG_verify_predictable) {
if (i::v8_flags.verify_predictable) {
bool ran_tasks = ProcessMessages(
isolate, [] { return platform::MessageLoopBehavior::kDoNotWait; });
if (get_waiting_behaviour() ==
......@@ -5392,7 +5393,7 @@ class D8Testing {
* stress coverage.
*/
static int GetStressRuns() {
if (internal::FLAG_stress_runs != 0) return internal::FLAG_stress_runs;
if (i::v8_flags.stress_runs != 0) return i::v8_flags.stress_runs;
#ifdef DEBUG
// In debug mode the code runs much slower so stressing will only make two
// runs.
......@@ -5480,7 +5481,7 @@ void d8_sigterm_handler(int signal, siginfo_t* info, void* context) {
void d8_install_sigterm_handler() {
#ifdef V8_OS_POSIX
CHECK(!i::FLAG_fuzzing);
CHECK(!i::v8_flags.fuzzing);
struct sigaction sa;
sa.sa_sigaction = d8_sigterm_handler;
sigemptyset(&sa.sa_mask);
......@@ -5496,7 +5497,7 @@ void d8_install_sigterm_handler() {
int Shell::Main(int argc, char* argv[]) {
v8::base::EnsureConsoleOutput();
if (!SetOptions(argc, argv)) return 1;
if (!i::FLAG_fuzzing) d8_install_sigterm_handler();
if (!i::v8_flags.fuzzing) d8_install_sigterm_handler();
v8::V8::InitializeICUDefaultLocation(argv[0], options.icu_data_file);
......@@ -5515,7 +5516,7 @@ int Shell::Main(int argc, char* argv[]) {
std::ofstream trace_file;
std::unique_ptr<platform::tracing::TracingController> tracing;
if (options.trace_enabled && !i::FLAG_verify_predictable) {
if (options.trace_enabled && !i::v8_flags.verify_predictable) {
tracing = std::make_unique<platform::tracing::TracingController>();
if (!options.enable_etw_stack_walking) {
......@@ -5564,29 +5565,29 @@ int Shell::Main(int argc, char* argv[]) {
options.thread_pool_size, v8::platform::IdleTaskSupport::kEnabled,
in_process_stack_dumping, std::move(tracing));
g_default_platform = g_platform.get();
if (i::FLAG_predictable) {
if (i::v8_flags.predictable) {
g_platform = MakePredictablePlatform(std::move(g_platform));
}
if (options.stress_delay_tasks) {
int64_t random_seed = i::FLAG_fuzzer_random_seed;
if (!random_seed) random_seed = i::FLAG_random_seed;
int64_t random_seed = i::v8_flags.fuzzer_random_seed;
if (!random_seed) random_seed = i::v8_flags.random_seed;
// If random_seed is still 0 here, the {DelayedTasksPlatform} will choose a
// random seed.
g_platform = MakeDelayedTasksPlatform(std::move(g_platform), random_seed);
}
if (i::FLAG_trace_turbo_cfg_file == nullptr) {
if (i::v8_flags.trace_turbo_cfg_file == nullptr) {
V8::SetFlagsFromString("--trace-turbo-cfg-file=turbo.cfg");
}
if (i::FLAG_redirect_code_traces_to == nullptr) {
if (i::v8_flags.redirect_code_traces_to == nullptr) {
V8::SetFlagsFromString("--redirect-code-traces-to=code.asm");
}
v8::V8::InitializePlatform(g_platform.get());
// Disable flag freezing if we are producing a code cache, because for that we
// modify FLAG_hash_seed (below).
// modify v8_flags.hash_seed (below).
if (options.code_cache_options != ShellOptions::kNoProduceCache) {
i::FLAG_freeze_flags_after_init = false;
i::v8_flags.freeze_flags_after_init = false;
}
v8::V8::Initialize();
......@@ -5623,7 +5624,7 @@ int Shell::Main(int argc, char* argv[]) {
}
create_params.array_buffer_allocator = Shell::array_buffer_allocator;
#ifdef ENABLE_VTUNE_JIT_INTERFACE
if (i::FLAG_enable_vtunejit) {
if (i::v8_flags.enable_vtunejit) {
create_params.code_event_handler = vTune::GetVtuneCodeEventHandler();
}
#endif
......@@ -5705,8 +5706,8 @@ int Shell::Main(int argc, char* argv[]) {
CpuProfilingOptions{});
}
if (i::FLAG_stress_runs > 0) {
options.stress_runs = i::FLAG_stress_runs;
if (i::v8_flags.stress_runs > 0) {
options.stress_runs = i::v8_flags.stress_runs;
for (int i = 0; i < options.stress_runs && result == 0; i++) {
printf("============ Run %d/%d ============\n", i + 1,
options.stress_runs.get());
......@@ -5725,10 +5726,10 @@ int Shell::Main(int argc, char* argv[]) {
Isolate::CreateParams create_params2;
create_params2.array_buffer_allocator = Shell::array_buffer_allocator;
// Use a different hash seed.
i::FLAG_hash_seed = i::FLAG_hash_seed ^ 1337;
i::v8_flags.hash_seed = i::v8_flags.hash_seed ^ 1337;
Isolate* isolate2 = Isolate::New(create_params2);
// Restore old hash seed.
i::FLAG_hash_seed = i::FLAG_hash_seed ^ 1337;
i::v8_flags.hash_seed = i::v8_flags.hash_seed ^ 1337;
{
D8Console console2(isolate2);
Initialize(isolate2, &console2);
......@@ -5764,7 +5765,7 @@ int Shell::Main(int argc, char* argv[]) {
RunShell(isolate);
}
if (i::FLAG_trace_ignition_dispatches_output_file != nullptr) {
if (i::v8_flags.trace_ignition_dispatches_output_file != nullptr) {
WriteIgnitionDispatchCountersFile(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