mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
deps: V8: backport d315af3d83cf
Original commit message:
[regexp] Reset compiler flags between word boundary branches
When compiling \b and \B word boundary checks in AssertionNode where the
succeeding character type is unknown, two code paths (before_non_word and
before_word) are generated sequentially.
If the boundary assertion is placed inside a modifier group (e.g.
(?i:\.|\bNULL)), emitting the first branch traverses through on_success
and reaches the ActionNode that restores outer flags at group exit.
This mutates flags without restoring it when returning to emit the
second branch. Consequently, subsequent nodes in the second branch
(before_word) were incorrectly compiled with outer flags instead
of the modifier group's flags.
This CL saves compiler->flags() and restores them before emitting the
before_word branch in AssertionNode::EmitBoundaryCheck.
TAG=agy
Fixed: 544575761
Change-Id: I7f08bcb99c749d5e22636c8bd6eb44bd1d3e2e39
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8257209
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Commit-Queue: Patrick Thier <pthier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#109236}
Refs: https://github.com/v8/v8/commit/d315af3d83cfe3bc1709f5b140db393db42790b3
Refs: https://github.com/nodejs/node/issues/66277
PR-URL: https://github.com/nodejs/node/pull/67207
Reviewed-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 parent
3c0d8636c3
commit
e37da67f49
3 files changed
+16
-1
No files matched your search
+1
-1
@@ -44,7 +44,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.46',
|
||||
'v8_embedder_string': '-node.47',
|
||||
|
||||
##### V8 defaults for Node.js #####
|
||||
|
||||
|
||||
+2
@@ -2134,6 +2134,7 @@ EmitResult AssertionNode::EmitBoundaryCheck(RegExpCompiler* compiler,
|
||||
}
|
||||
bool at_boundary = (assertion_type_ == AssertionNode::AT_BOUNDARY);
|
||||
if (next_is_word_character == Trace::UNKNOWN) {
|
||||
const RegExpFlags flags = compiler->flags();
|
||||
Label before_non_word;
|
||||
Label before_word;
|
||||
if (trace->characters_preloaded() != 1) {
|
||||
@@ -2148,6 +2149,7 @@ EmitResult AssertionNode::EmitBoundaryCheck(RegExpCompiler* compiler,
|
||||
at_boundary ? kIsNonWord : kIsWord));
|
||||
assembler->GoTo(&ok);
|
||||
|
||||
compiler->set_flags(flags);
|
||||
assembler->Bind(&before_word);
|
||||
RETURN_IF_ERROR(BacktrackIfPrevious(compiler, trace,
|
||||
at_boundary ? kIsWord : kIsNonWord));
|
||||
|
||||
+13
@@ -89,3 +89,16 @@ test(
|
||||
/^(?-i:(?:a|b)(?:c|d)(?:e|f)(?:g|h)(?:i|j)(?:k|l)(?:m|n)x)/i,
|
||||
['acegikmx', 'bdfhjlnx'],
|
||||
['acegikmX', 'bdfhjlnX']);
|
||||
|
||||
// Boundary assertions inside modifier groups with alternations must not leak
|
||||
// flags between branches during code generation.
|
||||
test(/(?i:\.|\bNULL)/, ['null', 'NULL', 'Null', '.foo'], ['xyz']);
|
||||
test(/(?i:\bNULL|\.)/, ['null', 'NULL', '.foo'], ['xyz']);
|
||||
test(/(?i:\.|\BNULL)/, ['xnull', 'xNULL'], ['null', 'xyz']);
|
||||
test(/(?i:\W|\bNULL)/, ['null', 'NULL', '!'], ['x']);
|
||||
test(/(?i:!|\?|\bNULL)/, ['null', 'NULL', '!', '?'], ['x']);
|
||||
test(/(?i:\.|\bnUll)/, ['null', 'NULL']);
|
||||
test(/(?i:\.|\bnuLl)/, ['null', 'NULL']);
|
||||
test(/(?i:\.|\bnulL)/, ['null', 'NULL']);
|
||||
test(/(?-i:(?i:\.|\bNULL))/, ['null', 'NULL', '.foo'], ['xyz']);
|
||||
test(/(?i:(?-i:\.|\bNULL))/, ['NULL', '.foo'], ['null', 'xyz']);
|
||||
Reference in new issue
Block a user