WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-147876-20150814174904.patch (text/plain), 111.53 KB, created by
Yusuke Suzuki
on 2015-08-14 17:49:23 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2015-08-14 17:49:23 PDT
Size:
111.53 KB
patch
obsolete
>Subversion Revision: 188498 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index fbf8c14719891ff319b3050d0d51caa73c40eb59..ae670cf0dc1600aee243622d6518f05152b6ac01 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,138 @@ >+2015-08-14 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ [ES6] prototyping module loader in JSC shell >+ https://bugs.webkit.org/show_bug.cgi?id=147876 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * DerivedSources.make: >+ * JavaScriptCore.xcodeproj/project.pbxproj: >+ * builtins/BuiltinNames.h: >+ (JSC::BuiltinNames::lookUpPrivateName): >+ (JSC::BuiltinNames::lookUpPublicName): >+ (JSC::BuiltinNames::getPrivateName): Deleted. >+ (JSC::BuiltinNames::getPublicName): Deleted. >+ * builtins/ModuleLoaderObject.js: Added. >+ (setStateToMax): >+ (newRegistryEntry): >+ (forceFulfillPromise): >+ (fulfillFetch): >+ (fulfillTranslate): >+ (fulfillInstantiate): >+ (instantiation): >+ (requestFetch): >+ (requestTranslate): >+ (requestInstantiate): >+ (requestInstantiateAll.return.this.requestInstantiate.then.): >+ (requestInstantiateAll.return.this.requestInstantiate.then): >+ (requestInstantiateAll): >+ * builtins/Operations.Promise.js: >+ (.onFulfilled): >+ (.onRejected): >+ (promiseThen): >+ * builtins/Promise.prototype.js: >+ (then): >+ (privateThen): >+ (.onFulfilled): Deleted. >+ (.onRejected): Deleted. >+ * builtins/PromiseConstructor.js: >+ (privateAll.newResolveElement): >+ (privateAll): >+ * jsc.cpp: >+ (stringFromUTF): >+ (jscSource): >+ (GlobalObject::loaderFetch): >+ (functionCheckModuleSyntax): >+ * parser/Lexer.cpp: >+ (JSC::Lexer<LChar>::parseIdentifier): >+ (JSC::Lexer<UChar>::parseIdentifier): >+ * parser/ModuleAnalyzer.cpp: >+ (JSC::ModuleAnalyzer::ModuleAnalyzer): >+ (JSC::ModuleAnalyzer::exportVariable): >+ (JSC::ModuleAnalyzer::analyze): >+ * parser/ModuleAnalyzer.h: >+ (JSC::ModuleAnalyzer::moduleRecord): >+ * parser/ModuleRecord.cpp: >+ (JSC::printableName): Deleted. >+ (JSC::ModuleRecord::dump): Deleted. >+ * parser/ModuleRecord.h: >+ (JSC::ModuleRecord::ImportEntry::isNamespace): Deleted. >+ (JSC::ModuleRecord::create): Deleted. >+ (JSC::ModuleRecord::appendRequestedModule): Deleted. >+ (JSC::ModuleRecord::addImportEntry): Deleted. >+ (JSC::ModuleRecord::addExportEntry): Deleted. >+ (JSC::ModuleRecord::addStarExportEntry): Deleted. >+ * parser/Nodes.h: >+ * parser/NodesAnalyzeModule.cpp: >+ (JSC::ImportDeclarationNode::analyzeModule): >+ (JSC::ExportAllDeclarationNode::analyzeModule): >+ (JSC::ExportNamedDeclarationNode::analyzeModule): >+ * runtime/CommonIdentifiers.cpp: >+ (JSC::CommonIdentifiers::lookUpPrivateName): >+ (JSC::CommonIdentifiers::lookUpPublicName): >+ (JSC::CommonIdentifiers::getPrivateName): Deleted. >+ (JSC::CommonIdentifiers::getPublicName): Deleted. >+ * runtime/CommonIdentifiers.h: >+ * runtime/Completion.cpp: >+ (JSC::checkModuleSyntax): >+ * runtime/Completion.h: >+ * runtime/ExceptionHelpers.cpp: >+ (JSC::createUndefinedVariableError): >+ * runtime/Identifier.h: >+ * runtime/JSGlobalObject.cpp: >+ (JSC::JSGlobalObject::init): >+ (JSC::JSGlobalObject::visitChildren): >+ * runtime/JSGlobalObject.h: >+ (JSC::JSGlobalObject::moduleRecordStructure): >+ (JSC::JSGlobalObject::promiseConstructor): Deleted. >+ (JSC::JSGlobalObject::promisePrototype): Deleted. >+ (JSC::JSGlobalObject::promiseStructure): Deleted. >+ * runtime/JSModuleRecord.cpp: Renamed from Source/JavaScriptCore/parser/ModuleRecord.cpp. >+ (JSC::JSModuleRecord::destroy): >+ (JSC::printableName): >+ (JSC::JSModuleRecord::dump): >+ * runtime/JSModuleRecord.h: Renamed from Source/JavaScriptCore/parser/ModuleRecord.h. >+ (JSC::JSModuleRecord::ImportEntry::isNamespace): >+ (JSC::JSModuleRecord::createStructure): >+ (JSC::JSModuleRecord::create): >+ (JSC::JSModuleRecord::requestedModules): >+ (JSC::JSModuleRecord::JSModuleRecord): >+ (JSC::JSModuleRecord::appendRequestedModule): >+ (JSC::JSModuleRecord::addImportEntry): >+ (JSC::JSModuleRecord::addExportEntry): >+ (JSC::JSModuleRecord::addStarExportEntry): >+ * runtime/JSPromiseConstructor.cpp: >+ (JSC::JSPromiseConstructor::finishCreation): >+ * runtime/JSPromiseDeferred.cpp: >+ (JSC::callFunction): >+ (JSC::JSPromiseDeferred::resolve): >+ (JSC::JSPromiseDeferred::reject): >+ * runtime/JSPromiseDeferred.h: >+ * runtime/JSPromisePrototype.cpp: >+ (JSC::JSPromisePrototype::create): >+ (JSC::JSPromisePrototype::JSPromisePrototype): >+ (JSC::JSPromisePrototype::finishCreation): >+ * runtime/JSPromisePrototype.h: >+ * runtime/MapPrototype.cpp: >+ (JSC::MapPrototype::finishCreation): >+ * runtime/ModuleLoaderObject.cpp: Added. >+ (JSC::ModuleLoaderObject::ModuleLoaderObject): >+ (JSC::ModuleLoaderObject::finishCreation): >+ (JSC::ModuleLoaderObject::getOwnPropertySlot): >+ (JSC::ModuleLoaderObject::resolve): >+ (JSC::ModuleLoaderObject::fetch): >+ (JSC::ModuleLoaderObject::translate): >+ (JSC::ModuleLoaderObject::instantiate): >+ (JSC::moduleLoaderObjectParseModule): >+ (JSC::moduleLoaderObjectRequestedModules): >+ (JSC::moduleLoaderObjectResolve): >+ (JSC::moduleLoaderObjectFetch): >+ (JSC::moduleLoaderObjectTranslate): >+ (JSC::moduleLoaderObjectInstantiate): >+ * runtime/ModuleLoaderObject.h: Copied from Source/JavaScriptCore/parser/ModuleAnalyzer.h. >+ (JSC::ModuleLoaderObject::create): >+ (JSC::ModuleLoaderObject::createStructure): >+ > 2015-08-14 Ryosuke Niwa <rniwa@webkit.org> > > ES6 class syntax should allow computed name method >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index bf7f73a2d80d27ab8b643b380b6957c541d90d99..ab5e0510f914120fae7a6a9d98d74c4de624587e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,15 @@ >+2015-08-14 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ [ES6] prototyping module loader in JSC shell >+ https://bugs.webkit.org/show_bug.cgi?id=147876 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests (OOPS!). >+ >+ * bindings/js/JSDOMWindowBase.cpp: >+ * bindings/js/JSWorkerGlobalScopeBase.cpp: >+ > 2015-08-14 Matthew Daiter <mdaiter@apple.com> > > Implementing enumerateDevices >diff --git a/Source/JavaScriptCore/DerivedSources.make b/Source/JavaScriptCore/DerivedSources.make >index 1cb2d5cba3bd35e209f9d2c7bb467b2b96f7fa5d..53abdb6adcb7108e7ef193b96995649595f2c151 100644 >--- a/Source/JavaScriptCore/DerivedSources.make >+++ b/Source/JavaScriptCore/DerivedSources.make >@@ -55,6 +55,7 @@ all : \ > JSPromiseConstructor.lut.h \ > KeywordLookup.h \ > Lexer.lut.h \ >+ ModuleLoaderObject.lut.h \ > NumberConstructor.lut.h \ > NumberPrototype.lut.h \ > ObjectConstructor.lut.h \ >diff --git a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >index fdc68371ddb2be5534941f832c8c7201b406daaf..96925740992c7e329f0abb5f7b9271f70f763ad9 100644 >--- a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >+++ b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >@@ -1694,13 +1694,15 @@ > E33637A61B63220200EE0840 /* ReflectObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E33637A41B63220200EE0840 /* ReflectObject.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E33B3E261B7ABD750048DB2E /* InspectorInstrumentationObject.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = E33B3E251B7ABD750048DB2E /* InspectorInstrumentationObject.lut.h */; }; > E354622B1B6065D100545386 /* ConstructAbility.h in Headers */ = {isa = PBXBuildFile; fileRef = E354622A1B6065D100545386 /* ConstructAbility.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ E355F3521B7DC85300C50DC5 /* ModuleLoaderObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E355F3501B7DC85300C50DC5 /* ModuleLoaderObject.cpp */; }; >+ E355F3531B7DC85300C50DC5 /* ModuleLoaderObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E355F3511B7DC85300C50DC5 /* ModuleLoaderObject.h */; }; > E3794E751B77EB97005543AE /* ModuleAnalyzer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3794E731B77EB97005543AE /* ModuleAnalyzer.cpp */; }; > E3794E761B77EB97005543AE /* ModuleAnalyzer.h in Headers */ = {isa = PBXBuildFile; fileRef = E3794E741B77EB97005543AE /* ModuleAnalyzer.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- E3963CED1B73F75000EB4CE5 /* ModuleRecord.h in Headers */ = {isa = PBXBuildFile; fileRef = E3963CEB1B73F75000EB4CE5 /* ModuleRecord.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E3963CEE1B73F75000EB4CE5 /* NodesAnalyzeModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3963CEC1B73F75000EB4CE5 /* NodesAnalyzeModule.cpp */; }; >- E3C09F551B79692A00EE36A2 /* ModuleRecord.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3C09F541B79692A00EE36A2 /* ModuleRecord.cpp */; }; > E35E035F1B7AB43E0073AD2A /* InspectorInstrumentationObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E35E035D1B7AB43E0073AD2A /* InspectorInstrumentationObject.cpp */; }; > E35E03601B7AB43E0073AD2A /* InspectorInstrumentationObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E35E035E1B7AB43E0073AD2A /* InspectorInstrumentationObject.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ E39DA4A61B7E8B7C0084F33A /* JSModuleRecord.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E39DA4A41B7E8B7C0084F33A /* JSModuleRecord.cpp */; }; >+ E39DA4A71B7E8B7C0084F33A /* JSModuleRecord.h in Headers */ = {isa = PBXBuildFile; fileRef = E39DA4A51B7E8B7C0084F33A /* JSModuleRecord.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E3EF88741B66DF23003F26CB /* JSPropertyNameIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3EF88721B66DF23003F26CB /* JSPropertyNameIterator.cpp */; }; > E3EF88751B66DF23003F26CB /* JSPropertyNameIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E3EF88731B66DF23003F26CB /* JSPropertyNameIterator.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E49DC16B12EF293E00184A1F /* SourceProviderCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E49DC15512EF277200184A1F /* SourceProviderCache.cpp */; }; >@@ -3526,14 +3528,16 @@ > E33637A41B63220200EE0840 /* ReflectObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReflectObject.h; sourceTree = "<group>"; }; > E33B3E251B7ABD750048DB2E /* InspectorInstrumentationObject.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InspectorInstrumentationObject.lut.h; path = InspectorInstrumentationObject.lut.h; sourceTree = "<group>"; }; > E354622A1B6065D100545386 /* ConstructAbility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConstructAbility.h; sourceTree = "<group>"; }; >+ E355F3501B7DC85300C50DC5 /* ModuleLoaderObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModuleLoaderObject.cpp; sourceTree = "<group>"; }; >+ E355F3511B7DC85300C50DC5 /* ModuleLoaderObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleLoaderObject.h; sourceTree = "<group>"; }; > E3794E731B77EB97005543AE /* ModuleAnalyzer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModuleAnalyzer.cpp; sourceTree = "<group>"; }; > E3794E741B77EB97005543AE /* ModuleAnalyzer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleAnalyzer.h; sourceTree = "<group>"; }; >- E3963CEB1B73F75000EB4CE5 /* ModuleRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleRecord.h; sourceTree = "<group>"; }; > E3963CEC1B73F75000EB4CE5 /* NodesAnalyzeModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NodesAnalyzeModule.cpp; sourceTree = "<group>"; }; >- E3C09F541B79692A00EE36A2 /* ModuleRecord.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModuleRecord.cpp; sourceTree = "<group>"; }; > E35E035D1B7AB43E0073AD2A /* InspectorInstrumentationObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorInstrumentationObject.cpp; sourceTree = "<group>"; }; > E35E035E1B7AB43E0073AD2A /* InspectorInstrumentationObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorInstrumentationObject.h; sourceTree = "<group>"; }; > E35E03611B7AB4850073AD2A /* InspectorInstrumentationObject.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = InspectorInstrumentationObject.js; sourceTree = "<group>"; }; >+ E39DA4A41B7E8B7C0084F33A /* JSModuleRecord.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSModuleRecord.cpp; sourceTree = "<group>"; }; >+ E39DA4A51B7E8B7C0084F33A /* JSModuleRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSModuleRecord.h; sourceTree = "<group>"; }; > E3EF88721B66DF23003F26CB /* JSPropertyNameIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPropertyNameIterator.cpp; sourceTree = "<group>"; }; > E3EF88731B66DF23003F26CB /* JSPropertyNameIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPropertyNameIterator.h; sourceTree = "<group>"; }; > E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SourceProviderCacheItem.h; sourceTree = "<group>"; }; >@@ -4446,8 +4450,6 @@ > F692A8660255597D01FF60F7 /* Lexer.h */, > E3794E731B77EB97005543AE /* ModuleAnalyzer.cpp */, > E3794E741B77EB97005543AE /* ModuleAnalyzer.h */, >- E3C09F541B79692A00EE36A2 /* ModuleRecord.cpp */, >- E3963CEB1B73F75000EB4CE5 /* ModuleRecord.h */, > 930DAD030FB1EB1A0082D205 /* NodeConstructors.h */, > F692A86D0255597D01FF60F7 /* Nodes.cpp */, > F692A86E0255597D01FF60F7 /* Nodes.h */, >@@ -4709,6 +4711,8 @@ > A700874017CBE8EB00C3E643 /* JSMap.h */, > A74DEF8F182D991400522C22 /* JSMapIterator.cpp */, > A74DEF90182D991400522C22 /* JSMapIterator.h */, >+ E39DA4A41B7E8B7C0084F33A /* JSModuleRecord.cpp */, >+ E39DA4A51B7E8B7C0084F33A /* JSModuleRecord.h */, > A72700780DAC605600E548D7 /* JSNotAnObject.cpp */, > A72700770DAC605600E548D7 /* JSNotAnObject.h */, > BC22A3980E16E14800AF21C8 /* JSObject.cpp */, >@@ -4788,6 +4792,8 @@ > 90213E3B123A40C200D422F3 /* MemoryStatistics.cpp */, > 90213E3C123A40C200D422F3 /* MemoryStatistics.h */, > 7C008CE5187631B600955C24 /* Microtask.h */, >+ E355F3501B7DC85300C50DC5 /* ModuleLoaderObject.cpp */, >+ E355F3511B7DC85300C50DC5 /* ModuleLoaderObject.h */, > BC02E9080E1839DB000F9297 /* NativeErrorConstructor.cpp */, > BC02E9090E1839DB000F9297 /* NativeErrorConstructor.h */, > BC02E90A0E1839DB000F9297 /* NativeErrorPrototype.cpp */, >@@ -5795,6 +5801,7 @@ > files = ( > 0FFA549816B8835300B3A982 /* A64DOpcode.h in Headers */, > 860161E30F3A83C100F84710 /* AbstractMacroAssembler.h in Headers */, >+ E355F3531B7DC85300C50DC5 /* ModuleLoaderObject.h in Headers */, > 0FE050291AA9095600D33B33 /* ScopedArgumentsTable.h in Headers */, > 0F55F0F514D1063C00AC7649 /* AbstractPC.h in Headers */, > 2A48D1911772365B00C65A5F /* APICallbackFunction.h in Headers */, >@@ -6193,7 +6200,6 @@ > 0FCEFAAC1804C13E00472CE4 /* FTLSaveRestore.h in Headers */, > 0F25F1B2181635F300522F39 /* FTLSlowPathCall.h in Headers */, > E354622B1B6065D100545386 /* ConstructAbility.h in Headers */, >- E3963CED1B73F75000EB4CE5 /* ModuleRecord.h in Headers */, > 0F25F1B4181635F300522F39 /* FTLSlowPathCallKey.h in Headers */, > 0F9D339B1803ADB70073C2BC /* FTLStackMaps.h in Headers */, > 0FEA0A12170513DB00BB722C /* FTLState.h in Headers */, >@@ -6214,6 +6220,7 @@ > BCBE2CAE14E985AA000593AD /* GCAssertions.h in Headers */, > 0F766D3015A8DCE2008F363E /* GCAwareJITStubRoutine.h in Headers */, > 70EC0EC71AA0D7DA00B6AAFA /* StringIteratorPrototype.h in Headers */, >+ E39DA4A71B7E8B7C0084F33A /* JSModuleRecord.h in Headers */, > 0F2B66AC17B6B53F00A7AE3F /* GCIncomingRefCounted.h in Headers */, > 0F2B66AD17B6B54500A7AE3F /* GCIncomingRefCountedInlines.h in Headers */, > 0F2B66AE17B6B54500A7AE3F /* GCIncomingRefCountedSet.h in Headers */, >@@ -7329,6 +7336,7 @@ > 2A88067819107D5500CB0BBB /* DFGFunctionWhitelist.cpp in Sources */, > 0F2DD8131AB3D8BE00BBB8E8 /* DFGArgumentsUtilities.cpp in Sources */, > A7D89CF317A0B8CC00773AD8 /* DFGBlockInsertionSet.cpp in Sources */, >+ E355F3521B7DC85300C50DC5 /* ModuleLoaderObject.cpp in Sources */, > 86EC9DC41328DF82002B2AD7 /* DFGByteCodeParser.cpp in Sources */, > 0FD82E2114172CE300179C94 /* DFGCapabilities.cpp in Sources */, > 0F2B9CE619D0BA7D00B1D1B5 /* DFGObjectAllocationSinkingPhase.cpp in Sources */, >@@ -7616,7 +7624,6 @@ > 0F2B66ED17B6B5AB00A7AE3F /* JSDataViewPrototype.cpp in Sources */, > 0F2D4DE819832DAC007D4B19 /* ToThisStatus.cpp in Sources */, > FE384EE51ADDB7AD0055DE2C /* JSDollarVM.cpp in Sources */, >- E3C09F551B79692A00EE36A2 /* ModuleRecord.cpp in Sources */, > 978801401471AD920041B016 /* JSDateMath.cpp in Sources */, > 0FE050171AA9091100D33B33 /* DirectArguments.cpp in Sources */, > 140566D6107EC271005DBC8D /* JSFunction.cpp in Sources */, >@@ -7858,6 +7865,7 @@ > 0FF42732158EBD58004CB9FF /* UDis86Disassembler.cpp in Sources */, > A76F279415F13C9600517D67 /* UnlinkedCodeBlock.cpp in Sources */, > B59F89391891F29F00D5CCDC /* UnlinkedInstructionStream.cpp in Sources */, >+ E39DA4A61B7E8B7C0084F33A /* JSModuleRecord.cpp in Sources */, > 0F7576D218E1FEE9002EF4CD /* AccessorCallJITStubRoutine.cpp in Sources */, > 0F24E55817F74EDB00ABB217 /* ValueRecovery.cpp in Sources */, > E18E3A590DF9278C00D90B34 /* VM.cpp in Sources */, >diff --git a/Source/JavaScriptCore/builtins/BuiltinNames.h b/Source/JavaScriptCore/builtins/BuiltinNames.h >index ce044479f7302f19b1d81168f99ec4835b40220a..7e54342e752f9f2d4e835ed034f4609cf365d39f 100644 >--- a/Source/JavaScriptCore/builtins/BuiltinNames.h >+++ b/Source/JavaScriptCore/builtins/BuiltinNames.h >@@ -67,8 +67,8 @@ class BuiltinNames { > bool isPrivateName(SymbolImpl& uid) const; > bool isPrivateName(UniquedStringImpl& uid) const; > bool isPrivateName(const Identifier&) const; >- const Identifier* getPrivateName(const Identifier&) const; >- const Identifier& getPublicName(const Identifier&) const; >+ const Identifier* lookUpPrivateName(const Identifier&) const; >+ const Identifier& lookUpPublicName(const Identifier&) const; > > JSC_FOREACH_BUILTIN_FUNCTION_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) > JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(DECLARE_BUILTIN_IDENTIFIER_ACCESSOR) >@@ -110,7 +110,7 @@ inline bool BuiltinNames::isPrivateName(const Identifier& ident) const > return isPrivateName(*ident.impl()); > } > >-inline const Identifier* BuiltinNames::getPrivateName(const Identifier& ident) const >+inline const Identifier* BuiltinNames::lookUpPrivateName(const Identifier& ident) const > { > auto iter = m_publicToPrivateMap.find(ident.impl()); > if (iter != m_publicToPrivateMap.end()) >@@ -118,7 +118,7 @@ inline const Identifier* BuiltinNames::getPrivateName(const Identifier& ident) c > return 0; > } > >-inline const Identifier& BuiltinNames::getPublicName(const Identifier& ident) const >+inline const Identifier& BuiltinNames::lookUpPublicName(const Identifier& ident) const > { > auto iter = m_privateToPublicMap.find(ident.impl()); > if (iter != m_privateToPublicMap.end()) >diff --git a/Source/JavaScriptCore/builtins/ModuleLoaderObject.js b/Source/JavaScriptCore/builtins/ModuleLoaderObject.js >new file mode 100644 >index 0000000000000000000000000000000000000000..8a1cb80aac9245330828d48e70dbc086e4a5f576 >--- /dev/null >+++ b/Source/JavaScriptCore/builtins/ModuleLoaderObject.js >@@ -0,0 +1,241 @@ >+/* >+ * Copyright (C) 2015 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+function setStateToMax(entry, newState) >+{ >+ "use strict"; >+ >+ if (entry.state < newState) >+ entry.state = newState; >+} >+ >+function newRegistryEntry(key) >+{ >+ "use strict"; >+ >+ return { >+ key: key, >+ state: this.Fetch, >+ metadata: undefined, >+ fetch: undefined, >+ translate: undefined, >+ instantiate: undefined, >+ dependencies: [], // Keep the order. >+ dependenciesMap: undefined, >+ module: undefined, >+ error: undefined, >+ }; >+} >+ >+function ensureRegistered(key) >+{ >+ "use strict"; >+ >+ var entry = this.registry.@get(key); >+ if (entry) >+ return entry; >+ >+ entry = this.newRegistryEntry(key); >+ this.registry.@set(key, entry); >+ >+ return entry; >+} >+ >+function forceFulfillPromise(promise, value) >+{ >+ "use strict"; >+ >+ if (promise.@promiseState === @promisePending) >+ @fulfillPromise(promise, value); >+} >+ >+function fulfillFetch(entry, payload) >+{ >+ "use strict"; >+ >+ if (!entry.fetch) >+ entry.fetch = @newPromiseDeferred().@promise; >+ this.forceFulfillPromise(entry.fetch, payload); >+ this.setStateToMax(entry, this.Translate); >+} >+ >+function fulfillTranslate(entry, source) >+{ >+ "use strict"; >+ >+ if (!entry.translate) >+ entry.translate = @newPromiseDeferred().@promise; >+ this.forceFulfillPromise(entry.translate, source); >+ this.setStateToMax(entry, this.Instantiate); >+} >+ >+function fulfillInstantiate(entry, optionalInstance, source) >+{ >+ "use strict"; >+ >+ if (!entry.instantiate) >+ entry.instantiate = @newPromiseDeferred().@promise; >+ this.commitInstantiated(entry, optionalInstance, source); >+} >+ >+function commitInstantiated(entry, optionalInstance, source) >+{ >+ "use strict"; >+ >+ var instance = this.instantiation(optionalInstance, source); >+ this.forceFulfillPromise(entry.instantiate, instance); >+ >+ var deps = []; >+ var depsMap = new @Map(); >+ instance.registryEntry = entry; >+ var requestedModules = this.requestedModules(instance) >+ for (var i = 0, length = requestedModules.length; i < length; ++i) { >+ var depKey = requestedModules[i]; >+ var pair = { >+ key: depKey, >+ value: undefined >+ }; >+ @putByValDirect(deps, i, pair); >+ depsMap.@set(depKey, pair); >+ } >+ entry.dependencies = deps; >+ entry.dependenciesMap = depsMap; >+ entry.module = instance; >+ this.setStateToMax(entry, this.Link); >+} >+ >+function instantiation(result, source) >+{ >+ "use strict"; >+ >+ // FIXME: Current implementation does not support optionalInstance. >+ >+ return this.parseModule(source); >+} >+ >+// Loader. >+ >+function requestFetch(key) >+{ >+ "use strict"; >+ >+ var entry = this.ensureRegistered(key); >+ if (entry.state > this.Link) { >+ var deferred = @newPromiseDeferred(); >+ deferred.@reject.@call(undefined, new @TypeError("")); >+ return deferred.@promise; >+ } >+ >+ if (entry.fetch) >+ return entry.fetch; >+ >+ var loader = this; >+ var fetchPromise = this.fetch(key).then(function (payload) { >+ loader.setStateToMax(entry, loader.Translate); >+ return payload; >+ }); >+ entry.fetch = fetchPromise; >+ return fetchPromise; >+} >+ >+function requestTranslate(key) >+{ >+ "use strict"; >+ >+ var entry = this.ensureRegistered(key); >+ if (entry.state > this.Link) { >+ var deferred = @newPromiseDeferred(); >+ deferred.@reject.@call(undefined, new @TypeError("")); >+ return deferred.@promise; >+ } >+ >+ if (entry.translate) >+ return entry.translate; >+ >+ var loader = this; >+ var translatePromise = this.requestFetch(key).then(function (payload) { >+ return loader.translate(key, payload).then(function (source) { >+ loader.setStateToMax(entry, loader.Instantiate); >+ return source; >+ }); >+ }); >+ entry.translate = translatePromise; >+ return translatePromise; >+} >+ >+function requestInstantiate(key) >+{ >+ "use strict"; >+ >+ var entry = this.ensureRegistered(key); >+ if (entry.state == this.Ready) { >+ var deferred = @newPromiseDeferred(); >+ deferred.@reject.@call(undefined, new @TypeError("")); >+ return deferred.@promise; >+ } >+ >+ if (entry.instantiate) >+ return entry.instantiate; >+ >+ var loader = this; >+ var instantiatePromise = this.requestTranslate(key).then(function (source) { >+ return loader.instantiate(key, source).then(function (optionalInstance) { >+ loader.commitInstantiated(entry, optionalInstance, source); >+ return entry; >+ }); >+ }); >+ entry.instantiate = instantiatePromise; >+ return instantiatePromise; >+} >+ >+function requestInstantiateAll(key) >+{ >+ "use strict"; >+ >+ var loader = this; >+ >+ return this.requestInstantiate(key).then(function (entry) { >+ var depLoads = []; >+ for (var i = 0, length = entry.dependencies.length; i < length; ++i) { >+ var pair = entry.dependencies[i]; >+ var promise = loader.resolve(pair.key, key).then(function (depKey) { >+ var depEntry = loader.ensureRegistered(depKey); >+ if (depEntry.state === loader.Ready) { >+ var dep = depEntry.module; >+ pair.value = dep; >+ return dep; >+ } >+ >+ return loader.requestInstantiateAll(depKey).then(function (dep) { >+ pair.value = dep; >+ return dep; >+ }); >+ }); >+ @putByValDirect(depLoads, i, promise); >+ } >+ >+ return @Promise.@all(depLoads).then(function (modules) { return entry; }); >+ }); >+} >diff --git a/Source/JavaScriptCore/builtins/Operations.Promise.js b/Source/JavaScriptCore/builtins/Operations.Promise.js >index 66f9c2515359c7a51254f937fc7f51ccd131241d..d0d41d4fb2b9ec7f78d1d637a18a1daacbafbb39 100644 >--- a/Source/JavaScriptCore/builtins/Operations.Promise.js >+++ b/Source/JavaScriptCore/builtins/Operations.Promise.js >@@ -218,3 +218,29 @@ function initializePromise(executor) > > return this; > } >+ >+function promiseThen(promise, capability, onFulfilled, onRejected) >+{ >+ "use strict"; >+ >+ if (typeof onFulfilled !== "function") >+ onFulfilled = function (argument) { return argument; }; >+ >+ if (typeof onRejected !== "function") >+ onRejected = function (argument) { throw argument; }; >+ >+ var fulfillReaction = @newPromiseReaction(capability, onFulfilled); >+ var rejectReaction = @newPromiseReaction(capability, onRejected); >+ >+ var state = promise.@promiseState; >+ >+ if (state === @promisePending) { >+ @putByValDirect(promise.@promiseFulfillReactions, promise.@promiseFulfillReactions.length, fulfillReaction) >+ @putByValDirect(promise.@promiseRejectReactions, promise.@promiseRejectReactions.length, rejectReaction) >+ } else if (state === @promiseFulfilled) >+ @enqueueJob(@promiseReactionJob, [fulfillReaction, promise.@promiseResult]); >+ else if (state === @promiseRejected) >+ @enqueueJob(@promiseReactionJob, [rejectReaction, promise.@promiseResult]); >+ >+ return capability.@promise; >+} >diff --git a/Source/JavaScriptCore/builtins/Promise.prototype.js b/Source/JavaScriptCore/builtins/Promise.prototype.js >index 8563df0d927fb233968939e14942396ec85e65aa..ba022aba5a0d58d85efee079b39acbb11362bf8d 100644 >--- a/Source/JavaScriptCore/builtins/Promise.prototype.js >+++ b/Source/JavaScriptCore/builtins/Promise.prototype.js >@@ -41,26 +41,19 @@ function then(onFulfilled, onRejected) > // https://bugs.webkit.org/show_bug.cgi?id=146624 > var constructor = this.constructor; > >- var resultCapability = @newPromiseCapability(constructor); >- >- if (typeof onFulfilled !== "function") >- onFulfilled = function (argument) { return argument; }; >- >- if (typeof onRejected !== "function") >- onRejected = function (argument) { throw argument; }; >- >- var fulfillReaction = @newPromiseReaction(resultCapability, onFulfilled); >- var rejectReaction = @newPromiseReaction(resultCapability, onRejected); >+ return @promiseThen(this, @newPromiseCapability(constructor), onFulfilled, onRejected); >+} > >- var state = this.@promiseState; >+function privateThen(onFulfilled, onRejected) >+{ >+ // This function is intended to be used in the JSC internals. >+ // The implementation should take care not to perform the user >+ // observable / trappable operations. >+ // >+ // 1. Don't look up this.constructor / @@species. Always construct >+ // the plain Promise object. > >- if (state === @promisePending) { >- @putByValDirect(this.@promiseFulfillReactions, this.@promiseFulfillReactions.length, fulfillReaction) >- @putByValDirect(this.@promiseRejectReactions, this.@promiseRejectReactions.length, rejectReaction) >- } else if (state === @promiseFulfilled) >- @enqueueJob(@promiseReactionJob, [fulfillReaction, this.@promiseResult]); >- else if (state === @promiseRejected) >- @enqueueJob(@promiseReactionJob, [rejectReaction, this.@promiseResult]); >+ "use strict"; > >- return resultCapability.@promise; >+ return @promiseThen(this, @newPromiseDeferred(), onFulfilled, onRejected); > } >diff --git a/Source/JavaScriptCore/builtins/PromiseConstructor.js b/Source/JavaScriptCore/builtins/PromiseConstructor.js >index 1f83b47f790a75e5bf8c93d5e6649618cb1aec67..d47044cb752286b0988e59bdca8845cd3b212471 100644 >--- a/Source/JavaScriptCore/builtins/PromiseConstructor.js >+++ b/Source/JavaScriptCore/builtins/PromiseConstructor.js >@@ -137,3 +137,65 @@ function resolve(value) > > return promiseCapability.@promise; > } >+ >+function privateAll(array) >+{ >+ // This function is intended to be used in the JSC internals. >+ // The implementation should take care not to perform the user >+ // observable / trappable operations. >+ // >+ // 1. Don't use for-of and iterables. This function only accepts >+ // the dense array of the promises. >+ // 2. Don't look up this.constructor / @@species. Always construct >+ // the plain Promise object. >+ >+ "use strict"; >+ >+ var promiseCapability = @newPromiseDeferred(); >+ >+ var values = []; >+ var index = 0; >+ var remainingElementsCount = 1; >+ >+ function newResolveElement(index) >+ { >+ var alreadyCalled = false; >+ return function (argument) >+ { >+ if (alreadyCalled) >+ return undefined; >+ alreadyCalled = true; >+ >+ @putByValDirect(values, index, argument); >+ >+ --remainingElementsCount; >+ if (remainingElementsCount === 0) >+ return promiseCapability.@resolve.@call(undefined, values); >+ >+ return undefined; >+ } >+ } >+ >+ try { >+ for (var i = 0, length = array.length; i < length; ++i) { >+ @putByValDirect(values, index, undefined); >+ >+ var nextPromiseCapability = @newPromiseDeferred(); >+ nextPromiseCapability.@resolve.@call(undefined, value); >+ var nextPromise = nextPromiseCapability.@promise; >+ >+ var resolveElement = newResolveElement(index); >+ ++remainingElementsCount; >+ nextPromise.@then(resolveElement, promiseCapability.@reject); >+ ++index; >+ } >+ >+ --remainingElementsCount; >+ if (remainingElementsCount === 0) >+ promiseCapability.@resolve.@call(undefined, values); >+ } catch (error) { >+ promiseCapability.@reject.@call(undefined, error); >+ } >+ >+ return promiseCapability.@promise; >+} >diff --git a/Source/JavaScriptCore/jsc.cpp b/Source/JavaScriptCore/jsc.cpp >index 5b19533c40aa51442cc41c1698abbec212faf378..5a60d13ac39d6225102b289a1a25550694e22487 100644 >--- a/Source/JavaScriptCore/jsc.cpp >+++ b/Source/JavaScriptCore/jsc.cpp >@@ -41,6 +41,7 @@ > #include "JSFunction.h" > #include "JSLock.h" > #include "JSONObject.h" >+#include "JSPromiseDeferred.h" > #include "JSProxy.h" > #include "JSString.h" > #include "JSWASMModule.h" >@@ -566,6 +567,17 @@ long StopWatch::getElapsedMS() > return static_cast<long>((m_stopTime - m_startTime) * 1000); > } > >+static inline String stringFromUTF(const char* utf8) >+{ >+ return String::fromUTF8WithLatin1Fallback(utf8, strlen(utf8)); >+} >+ >+static inline SourceCode jscSource(const char* utf8, const String& filename) >+{ >+ String str = stringFromUTF(utf8); >+ return makeSource(str, filename); >+} >+ > class GlobalObject : public JSGlobalObject { > private: > GlobalObject(VM&, Structure*); >@@ -687,10 +699,31 @@ class GlobalObject : public JSGlobalObject { > Identifier identifier = Identifier::fromString(&vm, name); > putDirect(vm, identifier, JSFunction::create(vm, this, arguments, identifier.string(), function, NoIntrinsic, function)); > } >+ >+ static JSValue loaderFetch(JSGlobalObject* globalObject, ExecState* exec, JSValue key) >+ { >+ JSPromiseDeferred* deferred = JSPromiseDeferred::create(exec, globalObject); >+ String moduleKey = key.toString(exec)->value(exec); >+ if (exec->hadException()) { >+ JSValue exception = exec->exception(); >+ exec->clearException(); >+ deferred->reject(exec, exception); >+ return deferred->promise(); >+ } >+ >+ // Here, now we consider moduleKey as the fileName. >+ Vector<char> utf8; >+ if (!fillBufferWithContentsOfFile(moduleKey, utf8)) { >+ deferred->reject(exec, createError(exec, makeString("Could not open file '", moduleKey, "'."))); >+ return deferred->promise(); >+ } >+ deferred->resolve(exec, jsString(exec, stringFromUTF(utf8.data()))); >+ return deferred->promise(); >+ } > }; > > const ClassInfo GlobalObject::s_info = { "global", &JSGlobalObject::s_info, &globalObjectTable, CREATE_METHOD_TABLE(GlobalObject) }; >-const GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, 0, &shouldInterruptScriptBeforeTimeout }; >+const GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, 0, &shouldInterruptScriptBeforeTimeout, nullptr, &loaderFetch, nullptr, nullptr }; > > > GlobalObject::GlobalObject(VM& vm, Structure* structure) >@@ -698,17 +731,6 @@ GlobalObject::GlobalObject(VM& vm, Structure* structure) > { > } > >-static inline String stringFromUTF(const char* utf8) >-{ >- return String::fromUTF8WithLatin1Fallback(utf8, strlen(utf8)); >-} >- >-static inline SourceCode jscSource(const char* utf8, const String& filename) >-{ >- String str = stringFromUTF(utf8); >- return makeSource(str, filename); >-} >- > EncodedJSValue JSC_HOST_CALL functionPrint(ExecState* exec) > { > for (unsigned i = 0; i < exec->argumentCount(); ++i) { >@@ -1212,7 +1234,7 @@ EncodedJSValue JSC_HOST_CALL functionCheckModuleSyntax(ExecState* exec) > stopWatch.start(); > > ParserError error; >- bool validSyntax = checkModuleSyntax(exec->vm(), makeSource(source), error); >+ bool validSyntax = checkModuleSyntax(exec, makeSource(source), error); > stopWatch.stop(); > > if (!validSyntax) >diff --git a/Source/JavaScriptCore/parser/Lexer.cpp b/Source/JavaScriptCore/parser/Lexer.cpp >index 259d254e397518c7bccffc9edec156ba5f00db7a..476043ff6e255f9eb63145cb86cda9eef0a41566 100644 >--- a/Source/JavaScriptCore/parser/Lexer.cpp >+++ b/Source/JavaScriptCore/parser/Lexer.cpp >@@ -935,7 +935,7 @@ template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer<LChar>::p > return ERRORTOK; > } > if (isPrivateName) >- ident = m_vm->propertyNames->getPrivateName(*ident); >+ ident = m_vm->propertyNames->lookUpPrivateName(*ident); > else if (*ident == m_vm->propertyNames->undefinedKeyword) > tokenData->ident = &m_vm->propertyNames->undefinedPrivateName; > if (!ident) >@@ -1012,7 +1012,7 @@ template <bool shouldCreateIdentifier> ALWAYS_INLINE JSTokenType Lexer<UChar>::p > return ERRORTOK; > } > if (isPrivateName) >- ident = m_vm->propertyNames->getPrivateName(*ident); >+ ident = m_vm->propertyNames->lookUpPrivateName(*ident); > else if (*ident == m_vm->propertyNames->undefinedKeyword) > tokenData->ident = &m_vm->propertyNames->undefinedPrivateName; > if (!ident) >diff --git a/Source/JavaScriptCore/parser/ModuleAnalyzer.cpp b/Source/JavaScriptCore/parser/ModuleAnalyzer.cpp >index b2de960b39325841cd9f85c671622c3df7ba9d77..27caff2950226013d272dcf3709c78e7ede4033a 100644 >--- a/Source/JavaScriptCore/parser/ModuleAnalyzer.cpp >+++ b/Source/JavaScriptCore/parser/ModuleAnalyzer.cpp >@@ -27,14 +27,17 @@ > #include "ModuleAnalyzer.h" > > #include "IdentifierInlines.h" >-#include "ModuleRecord.h" >+#include "JSCellInlines.h" >+#include "JSGlobalObject.h" >+#include "JSModuleRecord.h" >+#include "StrongInlines.h" > > namespace JSC { > > >-ModuleAnalyzer::ModuleAnalyzer(VM& vm, const VariableEnvironment& declaredVariables, const VariableEnvironment& lexicalVariables) >- : m_vm(&vm) >- , m_moduleRecord(ModuleRecord::create()) >+ModuleAnalyzer::ModuleAnalyzer(ExecState* exec, const VariableEnvironment& declaredVariables, const VariableEnvironment& lexicalVariables) >+ : m_vm(&exec->vm()) >+ , m_moduleRecord(exec->vm(), JSModuleRecord::create(exec->vm(), exec->lexicalGlobalObject()->moduleRecordStructure())) > , m_declaredVariables(declaredVariables) > , m_lexicalVariables(lexicalVariables) > { >@@ -76,28 +79,28 @@ void ModuleAnalyzer::exportVariable(const RefPtr<UniquedStringImpl>& localName, > > // Exported module local variable. > if (!variable.isImported()) { >- moduleRecord().addExportEntry(ModuleRecord::ExportEntry::createLocal(exportName, Identifier::fromUid(m_vm, localName.get()), variable)); >+ moduleRecord()->addExportEntry(JSModuleRecord::ExportEntry::createLocal(exportName, Identifier::fromUid(m_vm, localName.get()), variable)); > return; > } > >- const auto& importEntry = moduleRecord().lookUpImportEntry(localName); >+ const auto& importEntry = moduleRecord()->lookUpImportEntry(localName); > if (importEntry.isNamespace(vm())) { > // Exported namespace binding. > // import * as namespace from "mod" > // export { namespace } >- moduleRecord().addExportEntry(ModuleRecord::ExportEntry::createNamespace(exportName, importEntry.moduleRequest)); >+ moduleRecord()->addExportEntry(JSModuleRecord::ExportEntry::createNamespace(exportName, importEntry.moduleRequest)); > return; > } > > // Indirectly exported binding. > // import a from "mod" > // export { a } >- moduleRecord().addExportEntry(ModuleRecord::ExportEntry::createIndirect(exportName, importEntry.importName, importEntry.moduleRequest)); >+ moduleRecord()->addExportEntry(JSModuleRecord::ExportEntry::createIndirect(exportName, importEntry.importName, importEntry.moduleRequest)); > } > > > >-Ref<ModuleRecord> ModuleAnalyzer::analyze(ModuleProgramNode& moduleProgramNode) >+JSModuleRecord* ModuleAnalyzer::analyze(ModuleProgramNode& moduleProgramNode) > { > // Traverse the module AST and collect > // * Import entries >@@ -149,7 +152,7 @@ Ref<ModuleRecord> ModuleAnalyzer::analyze(ModuleProgramNode& moduleProgramNode) > if (Options::dumpModuleRecord()) > m_moduleRecord->dump(); > >- return *m_moduleRecord; >+ return m_moduleRecord.get(); > } > > } // namespace JSC >diff --git a/Source/JavaScriptCore/parser/ModuleAnalyzer.h b/Source/JavaScriptCore/parser/ModuleAnalyzer.h >index 02764847650b3024fd2a8c3722e73a747b963cb6..3390b7baf1f65e810c1139b6dec465946b89d492 100644 >--- a/Source/JavaScriptCore/parser/ModuleAnalyzer.h >+++ b/Source/JavaScriptCore/parser/ModuleAnalyzer.h >@@ -26,20 +26,22 @@ > #ifndef ModuleAnalyzer_h > #define ModuleAnalyzer_h > >-#include "ModuleRecord.h" > #include "Nodes.h" > > namespace JSC { > >+class JSModuleRecord; >+ > class ModuleAnalyzer { >+ WTF_MAKE_NONCOPYABLE(ModuleAnalyzer); > public: >- ModuleAnalyzer(VM&, const VariableEnvironment& declaredVariables, const VariableEnvironment& lexicalVariables); >+ ModuleAnalyzer(ExecState*, const VariableEnvironment& declaredVariables, const VariableEnvironment& lexicalVariables); > >- Ref<ModuleRecord> analyze(ModuleProgramNode&); >+ JSModuleRecord* analyze(ModuleProgramNode&); > > VM& vm() { return *m_vm; } > >- ModuleRecord& moduleRecord() { return *m_moduleRecord; } >+ JSModuleRecord* moduleRecord() { return m_moduleRecord.get(); } > > void declareExportAlias(const Identifier& localName, const Identifier& exportName); > >@@ -51,7 +53,7 @@ class ModuleAnalyzer { > Identifier exportedBinding(const RefPtr<UniquedStringImpl>& ident); > > VM* m_vm; >- RefPtr<ModuleRecord> m_moduleRecord; >+ Strong<JSModuleRecord> m_moduleRecord; > VariableEnvironment m_declaredVariables; > VariableEnvironment m_lexicalVariables; > IdentifierAliasMap m_aliasMap; >diff --git a/Source/JavaScriptCore/parser/ModuleRecord.cpp b/Source/JavaScriptCore/parser/ModuleRecord.cpp >deleted file mode 100644 >index ec973568bec8a0b153332f4875f9efe13782ec8a..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/parser/ModuleRecord.cpp >+++ /dev/null >@@ -1,95 +0,0 @@ >-/* >- * Copyright (C) 2015 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#include "config.h" >-#include "ModuleRecord.h" >- >-#include "IdentifierInlines.h" >- >-namespace JSC { >- >- >-auto ModuleRecord::ExportEntry::createLocal(const Identifier& exportName, const Identifier& localName, const VariableEnvironmentEntry& variable) -> ExportEntry >-{ >- return ExportEntry { Type::Local, exportName, Identifier(), Identifier(), localName, variable }; >-} >- >-auto ModuleRecord::ExportEntry::createNamespace(const Identifier& exportName, const Identifier& moduleName) -> ExportEntry >-{ >- return ExportEntry { Type::Namespace, exportName, moduleName, Identifier(), Identifier(), VariableEnvironmentEntry() }; >-} >- >-auto ModuleRecord::ExportEntry::createIndirect(const Identifier& exportName, const Identifier& importName, const Identifier& moduleName) -> ExportEntry >-{ >- return ExportEntry { Type::Indirect, exportName, moduleName, importName, Identifier(), VariableEnvironmentEntry() }; >-} >- >-static String printableName(const RefPtr<UniquedStringImpl>& uid) >-{ >- if (uid->isSymbol()) >- return uid.get(); >- return WTF::makeString("'", String(uid.get()), "'"); >-} >- >-static String printableName(const Identifier& ident) >-{ >- return printableName(ident.impl()); >-} >- >- >-void ModuleRecord::dump() >-{ >- dataLog("\nAnalyzing ModuleRecord\n"); >- >- dataLog(" Dependencies: ", m_requestedModules.size(), " modules\n"); >- for (const auto& moduleName : m_requestedModules) >- dataLog(" module(", printableName(moduleName), ")\n"); >- >- dataLog(" Import: ", m_importEntries.size(), " entries\n"); >- for (const auto& pair : m_importEntries) >- dataLog(" import(", printableName(pair.value.importName), "), local(", printableName(pair.value.localName), "), module(", printableName(pair.value.moduleRequest), ")\n"); >- >- dataLog(" Export: ", m_exportEntries.size(), " entries\n"); >- for (const auto& pair : m_exportEntries) { >- const ExportEntry& entry = pair.value; >- switch (entry.type) { >- case ExportEntry::Type::Local: >- dataLog(" [Local] ", "export(", printableName(entry.exportName), "), local(", printableName(entry.localName), ")\n"); >- break; >- >- case ExportEntry::Type::Namespace: >- dataLog(" [Namespace] ", "export(", printableName(entry.exportName), "), module(", printableName(entry.moduleName), ")\n"); >- break; >- >- case ExportEntry::Type::Indirect: >- dataLog(" [Indirect] ", "export(", printableName(entry.exportName), "), import(", printableName(entry.importName), "), module(", printableName(entry.moduleName), ")\n"); >- break; >- } >- } >- for (const auto& moduleName : m_starExportEntries) >- dataLog(" [Star] module(", printableName(moduleName.get()), ")\n"); >-} >- >-} // namespace JSC >diff --git a/Source/JavaScriptCore/parser/ModuleRecord.h b/Source/JavaScriptCore/parser/ModuleRecord.h >deleted file mode 100644 >index ef081c03b0a5bde6f155629df3f506caf3cb1714..0000000000000000000000000000000000000000 >--- a/Source/JavaScriptCore/parser/ModuleRecord.h >+++ /dev/null >@@ -1,128 +0,0 @@ >-/* >- * Copyright (C) 2015 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#ifndef ModuleRecord_h >-#define ModuleRecord_h >- >-#include "Nodes.h" >-#include <wtf/HashMap.h> >-#include <wtf/ListHashSet.h> >- >-namespace JSC { >- >-// Based on the Source Text Module Record >-// http://www.ecma-international.org/ecma-262/6.0/#sec-source-text-module-records >-class ModuleRecord : public RefCounted<ModuleRecord> { >-public: >- struct ExportEntry { >- enum class Type { >- Local, >- Namespace, >- Indirect >- }; >- >- static ExportEntry createLocal(const Identifier& exportName, const Identifier& localName, const VariableEnvironmentEntry&); >- static ExportEntry createNamespace(const Identifier& exportName, const Identifier& moduleName); >- static ExportEntry createIndirect(const Identifier& exportName, const Identifier& importName, const Identifier& moduleName); >- >- Type type; >- Identifier exportName; >- Identifier moduleName; >- Identifier importName; >- Identifier localName; >- VariableEnvironmentEntry variable; >- }; >- >- struct ImportEntry { >- Identifier moduleRequest; >- Identifier importName; >- Identifier localName; >- >- bool isNamespace(VM& vm) const >- { >- return importName == vm.propertyNames->timesIdentifier; >- } >- }; >- >- typedef WTF::ListHashSet<RefPtr<UniquedStringImpl>, IdentifierRepHash> OrderedIdentifierSet; >- typedef HashMap<RefPtr<UniquedStringImpl>, ImportEntry, IdentifierRepHash, HashTraits<RefPtr<UniquedStringImpl>>> ImportMap; >- typedef HashMap<RefPtr<UniquedStringImpl>, ExportEntry, IdentifierRepHash, HashTraits<RefPtr<UniquedStringImpl>>> ExportMap; >- >- static Ref<ModuleRecord> create() >- { >- return adoptRef(*new ModuleRecord); >- } >- >- void appendRequestedModule(const Identifier&); >- void addStarExportEntry(const Identifier&); >- void addImportEntry(const ImportEntry&); >- void addExportEntry(const ExportEntry&); >- >- const ImportEntry& lookUpImportEntry(const RefPtr<UniquedStringImpl>& localName); >- >- void dump(); >- >-private: >- // Map localName -> ImportEntry. >- ImportMap m_importEntries; >- >- // Map exportName -> ExportEntry. >- ExportMap m_exportEntries; >- >- IdentifierSet m_starExportEntries; >- >- // Save the occurrence order since the module loader loads and runs the modules in this order. >- // http://www.ecma-international.org/ecma-262/6.0/#sec-moduleevaluation >- OrderedIdentifierSet m_requestedModules; >-}; >- >-inline void ModuleRecord::appendRequestedModule(const Identifier& moduleName) >-{ >- m_requestedModules.add(moduleName.impl()); >-} >- >-inline void ModuleRecord::addImportEntry(const ImportEntry& entry) >-{ >- m_importEntries.add(entry.localName.impl(), entry); >-} >- >-inline void ModuleRecord::addExportEntry(const ExportEntry& entry) >-{ >- m_exportEntries.add(entry.exportName.impl(), entry); >-} >- >-inline void ModuleRecord::addStarExportEntry(const Identifier& moduleName) >-{ >- m_starExportEntries.add(moduleName.impl()); >-} >- >-inline auto ModuleRecord::lookUpImportEntry(const RefPtr<UniquedStringImpl>& localName) -> const ImportEntry& >-{ >- return (*m_importEntries.find(localName)).value; >-} >- >-} // namespace JSC >- >-#endif // ModuleRecord_h >diff --git a/Source/JavaScriptCore/parser/Nodes.h b/Source/JavaScriptCore/parser/Nodes.h >index c02b42cecbada16ee9bde334f52d90aa885cccfa..919134c1b5a72e7fbb7481486ae3debc5dd04f41 100644 >--- a/Source/JavaScriptCore/parser/Nodes.h >+++ b/Source/JavaScriptCore/parser/Nodes.h >@@ -79,8 +79,6 @@ namespace JSC { > }; > inline FallThroughMode invert(FallThroughMode fallThroughMode) { return static_cast<FallThroughMode>(!fallThroughMode); } > >- typedef HashSet<RefPtr<UniquedStringImpl>, IdentifierRepHash> IdentifierSet; >- > namespace DeclarationStacks { > typedef Vector<FunctionMetadataNode*> FunctionStack; > } >diff --git a/Source/JavaScriptCore/parser/NodesAnalyzeModule.cpp b/Source/JavaScriptCore/parser/NodesAnalyzeModule.cpp >index 633deaece6af66659d0e76ac1aa416159ab75a35..07d930ffc6091891f9fb74e6afa7b8ee6b79b02f 100644 >--- a/Source/JavaScriptCore/parser/NodesAnalyzeModule.cpp >+++ b/Source/JavaScriptCore/parser/NodesAnalyzeModule.cpp >@@ -27,8 +27,8 @@ > #include "Nodes.h" > #include "NodeConstructors.h" > >+#include "JSModuleRecord.h" > #include "ModuleAnalyzer.h" >-#include "ModuleRecord.h" > > namespace JSC { > >@@ -48,9 +48,9 @@ void SourceElements::analyzeModule(ModuleAnalyzer& analyzer) > > void ImportDeclarationNode::analyzeModule(ModuleAnalyzer& analyzer) > { >- analyzer.moduleRecord().appendRequestedModule(m_moduleName->moduleName()); >+ analyzer.moduleRecord()->appendRequestedModule(m_moduleName->moduleName()); > for (auto* specifier : m_specifierList->specifiers()) { >- analyzer.moduleRecord().addImportEntry(ModuleRecord::ImportEntry { >+ analyzer.moduleRecord()->addImportEntry(JSModuleRecord::ImportEntry { > m_moduleName->moduleName(), > specifier->importedName(), > specifier->localName() >@@ -60,8 +60,8 @@ void ImportDeclarationNode::analyzeModule(ModuleAnalyzer& analyzer) > > void ExportAllDeclarationNode::analyzeModule(ModuleAnalyzer& analyzer) > { >- analyzer.moduleRecord().appendRequestedModule(m_moduleName->moduleName()); >- analyzer.moduleRecord().addStarExportEntry(m_moduleName->moduleName()); >+ analyzer.moduleRecord()->appendRequestedModule(m_moduleName->moduleName()); >+ analyzer.moduleRecord()->addStarExportEntry(m_moduleName->moduleName()); > } > > void ExportDefaultDeclarationNode::analyzeModule(ModuleAnalyzer& analyzer) >@@ -76,7 +76,7 @@ void ExportLocalDeclarationNode::analyzeModule(ModuleAnalyzer&) > void ExportNamedDeclarationNode::analyzeModule(ModuleAnalyzer& analyzer) > { > if (m_moduleName) >- analyzer.moduleRecord().appendRequestedModule(m_moduleName->moduleName()); >+ analyzer.moduleRecord()->appendRequestedModule(m_moduleName->moduleName()); > > for (auto* specifier : m_specifierList->specifiers()) { > if (m_moduleName) { >@@ -84,7 +84,7 @@ void ExportNamedDeclarationNode::analyzeModule(ModuleAnalyzer& analyzer) > // > // In this case, no local variable names are imported into the current module. > // "v" indirectly points the binding in "mod". >- analyzer.moduleRecord().addExportEntry(ModuleRecord::ExportEntry::createIndirect(specifier->exportedName(), specifier->localName(), m_moduleName->moduleName())); >+ analyzer.moduleRecord()->addExportEntry(JSModuleRecord::ExportEntry::createIndirect(specifier->exportedName(), specifier->localName(), m_moduleName->moduleName())); > continue; > } > >diff --git a/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp b/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp >index fc6e62ca045e3629cf2ad3b6bfcb73d5ddff0ce1..aa392ceb8d1a065a9252aa7744dab8d9b16054e9 100644 >--- a/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp >+++ b/Source/JavaScriptCore/runtime/CommonIdentifiers.cpp >@@ -68,14 +68,14 @@ bool CommonIdentifiers::isPrivateName(const Identifier& ident) const > return m_builtinNames->isPrivateName(ident); > } > >-const Identifier* CommonIdentifiers::getPrivateName(const Identifier& ident) const >+const Identifier* CommonIdentifiers::lookUpPrivateName(const Identifier& ident) const > { >- return m_builtinNames->getPrivateName(ident); >+ return m_builtinNames->lookUpPrivateName(ident); > } > >-Identifier CommonIdentifiers::getPublicName(const Identifier& ident) const >+Identifier CommonIdentifiers::lookUpPublicName(const Identifier& ident) const > { >- return m_builtinNames->getPublicName(ident); >+ return m_builtinNames->lookUpPublicName(ident); > } > > >diff --git a/Source/JavaScriptCore/runtime/CommonIdentifiers.h b/Source/JavaScriptCore/runtime/CommonIdentifiers.h >index 3447b398fd061805909e6f022e3d66523bac4698..d59d4448d293a1475c01b7c7e66aef7962eb126d 100644 >--- a/Source/JavaScriptCore/runtime/CommonIdentifiers.h >+++ b/Source/JavaScriptCore/runtime/CommonIdentifiers.h >@@ -42,6 +42,7 @@ > macro(Infinity) \ > macro(Intl) \ > macro(JSON) \ >+ macro(Loader) \ > macro(Map)\ > macro(MapIterator)\ > macro(Math) \ >@@ -281,6 +282,7 @@ > macro(Number) \ > macro(Array) \ > macro(String) \ >+ macro(Map) \ > macro(Promise) \ > macro(abs) \ > macro(floor) \ >@@ -302,6 +304,8 @@ > macro(capabilities) \ > macro(starDefault) \ > macro(InspectorInstrumentation) \ >+ macro(get) \ >+ macro(set) \ > > > namespace JSC { >@@ -348,8 +352,8 @@ namespace JSC { > bool isPrivateName(UniquedStringImpl& uid) const; > bool isPrivateName(const Identifier&) const; > >- const Identifier* getPrivateName(const Identifier&) const; >- Identifier getPublicName(const Identifier&) const; >+ const Identifier* lookUpPrivateName(const Identifier&) const; >+ Identifier lookUpPublicName(const Identifier&) const; > > const BytecodeIntrinsicRegistry& bytecodeIntrinsicRegistry() const { return m_bytecodeIntrinsicRegistry; } > >diff --git a/Source/JavaScriptCore/runtime/Completion.cpp b/Source/JavaScriptCore/runtime/Completion.cpp >index a3daee60343ac14b14ad0304ebdc9a25aab15723..1d57dddfc1376a6037d13b666a77aef7b480346d 100644 >--- a/Source/JavaScriptCore/runtime/Completion.cpp >+++ b/Source/JavaScriptCore/runtime/Completion.cpp >@@ -28,11 +28,11 @@ > #include "Debugger.h" > #include "Exception.h" > #include "Interpreter.h" >+#include "JSCInlines.h" > #include "JSGlobalObject.h" > #include "JSLock.h" >-#include "JSCInlines.h" >+#include "JSModuleRecord.h" > #include "ModuleAnalyzer.h" >-#include "ModuleRecord.h" > #include "Parser.h" > #include <wtf/WTFThreadData.h> > >@@ -63,8 +63,9 @@ bool checkSyntax(VM& vm, const SourceCode& source, ParserError& error) > JSParserStrictMode::NotStrict, SourceParseMode::ProgramMode, error); > } > >-bool checkModuleSyntax(VM& vm, const SourceCode& source, ParserError& error) >+bool checkModuleSyntax(ExecState* exec, const SourceCode& source, ParserError& error) > { >+ VM& vm = exec->vm(); > JSLockHolder lock(vm); > RELEASE_ASSERT(vm.atomicStringTable() == wtfThreadData().atomicStringTable()); > std::unique_ptr<ModuleProgramNode> moduleProgramNode = parse<ModuleProgramNode>( >@@ -73,7 +74,7 @@ bool checkModuleSyntax(VM& vm, const SourceCode& source, ParserError& error) > if (!moduleProgramNode) > return false; > >- ModuleAnalyzer moduleAnalyzer(vm, moduleProgramNode->varDeclarations(), moduleProgramNode->lexicalVariables()); >+ ModuleAnalyzer moduleAnalyzer(exec, moduleProgramNode->varDeclarations(), moduleProgramNode->lexicalVariables()); > moduleAnalyzer.analyze(*moduleProgramNode); > return true; > } >diff --git a/Source/JavaScriptCore/runtime/Completion.h b/Source/JavaScriptCore/runtime/Completion.h >index 702ed9fab0c791fae15505627bc731adbae3a5fd..01ae2823e1fad54705cc2b547e0c109b4226a4c2 100644 >--- a/Source/JavaScriptCore/runtime/Completion.h >+++ b/Source/JavaScriptCore/runtime/Completion.h >@@ -37,7 +37,7 @@ class VM; > > JS_EXPORT_PRIVATE bool checkSyntax(VM&, const SourceCode&, ParserError&); > JS_EXPORT_PRIVATE bool checkSyntax(ExecState*, const SourceCode&, JSValue* exception = 0); >-JS_EXPORT_PRIVATE bool checkModuleSyntax(VM&, const SourceCode&, ParserError&); >+JS_EXPORT_PRIVATE bool checkModuleSyntax(ExecState*, const SourceCode&, ParserError&); > JS_EXPORT_PRIVATE JSValue evaluate(ExecState*, const SourceCode&, JSValue thisValue, NakedPtr<Exception>& returnedException); > inline JSValue evaluate(ExecState* exec, const SourceCode& sourceCode, JSValue thisValue = JSValue()) > { >diff --git a/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp b/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp >index 46c0cef9392a4ad7c0b00a9a0847e0b9aefc5fae..b7859bfe3e8eafd1ec64ab5fbfeaf2572ad27c17 100644 >--- a/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp >+++ b/Source/JavaScriptCore/runtime/ExceptionHelpers.cpp >@@ -73,7 +73,7 @@ JSObject* createStackOverflowError(ExecState* exec) > JSObject* createUndefinedVariableError(ExecState* exec, const Identifier& ident) > { > if (exec->propertyNames().isPrivateName(ident)) { >- String message(makeString("Can't find private variable: @", exec->propertyNames().getPublicName(ident).string())); >+ String message(makeString("Can't find private variable: @", exec->propertyNames().lookUpPublicName(ident).string())); > return createReferenceError(exec, message); > } > String message(makeString("Can't find variable: ", ident.string())); >diff --git a/Source/JavaScriptCore/runtime/Identifier.h b/Source/JavaScriptCore/runtime/Identifier.h >index 61de6536a6fa4c29aca4df14b7d6fec4d2a503e6..889ca6b22e4379362f25805fd05e6f84aa67bba6 100644 >--- a/Source/JavaScriptCore/runtime/Identifier.h >+++ b/Source/JavaScriptCore/runtime/Identifier.h >@@ -292,6 +292,7 @@ struct IdentifierMapIndexHashTraits : HashTraits<int> { > static const bool emptyValueIsZero = false; > }; > >+typedef HashSet<RefPtr<UniquedStringImpl>, IdentifierRepHash> IdentifierSet; > typedef HashMap<RefPtr<UniquedStringImpl>, int, IdentifierRepHash, HashTraits<RefPtr<UniquedStringImpl>>, IdentifierMapIndexHashTraits> IdentifierMap; > typedef HashMap<UniquedStringImpl*, int, IdentifierRepHash, HashTraits<UniquedStringImpl*>, IdentifierMapIndexHashTraits> BorrowedIdentifierMap; > >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >index 25ace9269180add73c4eae98d389578e46aeb544..1f8a8e64056e97b5b180c8ee168edcd5a60052dd 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >@@ -80,6 +80,7 @@ > #include "JSLock.h" > #include "JSMap.h" > #include "JSMapIterator.h" >+#include "JSModuleRecord.h" > #include "JSONObject.h" > #include "JSPromise.h" > #include "JSPromiseConstructor.h" >@@ -103,6 +104,7 @@ > #include "MapPrototype.h" > #include "MathObject.h" > #include "Microtask.h" >+#include "ModuleLoaderObject.h" > #include "NativeErrorConstructor.h" > #include "NativeErrorPrototype.h" > #include "NullGetterFunction.h" >@@ -156,7 +158,7 @@ namespace JSC { > > const ClassInfo JSGlobalObject::s_info = { "GlobalObject", &Base::s_info, &globalObjectTable, CREATE_METHOD_TABLE(JSGlobalObject) }; > >-const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, nullptr, &shouldInterruptScriptBeforeTimeout }; >+const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, nullptr, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr }; > > /* Source for JSGlobalObject.lut.h > @begin globalObjectTable >@@ -336,10 +338,9 @@ void JSGlobalObject::init(VM& vm) > m_regExpPrototype.set(vm, this, RegExpPrototype::create(vm, RegExpPrototype::createStructure(vm, this, m_objectPrototype.get()), emptyRegex)); > m_regExpStructure.set(vm, this, RegExpObject::createStructure(vm, this, m_regExpPrototype.get())); > m_regExpMatchesArrayStructure.set(vm, this, createRegExpMatchesArrayStructure(vm, *this)); >- >- m_promisePrototype.set(vm, this, JSPromisePrototype::create(exec, this, JSPromisePrototype::createStructure(vm, this, m_objectPrototype.get()))); >- m_promiseStructure.set(vm, this, JSPromise::createStructure(vm, this, m_promisePrototype.get())); > >+ m_moduleRecordStructure.set(vm, this, JSModuleRecord::createStructure(vm, this, m_objectPrototype.get())); >+ > #if ENABLE(WEBASSEMBLY) > m_wasmModuleStructure.set(vm, this, JSWASMModule::createStructure(vm, this)); > #endif >@@ -397,13 +398,11 @@ m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->c > m_syntaxErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("SyntaxError"))); > m_typeErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("TypeError"))); > m_URIErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, nativeErrorStructure, nativeErrorPrototypeStructure, ASCIILiteral("URIError"))); >- m_promiseConstructor.set(vm, this, JSPromiseConstructor::create(vm, JSPromiseConstructor::createStructure(vm, this, m_functionPrototype.get()), m_promisePrototype.get())); > > m_objectPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, objectConstructor, DontEnum); > m_functionPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, functionConstructor, DontEnum); > m_arrayPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, arrayConstructor, DontEnum); > m_regExpPrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, m_regExpConstructor.get(), DontEnum); >- m_promisePrototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, m_promiseConstructor.get(), DontEnum); > > putDirectWithoutTransition(vm, vm.propertyNames->Object, objectConstructor, DontEnum); > putDirectWithoutTransition(vm, vm.propertyNames->Function, functionConstructor, DontEnum); >@@ -415,7 +414,6 @@ m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->c > putDirectWithoutTransition(vm, vm.propertyNames->SyntaxError, m_syntaxErrorConstructor.get(), DontEnum); > putDirectWithoutTransition(vm, vm.propertyNames->TypeError, m_typeErrorConstructor.get(), DontEnum); > putDirectWithoutTransition(vm, vm.propertyNames->URIError, m_URIErrorConstructor.get(), DontEnum); >- putDirectWithoutTransition(vm, vm.propertyNames->Promise, m_promiseConstructor.get(), DontEnum); > > > #define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \ >@@ -440,7 +438,8 @@ putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct > putDirectWithoutTransition(vm, vm.propertyNames->JSON, JSONObject::create(vm, JSONObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum); > putDirectWithoutTransition(vm, vm.propertyNames->Math, MathObject::create(vm, this, MathObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum); > putDirectWithoutTransition(vm, vm.propertyNames->Reflect, ReflectObject::create(vm, this, ReflectObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum); >- >+ putDirectWithoutTransition(vm, vm.propertyNames->Loader, ModuleLoaderObject::create(vm, this, ModuleLoaderObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum); >+ > std::array<InternalFunction*, NUMBER_OF_TYPED_ARRAY_TYPES> typedArrayConstructors; > typedArrayConstructors[toIndex(TypeInt8)] = JSInt8ArrayConstructor::create(vm, JSInt8ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_typedArrays[toIndex(TypeInt8)].prototype.get(), ASCIILiteral("Int8Array")); > typedArrayConstructors[toIndex(TypeInt16)] = JSInt16ArrayConstructor::create(vm, JSInt16ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_typedArrays[toIndex(TypeInt16)].prototype.get(), ASCIILiteral("Int16Array")); >@@ -491,7 +490,7 @@ putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct > GlobalPropertyInfo(vm.propertyNames->arrayIterationKindValuePrivateName, jsNumber(ArrayIterateValue), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->arrayIterationKindKeyValuePrivateName, jsNumber(ArrayIterateKeyValue), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().symbolIteratorPrivateName(), Symbol::create(vm, static_cast<SymbolImpl&>(*vm.propertyNames->iteratorSymbol.impl())), DontEnum | DontDelete | ReadOnly), >- GlobalPropertyInfo(vm.propertyNames->PromisePrivateName, m_promiseConstructor.get(), DontEnum | DontDelete | ReadOnly), >+ GlobalPropertyInfo(vm.propertyNames->PromisePrivateName, promiseConstructor, DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->promisePendingPrivateName, jsNumber(static_cast<unsigned>(JSPromise::Status::Pending)), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().promiseFulfilledPrivateName(), jsNumber(static_cast<unsigned>(JSPromise::Status::Fulfilled)), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().promiseRejectedPrivateName(), jsNumber(static_cast<unsigned>(JSPromise::Status::Rejected)), DontEnum | DontDelete | ReadOnly), >@@ -507,7 +506,10 @@ putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct > GlobalPropertyInfo(vm.propertyNames->builtinNames().createResolvingFunctionsPrivateName(), JSFunction::createBuiltinFunction(vm, operationsPromiseCreateResolvingFunctionsCodeGenerator(vm), this), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().promiseReactionJobPrivateName(), JSFunction::createBuiltinFunction(vm, operationsPromisePromiseReactionJobCodeGenerator(vm), this), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().promiseResolveThenableJobPrivateName(), JSFunction::createBuiltinFunction(vm, operationsPromisePromiseResolveThenableJobCodeGenerator(vm), this), DontEnum | DontDelete | ReadOnly), >+ GlobalPropertyInfo(vm.propertyNames->builtinNames().newPromiseDeferredPrivateName(), m_newPromiseDeferredFunction.get(), DontEnum | DontDelete | ReadOnly), >+ GlobalPropertyInfo(vm.propertyNames->builtinNames().promiseThenPrivateName(), JSFunction::createBuiltinFunction(vm, operationsPromisePromiseThenCodeGenerator(vm), this), DontEnum | DontDelete | ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().InspectorInstrumentationPrivateName(), InspectorInstrumentationObject::create(vm, this, InspectorInstrumentationObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum | DontDelete | ReadOnly), >+ GlobalPropertyInfo(vm.propertyNames->MapPrivateName, mapConstructor, DontEnum | DontDelete | ReadOnly), > }; > addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals)); > >@@ -750,7 +752,6 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor) > visitor.append(&thisObject->m_typeErrorConstructor); > visitor.append(&thisObject->m_URIErrorConstructor); > visitor.append(&thisObject->m_objectConstructor); >- visitor.append(&thisObject->m_promiseConstructor); > > visitor.append(&thisObject->m_nullGetterFunction); > visitor.append(&thisObject->m_nullSetterFunction); >@@ -770,7 +771,6 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor) > visitor.append(&thisObject->m_arrayPrototype); > visitor.append(&thisObject->m_errorPrototype); > visitor.append(&thisObject->m_iteratorPrototype); >- visitor.append(&thisObject->m_promisePrototype); > > visitor.append(&thisObject->m_debuggerScopeStructure); > visitor.append(&thisObject->m_withScopeStructure); >@@ -801,10 +801,10 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor) > visitor.append(&thisObject->m_symbolObjectStructure); > visitor.append(&thisObject->m_regExpStructure); > visitor.append(&thisObject->m_regExpMatchesArrayStructure); >+ visitor.append(&thisObject->m_moduleRecordStructure); > visitor.append(&thisObject->m_consoleStructure); > visitor.append(&thisObject->m_dollarVMStructure); > visitor.append(&thisObject->m_internalFunctionStructure); >- visitor.append(&thisObject->m_promiseStructure); > #if ENABLE(WEBASSEMBLY) > visitor.append(&thisObject->m_wasmModuleStructure); > #endif >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.h b/Source/JavaScriptCore/runtime/JSGlobalObject.h >index 9986bcf6245e2cc46820b13102b2342900ec3d7b..af14ad05083e8889081bbdc04e01340ecc9bc38d 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObject.h >+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.h >@@ -70,6 +70,7 @@ class GetterSetter; > class GlobalCodeBlock; > class InputCursor; > class JSGlobalObjectDebuggable; >+class JSPromise; > class JSPromiseConstructor; > class JSPromisePrototype; > class JSStack; >@@ -99,6 +100,7 @@ struct HashTable; > macro(Boolean, boolean, booleanObject, BooleanObject, Boolean) \ > macro(Number, number, numberObject, NumberObject, Number) \ > macro(Error, error, error, ErrorInstance, Error) \ >+ macro(JSPromise, promise, promise, JSPromise, Promise) \ > macro(JSArrayBuffer, arrayBuffer, arrayBuffer, JSArrayBuffer, ArrayBuffer) \ > DEFINE_STANDARD_BUILTIN(macro, WeakMap, weakMap) \ > DEFINE_STANDARD_BUILTIN(macro, WeakSet, weakSet) \ >@@ -150,6 +152,18 @@ struct GlobalObjectMethodTable { > > typedef bool (*ShouldInterruptScriptBeforeTimeoutPtr)(const JSGlobalObject*); > ShouldInterruptScriptBeforeTimeoutPtr shouldInterruptScriptBeforeTimeout; >+ >+ typedef JSValue (*LoaderResolvePtr)(JSGlobalObject*, ExecState*, JSValue, JSValue); >+ LoaderResolvePtr loaderResolve; >+ >+ typedef JSValue (*LoaderFetchPtr)(JSGlobalObject*, ExecState*, JSValue); >+ LoaderFetchPtr loaderFetch; >+ >+ typedef JSValue (*LoaderTranslatePtr)(JSGlobalObject*, ExecState*, JSValue, JSValue); >+ LoaderTranslatePtr loaderTranslate; >+ >+ typedef JSValue (*LoaderInstantiatePtr)(JSGlobalObject*, ExecState*, JSValue, JSValue); >+ LoaderInstantiatePtr loaderInstantiate; > }; > > class JSGlobalObject : public JSSegmentedVariableObject { >@@ -183,7 +197,6 @@ class JSGlobalObject : public JSSegmentedVariableObject { > WriteBarrier<NativeErrorConstructor> m_syntaxErrorConstructor; > WriteBarrier<NativeErrorConstructor> m_typeErrorConstructor; > WriteBarrier<NativeErrorConstructor> m_URIErrorConstructor; >- WriteBarrier<JSPromiseConstructor> m_promiseConstructor; > WriteBarrier<ObjectConstructor> m_objectConstructor; > > WriteBarrier<NullGetterFunction> m_nullGetterFunction; >@@ -205,7 +218,6 @@ class JSGlobalObject : public JSSegmentedVariableObject { > WriteBarrier<ArrayPrototype> m_arrayPrototype; > WriteBarrier<RegExpPrototype> m_regExpPrototype; > WriteBarrier<IteratorPrototype> m_iteratorPrototype; >- WriteBarrier<JSPromisePrototype> m_promisePrototype; > > WriteBarrier<Structure> m_debuggerScopeStructure; > WriteBarrier<Structure> m_withScopeStructure; >@@ -241,7 +253,7 @@ class JSGlobalObject : public JSSegmentedVariableObject { > WriteBarrier<Structure> m_internalFunctionStructure; > WriteBarrier<Structure> m_iteratorResultStructure; > WriteBarrier<Structure> m_regExpMatchesArrayStructure; >- WriteBarrier<Structure> m_promiseStructure; >+ WriteBarrier<Structure> m_moduleRecordStructure; > #if ENABLE(WEBASSEMBLY) > WriteBarrier<Structure> m_wasmModuleStructure; > #endif >@@ -386,7 +398,6 @@ class JSGlobalObject : public JSSegmentedVariableObject { > NativeErrorConstructor* syntaxErrorConstructor() const { return m_syntaxErrorConstructor.get(); } > NativeErrorConstructor* typeErrorConstructor() const { return m_typeErrorConstructor.get(); } > NativeErrorConstructor* URIErrorConstructor() const { return m_URIErrorConstructor.get(); } >- JSPromiseConstructor* promiseConstructor() const { return m_promiseConstructor.get(); } > > NullGetterFunction* nullGetterFunction() const { return m_nullGetterFunction.get(); } > NullSetterFunction* nullSetterFunction() const { return m_nullSetterFunction.get(); } >@@ -418,7 +429,6 @@ class JSGlobalObject : public JSSegmentedVariableObject { > RegExpPrototype* regExpPrototype() const { return m_regExpPrototype.get(); } > ErrorPrototype* errorPrototype() const { return m_errorPrototype.get(); } > IteratorPrototype* iteratorPrototype() const { return m_iteratorPrototype.get(); } >- JSPromisePrototype* promisePrototype() const { return m_promisePrototype.get(); } > > Structure* debuggerScopeStructure() const { return m_debuggerScopeStructure.get(); } > Structure* withScopeStructure() const { return m_withScopeStructure.get(); } >@@ -475,7 +485,7 @@ class JSGlobalObject : public JSSegmentedVariableObject { > Structure* iteratorResultStructure() const { return m_iteratorResultStructure.get(); } > static ptrdiff_t iteratorResultStructureOffset() { return OBJECT_OFFSETOF(JSGlobalObject, m_iteratorResultStructure); } > Structure* regExpMatchesArrayStructure() const { return m_regExpMatchesArrayStructure.get(); } >- Structure* promiseStructure() const { return m_promiseStructure.get(); } >+ Structure* moduleRecordStructure() const { return m_moduleRecordStructure.get(); } > #if ENABLE(WEBASSEMBLY) > Structure* wasmModuleStructure() const { return m_wasmModuleStructure.get(); } > #endif >diff --git a/Source/JavaScriptCore/runtime/JSModuleRecord.cpp b/Source/JavaScriptCore/runtime/JSModuleRecord.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..3ab89335f75f2cab12c89871fbe79e0dee7864eb >--- /dev/null >+++ b/Source/JavaScriptCore/runtime/JSModuleRecord.cpp >@@ -0,0 +1,105 @@ >+/* >+ * Copyright (C) 2015 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "JSModuleRecord.h" >+ >+#include "IdentifierInlines.h" >+#include "JSCJSValueInlines.h" >+#include "JSCellInlines.h" >+#include "StructureInlines.h" >+ >+namespace JSC { >+ >+const ClassInfo JSModuleRecord::s_info = { "ModuleRecord", &Base::s_info, 0, CREATE_METHOD_TABLE(JSModuleRecord) }; >+ >+void JSModuleRecord::destroy(JSCell* cell) >+{ >+ JSModuleRecord* thisObject = jsCast<JSModuleRecord*>(cell); >+ thisObject->JSModuleRecord::~JSModuleRecord(); >+} >+ >+auto JSModuleRecord::ExportEntry::createLocal(const Identifier& exportName, const Identifier& localName, const VariableEnvironmentEntry& variable) -> ExportEntry >+{ >+ return ExportEntry { Type::Local, exportName, Identifier(), Identifier(), localName, variable }; >+} >+ >+auto JSModuleRecord::ExportEntry::createNamespace(const Identifier& exportName, const Identifier& moduleName) -> ExportEntry >+{ >+ return ExportEntry { Type::Namespace, exportName, moduleName, Identifier(), Identifier(), VariableEnvironmentEntry() }; >+} >+ >+auto JSModuleRecord::ExportEntry::createIndirect(const Identifier& exportName, const Identifier& importName, const Identifier& moduleName) -> ExportEntry >+{ >+ return ExportEntry { Type::Indirect, exportName, moduleName, importName, Identifier(), VariableEnvironmentEntry() }; >+} >+ >+static String printableName(const RefPtr<UniquedStringImpl>& uid) >+{ >+ if (uid->isSymbol()) >+ return uid.get(); >+ return WTF::makeString("'", String(uid.get()), "'"); >+} >+ >+static String printableName(const Identifier& ident) >+{ >+ return printableName(ident.impl()); >+} >+ >+ >+void JSModuleRecord::dump() >+{ >+ dataLog("\nAnalyzing ModuleRecord\n"); >+ >+ dataLog(" Dependencies: ", m_requestedModules.size(), " modules\n"); >+ for (const auto& moduleName : m_requestedModules) >+ dataLog(" module(", printableName(moduleName), ")\n"); >+ >+ dataLog(" Import: ", m_importEntries.size(), " entries\n"); >+ for (const auto& pair : m_importEntries) >+ dataLog(" import(", printableName(pair.value.importName), "), local(", printableName(pair.value.localName), "), module(", printableName(pair.value.moduleRequest), ")\n"); >+ >+ dataLog(" Export: ", m_exportEntries.size(), " entries\n"); >+ for (const auto& pair : m_exportEntries) { >+ const ExportEntry& entry = pair.value; >+ switch (entry.type) { >+ case ExportEntry::Type::Local: >+ dataLog(" [Local] ", "export(", printableName(entry.exportName), "), local(", printableName(entry.localName), ")\n"); >+ break; >+ >+ case ExportEntry::Type::Namespace: >+ dataLog(" [Namespace] ", "export(", printableName(entry.exportName), "), module(", printableName(entry.moduleName), ")\n"); >+ break; >+ >+ case ExportEntry::Type::Indirect: >+ dataLog(" [Indirect] ", "export(", printableName(entry.exportName), "), import(", printableName(entry.importName), "), module(", printableName(entry.moduleName), ")\n"); >+ break; >+ } >+ } >+ for (const auto& moduleName : m_starExportEntries) >+ dataLog(" [Star] module(", printableName(moduleName.get()), ")\n"); >+} >+ >+} // namespace JSC >diff --git a/Source/JavaScriptCore/runtime/JSModuleRecord.h b/Source/JavaScriptCore/runtime/JSModuleRecord.h >new file mode 100644 >index 0000000000000000000000000000000000000000..dc358781e6c7f97f70d3867680338df31ee6d0e2 >--- /dev/null >+++ b/Source/JavaScriptCore/runtime/JSModuleRecord.h >@@ -0,0 +1,155 @@ >+/* >+ * Copyright (C) 2015 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef JSModuleRecord_h >+#define JSModuleRecord_h >+ >+#include "Identifier.h" >+#include "JSDestructibleObject.h" >+#include "VariableEnvironment.h" >+#include <wtf/HashMap.h> >+#include <wtf/ListHashSet.h> >+ >+namespace JSC { >+ >+// Based on the Source Text Module Record >+// http://www.ecma-international.org/ecma-262/6.0/#sec-source-text-module-records >+class JSModuleRecord : public JSDestructibleObject { >+public: >+ typedef JSDestructibleObject Base; >+ >+ struct ExportEntry { >+ enum class Type { >+ Local, >+ Namespace, >+ Indirect >+ }; >+ >+ static ExportEntry createLocal(const Identifier& exportName, const Identifier& localName, const VariableEnvironmentEntry&); >+ static ExportEntry createNamespace(const Identifier& exportName, const Identifier& moduleName); >+ static ExportEntry createIndirect(const Identifier& exportName, const Identifier& importName, const Identifier& moduleName); >+ >+ Type type; >+ Identifier exportName; >+ Identifier moduleName; >+ Identifier importName; >+ Identifier localName; >+ VariableEnvironmentEntry variable; >+ }; >+ >+ struct ImportEntry { >+ Identifier moduleRequest; >+ Identifier importName; >+ Identifier localName; >+ >+ bool isNamespace(VM& vm) const >+ { >+ return importName == vm.propertyNames->timesIdentifier; >+ } >+ }; >+ >+ typedef WTF::ListHashSet<RefPtr<UniquedStringImpl>, IdentifierRepHash> OrderedIdentifierSet; >+ typedef HashMap<RefPtr<UniquedStringImpl>, ImportEntry, IdentifierRepHash, HashTraits<RefPtr<UniquedStringImpl>>> ImportMap; >+ typedef HashMap<RefPtr<UniquedStringImpl>, ExportEntry, IdentifierRepHash, HashTraits<RefPtr<UniquedStringImpl>>> ExportMap; >+ >+ DECLARE_EXPORT_INFO; >+ >+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) >+ { >+ return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); >+ } >+ >+ static JSModuleRecord* create(VM& vm, Structure* structure) >+ { >+ JSModuleRecord* instance = new (NotNull, allocateCell<JSModuleRecord>(vm.heap)) JSModuleRecord(vm, structure); >+ instance->finishCreation(vm); >+ return instance; >+ } >+ >+ static JSModuleRecord* create(ExecState* exec, Structure* structure) >+ { >+ return create(exec->vm(), structure); >+ } >+ >+ void appendRequestedModule(const Identifier&); >+ void addStarExportEntry(const Identifier&); >+ void addImportEntry(const ImportEntry&); >+ void addExportEntry(const ExportEntry&); >+ >+ const ImportEntry& lookUpImportEntry(const RefPtr<UniquedStringImpl>& localName); >+ >+ const OrderedIdentifierSet& requestedModules() const { return m_requestedModules; } >+ >+ void dump(); >+ >+private: >+ JSModuleRecord(VM& vm, Structure* structure) >+ : Base(vm, structure) >+ { >+ } >+ >+ static void destroy(JSCell*); >+ >+ // Map localName -> ImportEntry. >+ ImportMap m_importEntries; >+ >+ // Map exportName -> ExportEntry. >+ ExportMap m_exportEntries; >+ >+ IdentifierSet m_starExportEntries; >+ >+ // Save the occurrence order since the module loader loads and runs the modules in this order. >+ // http://www.ecma-international.org/ecma-262/6.0/#sec-moduleevaluation >+ OrderedIdentifierSet m_requestedModules; >+}; >+ >+inline void JSModuleRecord::appendRequestedModule(const Identifier& moduleName) >+{ >+ m_requestedModules.add(moduleName.impl()); >+} >+ >+inline void JSModuleRecord::addImportEntry(const ImportEntry& entry) >+{ >+ m_importEntries.add(entry.localName.impl(), entry); >+} >+ >+inline void JSModuleRecord::addExportEntry(const ExportEntry& entry) >+{ >+ m_exportEntries.add(entry.exportName.impl(), entry); >+} >+ >+inline void JSModuleRecord::addStarExportEntry(const Identifier& moduleName) >+{ >+ m_starExportEntries.add(moduleName.impl()); >+} >+ >+inline auto JSModuleRecord::lookUpImportEntry(const RefPtr<UniquedStringImpl>& localName) -> const ImportEntry& >+{ >+ return (*m_importEntries.find(localName)).value; >+} >+ >+} // namespace JSC >+ >+#endif // JSModuleRecord_h >diff --git a/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp b/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp >index 44e1e73caba55b0bf54092ec584fe657e5461ae5..243bc527c46ffd5edad364d5200ff8ef946c2d85 100644 >--- a/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp >+++ b/Source/JavaScriptCore/runtime/JSPromiseConstructor.cpp >@@ -26,6 +26,7 @@ > #include "config.h" > #include "JSPromiseConstructor.h" > >+#include "BuiltinNames.h" > #include "Error.h" > #include "Exception.h" > #include "IteratorOperations.h" >@@ -81,6 +82,7 @@ void JSPromiseConstructor::finishCreation(VM& vm, JSPromisePrototype* promisePro > Base::finishCreation(vm, ASCIILiteral("Promise")); > putDirectWithoutTransition(vm, vm.propertyNames->prototype, promisePrototype, DontEnum | DontDelete | ReadOnly); > putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete); >+ putDirectBuiltinFunctionWithoutTransition(vm, globalObject(), vm.propertyNames->builtinNames().allPrivateName(), promiseConstructorPrivateAllCodeGenerator(vm), ReadOnly | DontEnum | DontDelete); > } > > static EncodedJSValue JSC_HOST_CALL constructPromise(ExecState* exec) >diff --git a/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp b/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp >index 6f3543235bd8a0938418ff7affcdd02b13584747..000b6462dfc7aad42084e2c96fe32e7807c702de 100644 >--- a/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp >+++ b/Source/JavaScriptCore/runtime/JSPromiseDeferred.cpp >@@ -72,6 +72,28 @@ JSPromiseDeferred::JSPromiseDeferred(VM& vm) > { > } > >+static void callFunction(ExecState* exec, JSValue function, JSValue value) >+{ >+ CallData callData; >+ CallType callType = getCallData(function, callData); >+ ASSERT(callType != CallTypeNone); >+ >+ MarkedArgumentBuffer arguments; >+ arguments.append(value); >+ >+ call(exec, function, callType, callData, jsUndefined(), arguments); >+} >+ >+void JSPromiseDeferred::resolve(ExecState* exec, JSValue value) >+{ >+ callFunction(exec, m_resolve.get(), value); >+} >+ >+void JSPromiseDeferred::reject(ExecState* exec, JSValue reason) >+{ >+ callFunction(exec, m_reject.get(), reason); >+} >+ > void JSPromiseDeferred::finishCreation(VM& vm, JSObject* promise, JSValue resolve, JSValue reject) > { > Base::finishCreation(vm); >diff --git a/Source/JavaScriptCore/runtime/JSPromiseDeferred.h b/Source/JavaScriptCore/runtime/JSPromiseDeferred.h >index dea0d17f9b42cec67acc8235506595db51e94107..4a0b4b8568a47bdd9fe2c38f850476f2db91da27 100644 >--- a/Source/JavaScriptCore/runtime/JSPromiseDeferred.h >+++ b/Source/JavaScriptCore/runtime/JSPromiseDeferred.h >@@ -50,6 +50,9 @@ class JSPromiseDeferred final : public JSCell { > JSValue resolve() const { return m_resolve.get(); } > JSValue reject() const { return m_reject.get(); } > >+ JS_EXPORT_PRIVATE void resolve(ExecState*, JSValue); >+ JS_EXPORT_PRIVATE void reject(ExecState*, JSValue); >+ > private: > JSPromiseDeferred(VM&); > void finishCreation(VM&, JSObject*, JSValue, JSValue); >diff --git a/Source/JavaScriptCore/runtime/JSPromisePrototype.cpp b/Source/JavaScriptCore/runtime/JSPromisePrototype.cpp >index a0f1024320c14bb364e810343935ad793a7da486..026837348075da3e4787b4a2df4ceeec51ca619d 100644 >--- a/Source/JavaScriptCore/runtime/JSPromisePrototype.cpp >+++ b/Source/JavaScriptCore/runtime/JSPromisePrototype.cpp >@@ -26,6 +26,7 @@ > #include "config.h" > #include "JSPromisePrototype.h" > >+#include "BuiltinNames.h" > #include "Error.h" > #include "JSCBuiltins.h" > #include "JSCJSValueInlines.h" >@@ -54,10 +55,9 @@ const ClassInfo JSPromisePrototype::s_info = { "PromisePrototype", &JSNonFinalOb > @end > */ > >-JSPromisePrototype* JSPromisePrototype::create(ExecState* exec, JSGlobalObject*, Structure* structure) >+JSPromisePrototype* JSPromisePrototype::create(VM& vm, JSGlobalObject*, Structure* structure) > { >- VM& vm = exec->vm(); >- JSPromisePrototype* object = new (NotNull, allocateCell<JSPromisePrototype>(vm.heap)) JSPromisePrototype(exec, structure); >+ JSPromisePrototype* object = new (NotNull, allocateCell<JSPromisePrototype>(vm.heap)) JSPromisePrototype(vm, structure); > object->finishCreation(vm, structure); > return object; > } >@@ -67,14 +67,15 @@ Structure* JSPromisePrototype::createStructure(VM& vm, JSGlobalObject* globalObj > return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); > } > >-JSPromisePrototype::JSPromisePrototype(ExecState* exec, Structure* structure) >- : JSNonFinalObject(exec->vm(), structure) >+JSPromisePrototype::JSPromisePrototype(VM& vm, Structure* structure) >+ : JSNonFinalObject(vm, structure) > { > } > > void JSPromisePrototype::finishCreation(VM& vm, Structure*) > { > Base::finishCreation(vm); >+ putDirectBuiltinFunctionWithoutTransition(vm, globalObject(), vm.propertyNames->builtinNames().thenPrivateName(), promisePrototypePrivateThenCodeGenerator(vm), ReadOnly | DontEnum | DontDelete); > } > > bool JSPromisePrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot) >diff --git a/Source/JavaScriptCore/runtime/JSPromisePrototype.h b/Source/JavaScriptCore/runtime/JSPromisePrototype.h >index 458d14119ddf9abe0763b77739b4ea9b85c21906..4e871c756cc8e7577a0704115603f93e8553e1f7 100644 >--- a/Source/JavaScriptCore/runtime/JSPromisePrototype.h >+++ b/Source/JavaScriptCore/runtime/JSPromisePrototype.h >@@ -35,7 +35,7 @@ class JSPromisePrototype : public JSNonFinalObject { > typedef JSNonFinalObject Base; > static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot; > >- static JSPromisePrototype* create(ExecState*, JSGlobalObject*, Structure*); >+ static JSPromisePrototype* create(VM&, JSGlobalObject*, Structure*); > static Structure* createStructure(VM&, JSGlobalObject*, JSValue); > > DECLARE_INFO; >@@ -44,7 +44,7 @@ class JSPromisePrototype : public JSNonFinalObject { > void finishCreation(VM&, Structure*); > > private: >- JSPromisePrototype(ExecState*, Structure*); >+ JSPromisePrototype(VM&, Structure*); > static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&); > }; > >diff --git a/Source/JavaScriptCore/runtime/MapPrototype.cpp b/Source/JavaScriptCore/runtime/MapPrototype.cpp >index 96deae714ca51a67fd16408e5c39d3c65673894d..e972f540efb2f1e6a48d12503f0318971f42df82 100644 >--- a/Source/JavaScriptCore/runtime/MapPrototype.cpp >+++ b/Source/JavaScriptCore/runtime/MapPrototype.cpp >@@ -68,6 +68,10 @@ void MapPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject) > JSC_NATIVE_FUNCTION(vm.propertyNames->keys, mapProtoFuncKeys, DontEnum, 0); > JSC_NATIVE_FUNCTION(vm.propertyNames->values, mapProtoFuncValues, DontEnum, 0); > >+ // Private get / set operations. >+ JSC_NATIVE_FUNCTION(vm.propertyNames->getPrivateName, mapProtoFuncGet, DontEnum, 1); >+ JSC_NATIVE_FUNCTION(vm.propertyNames->setPrivateName, mapProtoFuncSet, DontEnum, 2); >+ > JSFunction* entries = JSFunction::create(vm, globalObject, 0, vm.propertyNames->entries.string(), mapProtoFuncEntries); > putDirectWithoutTransition(vm, vm.propertyNames->entries, entries, DontEnum); > putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, entries, DontEnum); >diff --git a/Source/JavaScriptCore/runtime/ModuleLoaderObject.cpp b/Source/JavaScriptCore/runtime/ModuleLoaderObject.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..78de7b8ef87b9d58f268d28808b939d0d8161217 >--- /dev/null >+++ b/Source/JavaScriptCore/runtime/ModuleLoaderObject.cpp >@@ -0,0 +1,248 @@ >+/* >+ * Copyright (C) 2015 Apple Inc. All Rights Reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "ModuleLoaderObject.h" >+ >+#include "Error.h" >+#include "Exception.h" >+#include "JSCInlines.h" >+#include "JSGlobalObjectFunctions.h" >+#include "JSMap.h" >+#include "JSModuleRecord.h" >+#include "JSPromise.h" >+#include "JSPromiseDeferred.h" >+#include "ModuleAnalyzer.h" >+#include "Nodes.h" >+#include "Parser.h" >+#include "ParserError.h" >+ >+namespace JSC { >+ >+static EncodedJSValue JSC_HOST_CALL moduleLoaderObjectParseModule(ExecState*); >+static EncodedJSValue JSC_HOST_CALL moduleLoaderObjectRequestedModules(ExecState*); >+static EncodedJSValue JSC_HOST_CALL moduleLoaderObjectResolve(ExecState*); >+static EncodedJSValue JSC_HOST_CALL moduleLoaderObjectFetch(ExecState*); >+static EncodedJSValue JSC_HOST_CALL moduleLoaderObjectTranslate(ExecState*); >+static EncodedJSValue JSC_HOST_CALL moduleLoaderObjectInstantiate(ExecState*); >+ >+} >+ >+#include "ModuleLoaderObject.lut.h" >+ >+namespace JSC { >+ >+STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(ModuleLoaderObject); >+ >+const ClassInfo ModuleLoaderObject::s_info = { "ModuleLoader", &Base::s_info, &moduleLoaderObjectTable, CREATE_METHOD_TABLE(ModuleLoaderObject) }; >+ >+/* Source for ModuleLoaderObject.lut.h >+@begin moduleLoaderObjectTable >+ setStateToMax moduleLoaderObjectSetStateToMax DontEnum|Function 2 >+ newRegistryEntry moduleLoaderObjectNewRegistryEntry DontEnum|Function 1 >+ ensureRegistered moduleLoaderObjectEnsureRegistered DontEnum|Function 1 >+ forceFulfillPromise moduleLoaderObjectForceFulfillPromise DontEnum|Function 2 >+ fulfillFetch moduleLoaderObjectFulfillFetch DontEnum|Function 2 >+ fulfillTranslate moduleLoaderObjectFulfillTranslate DontEnum|Function 2 >+ fulfillInstantiate moduleLoaderObjectFulfillInstantiate DontEnum|Function 2 >+ commitInstantiated moduleLoaderObjectCommitInstantiated DontEnum|Function 3 >+ instantiation moduleLoaderObjectInstantiation DontEnum|Function 2 >+ requestFetch moduleLoaderObjectRequestFetch DontEnum|Function 1 >+ requestTranslate moduleLoaderObjectRequestTranslate DontEnum|Function 1 >+ requestInstantiate moduleLoaderObjectRequestInstantiate DontEnum|Function 1 >+ requestInstantiateAll moduleLoaderObjectRequestInstantiateAll DontEnum|Function 1 >+ parseModule moduleLoaderObjectParseModule DontEnum|Function 1 >+ requestedModules moduleLoaderObjectRequestedModules DontEnum|Function 1 >+ resolve moduleLoaderObjectResolve DontEnum|Function 1 >+ fetch moduleLoaderObjectFetch DontEnum|Function 1 >+ translate moduleLoaderObjectTranslate DontEnum|Function 2 >+ instantiate moduleLoaderObjectInstantiate DontEnum|Function 2 >+@end >+*/ >+ >+ModuleLoaderObject::ModuleLoaderObject(VM& vm, Structure* structure) >+ : JSNonFinalObject(vm, structure) >+{ >+} >+ >+void ModuleLoaderObject::finishCreation(VM& vm, JSGlobalObject* globalObject) >+{ >+ Base::finishCreation(vm); >+ ASSERT(inherits(info())); >+ >+ // Constant values for the state. >+ putDirectWithoutTransition(vm, Identifier::fromString(&vm, "Fetch"), jsNumber(exp(0))); >+ putDirectWithoutTransition(vm, Identifier::fromString(&vm, "Translate"), jsNumber(1)); >+ putDirectWithoutTransition(vm, Identifier::fromString(&vm, "Instantiate"), jsNumber(2)); >+ putDirectWithoutTransition(vm, Identifier::fromString(&vm, "Link"), jsNumber(3)); >+ putDirectWithoutTransition(vm, Identifier::fromString(&vm, "Ready"), jsNumber(4)); >+ >+ putDirectWithoutTransition(vm, Identifier::fromString(&vm, "registry"), JSMap::create(vm, globalObject->mapStructure())); >+} >+ >+bool ModuleLoaderObject::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot &slot) >+{ >+ return getStaticFunctionSlot<Base>(exec, moduleLoaderObjectTable, jsCast<ModuleLoaderObject*>(object), propertyName, slot); >+} >+ >+// ------------------------------ Functions -------------------------------- >+ >+JSValue ModuleLoaderObject::resolve(ExecState* exec, JSValue name, JSValue referrer) >+{ >+ JSGlobalObject* globalObject = exec->lexicalGlobalObject(); >+ if (globalObject->globalObjectMethodTable()->loaderResolve) >+ return globalObject->globalObjectMethodTable()->loaderResolve(globalObject, exec, name, referrer); >+ JSPromiseDeferred* deferred = JSPromiseDeferred::create(exec, globalObject); >+ deferred->resolve(exec, name); >+ return deferred->promise(); >+} >+ >+JSValue ModuleLoaderObject::fetch(ExecState* exec, JSValue key) >+{ >+ JSGlobalObject* globalObject = exec->lexicalGlobalObject(); >+ if (globalObject->globalObjectMethodTable()->loaderFetch) >+ return globalObject->globalObjectMethodTable()->loaderFetch(globalObject, exec, key); >+ JSPromiseDeferred* deferred = JSPromiseDeferred::create(exec, globalObject); >+ String moduleKey = key.toString(exec)->value(exec); >+ if (exec->hadException()) { >+ JSValue exception = exec->exception()->value(); >+ exec->clearException(); >+ deferred->reject(exec, exception); >+ return deferred->promise(); >+ } >+ deferred->reject(exec, createError(exec, makeString("Could not open the module '", moduleKey, "'."))); >+ return deferred->promise(); >+} >+ >+JSValue ModuleLoaderObject::translate(ExecState* exec, JSValue key, JSValue payload) >+{ >+ JSGlobalObject* globalObject = exec->lexicalGlobalObject(); >+ if (globalObject->globalObjectMethodTable()->loaderTranslate) >+ return globalObject->globalObjectMethodTable()->loaderTranslate(globalObject, exec, key, payload); >+ JSPromiseDeferred* deferred = JSPromiseDeferred::create(exec, globalObject); >+ deferred->resolve(exec, payload); >+ return deferred->promise(); >+} >+ >+JSValue ModuleLoaderObject::instantiate(ExecState* exec, JSValue key, JSValue source) >+{ >+ JSGlobalObject* globalObject = exec->lexicalGlobalObject(); >+ if (globalObject->globalObjectMethodTable()->loaderInstantiate) >+ return globalObject->globalObjectMethodTable()->loaderInstantiate(globalObject, exec, key, source); >+ JSPromiseDeferred* deferred = JSPromiseDeferred::create(exec, globalObject); >+ deferred->resolve(exec, jsUndefined()); >+ return deferred->promise(); >+} >+ >+// ------------------------------ Hook Functions --------------------------- >+ >+EncodedJSValue JSC_HOST_CALL moduleLoaderObjectParseModule(ExecState* exec) >+{ >+ VM& vm = exec->vm(); >+ String source = exec->argument(0).toString(exec)->value(exec); >+ if (exec->hadException()) >+ return JSValue::encode(jsUndefined()); >+ >+ // FIXME: Construct SourceCode with the location identifier. >+ SourceCode sourceCode = makeSource(source); >+ >+ ParserError error; >+ std::unique_ptr<ModuleProgramNode> moduleProgramNode = parse<ModuleProgramNode>( >+ &vm, sourceCode, Identifier(), JSParserBuiltinMode::NotBuiltin, >+ JSParserStrictMode::Strict, SourceParseMode::ModuleAnalyzeMode, error); >+ >+ if (error.isValid()) { >+ throwVMError(exec, error.toErrorObject(exec->lexicalGlobalObject(), sourceCode)); >+ return JSValue::encode(jsUndefined()); >+ } >+ ASSERT(moduleProgramNode); >+ >+ ModuleAnalyzer moduleAnalyzer(exec, moduleProgramNode->varDeclarations(), moduleProgramNode->lexicalVariables()); >+ return JSValue::encode(moduleAnalyzer.analyze(*moduleProgramNode)); >+} >+ >+EncodedJSValue JSC_HOST_CALL moduleLoaderObjectRequestedModules(ExecState* exec) >+{ >+ JSModuleRecord* moduleRecord = jsDynamicCast<JSModuleRecord*>(exec->argument(0)); >+ if (!moduleRecord) >+ return JSValue::encode(constructEmptyArray(exec, nullptr)); >+ >+ JSArray* result = constructEmptyArray(exec, nullptr, moduleRecord->requestedModules().size()); >+ size_t i = 0; >+ for (auto& key : moduleRecord->requestedModules()) >+ result->putDirectIndex(exec, i++, jsString(exec, key.get())); >+ >+ return JSValue::encode(result); >+} >+ >+EncodedJSValue JSC_HOST_CALL moduleLoaderObjectResolve(ExecState* exec) >+{ >+ // Hook point, Loader.resolve. >+ // https://whatwg.github.io/loader/#browser-resolve >+ // Take the name and resolve it to the unique identifier for the resource location. >+ // For example, take the "jquery" and return the URL for the resource. >+ ModuleLoaderObject* loader = jsDynamicCast<ModuleLoaderObject*>(exec->thisValue()); >+ if (!loader) >+ return JSValue::encode(jsUndefined()); >+ return JSValue::encode(loader->resolve(exec, exec->argument(0), exec->argument(1))); >+} >+ >+EncodedJSValue JSC_HOST_CALL moduleLoaderObjectFetch(ExecState* exec) >+{ >+ // Hook point, Loader.fetch >+ // https://whatwg.github.io/loader/#browser-fetch >+ // Take the key and fetch the resource actually. >+ ModuleLoaderObject* loader = jsDynamicCast<ModuleLoaderObject*>(exec->thisValue()); >+ if (!loader) >+ return JSValue::encode(jsUndefined()); >+ return JSValue::encode(loader->fetch(exec, exec->argument(0))); >+} >+ >+EncodedJSValue JSC_HOST_CALL moduleLoaderObjectTranslate(ExecState* exec) >+{ >+ // Hook point, Loader.translate >+ // https://whatwg.github.io/loader/#browser-translate >+ // Take the key and the fetched source code and translate it to the ES6 source code. >+ // It may be used for the transpilers in the future. >+ ModuleLoaderObject* loader = jsDynamicCast<ModuleLoaderObject*>(exec->thisValue()); >+ if (!loader) >+ return JSValue::encode(jsUndefined()); >+ return JSValue::encode(loader->translate(exec, exec->argument(0), exec->argument(1))); >+} >+ >+EncodedJSValue JSC_HOST_CALL moduleLoaderObjectInstantiate(ExecState* exec) >+{ >+ // Hook point, Loader.instantiate >+ // https://whatwg.github.io/loader/#browser-instantiate >+ // Take the key and the translated source code. >+ // It has the chance to provide the optional module instance that is different from >+ // the ordinary one. >+ ModuleLoaderObject* loader = jsDynamicCast<ModuleLoaderObject*>(exec->thisValue()); >+ if (!loader) >+ return JSValue::encode(jsUndefined()); >+ return JSValue::encode(loader->instantiate(exec, exec->argument(0), exec->argument(1))); >+} >+ >+} // namespace JSC >diff --git a/Source/JavaScriptCore/runtime/ModuleLoaderObject.h b/Source/JavaScriptCore/runtime/ModuleLoaderObject.h >new file mode 100644 >index 0000000000000000000000000000000000000000..754e441f40cd6f56a3a6a2bcfd4a43999b9c0478 >--- /dev/null >+++ b/Source/JavaScriptCore/runtime/ModuleLoaderObject.h >@@ -0,0 +1,68 @@ >+/* >+ * Copyright (C) 2015 Apple Inc. All Rights Reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef ModuleLoaderObject_h >+#define ModuleLoaderObject_h >+ >+#include "JSObject.h" >+ >+namespace JSC { >+ >+class ModuleLoaderObject : public JSNonFinalObject { >+private: >+ ModuleLoaderObject(VM&, Structure*); >+ >+public: >+ typedef JSNonFinalObject Base; >+ static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot; >+ >+ static ModuleLoaderObject* create(VM& vm, JSGlobalObject* globalObject, Structure* structure) >+ { >+ ModuleLoaderObject* object = new (NotNull, allocateCell<ModuleLoaderObject>(vm.heap)) ModuleLoaderObject(vm, structure); >+ object->finishCreation(vm, globalObject); >+ return object; >+ } >+ >+ DECLARE_INFO; >+ >+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) >+ { >+ return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info()); >+ } >+ >+ JSValue resolve(ExecState*, JSValue name, JSValue referrer); >+ JSValue fetch(ExecState*, JSValue key); >+ JSValue translate(ExecState*, JSValue key, JSValue payload); >+ JSValue instantiate(ExecState*, JSValue key, JSValue source); >+ >+ static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&); >+ >+protected: >+ void finishCreation(VM&, JSGlobalObject*); >+}; >+ >+} // namespace JSC >+ >+#endif // ModuleLoaderObject_h >diff --git a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp b/Source/WebCore/bindings/js/JSDOMWindowBase.cpp >index 9ab0a8f0d0fbd78e5e57d580477e655cb89595d1..a290ddc9e581acd634301700baf827ca1a4efd02 100644 >--- a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp >+++ b/Source/WebCore/bindings/js/JSDOMWindowBase.cpp >@@ -56,7 +56,7 @@ static bool shouldAllowAccessFrom(const JSGlobalObject* thisObject, ExecState* e > > const ClassInfo JSDOMWindowBase::s_info = { "Window", &JSDOMGlobalObject::s_info, 0, CREATE_METHOD_TABLE(JSDOMWindowBase) }; > >-const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &shouldAllowAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout }; >+const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &shouldAllowAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr }; > > JSDOMWindowBase::JSDOMWindowBase(VM& vm, Structure* structure, PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell) > : JSDOMGlobalObject(vm, structure, &shell->world(), &s_globalObjectMethodTable) >diff --git a/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp b/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp >index aaa5dba55171cb9541ba65e1d247ab29c9d9c7c3..5044bc1783513b9b1a26bd3bd1cb5c00b70a10d0 100644 >--- a/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp >+++ b/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp >@@ -43,7 +43,7 @@ namespace WebCore { > > const ClassInfo JSWorkerGlobalScopeBase::s_info = { "WorkerGlobalScope", &JSDOMGlobalObject::s_info, 0, CREATE_METHOD_TABLE(JSWorkerGlobalScopeBase) }; > >-const GlobalObjectMethodTable JSWorkerGlobalScopeBase::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout }; >+const GlobalObjectMethodTable JSWorkerGlobalScopeBase::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr }; > > JSWorkerGlobalScopeBase::JSWorkerGlobalScopeBase(JSC::VM& vm, JSC::Structure* structure, PassRefPtr<WorkerGlobalScope> impl) > : JSDOMGlobalObject(vm, structure, &normalWorld(vm), &s_globalObjectMethodTable)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 147876
:
259060
|
259085
|
259087
|
259100
|
259101
|
259367
|
259386
|
259388
|
259447
|
259455
|
259490