Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.11',
'v8_embedder_string': '-node.12',

##### V8 defaults for Node.js #####

Expand Down
16 changes: 11 additions & 5 deletions deps/v8/src/regexp/regexp-compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3236,20 +3236,25 @@ void ChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) {
int text_length = FixedLengthLoopLengthForAlternative(&alternatives_->at(0));
AlternativeGenerationList alt_gens(choice_count, zone());

// Flags need to be reset to the state of the ChoiceNode at the beginning
// of each alternative (in-line and out-of-line), as flags might be modified
// when emitting an alternative.
RegExpFlags flags = compiler->flags();
if (choice_count > 1 && text_length != kNodeIsTooComplexForFixedLengthLoops) {
trace = EmitFixedLengthLoop(compiler, trace, &alt_gens, &preload,
&fixed_length_loop_state, text_length);
&fixed_length_loop_state, text_length, flags);
} else {
preload.eats_at_least_ = EmitOptimizedUnanchoredSearch(compiler, trace);

EmitChoices(compiler, &alt_gens, 0, trace, &preload);
EmitChoices(compiler, &alt_gens, 0, trace, &preload, flags);
}

// At this point we need to generate slow checks for the alternatives where
// the quick check was inlined. We can recognize these because the associated
// label was bound.
int new_flush_budget = trace->flush_budget() / choice_count;
for (int i = 0; i < choice_count; i++) {
compiler->set_flags(flags);
AlternativeGeneration* alt_gen = alt_gens.at(i);
Trace new_trace(*trace);
// If there are actions to be flushed we have to limit how many times
Expand All @@ -3269,7 +3274,7 @@ void ChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) {
Trace* ChoiceNode::EmitFixedLengthLoop(
RegExpCompiler* compiler, Trace* trace, AlternativeGenerationList* alt_gens,
PreloadState* preload, FixedLengthLoopState* fixed_length_loop_state,
int text_length) {
int text_length, RegExpFlags flags) {
RegExpMacroAssembler* macro_assembler = compiler->macro_assembler();
// Here we have special handling for greedy loops containing only text nodes
// and other simple nodes. We call these fixed length loops. These are
Expand All @@ -3296,7 +3301,7 @@ Trace* ChoiceNode::EmitFixedLengthLoop(

// In a fixed length loop there is only one other choice, which is what
// comes after the greedy quantifer. Try to match that now.
EmitChoices(compiler, alt_gens, 1, new_trace, preload);
EmitChoices(compiler, alt_gens, 1, new_trace, preload, flags);

fixed_length_loop_state->BindStepBackwardsLabel(macro_assembler);
// If we have unwound to the bottom then backtrack.
Expand Down Expand Up @@ -3356,7 +3361,7 @@ int ChoiceNode::EmitOptimizedUnanchoredSearch(RegExpCompiler* compiler,
void ChoiceNode::EmitChoices(RegExpCompiler* compiler,
AlternativeGenerationList* alt_gens,
int first_choice, Trace* trace,
PreloadState* preload) {
PreloadState* preload, RegExpFlags flags) {
RegExpMacroAssembler* macro_assembler = compiler->macro_assembler();
SetUpPreLoad(compiler, trace, preload);

Expand All @@ -3367,6 +3372,7 @@ void ChoiceNode::EmitChoices(RegExpCompiler* compiler,
int new_flush_budget = trace->flush_budget() / choice_count;

for (int i = first_choice; i < choice_count; i++) {
compiler->set_flags(flags);
bool is_last = i == choice_count - 1;
bool fall_through_on_failure = !is_last;
GuardedAlternative alternative = alternatives_->at(i);
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/regexp/regexp-nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,10 +709,10 @@ class ChoiceNode : public RegExpNode {
AlternativeGenerationList* alt_gens,
PreloadState* preloads,
FixedLengthLoopState* fixed_length_loop_state,
int text_length);
int text_length, RegExpFlags flags);
void EmitChoices(RegExpCompiler* compiler,
AlternativeGenerationList* alt_gens, int first_choice,
Trace* trace, PreloadState* preloads);
Trace* trace, PreloadState* preloads, RegExpFlags flags);

// If true, this node is never checked at the start of the input.
// Allows a new trace to start with at_start() set to false.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ test(/F(?i:oo(?-i:b)a)r/, ['Foobar', 'FoObAr'], ['FooBar', 'FoobaR']);
test(/F(?i:oo(?i:b)a)r/, ['Foobar', 'FoObAr', 'FOOBAr'], ['FoobaR']);
test(/^[a-z](?-i:[a-z])$/i, ['ab', 'Ab'], ['aB']);
test(/^(?i:[a-z])[a-z]$/, ['ab', 'Ab'], ['aB']);
test(/(?i:foo|bar)/, ['FOO', 'FOo', 'Foo', 'fOO', 'BAR', 'BAr', 'Bar', 'bAR']);
test(/(?i:foo|bar|baz)/, [
'FOO', 'FOo', 'Foo', 'fOO', 'BAR', 'BAr', 'Bar', 'bAR', 'BAZ', 'BAz', 'Baz',
'bAZ'
]);
test(
/Foo(?i:B[\q{ĀĂĄ|AaA}--\q{āăą}])r/v, ['FooBaaar', 'FoobAAAr'],
['FooBĀĂĄr', 'FooBaaaR']);
Expand Down
Loading