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

[interpreter] Use v8_flags for accessing flag values

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

R=jgruber@chromium.org

Bug: v8:12887
Change-Id: I0454426c664e54e9b8c8b39f903eeca1a80d4bc2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3898933
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarJakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83214}
parent e0c69483
......@@ -58,7 +58,7 @@ BytecodeArrayBuilder::BytecodeArrayBuilder(
DCHECK_GE(parameter_count_, 0);
DCHECK_GE(local_register_count_, 0);
if (FLAG_ignition_reo) {
if (v8_flags.ignition_reo) {
register_optimizer_ = zone->New<BytecodeRegisterOptimizer>(
zone, &register_allocator_, fixed_register_count(), parameter_count,
zone->New<RegisterTransferWriter>(this));
......@@ -138,7 +138,7 @@ BytecodeSourceInfo BytecodeArrayBuilder::CurrentSourcePosition(
// throw (if expression position filtering is turned on). We only
// invalidate the existing source position information if it is used.
if (latest_source_info_.is_statement() ||
!FLAG_ignition_filter_expression_positions ||
!v8_flags.ignition_filter_expression_positions ||
!Bytecodes::IsWithoutExternalSideEffects(bytecode)) {
source_position = latest_source_info_;
latest_source_info_.set_invalid();
......
......@@ -31,7 +31,8 @@ BytecodeArrayWriter::BytecodeArrayWriter(
last_bytecode_(Bytecode::kIllegal),
last_bytecode_offset_(0),
last_bytecode_had_source_info_(false),
elide_noneffectful_bytecodes_(FLAG_ignition_elide_noneffectful_bytecodes),
elide_noneffectful_bytecodes_(
v8_flags.ignition_elide_noneffectful_bytecodes),
exit_seen_in_block_(false) {
bytecodes_.reserve(512); // Derived via experimentation.
}
......
......@@ -1213,7 +1213,7 @@ Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(
Handle<CoverageInfo> coverage_info =
isolate->factory()->NewCoverageInfo(block_coverage_builder_->slots());
info()->set_coverage_info(coverage_info);
if (FLAG_trace_block_coverage) {
if (v8_flags.trace_block_coverage) {
StdoutStream os;
coverage_info->CoverageInfoPrint(os, info()->literal()->GetDebugName());
}
......@@ -1421,7 +1421,7 @@ void BytecodeGenerator::GenerateBytecodeBody() {
}
// Emit tracing call if requested to do so.
if (FLAG_trace) builder()->CallRuntime(Runtime::kTraceEnter);
if (v8_flags.trace) builder()->CallRuntime(Runtime::kTraceEnter);
// Emit type profile call.
if (info()->flags().collect_type_profile()) {
......@@ -1831,7 +1831,7 @@ inline int ReduceToSmiSwitchCaseValue(Expression* expr) {
// Is the range of Smi's small enough relative to number of cases?
inline bool IsSpreadAcceptable(int spread, int ncases) {
return spread < FLAG_switch_table_spread_threshold * ncases;
return spread < v8_flags.switch_table_spread_threshold * ncases;
}
struct SwitchInfo {
......@@ -1894,7 +1894,7 @@ bool IsSwitchOptimizable(SwitchStatement* stmt, SwitchInfo* info) {
// GCC also jump-table optimizes switch statements with 6 cases or more.
if (static_cast<int>(info->covered_cases.size()) >=
FLAG_switch_table_min_cases) {
v8_flags.switch_table_min_cases) {
// Due to case spread will be used as the size of jump-table,
// we need to check if it doesn't overflow by casting its
// min and max bounds to int64_t, and calculate if the difference is less
......@@ -3680,7 +3680,7 @@ void BytecodeGenerator::BuildVariableLoadForAccumulatorValue(
}
void BytecodeGenerator::BuildReturn(int source_position) {
if (FLAG_trace) {
if (v8_flags.trace) {
RegisterAllocationScope register_scope(this);
Register result = register_allocator()->NewRegister();
// Runtime returns {result} value, preserving accumulator.
......@@ -5322,7 +5322,7 @@ void BytecodeGenerator::VisitPropertyLoadForRegister(Register obj,
void BytecodeGenerator::VisitNamedSuperPropertyLoad(Property* property,
Register opt_receiver_out) {
RegisterAllocationScope register_scope(this);
if (FLAG_super_ic) {
if (v8_flags.super_ic) {
Register receiver = register_allocator()->NewRegister();
BuildThisVariableLoad();
builder()->StoreAccumulatorInRegister(receiver);
......@@ -5655,7 +5655,7 @@ void BytecodeGenerator::VisitCallSuper(Call* expr) {
Register constructor_then_instance = register_allocator()->NewRegister();
BytecodeLabel super_ctor_call_done;
bool omit_super_ctor = FLAG_omit_default_ctors &&
bool omit_super_ctor = v8_flags.omit_default_ctors &&
IsDerivedConstructor(info()->literal()->kind());
if (spread_position == Call::kHasNonFinalSpread) {
......@@ -5790,7 +5790,7 @@ void BytecodeGenerator::VisitCallSuper(Call* expr) {
void BytecodeGenerator::BuildSuperCallOptimization(
Register this_function, Register new_target,
Register constructor_then_instance, BytecodeLabel* super_ctor_call_done) {
DCHECK(FLAG_omit_default_ctors);
DCHECK(v8_flags.omit_default_ctors);
RegisterList output = register_allocator()->NewRegisterList(2);
builder()->FindNonDefaultConstructor(this_function, new_target, output);
builder()->MoveRegister(output[1], constructor_then_instance);
......@@ -7347,7 +7347,7 @@ FeedbackSlot BytecodeGenerator::GetCachedStoreGlobalICSlot(
FeedbackSlot BytecodeGenerator::GetCachedLoadICSlot(const Expression* expr,
const AstRawString* name) {
DCHECK(!expr->IsSuperPropertyReference());
if (!FLAG_ignition_share_named_property_feedback) {
if (!v8_flags.ignition_share_named_property_feedback) {
return feedback_spec()->AddLoadICSlot();
}
FeedbackSlotCache::SlotKind slot_kind =
......@@ -7369,7 +7369,7 @@ FeedbackSlot BytecodeGenerator::GetCachedLoadICSlot(const Expression* expr,
FeedbackSlot BytecodeGenerator::GetCachedLoadSuperICSlot(
const AstRawString* name) {
if (!FLAG_ignition_share_named_property_feedback) {
if (!v8_flags.ignition_share_named_property_feedback) {
return feedback_spec()->AddLoadICSlot();
}
FeedbackSlotCache::SlotKind slot_kind =
......@@ -7386,7 +7386,7 @@ FeedbackSlot BytecodeGenerator::GetCachedLoadSuperICSlot(
FeedbackSlot BytecodeGenerator::GetCachedStoreICSlot(const Expression* expr,
const AstRawString* name) {
if (!FLAG_ignition_share_named_property_feedback) {
if (!v8_flags.ignition_share_named_property_feedback) {
return feedback_spec()->AddStoreICSlot(language_mode());
}
FeedbackSlotCache::SlotKind slot_kind =
......
......@@ -1494,7 +1494,7 @@ TNode<FixedArray> InterpreterAssembler::ExportParametersAndRegisterFile(
TNode<IntPtrT> formal_parameter_count_intptr =
Signed(ChangeUint32ToWord(formal_parameter_count));
TNode<UintPtrT> register_count = ChangeUint32ToWord(registers.reg_count());
if (FLAG_debug_code) {
if (v8_flags.debug_code) {
CSA_DCHECK(this, IntPtrEqual(registers.base_reg_location(),
RegisterLocation(Register(0))));
AbortIfRegisterCountInvalid(array, formal_parameter_count_intptr,
......@@ -1566,7 +1566,7 @@ TNode<FixedArray> InterpreterAssembler::ImportRegisterFile(
TNode<IntPtrT> formal_parameter_count_intptr =
Signed(ChangeUint32ToWord(formal_parameter_count));
TNode<UintPtrT> register_count = ChangeUint32ToWord(registers.reg_count());
if (FLAG_debug_code) {
if (v8_flags.debug_code) {
CSA_DCHECK(this, IntPtrEqual(registers.base_reg_location(),
RegisterLocation(Register(0))));
AbortIfRegisterCountInvalid(array, formal_parameter_count_intptr,
......
......@@ -3176,7 +3176,7 @@ Handle<Code> GenerateBytecodeHandler(Isolate* isolate, const char* debug_name,
&state, options, ProfileDataFromFile::TryRead(debug_name));
#ifdef ENABLE_DISASSEMBLER
if (FLAG_trace_ignition_codegen) {
if (v8_flags.trace_ignition_codegen) {
StdoutStream os;
code->Disassemble(Bytecodes::ToString(bytecode), os, isolate);
os << std::flush;
......
......@@ -82,7 +82,7 @@ TNode<Object> IntrinsicsGenerator::InvokeIntrinsic(
#define HANDLE_CASE(name, lower_case, expected_arg_count) \
__ BIND(&lower_case); \
{ \
if (FLAG_debug_code && expected_arg_count >= 0) { \
if (v8_flags.debug_code && expected_arg_count >= 0) { \
AbortIfArgCountMismatch(expected_arg_count, args.reg_count()); \
} \
TNode<Object> value = name(args, context, expected_arg_count); \
......
......@@ -139,7 +139,7 @@ namespace {
void MaybePrintAst(ParseInfo* parse_info,
UnoptimizedCompilationInfo* compilation_info) {
if (!FLAG_print_ast) return;
if (!v8_flags.print_ast) return;
StdoutStream os;
std::unique_ptr<char[]> name = compilation_info->literal()->GetDebugName();
......@@ -153,15 +153,15 @@ void MaybePrintAst(ParseInfo* parse_info,
}
bool ShouldPrintBytecode(Handle<SharedFunctionInfo> shared) {
if (!FLAG_print_bytecode) return false;
if (!v8_flags.print_bytecode) return false;
// Checks whether function passed the filter.
if (shared->is_toplevel()) {
base::Vector<const char> filter =
base::CStrVector(FLAG_print_bytecode_filter);
base::CStrVector(v8_flags.print_bytecode_filter);
return (filter.length() == 0) || (filter.length() == 1 && filter[0] == '*');
} else {
return shared->PassesFilter(FLAG_print_bytecode_filter);
return shared->PassesFilter(v8_flags.print_bytecode_filter);
}
}
......
......@@ -246,7 +246,7 @@ TEST_F(BytecodeArrayWriterUnittest, ComplexExample) {
}
TEST_F(BytecodeArrayWriterUnittest, ElideNoneffectfulBytecodes) {
if (!i::FLAG_ignition_elide_noneffectful_bytecodes) return;
if (!i::v8_flags.ignition_elide_noneffectful_bytecodes) return;
static const uint8_t expected_bytes[] = {
// clang-format off
......
......@@ -393,7 +393,7 @@ void BytecodeExpectationsPrinter::PrintExpectation(
wrap_ ? WrapCodeInFunction(test_function_name_.c_str(), snippet)
: snippet;
i::FLAG_compilation_cache = false;
i::v8_flags.compilation_cache = false;
i::Handle<i::BytecodeArray> bytecode_array;
if (module_) {
CHECK(top_level_ && !wrap_);
......
......@@ -23,9 +23,9 @@ class BytecodeGeneratorTest : public TestWithContext {
public:
BytecodeGeneratorTest() : printer_(isolate()) {}
static void SetUpTestSuite() {
i::FLAG_always_turbofan = false;
i::FLAG_allow_natives_syntax = true;
i::FLAG_enable_lazy_source_positions = false;
i::v8_flags.always_turbofan = false;
i::v8_flags.allow_natives_syntax = true;
i::v8_flags.enable_lazy_source_positions = false;
TestWithContext::SetUpTestSuite();
}
......
......@@ -336,13 +336,13 @@ void ProgramOptions::PrintHeader(std::ostream* stream) const {
V8InitializationScope::V8InitializationScope(const char* exec_path)
: platform_(v8::platform::NewDefaultPlatform()) {
i::FLAG_always_turbofan = false;
i::FLAG_allow_natives_syntax = true;
i::FLAG_enable_lazy_source_positions = false;
i::v8_flags.always_turbofan = false;
i::v8_flags.allow_natives_syntax = true;
i::v8_flags.enable_lazy_source_positions = false;
// The bytecode expectations printer changes flags; this is not security
// relevant, allow this.
i::FLAG_freeze_flags_after_init = false;
i::v8_flags.freeze_flags_after_init = false;
v8::V8::InitializeICUDefaultLocation(exec_path);
v8::V8::InitializeExternalStartupData(exec_path);
......
......@@ -25,7 +25,7 @@ InterpreterTester::InterpreterTester(
source_(source),
bytecode_(bytecode),
feedback_metadata_(feedback_metadata) {
i::FLAG_always_turbofan = false;
i::v8_flags.always_turbofan = false;
}
InterpreterTester::InterpreterTester(
......
......@@ -4739,9 +4739,9 @@ TEST_F(InterpreterTest, InterpreterGenerators) {
#ifndef V8_TARGET_ARCH_ARM
TEST_F(InterpreterTest, InterpreterWithNativeStack) {
// "Always sparkplug" messes with this test.
if (FLAG_always_sparkplug) return;
if (v8_flags.always_sparkplug) return;
i::FLAG_interpreted_frames_native_stack = true;
i::v8_flags.interpreted_frames_native_stack = true;
const char* source_text =
"function testInterpreterWithNativeStack(a,b) { return a + b };";
......@@ -4793,8 +4793,8 @@ TEST_F(InterpreterTest, InterpreterGetBytecodeHandler) {
}
TEST_F(InterpreterTest, InterpreterCollectSourcePositions) {
FLAG_enable_lazy_source_positions = true;
FLAG_stress_lazy_source_positions = false;
v8_flags.enable_lazy_source_positions = true;
v8_flags.stress_lazy_source_positions = false;
const char* source =
"(function () {\n"
......@@ -4817,8 +4817,8 @@ TEST_F(InterpreterTest, InterpreterCollectSourcePositions) {
}
TEST_F(InterpreterTest, InterpreterCollectSourcePositions_StackOverflow) {
FLAG_enable_lazy_source_positions = true;
FLAG_stress_lazy_source_positions = false;
v8_flags.enable_lazy_source_positions = true;
v8_flags.stress_lazy_source_positions = false;
const char* source =
"(function () {\n"
......@@ -4852,8 +4852,8 @@ TEST_F(InterpreterTest, InterpreterCollectSourcePositions_StackOverflow) {
}
TEST_F(InterpreterTest, InterpreterCollectSourcePositions_ThrowFrom1stFrame) {
FLAG_enable_lazy_source_positions = true;
FLAG_stress_lazy_source_positions = false;
v8_flags.enable_lazy_source_positions = true;
v8_flags.stress_lazy_source_positions = false;
const char* source =
R"javascript(
......@@ -4886,8 +4886,8 @@ TEST_F(InterpreterTest, InterpreterCollectSourcePositions_ThrowFrom1stFrame) {
}
TEST_F(InterpreterTest, InterpreterCollectSourcePositions_ThrowFrom2ndFrame) {
FLAG_enable_lazy_source_positions = true;
FLAG_stress_lazy_source_positions = false;
v8_flags.enable_lazy_source_positions = true;
v8_flags.stress_lazy_source_positions = false;
const char* source =
R"javascript(
......@@ -4941,8 +4941,8 @@ void CheckStringEqual(const char* expected_ptr, Handle<Object> actual_handle) {
} // namespace
TEST_F(InterpreterTest, InterpreterCollectSourcePositions_GenerateStackTrace) {
FLAG_enable_lazy_source_positions = true;
FLAG_stress_lazy_source_positions = false;
v8_flags.enable_lazy_source_positions = true;
v8_flags.stress_lazy_source_positions = false;
const char* source =
R"javascript(
......
......@@ -21,9 +21,10 @@ namespace interpreter {
// Flags enabling optimizations that change generated bytecode array.
// Format is <command-line flag> <flag name> <bit index>
#define OPTIMIZATION_FLAGS(V) \
V(FLAG_ignition_reo, kUseReo, 0) \
V(FLAG_ignition_filter_expression_positions, kUseFilterExpressionPositions, 2)
#define OPTIMIZATION_FLAGS(V) \
V(v8_flags.ignition_reo, kUseReo, 0) \
V(v8_flags.ignition_filter_expression_positions, \
kUseFilterExpressionPositions, 2)
#define DECLARE_BIT(_, Name, BitIndex) static const int Name = 1 << BitIndex;
OPTIMIZATION_FLAGS(DECLARE_BIT)
......@@ -105,8 +106,8 @@ class SourcePositionTest : public TestWithContext,
std::tuple<int, TestCaseData>> {
public:
static void SetUpTestSuite() {
FLAG_always_turbofan = false;
FLAG_enable_lazy_source_positions = false;
v8_flags.always_turbofan = false;
v8_flags.enable_lazy_source_positions = false;
TestWithContext::SetUpTestSuite();
}
bool SourcePositionsMatch(int optimization_bitmap, const char* function_body,
......
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