[webkit-changes] [WebKit/WebKit] e0132b: [JSC] Node's JSTokenLocation sometimes doesn't poi...
Commit Queue
noreply at github.com
Fri Jan 19 19:11:19 PST 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e0132b80a4223be92a41f2b65a34b6342eab6f76
https://github.com/WebKit/WebKit/commit/e0132b80a4223be92a41f2b65a34b6342eab6f76
Author: Alexey Shvayka <ashvayka at apple.com>
Date: 2024-01-19 (Fri, 19 Jan 2024)
Changed paths:
A JSTests/stress/regress-267728.js
M Source/JavaScriptCore/builtins/BuiltinExecutables.cpp
M Source/JavaScriptCore/parser/ASTBuilder.h
M Source/JavaScriptCore/parser/Parser.cpp
M Source/JavaScriptCore/parser/Parser.h
M Source/JavaScriptCore/parser/SyntaxChecker.h
M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewConfiguration.mm
Log Message:
-----------
[JSC] Node's JSTokenLocation sometimes doesn't point to the start of an expression
https://bugs.webkit.org/show_bug.cgi?id=267728
<rdar://problem/121215280>
Reviewed by Justin Michaud.
Before this patch, if we tried to reparse at node->position(), we would fail with SyntaxError for
object / array literals, async (arrow) functions, and member expressions with `new` / optional chaining,
due to Node's JSTokenLocation not pointing to the start of an expression.
This change fixes JSTokenLocation to be correct for above-mentioned cases, enabling us to redesign
class field initializers reparsing, and also improves accuracy of expression divots by removing
lastTokenEndPosition() usage from OPENBRACKET / DOT / BACKQUOTE cases of parseMemberExpression().
lastTokenEndPosition() makes sense in case of e.g. parseArguments() because after it exits, the
current token is the next one after `)`, yet in the e.g. DOT case, lastTokenEndPosition() most
likely points to previous identifier, which might be even on a different line.
On top of that, this patch improves stack trace accuracy for `new new new C` expressions by
storing position of each NEW token in a vector.
Aligns stack traces (error locations) with V8 and SpiderMonkey, including for modified API test.
* JSTests/stress/regress-267728.js: Added.
* Source/JavaScriptCore/builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* Source/JavaScriptCore/parser/ASTBuilder.h:
(JSC::ASTBuilder::createNewExpr):
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseAssignmentExpression):
(JSC::Parser<LexerType>::parseObjectLiteral):
(JSC::Parser<LexerType>::parseArrayLiteral):
(JSC::Parser<LexerType>::parseAsyncFunctionExpression):
(JSC::Parser<LexerType>::parsePrimaryExpression):
(JSC::Parser<LexerType>::parseMemberExpression):
(JSC::Parser<LexerType>::parseArrowFunctionExpression):
* Source/JavaScriptCore/parser/Parser.h:
* Source/JavaScriptCore/parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createNewExpr):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebViewConfiguration.mm:
Canonical link: https://commits.webkit.org/273255@main
More information about the webkit-changes
mailing list