Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[JSC] Not generating import.meta object if it is not referenced
https://bugs.webkit.org/show_bug.cgi?id=244176 Reviewed by Ross Kirsling. `import.meta` is only available in modules. And eval, function constructor etc. cannot evaluate it. This means that we can detect `import.meta` existence when parsing statically. This patch collects this information and avoid to materialize it if it is not referenced. * Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedCodeBlock::usesImportMeta const): * Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.h: * Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): * Source/JavaScriptCore/parser/ModuleAnalyzer.cpp: (JSC::ModuleAnalyzer::ModuleAnalyzer): (JSC::ModuleAnalyzer::analyze): * Source/JavaScriptCore/parser/ModuleAnalyzer.h: (JSC::ModuleAnalyzer::moduleRecord): * Source/JavaScriptCore/parser/Parser.cpp: (JSC::Parser<LexerType>::parseInner): (JSC::Parser<LexerType>::parseMemberExpression): * Source/JavaScriptCore/parser/Parser.h: (JSC::Scope::Scope): (JSC::Scope::isLexicalScope const): (JSC::Scope::usesEval const): (JSC::Scope::usesImportMeta const): (JSC::Scope::setUsesImportMeta): (JSC::Scope::setExpectedSuperBinding): (JSC::Scope::expectedSuperBinding const): (JSC::Scope::setConstructorKind): (JSC::Scope::constructorKind const): (JSC::Scope::collectFreeVariables): (JSC::Scope::fillParametersForSourceProviderCache): (JSC::Scope::restoreFromSourceProviderCache): (JSC::Scope::isLexicalScope): Deleted. (JSC::Scope::usesEval): Deleted. * Source/JavaScriptCore/parser/ParserModes.h: * Source/JavaScriptCore/parser/SourceProviderCacheItem.h: (JSC::SourceProviderCacheItem::SourceProviderCacheItem): * Source/JavaScriptCore/runtime/Completion.cpp: (JSC::checkModuleSyntax): * Source/JavaScriptCore/runtime/JSModuleLoader.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * Source/JavaScriptCore/runtime/JSModuleRecord.cpp: (JSC::JSModuleRecord::create): (JSC::JSModuleRecord::JSModuleRecord): (JSC::JSModuleRecord::instantiateDeclarations): * Source/JavaScriptCore/runtime/JSModuleRecord.h: * Source/JavaScriptCore/runtime/SyntheticModuleRecord.cpp: (JSC::SyntheticModuleRecord::tryCreateWithExportNamesAndValues): Canonical link: https://commits.webkit.org/253636@main
- Loading branch information
1 parent
609758e
commit 1e07f486b4a0bf18fe258b8d1a5f6cb343f0d5b4
Showing
15 changed files
with
101 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { shouldThrow } from "./resources/assert.js"; | ||
|
||
shouldThrow(() => { | ||
eval('import.meta'); | ||
}, `SyntaxError: import.meta is only valid inside modules.`); | ||
|
||
shouldThrow(() => { | ||
new Function('import.meta')(); | ||
}, `SyntaxError: import.meta is only valid inside modules.`); | ||
|
||
shouldThrow(() => { | ||
(void 0, eval)('import.meta'); | ||
}, `SyntaxError: import.meta is only valid inside modules.`); |
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
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.