Reland "[flags] Remove FLAG_* aliases"

This is a reland of commit e3096c31d6.
The one additional use of FLAG_turboshaft is also rewritten now.

Original change's description:
> [flags] Remove FLAG_* aliases
>
> This removes the deprecated FLAG_* aliases, and switches remaining uses
> to the new v8_flags syntax.
>
> R=jkummerow@chromium.org
>
> Bug: v8:12887
> Change-Id: Icde494a3819a9b1386c91e44f5d72a55666d9eae
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3952350
> Reviewed-by: Maya Lekova <mslekova@chromium.org>
> Reviewed-by: Marja Hölttä <marja@chromium.org>
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Commit-Queue: Clemens Backes <clemensb@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#83686}

Bug: v8:12887
Change-Id: I978df89f51e11c9a101ff3c1e385b1eced697a74
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3953292
Reviewed-by: Marja Hölttä <marja@chromium.org>
Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83717}
This commit is contained in:
Clemens Backes 2022-10-13 16:17:31 +02:00 committed by V8 LUCI CQ
parent 7472e195cb
commit 444e6e3482
28 changed files with 49 additions and 64 deletions

View File

@ -133,7 +133,7 @@ void Report(Handle<Script> script, int position, base::Vector<const char> text,
// Hook to report successful execution of {AsmJs::CompileAsmViaWasm} phase.
void ReportCompilationSuccess(Handle<Script> script, int position,
double compile_time, size_t module_size) {
if (FLAG_suppress_asm_messages || !FLAG_trace_asm_time) return;
if (v8_flags.suppress_asm_messages || !v8_flags.trace_asm_time) return;
base::EmbeddedVector<char, 100> text;
int length = SNPrintF(text, "success, compile time %0.3f ms, %zu bytes",
compile_time, module_size);
@ -146,7 +146,7 @@ void ReportCompilationSuccess(Handle<Script> script, int position,
// Hook to report failed execution of {AsmJs::CompileAsmViaWasm} phase.
void ReportCompilationFailure(ParseInfo* parse_info, int position,
const char* reason) {
if (FLAG_suppress_asm_messages) return;
if (v8_flags.suppress_asm_messages) return;
parse_info->pending_error_handler()->ReportWarningAt(
position, position, MessageTemplate::kAsmJsInvalid, reason);
}
@ -154,7 +154,7 @@ void ReportCompilationFailure(ParseInfo* parse_info, int position,
// Hook to report successful execution of {AsmJs::InstantiateAsmWasm} phase.
void ReportInstantiationSuccess(Handle<Script> script, int position,
double instantiate_time) {
if (FLAG_suppress_asm_messages || !FLAG_trace_asm_time) return;
if (v8_flags.suppress_asm_messages || !v8_flags.trace_asm_time) return;
base::EmbeddedVector<char, 50> text;
int length = SNPrintF(text, "success, %0.3f ms", instantiate_time);
CHECK_NE(-1, length);
@ -166,7 +166,7 @@ void ReportInstantiationSuccess(Handle<Script> script, int position,
// Hook to report failed execution of {AsmJs::InstantiateAsmWasm} phase.
void ReportInstantiationFailure(Handle<Script> script, int position,
const char* reason) {
if (FLAG_suppress_asm_messages) return;
if (v8_flags.suppress_asm_messages) return;
base::Vector<const char> text = base::CStrVector(reason);
Report(script, position, text, MessageTemplate::kAsmJsLinkingFailed,
v8::Isolate::kMessageWarning);
@ -237,7 +237,7 @@ UnoptimizedCompilationJob::Status AsmJsCompilationJob::ExecuteJobImpl() {
stream->Seek(compilation_info()->literal()->start_position());
wasm::AsmJsParser parser(&translate_zone, stack_limit(), stream);
if (!parser.Run()) {
if (!FLAG_suppress_asm_messages) {
if (!v8_flags.suppress_asm_messages) {
ReportCompilationFailure(parse_info(), parser.failure_location(),
parser.failure_message());
}

View File

@ -28,7 +28,7 @@ namespace wasm {
failed_ = true; \
failure_message_ = msg; \
failure_location_ = static_cast<int>(scanner_.Position()); \
if (FLAG_trace_asm_parser) { \
if (v8_flags.trace_asm_parser) { \
PrintF("[asm.js failure: %s, token: '%s', see: %s:%d]\n", msg, \
scanner_.Name(scanner_.Token()).c_str(), __FILE__, __LINE__); \
} \

View File

@ -67,7 +67,7 @@ void AsmJsScanner::Next() {
}
#if DEBUG
if (FLAG_trace_asm_scanner) {
if (v8_flags.trace_asm_scanner) {
if (Token() == kDouble) {
PrintF("%lf ", AsDouble());
} else if (Token() == kUnsigned) {

View File

@ -715,7 +715,7 @@ bool DeclarationScope::Analyze(ParseInfo* info) {
scope->GetScriptScope()->RewriteReplGlobalVariables();
#ifdef DEBUG
if (FLAG_print_scopes) {
if (v8_flags.print_scopes) {
PrintF("Global scope:\n");
scope->Print();
}
@ -1762,7 +1762,7 @@ void DeclarationScope::AnalyzePartially(Parser* parser,
}
#ifdef DEBUG
if (FLAG_print_scopes) {
if (v8_flags.print_scopes) {
PrintF("Inner function scope:\n");
Print();
}

View File

@ -3076,7 +3076,7 @@ void RestoreAfterBuiltinCall(MacroAssembler* masm, Register function_data,
void SwitchStackState(MacroAssembler* masm, Register jmpbuf,
wasm::JumpBuffer::StackState old_state,
wasm::JumpBuffer::StackState new_state) {
if (FLAG_debug_code) {
if (v8_flags.debug_code) {
__ cmpl(MemOperand(jmpbuf, wasm::kJmpBufStateOffset), Immediate(old_state));
Label ok;
__ j(equal, &ok, Label::kNear);

View File

@ -587,7 +587,7 @@ ExternalReference ExternalReference::address_of_log_or_trace_osr() {
ExternalReference
ExternalReference::address_of_FLAG_harmony_symbol_as_weakmap_key() {
return ExternalReference(&FLAG_harmony_symbol_as_weakmap_key);
return ExternalReference(&v8_flags.harmony_symbol_as_weakmap_key);
}
ExternalReference ExternalReference::address_of_builtin_subclassing_flag() {

View File

@ -15,7 +15,7 @@
#ifdef ENABLE_SLOW_DCHECKS
#define SLOW_DCHECK(condition) \
CHECK(!v8::internal::FLAG_enable_slow_asserts || (condition))
CHECK(!v8::internal::v8_flags.enable_slow_asserts || (condition))
#define SLOW_DCHECK_IMPLIES(lhs, rhs) SLOW_DCHECK(!(lhs) || (rhs))
#else
#define SLOW_DCHECK(condition) ((void)0)

View File

@ -16,13 +16,13 @@ namespace internal {
RwxMemoryWriteScope::RwxMemoryWriteScope(const char* comment) {
DCHECK(is_key_permissions_initialized_for_current_thread());
if (!FLAG_jitless) {
if (!v8_flags.jitless) {
SetWritable();
}
}
RwxMemoryWriteScope::~RwxMemoryWriteScope() {
if (!FLAG_jitless) {
if (!v8_flags.jitless) {
SetExecutable();
}
}

View File

@ -1991,7 +1991,7 @@ struct LateOptimizationPhase {
AddReducer(data, &graph_reducer, &dead_code_elimination);
AddReducer(data, &graph_reducer, &machine_reducer);
AddReducer(data, &graph_reducer, &common_reducer);
if (!FLAG_turboshaft) {
if (!v8_flags.turboshaft) {
AddReducer(data, &graph_reducer, &select_lowering);
}
AddReducer(data, &graph_reducer, &value_numbering);
@ -2076,7 +2076,7 @@ struct OptimizeTurboshaftPhase {
void Run(PipelineData* data, Zone* temp_zone) {
UnparkedScopeIfNeeded scope(data->broker(),
FLAG_turboshaft_trace_reduction);
v8_flags.turboshaft_trace_reduction);
turboshaft::OptimizationPhase<
turboshaft::AnalyzerBase,
turboshaft::MachineOptimizationAssembler<

View File

@ -13,10 +13,10 @@ namespace v8::internal::compiler::turboshaft {
bool ShouldSkipOptimizationStep() {
static std::atomic<uint64_t> counter{0};
uint64_t current = counter++;
if (current == FLAG_turboshaft_opt_bisect_break) {
if (current == v8_flags.turboshaft_opt_bisect_break) {
base::OS::DebugBreak();
}
if (current >= FLAG_turboshaft_opt_bisect_limit) {
if (current >= v8_flags.turboshaft_opt_bisect_limit) {
return true;
}
return false;

View File

@ -36,16 +36,6 @@
#define FLAG_READONLY(ftype, ctype, nam, def, cmt) \
static constexpr FlagValue<ctype> nam{def};
// Define a {FLAG_foo} alias per flag, pointing to {v8_flags.foo}.
// This allows to still use the old and deprecated syntax for accessing flag
// values. This will be removed after v10.7.
// TODO(clemensb): Remove this after v10.7.
#elif defined(FLAG_MODE_DEFINE_GLOBAL_ALIASES)
#define FLAG_FULL(ftype, ctype, nam, def, cmt) \
inline auto& FLAG_##nam = v8_flags.nam;
#define FLAG_READONLY(ftype, ctype, nam, def, cmt) \
inline auto constexpr& FLAG_##nam = v8_flags.nam;
// We need to define all of our default values so that the Flag structure can
// access them by pointer. These are just used internally inside of one .cc,
// for MODE_META, so there is no impact on the flags interface.
@ -2114,9 +2104,9 @@ DEFINE_BOOL(print_break_location, false, "print source location on debug break")
//
// Logging and profiling flags
//
// Logging flag dependencies are are also set separately in
// Logging flag dependencies are also set separately in
// V8::InitializeOncePerProcessImpl. Please add your flag to the log_all_flags
// list in v8.cc to properly set FLAG_log and automatically enable it with
// list in v8.cc to properly set v8_flags.log and automatically enable it with
// --log-all.
#undef FLAG
#define FLAG FLAG_FULL
@ -2390,7 +2380,6 @@ DEFINE_INT(dump_allocations_digest_at_alloc, -1,
#undef DEFINE_ALIAS_FLOAT
#undef FLAG_MODE_DECLARE
#undef FLAG_MODE_DEFINE_GLOBAL_ALIASES
#undef FLAG_MODE_DEFINE_DEFAULTS
#undef FLAG_MODE_META
#undef FLAG_MODE_DEFINE_IMPLICATIONS

View File

@ -70,10 +70,6 @@ struct alignas(kMinimumOSPageSize) FlagValues {
V8_EXPORT_PRIVATE extern FlagValues v8_flags;
// TODO(clemensb): Remove this after v10.7.
#define FLAG_MODE_DEFINE_GLOBAL_ALIASES
#include "src/flags/flag-definitions.h" // NOLINT(build/include)
// The global list of all flags.
class V8_EXPORT_PRIVATE FlagList {
public:

View File

@ -5585,7 +5585,7 @@ void Genesis::InitializeGlobal_experimental_web_snapshots() {
#ifdef V8_INTL_SUPPORT
void Genesis::InitializeGlobal_harmony_intl_duration_format() {
if (!FLAG_harmony_intl_duration_format) return;
if (!v8_flags.harmony_intl_duration_format) return;
Handle<JSObject> intl = Handle<JSObject>::cast(
JSReceiver::GetProperty(
isolate(),

View File

@ -44,8 +44,8 @@ Address MathRandom::RefillCache(Isolate* isolate, Address raw_native_context) {
// sequence.
if (state.s0 == 0 && state.s1 == 0) {
uint64_t seed;
if (FLAG_random_seed != 0) {
seed = FLAG_random_seed;
if (v8_flags.random_seed != 0) {
seed = v8_flags.random_seed;
} else {
isolate->random_number_generator()->NextBytes(&seed, sizeof(seed));
}

View File

@ -100,7 +100,7 @@ class JSRegExp : public TorqueGeneratedJSRegExp<JSRegExp, JSObject> {
return {};
}
if (f.value() == RegExpFlag::kUnicodeSets &&
!FLAG_harmony_regexp_unicode_sets) {
!v8_flags.harmony_regexp_unicode_sets) {
return {};
}
return f;

View File

@ -190,7 +190,7 @@ int StringForwardingTable::AddExternalResourceAndHash(String string,
constexpr bool is_one_byte =
std::is_base_of_v<v8::String::ExternalOneByteStringResource, T>;
DCHECK_IMPLIES(!FLAG_always_use_string_forwarding_table,
DCHECK_IMPLIES(!v8_flags.always_use_string_forwarding_table,
string.InSharedHeap());
int index = next_free_index_++;
uint32_t index_in_block;

View File

@ -1282,7 +1282,7 @@ Maybe<T> ValueDeserializer::ReadVarint() {
// same end state and result.
auto previous_position = position_;
Maybe<T> maybe_expected_value = ReadVarintLoop<T>();
if (FLAG_fuzzing && maybe_expected_value.IsNothing()) {
if (v8_flags.fuzzing && maybe_expected_value.IsNothing()) {
return maybe_expected_value;
}
T expected_value = maybe_expected_value.ToChecked();
@ -1671,7 +1671,7 @@ bool ValueDeserializer::ReadExpectedString(Handle<String> expected) {
return {};
}
// Length is also checked in ReadRawBytes.
DCHECK_IMPLIES(!FLAG_fuzzing,
DCHECK_IMPLIES(!v8_flags.fuzzing,
byte_length <= static_cast<uint32_t>(
std::numeric_limits<int32_t>::max()));
if (!ReadRawBytes(byte_length).To(&bytes)) {

View File

@ -156,7 +156,7 @@ void* AllocatePages(v8::PageAllocator* page_allocator, void* hint, size_t size,
DCHECK_NOT_NULL(page_allocator);
DCHECK_EQ(hint, AlignedAddress(hint, alignment));
DCHECK(IsAligned(size, page_allocator->AllocatePageSize()));
if (FLAG_randomize_all_allocations) {
if (v8_flags.randomize_all_allocations) {
hint = AlignedAddress(page_allocator->GetRandomMmapAddr(), alignment);
}
void* result = nullptr;

View File

@ -1887,7 +1887,7 @@ NativeModule::~NativeModule() {
import_wrapper_cache_.reset();
// If experimental PGO support is enabled, serialize the PGO data now.
if (V8_UNLIKELY(FLAG_experimental_wasm_pgo_to_file)) {
if (V8_UNLIKELY(v8_flags.experimental_wasm_pgo_to_file)) {
DumpProfileToFile(module_.get(), wire_bytes());
}
}

View File

@ -550,7 +550,7 @@ MaybeHandle<WasmModuleObject> WasmEngine::SyncCompile(
}
// If experimental PGO via files is enabled, load profile information now.
if (V8_UNLIKELY(FLAG_experimental_wasm_pgo_from_file)) {
if (V8_UNLIKELY(v8_flags.experimental_wasm_pgo_from_file)) {
LoadProfileFromFile(module.get(), bytes.module_bytes());
}

View File

@ -28,9 +28,9 @@ class V8_NODISCARD FlagScope {
} // namespace internal
} // namespace v8
#define FLAG_VALUE_SCOPE(flag, value) \
v8::internal::FlagScope<bool> UNIQUE_IDENTIFIER(__scope_##flag)( \
&v8::internal::FLAG_##flag, value)
#define FLAG_VALUE_SCOPE(flag, value) \
::v8::internal::FlagScope<bool> UNIQUE_IDENTIFIER(__scope_##flag)( \
&::v8::internal::v8_flags.flag, value)
#define FLAG_SCOPE(flag) FLAG_VALUE_SCOPE(flag, true)
#endif // V8_TEST_COMMON_FLAG_UTILS_H

View File

@ -19,13 +19,13 @@ namespace v8_fuzzer {
FuzzerSupport::FuzzerSupport(int* argc, char*** argv) {
// Disable hard abort, which generates a trap instead of a proper abortion.
// Traps by default do not cause libfuzzer to generate a crash file.
i::FLAG_hard_abort = false;
i::v8_flags.hard_abort = false;
i::FLAG_expose_gc = true;
i::v8_flags.expose_gc = true;
// Allow changing flags in fuzzers.
// TODO(12887): Refactor fuzzers to not change flags after initialization.
i::FLAG_freeze_flags_after_init = false;
i::v8_flags.freeze_flags_after_init = false;
#if V8_ENABLE_WEBASSEMBLY
if (V8_TRAP_HANDLER_SUPPORTED) {

View File

@ -168,7 +168,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
CallDescriptor* desc =
CreateRandomCallDescriptor(&zone, return_count, param_count, &input);
if (FLAG_wasm_fuzzer_gen_test) {
if (v8_flags.wasm_fuzzer_gen_test) {
// Print some debugging output which describes the produced signature.
printf("[");
for (size_t j = 0; j < param_count; ++j) {

View File

@ -453,7 +453,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Flag definitions.
FLAG_allow_natives_syntax = true;
v8_flags.allow_natives_syntax = true;
// V8 setup.

View File

@ -806,7 +806,7 @@ int InspectorTestMain(int argc, char* argv[]) {
v8::V8::InitializeICUDefaultLocation(argv[0]);
std::unique_ptr<Platform> platform(platform::NewDefaultPlatform());
v8::V8::InitializePlatform(platform.get());
FLAG_abort_on_contradictory_flags = true;
v8_flags.abort_on_contradictory_flags = true;
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::V8::InitializeExternalStartupData(argv[0]);
v8::V8::Initialize();

View File

@ -88,7 +88,7 @@ void TaskRunner::RunMessageLoop(bool only_protocol) {
// This can be removed once https://crbug.com/v8/10747 is fixed.
// TODO(10748): Enable --stress-incremental-marking after the existing
// tests are fixed.
if (!i::FLAG_stress_incremental_marking) {
if (!i::v8_flags.stress_incremental_marking) {
while (v8::platform::PumpMessageLoop(
v8::internal::V8::GetCurrentPlatform(), isolate(),
isolate()->HasPendingBackgroundTasks()

View File

@ -214,7 +214,7 @@ assertKind(elements_kind.fast_double, obj);
// Try to continue the transition to fast object.
// TODO(mvstanton): re-enable commented out code when
// FLAG_pretenuring_call_new is turned on in the build.
// v8_flags.pretenuring_call_new is turned on in the build.
obj = newarraycase_length_smidouble("coates");
assertKind(elements_kind.fast, obj);
obj = newarraycase_length_smidouble(2);

View File

@ -120,13 +120,13 @@ found in the LICENSE file. -->
<h3><code>LOG_FLAGS</code>:</h3>
<dl class="d8-options">
<dt>
<a href="https://source.chromium.org/search?q=FLAG_log_all">
<a href="https://source.chromium.org/search?q=v8_flags.log_all">
<code>--log-all</code>
</a>
</dt>
<dd>Enable all V8 logging options.</dd>
<dt>
<a href="https://source.chromium.org/search?q=FLAG_trace_maps">
<a href="https://source.chromium.org/search?q=v8_flags.trace_maps">
<code>--log-maps</code>
</a>
</dt>
@ -134,7 +134,7 @@ found in the LICENSE file. -->
Log <a href="https://v8.dev/blog/fast-properties">Maps</a>
</dd>
<dt>
<a href="https://source.chromium.org/search?q=FLAG_log_ic">
<a href="https://source.chromium.org/search?q=v8_flags.log_ic">
<code>--log-ic</code>
</a>
</dt>
@ -142,31 +142,31 @@ found in the LICENSE file. -->
Log <a href="https://mathiasbynens.be/notes/shapes-ics">ICs</a>
</dd>
<dt>
<a href="https://source.chromium.org/search?q=FLAG_log_source_code">
<a href="https://source.chromium.org/search?q=v8_flags.log_source_code">
<code>--log-source-code</code>
</a>
</dt>
<dd>Log source code</dd>
<dt>
<a href="https://source.chromium.org/search?q=FLAG_log_code_disassemble">
<a href="https://source.chromium.org/search?q=v8_flags.log_code_disassemble">
<code>--log-code-disassemble</code>
</a>
</dt>
<dd>Log detailed generated generated code</dd>
<dt>
<a href="https://source.chromium.org/search?q=FLAG_log_code">
<a href="https://source.chromium.org/search?q=v8_flags.log_code">
<code>--log-code</code>
</a>
</dt>
<dd>Log details about deoptimized code</dd>
<dt>
<a href="https://source.chromium.org/search?q=FLAG_log_deopt">
<a href="https://source.chromium.org/search?q=v8_flags.log_deopt">
<code>--log-deopt</code>
</a>
</dt>
<dd>Log various API uses.</dd>
<dt>
<a href="https://source.chromium.org/search?q=FLAG_prof">
<a href="https://source.chromium.org/search?q=v8_flags.prof">
<code>--prof</code>
</a>
</dt>