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

[regexp] 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: Ide7272de6a59e8324f19d4f52053737b56a380d9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3875083
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarJakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82989}
parent f5cda3d1
...@@ -400,7 +400,7 @@ void RegExpMacroAssemblerARM64::CheckNotBackReferenceIgnoreCase( ...@@ -400,7 +400,7 @@ void RegExpMacroAssemblerARM64::CheckNotBackReferenceIgnoreCase(
__ Sub(current_input_offset().X(), current_input_offset().X(), __ Sub(current_input_offset().X(), current_input_offset().X(),
Operand(capture_length, SXTW)); Operand(capture_length, SXTW));
} }
if (FLAG_debug_code) { if (v8_flags.debug_code) {
__ Cmp(current_input_offset().X(), Operand(current_input_offset(), SXTW)); __ Cmp(current_input_offset().X(), Operand(current_input_offset(), SXTW));
__ Ccmp(current_input_offset(), 0, NoFlag, eq); __ Ccmp(current_input_offset(), 0, NoFlag, eq);
// The current input offset should be <= 0, and fit in a W register. // The current input offset should be <= 0, and fit in a W register.
...@@ -529,7 +529,7 @@ void RegExpMacroAssemblerARM64::CheckNotBackReference(int start_reg, ...@@ -529,7 +529,7 @@ void RegExpMacroAssemblerARM64::CheckNotBackReference(int start_reg,
Operand(capture_length, SXTW)); Operand(capture_length, SXTW));
} }
if (FLAG_debug_code) { if (v8_flags.debug_code) {
__ Cmp(current_input_offset().X(), Operand(current_input_offset(), SXTW)); __ Cmp(current_input_offset().X(), Operand(current_input_offset(), SXTW));
__ Ccmp(current_input_offset(), 0, NoFlag, eq); __ Ccmp(current_input_offset(), 0, NoFlag, eq);
// The current input offset should be <= 0, and fit in a W register. // The current input offset should be <= 0, and fit in a W register.
...@@ -893,7 +893,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) { ...@@ -893,7 +893,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
// Find negative length (offset of start relative to end). // Find negative length (offset of start relative to end).
__ Sub(x10, input_start(), input_end()); __ Sub(x10, input_start(), input_end());
if (FLAG_debug_code) { if (v8_flags.debug_code) {
// Check that the size of the input string chars is in range. // Check that the size of the input string chars is in range.
__ Neg(x11, x10); __ Neg(x11, x10);
__ Cmp(x11, SeqTwoByteString::kMaxCharsSize); __ Cmp(x11, SeqTwoByteString::kMaxCharsSize);
...@@ -959,7 +959,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) { ...@@ -959,7 +959,7 @@ Handle<HeapObject> RegExpMacroAssemblerARM64::GetCode(Handle<String> source) {
// Get string length. // Get string length.
__ Sub(x10, input_end(), input_start()); __ Sub(x10, input_end(), input_start());
if (FLAG_debug_code) { if (v8_flags.debug_code) {
// Check that the size of the input string chars is in range. // Check that the size of the input string chars is in range.
__ Cmp(x10, SeqTwoByteString::kMaxCharsSize); __ Cmp(x10, SeqTwoByteString::kMaxCharsSize);
__ Check(ls, AbortReason::kInputStringTooLong); __ Check(ls, AbortReason::kInputStringTooLong);
...@@ -1248,7 +1248,7 @@ void RegExpMacroAssemblerARM64::PushBacktrack(Label* label) { ...@@ -1248,7 +1248,7 @@ void RegExpMacroAssemblerARM64::PushBacktrack(Label* label) {
} else { } else {
__ Adr(x10, label, MacroAssembler::kAdrFar); __ Adr(x10, label, MacroAssembler::kAdrFar);
__ Sub(x10, x10, code_pointer()); __ Sub(x10, x10, code_pointer());
if (FLAG_debug_code) { if (v8_flags.debug_code) {
__ Cmp(x10, kWRegMask); __ Cmp(x10, kWRegMask);
// The code offset has to fit in a W register. // The code offset has to fit in a W register.
__ Check(ls, AbortReason::kOffsetOutOfRange); __ Check(ls, AbortReason::kOffsetOutOfRange);
...@@ -1296,7 +1296,7 @@ void RegExpMacroAssemblerARM64::WriteStackPointerToRegister(int reg) { ...@@ -1296,7 +1296,7 @@ void RegExpMacroAssemblerARM64::WriteStackPointerToRegister(int reg) {
__ Mov(x10, ref); __ Mov(x10, ref);
__ Ldr(x10, MemOperand(x10)); __ Ldr(x10, MemOperand(x10));
__ Sub(x10, backtrack_stackpointer(), x10); __ Sub(x10, backtrack_stackpointer(), x10);
if (FLAG_debug_code) { if (v8_flags.debug_code) {
__ Cmp(x10, Operand(w10, SXTW)); __ Cmp(x10, Operand(w10, SXTW));
// The stack offset needs to fit in a W register. // The stack offset needs to fit in a W register.
__ Check(eq, AbortReason::kOffsetOutOfRange); __ Check(eq, AbortReason::kOffsetOutOfRange);
...@@ -1712,7 +1712,7 @@ void RegExpMacroAssemblerARM64::LoadCurrentCharacterUnchecked(int cp_offset, ...@@ -1712,7 +1712,7 @@ void RegExpMacroAssemblerARM64::LoadCurrentCharacterUnchecked(int cp_offset,
} }
if (cp_offset != 0) { if (cp_offset != 0) {
if (FLAG_debug_code) { if (v8_flags.debug_code) {
__ Mov(x10, cp_offset * char_size()); __ Mov(x10, cp_offset * char_size());
__ Add(x10, x10, Operand(current_input_offset(), SXTW)); __ Add(x10, x10, Operand(current_input_offset(), SXTW));
__ Cmp(x10, Operand(w10, SXTW)); __ Cmp(x10, Operand(w10, SXTW));
......
...@@ -16,16 +16,16 @@ namespace internal { ...@@ -16,16 +16,16 @@ namespace internal {
bool ExperimentalRegExp::CanBeHandled(RegExpTree* tree, RegExpFlags flags, bool ExperimentalRegExp::CanBeHandled(RegExpTree* tree, RegExpFlags flags,
int capture_count) { int capture_count) {
DCHECK(FLAG_enable_experimental_regexp_engine || DCHECK(v8_flags.enable_experimental_regexp_engine ||
FLAG_enable_experimental_regexp_engine_on_excessive_backtracks); v8_flags.enable_experimental_regexp_engine_on_excessive_backtracks);
return ExperimentalRegExpCompiler::CanBeHandled(tree, flags, capture_count); return ExperimentalRegExpCompiler::CanBeHandled(tree, flags, capture_count);
} }
void ExperimentalRegExp::Initialize(Isolate* isolate, Handle<JSRegExp> re, void ExperimentalRegExp::Initialize(Isolate* isolate, Handle<JSRegExp> re,
Handle<String> source, RegExpFlags flags, Handle<String> source, RegExpFlags flags,
int capture_count) { int capture_count) {
DCHECK(FLAG_enable_experimental_regexp_engine); DCHECK(v8_flags.enable_experimental_regexp_engine);
if (FLAG_trace_experimental_regexp_engine) { if (v8_flags.trace_experimental_regexp_engine) {
StdoutStream{} << "Initializing experimental regexp " << *source StdoutStream{} << "Initializing experimental regexp " << *source
<< std::endl; << std::endl;
} }
...@@ -35,7 +35,7 @@ void ExperimentalRegExp::Initialize(Isolate* isolate, Handle<JSRegExp> re, ...@@ -35,7 +35,7 @@ void ExperimentalRegExp::Initialize(Isolate* isolate, Handle<JSRegExp> re,
} }
bool ExperimentalRegExp::IsCompiled(Handle<JSRegExp> re, Isolate* isolate) { bool ExperimentalRegExp::IsCompiled(Handle<JSRegExp> re, Isolate* isolate) {
DCHECK(FLAG_enable_experimental_regexp_engine); DCHECK(v8_flags.enable_experimental_regexp_engine);
DCHECK_EQ(re->type_tag(), JSRegExp::EXPERIMENTAL); DCHECK_EQ(re->type_tag(), JSRegExp::EXPERIMENTAL);
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
re->JSRegExpVerify(isolate); re->JSRegExpVerify(isolate);
...@@ -99,14 +99,14 @@ base::Optional<CompilationResult> CompileImpl(Isolate* isolate, ...@@ -99,14 +99,14 @@ base::Optional<CompilationResult> CompileImpl(Isolate* isolate,
} // namespace } // namespace
bool ExperimentalRegExp::Compile(Isolate* isolate, Handle<JSRegExp> re) { bool ExperimentalRegExp::Compile(Isolate* isolate, Handle<JSRegExp> re) {
DCHECK(FLAG_enable_experimental_regexp_engine); DCHECK(v8_flags.enable_experimental_regexp_engine);
DCHECK_EQ(re->type_tag(), JSRegExp::EXPERIMENTAL); DCHECK_EQ(re->type_tag(), JSRegExp::EXPERIMENTAL);
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
re->JSRegExpVerify(isolate); re->JSRegExpVerify(isolate);
#endif #endif
Handle<String> source(re->source(), isolate); Handle<String> source(re->source(), isolate);
if (FLAG_trace_experimental_regexp_engine) { if (v8_flags.trace_experimental_regexp_engine) {
StdoutStream{} << "Compiling experimental regexp " << *source << std::endl; StdoutStream{} << "Compiling experimental regexp " << *source << std::endl;
} }
...@@ -165,10 +165,10 @@ int32_t ExperimentalRegExp::ExecRaw(Isolate* isolate, ...@@ -165,10 +165,10 @@ int32_t ExperimentalRegExp::ExecRaw(Isolate* isolate,
int32_t* output_registers, int32_t* output_registers,
int32_t output_register_count, int32_t output_register_count,
int32_t subject_index) { int32_t subject_index) {
DCHECK(FLAG_enable_experimental_regexp_engine); DCHECK(v8_flags.enable_experimental_regexp_engine);
DisallowGarbageCollection no_gc; DisallowGarbageCollection no_gc;
if (FLAG_trace_experimental_regexp_engine) { if (v8_flags.trace_experimental_regexp_engine) {
StdoutStream{} << "Executing experimental regexp " << regexp.source() StdoutStream{} << "Executing experimental regexp " << regexp.source()
<< std::endl; << std::endl;
} }
...@@ -185,7 +185,7 @@ int32_t ExperimentalRegExp::MatchForCallFromJs( ...@@ -185,7 +185,7 @@ int32_t ExperimentalRegExp::MatchForCallFromJs(
Address subject, int32_t start_position, Address input_start, Address subject, int32_t start_position, Address input_start,
Address input_end, int* output_registers, int32_t output_register_count, Address input_end, int* output_registers, int32_t output_register_count,
RegExp::CallOrigin call_origin, Isolate* isolate, Address regexp) { RegExp::CallOrigin call_origin, Isolate* isolate, Address regexp) {
DCHECK(FLAG_enable_experimental_regexp_engine); DCHECK(v8_flags.enable_experimental_regexp_engine);
DCHECK_NOT_NULL(isolate); DCHECK_NOT_NULL(isolate);
DCHECK_NOT_NULL(output_registers); DCHECK_NOT_NULL(output_registers);
DCHECK(call_origin == RegExp::CallOrigin::kFromJs); DCHECK(call_origin == RegExp::CallOrigin::kFromJs);
...@@ -207,7 +207,7 @@ MaybeHandle<Object> ExperimentalRegExp::Exec( ...@@ -207,7 +207,7 @@ MaybeHandle<Object> ExperimentalRegExp::Exec(
Isolate* isolate, Handle<JSRegExp> regexp, Handle<String> subject, Isolate* isolate, Handle<JSRegExp> regexp, Handle<String> subject,
int subject_index, Handle<RegExpMatchInfo> last_match_info, int subject_index, Handle<RegExpMatchInfo> last_match_info,
RegExp::ExecQuirks exec_quirks) { RegExp::ExecQuirks exec_quirks) {
DCHECK(FLAG_enable_experimental_regexp_engine); DCHECK(v8_flags.enable_experimental_regexp_engine);
DCHECK_EQ(regexp->type_tag(), JSRegExp::EXPERIMENTAL); DCHECK_EQ(regexp->type_tag(), JSRegExp::EXPERIMENTAL);
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
regexp->JSRegExpVerify(isolate); regexp->JSRegExpVerify(isolate);
...@@ -262,9 +262,9 @@ int32_t ExperimentalRegExp::OneshotExecRaw(Isolate* isolate, ...@@ -262,9 +262,9 @@ int32_t ExperimentalRegExp::OneshotExecRaw(Isolate* isolate,
int32_t* output_registers, int32_t* output_registers,
int32_t output_register_count, int32_t output_register_count,
int32_t subject_index) { int32_t subject_index) {
DCHECK(FLAG_enable_experimental_regexp_engine_on_excessive_backtracks); DCHECK(v8_flags.enable_experimental_regexp_engine_on_excessive_backtracks);
if (FLAG_trace_experimental_regexp_engine) { if (v8_flags.trace_experimental_regexp_engine) {
StdoutStream{} << "Experimental execution (oneshot) of regexp " StdoutStream{} << "Experimental execution (oneshot) of regexp "
<< regexp->source() << std::endl; << regexp->source() << std::endl;
} }
...@@ -284,7 +284,7 @@ MaybeHandle<Object> ExperimentalRegExp::OneshotExec( ...@@ -284,7 +284,7 @@ MaybeHandle<Object> ExperimentalRegExp::OneshotExec(
Isolate* isolate, Handle<JSRegExp> regexp, Handle<String> subject, Isolate* isolate, Handle<JSRegExp> regexp, Handle<String> subject,
int subject_index, Handle<RegExpMatchInfo> last_match_info, int subject_index, Handle<RegExpMatchInfo> last_match_info,
RegExp::ExecQuirks exec_quirks) { RegExp::ExecQuirks exec_quirks) {
DCHECK(FLAG_enable_experimental_regexp_engine_on_excessive_backtracks); DCHECK(v8_flags.enable_experimental_regexp_engine_on_excessive_backtracks);
DCHECK_NE(regexp->type_tag(), JSRegExp::NOT_COMPILED); DCHECK_NE(regexp->type_tag(), JSRegExp::NOT_COMPILED);
int capture_count = regexp->capture_count(); int capture_count = regexp->capture_count();
......
...@@ -380,7 +380,7 @@ Handle<HeapObject> RegExpBytecodeGenerator::GetCode(Handle<String> source) { ...@@ -380,7 +380,7 @@ Handle<HeapObject> RegExpBytecodeGenerator::GetCode(Handle<String> source) {
Backtrack(); Backtrack();
Handle<ByteArray> array; Handle<ByteArray> array;
if (FLAG_regexp_peephole_optimization) { if (v8_flags.regexp_peephole_optimization) {
array = RegExpBytecodePeepholeOptimization::OptimizeBytecode( array = RegExpBytecodePeepholeOptimization::OptimizeBytecode(
isolate_, zone(), source, buffer_.data(), length(), jump_edges_); isolate_, zone(), source, buffer_.data(), length(), jump_edges_);
} else { } else {
......
...@@ -1018,7 +1018,7 @@ Handle<ByteArray> RegExpBytecodePeepholeOptimization::OptimizeBytecode( ...@@ -1018,7 +1018,7 @@ Handle<ByteArray> RegExpBytecodePeepholeOptimization::OptimizeBytecode(
Handle<ByteArray> array = isolate->factory()->NewByteArray(peephole.Length()); Handle<ByteArray> array = isolate->factory()->NewByteArray(peephole.Length());
peephole.CopyOptimizedBytecode(array->GetDataStartAddress()); peephole.CopyOptimizedBytecode(array->GetDataStartAddress());
if (did_optimize && FLAG_trace_regexp_peephole_optimization) { if (did_optimize && v8_flags.trace_regexp_peephole_optimization) {
PrintF("Original Bytecode:\n"); PrintF("Original Bytecode:\n");
RegExpBytecodeDisassemble(bytecode, length, source->ToCString().get()); RegExpBytecodeDisassemble(bytecode, length, source->ToCString().get());
PrintF("Optimized Bytecode:\n"); PrintF("Optimized Bytecode:\n");
......
...@@ -248,7 +248,7 @@ RegExpCompiler::RegExpCompiler(Isolate* isolate, Zone* zone, int capture_count, ...@@ -248,7 +248,7 @@ RegExpCompiler::RegExpCompiler(Isolate* isolate, Zone* zone, int capture_count,
one_byte_(one_byte), one_byte_(one_byte),
reg_exp_too_big_(false), reg_exp_too_big_(false),
limiting_recursion_(false), limiting_recursion_(false),
optimize_(FLAG_regexp_optimization), optimize_(v8_flags.regexp_optimization),
read_backward_(false), read_backward_(false),
current_expansion_factor_(1), current_expansion_factor_(1),
frequency_collator_(), frequency_collator_(),
...@@ -278,7 +278,7 @@ RegExpCompiler::CompilationResult RegExpCompiler::Assemble( ...@@ -278,7 +278,7 @@ RegExpCompiler::CompilationResult RegExpCompiler::Assemble(
if (!node->label()->is_bound()) node->Emit(this, &new_trace); if (!node->label()->is_bound()) node->Emit(this, &new_trace);
} }
if (reg_exp_too_big_) { if (reg_exp_too_big_) {
if (FLAG_correctness_fuzzer_suppressions) { if (v8_flags.correctness_fuzzer_suppressions) {
FATAL("Aborting on excess zone allocation"); FATAL("Aborting on excess zone allocation");
} }
macro_assembler_->AbortedCodeGeneration(); macro_assembler_->AbortedCodeGeneration();
...@@ -3677,7 +3677,7 @@ class Analysis : public NodeVisitor { ...@@ -3677,7 +3677,7 @@ class Analysis : public NodeVisitor {
void EnsureAnalyzed(RegExpNode* that) { void EnsureAnalyzed(RegExpNode* that) {
StackLimitCheck check(isolate()); StackLimitCheck check(isolate());
if (check.HasOverflowed()) { if (check.HasOverflowed()) {
if (FLAG_correctness_fuzzer_suppressions) { if (v8_flags.correctness_fuzzer_suppressions) {
FATAL("Analysis: Aborting on stack overflow"); FATAL("Analysis: Aborting on stack overflow");
} }
fail(RegExpError::kAnalysisStackOverflow); fail(RegExpError::kAnalysisStackOverflow);
......
...@@ -78,7 +78,7 @@ void MaybeTraceInterpreter(const byte* code_base, const byte* pc, ...@@ -78,7 +78,7 @@ void MaybeTraceInterpreter(const byte* code_base, const byte* pc,
int stack_depth, int current_position, int stack_depth, int current_position,
uint32_t current_char, int bytecode_length, uint32_t current_char, int bytecode_length,
const char* bytecode_name) { const char* bytecode_name) {
if (FLAG_trace_regexp_bytecodes) { if (v8_flags.trace_regexp_bytecodes) {
const bool printable = std::isprint(current_char); const bool printable = std::isprint(current_char);
const char* format = const char* format =
printable printable
...@@ -447,7 +447,7 @@ IrregexpInterpreter::Result RawMatch( ...@@ -447,7 +447,7 @@ IrregexpInterpreter::Result RawMatch(
uint32_t backtrack_count = 0; uint32_t backtrack_count = 0;
#ifdef DEBUG #ifdef DEBUG
if (FLAG_trace_regexp_bytecodes) { if (v8_flags.trace_regexp_bytecodes) {
PrintF("\n\nStart bytecode interpreter\n\n"); PrintF("\n\nStart bytecode interpreter\n\n");
} }
#endif #endif
...@@ -1057,7 +1057,7 @@ IrregexpInterpreter::Result IrregexpInterpreter::Match( ...@@ -1057,7 +1057,7 @@ IrregexpInterpreter::Result IrregexpInterpreter::Match(
Isolate* isolate, JSRegExp regexp, String subject_string, Isolate* isolate, JSRegExp regexp, String subject_string,
int* output_registers, int output_register_count, int start_position, int* output_registers, int output_register_count, int start_position,
RegExp::CallOrigin call_origin) { RegExp::CallOrigin call_origin) {
if (FLAG_regexp_tier_up) regexp.TierUpTick(); if (v8_flags.regexp_tier_up) regexp.TierUpTick();
bool is_one_byte = String::IsOneByteRepresentationUnderneath(subject_string); bool is_one_byte = String::IsOneByteRepresentationUnderneath(subject_string);
ByteArray code_array = ByteArray::cast(regexp.bytecode(is_one_byte)); ByteArray code_array = ByteArray::cast(regexp.bytecode(is_one_byte));
......
...@@ -274,7 +274,7 @@ void NativeRegExpMacroAssembler::LoadCurrentCharacterImpl( ...@@ -274,7 +274,7 @@ void NativeRegExpMacroAssembler::LoadCurrentCharacterImpl(
} }
bool NativeRegExpMacroAssembler::CanReadUnaligned() const { bool NativeRegExpMacroAssembler::CanReadUnaligned() const {
return FLAG_enable_regexp_unaligned_accesses && !slow_safe(); return v8_flags.enable_regexp_unaligned_accesses && !slow_safe();
} }
#ifndef COMPILING_IRREGEXP_FOR_EXTERNAL_EMBEDDER #ifndef COMPILING_IRREGEXP_FOR_EXTERNAL_EMBEDDER
......
...@@ -424,7 +424,7 @@ template <class CharT> ...@@ -424,7 +424,7 @@ template <class CharT>
void RegExpParserImpl<CharT>::Advance() { void RegExpParserImpl<CharT>::Advance() {
if (has_next()) { if (has_next()) {
if (GetCurrentStackPosition() < stack_limit_) { if (GetCurrentStackPosition() < stack_limit_) {
if (FLAG_correctness_fuzzer_suppressions) { if (v8_flags.correctness_fuzzer_suppressions) {
FATAL("Aborting on stack overflow"); FATAL("Aborting on stack overflow");
} }
ReportError(RegExpError::kStackOverflow); ReportError(RegExpError::kStackOverflow);
...@@ -852,8 +852,8 @@ RegExpTree* RegExpParserImpl<CharT>::ParseDisjunction() { ...@@ -852,8 +852,8 @@ RegExpTree* RegExpParserImpl<CharT>::ParseDisjunction() {
if (current() == '?') { if (current() == '?') {
quantifier_type = RegExpQuantifier::NON_GREEDY; quantifier_type = RegExpQuantifier::NON_GREEDY;
Advance(); Advance();
} else if (FLAG_regexp_possessive_quantifier && current() == '+') { } else if (v8_flags.regexp_possessive_quantifier && current() == '+') {
// FLAG_regexp_possessive_quantifier is a debug-only flag. // v8_flags.regexp_possessive_quantifier is a debug-only flag.
quantifier_type = RegExpQuantifier::POSSESSIVE; quantifier_type = RegExpQuantifier::POSSESSIVE;
Advance(); Advance();
} }
...@@ -2039,7 +2039,7 @@ bool RegExpParserImpl<CharT>::Parse(RegExpCompileData* result) { ...@@ -2039,7 +2039,7 @@ bool RegExpParserImpl<CharT>::Parse(RegExpCompileData* result) {
DCHECK_NOT_NULL(tree); DCHECK_NOT_NULL(tree);
DCHECK_EQ(error_, RegExpError::kNone); DCHECK_EQ(error_, RegExpError::kNone);
if (FLAG_trace_regexp_parser) { if (v8_flags.trace_regexp_parser) {
StdoutStream os; StdoutStream os;
tree->Print(os, zone()); tree->Print(os, zone());
os << "\n"; os << "\n";
......
...@@ -104,7 +104,7 @@ class RegExpImpl final : public AllStatic { ...@@ -104,7 +104,7 @@ class RegExpImpl final : public AllStatic {
// static // static
bool RegExp::CanGenerateBytecode() { bool RegExp::CanGenerateBytecode() {
return FLAG_regexp_interpret_all || FLAG_regexp_tier_up; return v8_flags.regexp_interpret_all || v8_flags.regexp_tier_up;
} }
// static // static
...@@ -219,15 +219,15 @@ MaybeHandle<Object> RegExp::Compile(Isolate* isolate, Handle<JSRegExp> re, ...@@ -219,15 +219,15 @@ MaybeHandle<Object> RegExp::Compile(Isolate* isolate, Handle<JSRegExp> re,
bool has_been_compiled = false; bool has_been_compiled = false;
if (FLAG_default_to_experimental_regexp_engine && if (v8_flags.default_to_experimental_regexp_engine &&
ExperimentalRegExp::CanBeHandled(parse_result.tree, flags, ExperimentalRegExp::CanBeHandled(parse_result.tree, flags,
parse_result.capture_count)) { parse_result.capture_count)) {
DCHECK(FLAG_enable_experimental_regexp_engine); DCHECK(v8_flags.enable_experimental_regexp_engine);
ExperimentalRegExp::Initialize(isolate, re, pattern, flags, ExperimentalRegExp::Initialize(isolate, re, pattern, flags,
parse_result.capture_count); parse_result.capture_count);
has_been_compiled = true; has_been_compiled = true;
} else if (flags & JSRegExp::kLinear) { } else if (flags & JSRegExp::kLinear) {
DCHECK(FLAG_enable_experimental_regexp_engine); DCHECK(v8_flags.enable_experimental_regexp_engine);
if (!ExperimentalRegExp::CanBeHandled(parse_result.tree, flags, if (!ExperimentalRegExp::CanBeHandled(parse_result.tree, flags,
parse_result.capture_count)) { parse_result.capture_count)) {
// TODO(mbid): The error could provide a reason for why the regexp can't // TODO(mbid): The error could provide a reason for why the regexp can't
...@@ -438,14 +438,14 @@ bool RegExpImpl::EnsureCompiledIrregexp(Isolate* isolate, Handle<JSRegExp> re, ...@@ -438,14 +438,14 @@ bool RegExpImpl::EnsureCompiledIrregexp(Isolate* isolate, Handle<JSRegExp> re,
bool needs_tier_up_compilation = bool needs_tier_up_compilation =
re->MarkedForTierUp() && bytecode.IsByteArray(); re->MarkedForTierUp() && bytecode.IsByteArray();
if (FLAG_trace_regexp_tier_up && needs_tier_up_compilation) { if (v8_flags.trace_regexp_tier_up && needs_tier_up_compilation) {
PrintF("JSRegExp object %p needs tier-up compilation\n", PrintF("JSRegExp object %p needs tier-up compilation\n",
reinterpret_cast<void*>(re->ptr())); reinterpret_cast<void*>(re->ptr()));
} }
if (!needs_initial_compilation && !needs_tier_up_compilation) { if (!needs_initial_compilation && !needs_tier_up_compilation) {
DCHECK(compiled_code.IsCodeT()); DCHECK(compiled_code.IsCodeT());
DCHECK_IMPLIES(FLAG_regexp_interpret_all, bytecode.IsByteArray()); DCHECK_IMPLIES(v8_flags.regexp_interpret_all, bytecode.IsByteArray());
return true; return true;
} }
...@@ -595,7 +595,7 @@ bool RegExpImpl::CompileIrregexp(Isolate* isolate, Handle<JSRegExp> re, ...@@ -595,7 +595,7 @@ bool RegExpImpl::CompileIrregexp(Isolate* isolate, Handle<JSRegExp> re,
} }
data->set(JSRegExp::kIrregexpBacktrackLimit, Smi::FromInt(backtrack_limit)); data->set(JSRegExp::kIrregexpBacktrackLimit, Smi::FromInt(backtrack_limit));
if (FLAG_trace_regexp_tier_up) { if (v8_flags.trace_regexp_tier_up) {
PrintF("JSRegExp object %p %s size: %d\n", PrintF("JSRegExp object %p %s size: %d\n",
reinterpret_cast<void*>(re->ptr()), reinterpret_cast<void*>(re->ptr()),
re->ShouldProduceBytecode() ? "bytecode" : "native code", re->ShouldProduceBytecode() ? "bytecode" : "native code",
...@@ -714,7 +714,7 @@ int RegExpImpl::IrregexpExecRaw(Isolate* isolate, Handle<JSRegExp> regexp, ...@@ -714,7 +714,7 @@ int RegExpImpl::IrregexpExecRaw(Isolate* isolate, Handle<JSRegExp> regexp,
// The string has changed representation, and we must restart the // The string has changed representation, and we must restart the
// match. // match.
// We need to reset the tier up to start over with compilation. // We need to reset the tier up to start over with compilation.
if (FLAG_regexp_tier_up) regexp->ResetLastTierUpTick(); if (v8_flags.regexp_tier_up) regexp->ResetLastTierUpTick();
is_one_byte = String::IsOneByteRepresentationUnderneath(*subject); is_one_byte = String::IsOneByteRepresentationUnderneath(*subject);
EnsureCompiledIrregexp(isolate, regexp, subject, is_one_byte); EnsureCompiledIrregexp(isolate, regexp, subject, is_one_byte);
break; break;
...@@ -733,7 +733,7 @@ MaybeHandle<Object> RegExpImpl::IrregexpExec( ...@@ -733,7 +733,7 @@ MaybeHandle<Object> RegExpImpl::IrregexpExec(
subject = String::Flatten(isolate, subject); subject = String::Flatten(isolate, subject);
#ifdef DEBUG #ifdef DEBUG
if (FLAG_trace_regexp_bytecodes && regexp->ShouldProduceBytecode()) { if (v8_flags.trace_regexp_bytecodes && regexp->ShouldProduceBytecode()) {
PrintF("\n\nRegexp match: /%s/\n\n", regexp->source().ToCString().get()); PrintF("\n\nRegexp match: /%s/\n\n", regexp->source().ToCString().get());
PrintF("\n\nSubject string: '%s'\n\n", subject->ToCString().get()); PrintF("\n\nSubject string: '%s'\n\n", subject->ToCString().get());
} }
...@@ -743,10 +743,10 @@ MaybeHandle<Object> RegExpImpl::IrregexpExec( ...@@ -743,10 +743,10 @@ MaybeHandle<Object> RegExpImpl::IrregexpExec(
// slower than the jitted code execution. If the tier-up strategy is turned // slower than the jitted code execution. If the tier-up strategy is turned
// on, we want to avoid this performance penalty so we eagerly tier-up if the // on, we want to avoid this performance penalty so we eagerly tier-up if the
// subject string length is equal or greater than the given heuristic value. // subject string length is equal or greater than the given heuristic value.
if (FLAG_regexp_tier_up && if (v8_flags.regexp_tier_up &&
subject->length() >= JSRegExp::kTierUpForSubjectLengthValue) { subject->length() >= JSRegExp::kTierUpForSubjectLengthValue) {
regexp->MarkTierUpForNextExec(); regexp->MarkTierUpForNextExec();
if (FLAG_trace_regexp_tier_up) { if (v8_flags.trace_regexp_tier_up) {
PrintF( PrintF(
"Forcing tier-up for very long strings in " "Forcing tier-up for very long strings in "
"RegExpImpl::IrregexpExec\n"); "RegExpImpl::IrregexpExec\n");
...@@ -902,13 +902,13 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data, ...@@ -902,13 +902,13 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data,
return false; return false;
} }
if (FLAG_trace_regexp_graph) DotPrinter::DotPrint("Start", data->node); if (v8_flags.trace_regexp_graph) DotPrinter::DotPrint("Start", data->node);
// Create the correct assembler for the architecture. // Create the correct assembler for the architecture.
std::unique_ptr<RegExpMacroAssembler> macro_assembler; std::unique_ptr<RegExpMacroAssembler> macro_assembler;
if (data->compilation_target == RegExpCompilationTarget::kNative) { if (data->compilation_target == RegExpCompilationTarget::kNative) {
// Native regexp implementation. // Native regexp implementation.
DCHECK(!FLAG_jitless); DCHECK(!v8_flags.jitless);
NativeRegExpMacroAssembler::Mode mode = NativeRegExpMacroAssembler::Mode mode =
is_one_byte ? NativeRegExpMacroAssembler::LATIN1 is_one_byte ? NativeRegExpMacroAssembler::LATIN1
...@@ -959,14 +959,14 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data, ...@@ -959,14 +959,14 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data,
} }
macro_assembler->set_slow_safe(TooMuchRegExpCode(isolate, pattern)); macro_assembler->set_slow_safe(TooMuchRegExpCode(isolate, pattern));
if (FLAG_enable_experimental_regexp_engine_on_excessive_backtracks && if (v8_flags.enable_experimental_regexp_engine_on_excessive_backtracks &&
ExperimentalRegExp::CanBeHandled(data->tree, flags, ExperimentalRegExp::CanBeHandled(data->tree, flags,
data->capture_count)) { data->capture_count)) {
if (backtrack_limit == JSRegExp::kNoBacktrackLimit) { if (backtrack_limit == JSRegExp::kNoBacktrackLimit) {
backtrack_limit = FLAG_regexp_backtracks_before_fallback; backtrack_limit = v8_flags.regexp_backtracks_before_fallback;
} else { } else {
backtrack_limit = std::min( backtrack_limit = std::min(
backtrack_limit, FLAG_regexp_backtracks_before_fallback.value()); backtrack_limit, v8_flags.regexp_backtracks_before_fallback.value());
} }
macro_assembler->set_backtrack_limit(backtrack_limit); macro_assembler->set_backtrack_limit(backtrack_limit);
macro_assembler->set_can_fallback(true); macro_assembler->set_can_fallback(true);
...@@ -999,7 +999,7 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data, ...@@ -999,7 +999,7 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data,
RegExpMacroAssembler* macro_assembler_ptr = macro_assembler.get(); RegExpMacroAssembler* macro_assembler_ptr = macro_assembler.get();
#ifdef DEBUG #ifdef DEBUG
std::unique_ptr<RegExpMacroAssembler> tracer_macro_assembler; std::unique_ptr<RegExpMacroAssembler> tracer_macro_assembler;
if (FLAG_trace_regexp_assembler) { if (v8_flags.trace_regexp_assembler) {
tracer_macro_assembler.reset( tracer_macro_assembler.reset(
new RegExpMacroAssemblerTracer(isolate, macro_assembler_ptr)); new RegExpMacroAssemblerTracer(isolate, macro_assembler_ptr));
macro_assembler_ptr = tracer_macro_assembler.get(); macro_assembler_ptr = tracer_macro_assembler.get();
...@@ -1012,7 +1012,7 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data, ...@@ -1012,7 +1012,7 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data,
// Code / bytecode printing. // Code / bytecode printing.
{ {
#ifdef ENABLE_DISASSEMBLER #ifdef ENABLE_DISASSEMBLER
if (FLAG_print_regexp_code && if (v8_flags.print_regexp_code &&
data->compilation_target == RegExpCompilationTarget::kNative) { data->compilation_target == RegExpCompilationTarget::kNative) {
CodeTracer::Scope trace_scope(isolate->GetCodeTracer()); CodeTracer::Scope trace_scope(isolate->GetCodeTracer());
OFStream os(trace_scope.file()); OFStream os(trace_scope.file());
...@@ -1021,7 +1021,7 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data, ...@@ -1021,7 +1021,7 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data,
c->Disassemble(pattern_cstring.get(), os, isolate); c->Disassemble(pattern_cstring.get(), os, isolate);
} }
#endif #endif
if (FLAG_print_regexp_bytecode && if (v8_flags.print_regexp_bytecode &&
data->compilation_target == RegExpCompilationTarget::kBytecode) { data->compilation_target == RegExpCompilationTarget::kBytecode) {
Handle<ByteArray> bytecode = Handle<ByteArray>::cast(result.code); Handle<ByteArray> bytecode = Handle<ByteArray>::cast(result.code);
auto pattern_cstring = pattern->ToCString(); auto pattern_cstring = pattern->ToCString();
...@@ -1031,7 +1031,7 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data, ...@@ -1031,7 +1031,7 @@ bool RegExpImpl::Compile(Isolate* isolate, Zone* zone, RegExpCompileData* data,
} }
if (result.error != RegExpError::kNone) { if (result.error != RegExpError::kNone) {
if (FLAG_correctness_fuzzer_suppressions && if (v8_flags.correctness_fuzzer_suppressions &&
result.error == RegExpError::kStackOverflow) { result.error == RegExpError::kStackOverflow) {
FATAL("Aborting on stack overflow"); FATAL("Aborting on stack overflow");
} }
......
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