-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick d8aca95. rdar://123524381
[JSC] Set correct ConstructorKind when reparsing functions https://bugs.webkit.org/show_bug.cgi?id=269869 <rdar://problem/123401267> Reviewed by Justin Michaud. Before this change, when reparsing a function, ConstructorKind was always set to None, which prevents a parser-level workaround to fix https://webkit.org/b/268411. Also, ConstructorKind was abused to allow super() in eval(): please see Parser constructor. However, passing down ConstructorKind to parser isn't trivial as it would conflict with `defaultConstructorKindForTopLevelFunction` that is needed only for bytecode validation. To avoid using one parameter for two purposes, this patch extracts parseRootNode(), which has parameters special for debugger / bytecode validation while lacking ones needed only for functions. overrideConstructorKindForTopLevelFunctionExpressions() is introduced for the same purpose. Also, this change: * passes correct DerivedContextType for eval() and reimplements SyntaxError check for super(), all to avoid setting ConstructorKind for non-functions; * hoists ConstructorKind override for bytecode validation up to parseFunctionExpression() to limit the surface of this bytecode validation only hack; * removes unused ParsingContext::Eval. No new tests, no behavior change. * Source/JavaScriptCore/API/JSScriptRef.cpp: (parseScript): * Source/JavaScriptCore/builtins/BuiltinExecutables.cpp: (JSC::BuiltinExecutables::createExecutable): * Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp: (JSC::generateUnlinkedFunctionCodeBlock): * Source/JavaScriptCore/debugger/DebuggerParseData.cpp: (JSC::gatherDebuggerParseData): * Source/JavaScriptCore/parser/Parser.cpp: (JSC::Parser<LexerType>::Parser): (JSC::Parser<LexerType>::parseFunctionInfo): (JSC::Parser<LexerType>::parseFunctionExpression): (JSC::Parser<LexerType>::parseMemberExpression): * Source/JavaScriptCore/parser/Parser.h: (JSC::Scope::setDerivedContextType): (JSC::Scope::derivedContextType const): (JSC::Parser::overrideConstructorKindForTopLevelFunctionExpressions): (JSC::parse): (JSC::parseRootNode): * Source/JavaScriptCore/runtime/CodeCache.cpp: (JSC::generateUnlinkedCodeBlockImpl): * Source/JavaScriptCore/runtime/Completion.cpp: (JSC::checkSyntaxInternal): (JSC::checkModuleSyntax): * Source/JavaScriptCore/runtime/JSModuleLoader.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): Canonical link: https://commits.webkit.org/275189@main Canonical link: https://commits.webkit.org/274941.55@safari-7619.1.5-branch
- Loading branch information
Alexey Shvayka
authored and
Dan Robson
committed
Mar 3, 2024
1 parent
4e7939d
commit 3ba5278
Showing
9 changed files
with
95 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.