[ES6] Add ModuleLoaderPrototype and move methods to it
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Aug 2016 08:37:06 +0000 (08:37 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Aug 2016 08:37:06 +0000 (08:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160633

Reviewed by Saam Barati.

Source/JavaScriptCore:

In the future, we need to add the ability to create the new Loader object (by users).
So rather than holding all the methods in the ModuleLoaderObject instance, moving them
to ModuleLoaderPrototype and create the default JSModuleLoader instance is better.

No behavior change.

* CMakeLists.txt:
* DerivedSources.make:
* JavaScriptCore.xcodeproj/project.pbxproj:
* builtins/ModuleLoaderObject.js:
(setStateToMax): Deleted.
(newRegistryEntry): Deleted.
(ensureRegistered): Deleted.
(forceFulfillPromise): Deleted.
(fulfillFetch): Deleted.
(fulfillTranslate): Deleted.
(fulfillInstantiate): Deleted.
(commitInstantiated): Deleted.
(instantiation): Deleted.
(requestFetch): Deleted.
(requestTranslate): Deleted.
(requestInstantiate): Deleted.
(requestResolveDependencies.): Deleted.
(requestResolveDependencies): Deleted.
(requestInstantiateAll): Deleted.
(requestLink): Deleted.
(requestReady): Deleted.
(link): Deleted.
(moduleEvaluation): Deleted.
(provide): Deleted.
(loadAndEvaluateModule): Deleted.
(loadModule): Deleted.
(linkAndEvaluateModule): Deleted.
* builtins/ModuleLoaderPrototype.js: Renamed from Source/JavaScriptCore/builtins/ModuleLoaderObject.js.
(setStateToMax):
(newRegistryEntry):
(ensureRegistered):
(forceFulfillPromise):
(fulfillFetch):
(fulfillTranslate):
(fulfillInstantiate):
(commitInstantiated):
(instantiation):
(requestFetch):
(requestTranslate):
(requestInstantiate):
(requestResolveDependencies.):
(requestResolveDependencies):
(requestInstantiateAll):
(requestLink):
(requestReady):
(link):
(moduleEvaluation):
(provide):
(loadAndEvaluateModule):
(loadModule):
(linkAndEvaluateModule):
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
* jsc.cpp:
(GlobalObject::moduleLoaderResolve):
(GlobalObject::moduleLoaderFetch):
* runtime/Completion.cpp:
(JSC::loadAndEvaluateModule):
(JSC::loadModule):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::moduleLoader):
(JSC::JSGlobalObject::moduleLoaderStructure):
* runtime/JSModuleLoader.cpp: Added.
(JSC::JSModuleLoader::JSModuleLoader):
(JSC::JSModuleLoader::finishCreation):
(JSC::printableModuleKey):
(JSC::JSModuleLoader::provide):
(JSC::JSModuleLoader::loadAndEvaluateModule):
(JSC::JSModuleLoader::loadModule):
(JSC::JSModuleLoader::linkAndEvaluateModule):
(JSC::JSModuleLoader::resolve):
(JSC::JSModuleLoader::fetch):
(JSC::JSModuleLoader::translate):
(JSC::JSModuleLoader::instantiate):
(JSC::JSModuleLoader::evaluate):
* runtime/JSModuleLoader.h: Copied from Source/JavaScriptCore/runtime/ModuleLoaderObject.h.
(JSC::JSModuleLoader::create):
(JSC::JSModuleLoader::createStructure):
* runtime/JSModuleRecord.h:
* runtime/ModuleLoaderObject.cpp: Removed.
(JSC::ModuleLoaderObject::ModuleLoaderObject): Deleted.
(JSC::ModuleLoaderObject::finishCreation): Deleted.
(JSC::printableModuleKey): Deleted.
(JSC::ModuleLoaderObject::provide): Deleted.
(JSC::ModuleLoaderObject::loadAndEvaluateModule): Deleted.
(JSC::ModuleLoaderObject::loadModule): Deleted.
(JSC::ModuleLoaderObject::linkAndEvaluateModule): Deleted.
(JSC::ModuleLoaderObject::resolve): Deleted.
(JSC::ModuleLoaderObject::fetch): Deleted.
(JSC::ModuleLoaderObject::translate): Deleted.
(JSC::ModuleLoaderObject::instantiate): Deleted.
(JSC::ModuleLoaderObject::evaluate): Deleted.
(JSC::moduleLoaderObjectParseModule): Deleted.
(JSC::moduleLoaderObjectRequestedModules): Deleted.
(JSC::moduleLoaderObjectModuleDeclarationInstantiation): Deleted.
(JSC::moduleLoaderObjectResolve): Deleted.
(JSC::moduleLoaderObjectFetch): Deleted.
(JSC::moduleLoaderObjectTranslate): Deleted.
(JSC::moduleLoaderObjectInstantiate): Deleted.
(JSC::moduleLoaderObjectEvaluate): Deleted.
* runtime/ModuleLoaderObject.h:
(JSC::ModuleLoaderObject::create): Deleted.
(JSC::ModuleLoaderObject::createStructure): Deleted.
* runtime/ModuleLoaderPrototype.cpp: Added.
(JSC::ModuleLoaderPrototype::ModuleLoaderPrototype):
(JSC::moduleLoaderPrototypeParseModule):
(JSC::moduleLoaderPrototypeRequestedModules):
(JSC::moduleLoaderPrototypeModuleDeclarationInstantiation):
(JSC::moduleLoaderPrototypeResolve):
(JSC::moduleLoaderPrototypeFetch):
(JSC::moduleLoaderPrototypeTranslate):
(JSC::moduleLoaderPrototypeInstantiate):
(JSC::moduleLoaderPrototypeEvaluate):
* runtime/ModuleLoaderPrototype.h: Renamed from Source/JavaScriptCore/runtime/ModuleLoaderObject.h.
(JSC::ModuleLoaderPrototype::create):
(JSC::ModuleLoaderPrototype::createStructure):

Source/WebCore:

No behavior change.

* ForwardingHeaders/runtime/JSModuleLoader.h: Added.
* bindings/js/JSDOMWindowBase.cpp:
(WebCore::JSDOMWindowBase::moduleLoaderResolve):
(WebCore::JSDOMWindowBase::moduleLoaderFetch):
(WebCore::JSDOMWindowBase::moduleLoaderEvaluate):
* bindings/js/JSDOMWindowBase.h:
* bindings/js/JSModuleLoader.cpp:
(WebCore::JSModuleLoader::resolve):
(WebCore::JSModuleLoader::fetch):
(WebCore::JSModuleLoader::evaluate):
* bindings/js/JSModuleLoader.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204330 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/DerivedSources.make
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js [moved from Source/JavaScriptCore/builtins/ModuleLoaderObject.js with 100% similarity]
Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp
Source/JavaScriptCore/jsc.cpp
Source/JavaScriptCore/runtime/Completion.cpp
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/JavaScriptCore/runtime/JSGlobalObject.h
Source/JavaScriptCore/runtime/JSModuleLoader.cpp [new file with mode: 0644]
Source/JavaScriptCore/runtime/JSModuleLoader.h [moved from Source/JavaScriptCore/runtime/ModuleLoaderObject.h with 84% similarity]
Source/JavaScriptCore/runtime/JSModuleRecord.h
Source/JavaScriptCore/runtime/ModuleLoaderObject.cpp [deleted file]
Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp [new file with mode: 0644]
Source/JavaScriptCore/runtime/ModuleLoaderPrototype.h [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/ForwardingHeaders/runtime/JSModuleLoader.h [new file with mode: 0644]
Source/WebCore/bindings/js/JSDOMWindowBase.cpp
Source/WebCore/bindings/js/JSDOMWindowBase.h
Source/WebCore/bindings/js/JSModuleLoader.cpp
Source/WebCore/bindings/js/JSModuleLoader.h

index 8458b93..03dfcab 100644 (file)
@@ -717,6 +717,7 @@ set(JavaScriptCore_SOURCES
     runtime/JSMap.cpp
     runtime/JSMapIterator.cpp
     runtime/JSModuleEnvironment.cpp
+    runtime/JSModuleLoader.cpp
     runtime/JSModuleNamespaceObject.cpp
     runtime/JSModuleRecord.cpp
     runtime/JSNativeStdFunction.cpp
@@ -757,7 +758,7 @@ set(JavaScriptCore_SOURCES
     runtime/MathCommon.cpp
     runtime/MathObject.cpp
     runtime/MemoryStatistics.cpp
-    runtime/ModuleLoaderObject.cpp
+    runtime/ModuleLoaderPrototype.cpp
     runtime/NativeErrorConstructor.cpp
     runtime/NativeErrorPrototype.cpp
     runtime/NativeStdFunctionCell.cpp
@@ -873,7 +874,7 @@ set(JavaScriptCore_OBJECT_LUT_SOURCES
     runtime/JSPromiseConstructor.cpp
     runtime/JSPromisePrototype.cpp
     runtime/MapPrototype.cpp
-    runtime/ModuleLoaderObject.cpp
+    runtime/ModuleLoaderPrototype.cpp
     runtime/NumberConstructor.cpp
     runtime/NumberPrototype.cpp
     runtime/ObjectConstructor.cpp
@@ -1231,7 +1232,7 @@ set(JavaScriptCore_BUILTINS_SOURCES
     ${JAVASCRIPTCORE_DIR}/builtins/InternalPromiseConstructor.js
     ${JAVASCRIPTCORE_DIR}/builtins/IteratorPrototype.js
     ${JAVASCRIPTCORE_DIR}/builtins/MapPrototype.js
-    ${JAVASCRIPTCORE_DIR}/builtins/ModuleLoaderObject.js
+    ${JAVASCRIPTCORE_DIR}/builtins/ModuleLoaderPrototype.js
     ${JAVASCRIPTCORE_DIR}/builtins/NumberConstructor.js
     ${JAVASCRIPTCORE_DIR}/builtins/NumberPrototype.js
     ${JAVASCRIPTCORE_DIR}/builtins/ObjectConstructor.js
index fda177c..cd0b5e8 100644 (file)
@@ -1,3 +1,136 @@
+2016-08-10  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [ES6] Add ModuleLoaderPrototype and move methods to it
+        https://bugs.webkit.org/show_bug.cgi?id=160633
+
+        Reviewed by Saam Barati.
+
+        In the future, we need to add the ability to create the new Loader object (by users).
+        So rather than holding all the methods in the ModuleLoaderObject instance, moving them
+        to ModuleLoaderPrototype and create the default JSModuleLoader instance is better.
+
+        No behavior change.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * builtins/ModuleLoaderObject.js:
+        (setStateToMax): Deleted.
+        (newRegistryEntry): Deleted.
+        (ensureRegistered): Deleted.
+        (forceFulfillPromise): Deleted.
+        (fulfillFetch): Deleted.
+        (fulfillTranslate): Deleted.
+        (fulfillInstantiate): Deleted.
+        (commitInstantiated): Deleted.
+        (instantiation): Deleted.
+        (requestFetch): Deleted.
+        (requestTranslate): Deleted.
+        (requestInstantiate): Deleted.
+        (requestResolveDependencies.): Deleted.
+        (requestResolveDependencies): Deleted.
+        (requestInstantiateAll): Deleted.
+        (requestLink): Deleted.
+        (requestReady): Deleted.
+        (link): Deleted.
+        (moduleEvaluation): Deleted.
+        (provide): Deleted.
+        (loadAndEvaluateModule): Deleted.
+        (loadModule): Deleted.
+        (linkAndEvaluateModule): Deleted.
+        * builtins/ModuleLoaderPrototype.js: Renamed from Source/JavaScriptCore/builtins/ModuleLoaderObject.js.
+        (setStateToMax):
+        (newRegistryEntry):
+        (ensureRegistered):
+        (forceFulfillPromise):
+        (fulfillFetch):
+        (fulfillTranslate):
+        (fulfillInstantiate):
+        (commitInstantiated):
+        (instantiation):
+        (requestFetch):
+        (requestTranslate):
+        (requestInstantiate):
+        (requestResolveDependencies.):
+        (requestResolveDependencies):
+        (requestInstantiateAll):
+        (requestLink):
+        (requestReady):
+        (link):
+        (moduleEvaluation):
+        (provide):
+        (loadAndEvaluateModule):
+        (loadModule):
+        (linkAndEvaluateModule):
+        * bytecode/BytecodeIntrinsicRegistry.cpp:
+        (JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
+        * jsc.cpp:
+        (GlobalObject::moduleLoaderResolve):
+        (GlobalObject::moduleLoaderFetch):
+        * runtime/Completion.cpp:
+        (JSC::loadAndEvaluateModule):
+        (JSC::loadModule):
+        * runtime/JSGlobalObject.cpp:
+        (JSC::JSGlobalObject::init):
+        (JSC::JSGlobalObject::visitChildren):
+        * runtime/JSGlobalObject.h:
+        (JSC::JSGlobalObject::moduleLoader):
+        (JSC::JSGlobalObject::moduleLoaderStructure):
+        * runtime/JSModuleLoader.cpp: Added.
+        (JSC::JSModuleLoader::JSModuleLoader):
+        (JSC::JSModuleLoader::finishCreation):
+        (JSC::printableModuleKey):
+        (JSC::JSModuleLoader::provide):
+        (JSC::JSModuleLoader::loadAndEvaluateModule):
+        (JSC::JSModuleLoader::loadModule):
+        (JSC::JSModuleLoader::linkAndEvaluateModule):
+        (JSC::JSModuleLoader::resolve):
+        (JSC::JSModuleLoader::fetch):
+        (JSC::JSModuleLoader::translate):
+        (JSC::JSModuleLoader::instantiate):
+        (JSC::JSModuleLoader::evaluate):
+        * runtime/JSModuleLoader.h: Copied from Source/JavaScriptCore/runtime/ModuleLoaderObject.h.
+        (JSC::JSModuleLoader::create):
+        (JSC::JSModuleLoader::createStructure):
+        * runtime/JSModuleRecord.h:
+        * runtime/ModuleLoaderObject.cpp: Removed.
+        (JSC::ModuleLoaderObject::ModuleLoaderObject): Deleted.
+        (JSC::ModuleLoaderObject::finishCreation): Deleted.
+        (JSC::printableModuleKey): Deleted.
+        (JSC::ModuleLoaderObject::provide): Deleted.
+        (JSC::ModuleLoaderObject::loadAndEvaluateModule): Deleted.
+        (JSC::ModuleLoaderObject::loadModule): Deleted.
+        (JSC::ModuleLoaderObject::linkAndEvaluateModule): Deleted.
+        (JSC::ModuleLoaderObject::resolve): Deleted.
+        (JSC::ModuleLoaderObject::fetch): Deleted.
+        (JSC::ModuleLoaderObject::translate): Deleted.
+        (JSC::ModuleLoaderObject::instantiate): Deleted.
+        (JSC::ModuleLoaderObject::evaluate): Deleted.
+        (JSC::moduleLoaderObjectParseModule): Deleted.
+        (JSC::moduleLoaderObjectRequestedModules): Deleted.
+        (JSC::moduleLoaderObjectModuleDeclarationInstantiation): Deleted.
+        (JSC::moduleLoaderObjectResolve): Deleted.
+        (JSC::moduleLoaderObjectFetch): Deleted.
+        (JSC::moduleLoaderObjectTranslate): Deleted.
+        (JSC::moduleLoaderObjectInstantiate): Deleted.
+        (JSC::moduleLoaderObjectEvaluate): Deleted.
+        * runtime/ModuleLoaderObject.h:
+        (JSC::ModuleLoaderObject::create): Deleted.
+        (JSC::ModuleLoaderObject::createStructure): Deleted.
+        * runtime/ModuleLoaderPrototype.cpp: Added.
+        (JSC::ModuleLoaderPrototype::ModuleLoaderPrototype):
+        (JSC::moduleLoaderPrototypeParseModule):
+        (JSC::moduleLoaderPrototypeRequestedModules):
+        (JSC::moduleLoaderPrototypeModuleDeclarationInstantiation):
+        (JSC::moduleLoaderPrototypeResolve):
+        (JSC::moduleLoaderPrototypeFetch):
+        (JSC::moduleLoaderPrototypeTranslate):
+        (JSC::moduleLoaderPrototypeInstantiate):
+        (JSC::moduleLoaderPrototypeEvaluate):
+        * runtime/ModuleLoaderPrototype.h: Renamed from Source/JavaScriptCore/runtime/ModuleLoaderObject.h.
+        (JSC::ModuleLoaderPrototype::create):
+        (JSC::ModuleLoaderPrototype::createStructure):
+
 2016-08-09  Saam Barati  <sbarati@apple.com>
 
         JSBoundFunction should lazily generate its name string
index 0db1a5b..b5336a6 100644 (file)
@@ -97,7 +97,7 @@ JavaScriptCore_BUILTINS_SOURCES = \
     $(JavaScriptCore)/builtins/InternalPromiseConstructor.js \
     $(JavaScriptCore)/builtins/IteratorPrototype.js \
     $(JavaScriptCore)/builtins/MapPrototype.js \
-    $(JavaScriptCore)/builtins/ModuleLoaderObject.js \
+    $(JavaScriptCore)/builtins/ModuleLoaderPrototype.js \
     $(JavaScriptCore)/builtins/NumberConstructor.js \
     $(JavaScriptCore)/builtins/NumberPrototype.js \
     $(JavaScriptCore)/builtins/ObjectConstructor.js \
@@ -147,7 +147,7 @@ OBJECT_LUT_HEADERS = \
     JSPromisePrototype.lut.h \
     JSPromiseConstructor.lut.h \
     MapPrototype.lut.h \
-    ModuleLoaderObject.lut.h \
+    ModuleLoaderPrototype.lut.h \
     NumberConstructor.lut.h \
     NumberPrototype.lut.h \
     ObjectConstructor.lut.h \
index e30dc9e..ac454fd 100644 (file)
                996B731D1BDA08EF00331B84 /* JSGlobalObject.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B730B1BD9FA2C00331B84 /* JSGlobalObject.lut.h */; };
                996B731E1BDA08EF00331B84 /* JSPromiseConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C184E2417BFFA36007CB63A /* JSPromiseConstructor.lut.h */; };
                996B731F1BDA08EF00331B84 /* JSPromisePrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C184E2517BFFA36007CB63A /* JSPromisePrototype.lut.h */; };
-               996B73201BDA08EF00331B84 /* ModuleLoaderObject.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B730C1BD9FA2C00331B84 /* ModuleLoaderObject.lut.h */; };
+               996B73201BDA08EF00331B84 /* ModuleLoaderPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B730C1BD9FA2C00331B84 /* ModuleLoaderPrototype.lut.h */; };
                996B73211BDA08EF00331B84 /* NumberPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B730D1BD9FA2C00331B84 /* NumberPrototype.lut.h */; };
                996B73221BDA08EF00331B84 /* ObjectConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B730E1BD9FA2C00331B84 /* ObjectConstructor.lut.h */; };
                996B73231BDA08EF00331B84 /* ReflectObject.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B730F1BD9FA2C00331B84 /* ReflectObject.lut.h */; };
                E33F50851B8437A000413856 /* JSInternalPromiseDeferred.h in Headers */ = {isa = PBXBuildFile; fileRef = E33F50831B8437A000413856 /* JSInternalPromiseDeferred.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E33F50871B8449EF00413856 /* JSInternalPromiseConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = E33F50861B8449EF00413856 /* JSInternalPromiseConstructor.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 */; };
+               E355F3521B7DC85300C50DC5 /* ModuleLoaderPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E355F3501B7DC85300C50DC5 /* ModuleLoaderPrototype.cpp */; };
+               E355F3531B7DC85300C50DC5 /* ModuleLoaderPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = E355F3511B7DC85300C50DC5 /* ModuleLoaderPrototype.h */; };
                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, ); }; };
                E3794E751B77EB97005543AE /* ModuleAnalyzer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3794E731B77EB97005543AE /* ModuleAnalyzer.cpp */; };
                FED94F2E171E3E2300BE77A4 /* Watchdog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */; };
                FED94F2F171E3E2300BE77A4 /* Watchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = FED94F2C171E3E2300BE77A4 /* Watchdog.h */; settings = {ATTRIBUTES = (Private, ); }; };
                FEF040511AAE662D00BD28B0 /* CompareAndSwapTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */; };
+               D9722752DC54459B9125B539 /* JSModuleLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 77B25CB2C3094A92A38E1DB3 /* JSModuleLoader.h */; };
+               13FECE06D3B445FCB6C93461 /* JSModuleLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1879510614C540FFB561C124 /* JSModuleLoader.cpp */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
                996B73091BD9FA2C00331B84 /* ErrorPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorPrototype.lut.h; sourceTree = "<group>"; };
                996B730A1BD9FA2C00331B84 /* JSDataViewPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDataViewPrototype.lut.h; sourceTree = "<group>"; };
                996B730B1BD9FA2C00331B84 /* JSGlobalObject.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObject.lut.h; sourceTree = "<group>"; };
-               996B730C1BD9FA2C00331B84 /* ModuleLoaderObject.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleLoaderObject.lut.h; sourceTree = "<group>"; };
+               996B730C1BD9FA2C00331B84 /* ModuleLoaderPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleLoaderPrototype.lut.h; sourceTree = "<group>"; };
                996B730D1BD9FA2C00331B84 /* NumberPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NumberPrototype.lut.h; sourceTree = "<group>"; };
                996B730E1BD9FA2C00331B84 /* ObjectConstructor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectConstructor.lut.h; sourceTree = "<group>"; };
                996B730F1BD9FA2C00331B84 /* ReflectObject.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReflectObject.lut.h; sourceTree = "<group>"; };
                E178636C0D9BEEC300D74E75 /* InitializeThreading.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InitializeThreading.cpp; sourceTree = "<group>"; };
                E18E3A560DF9278C00D90B34 /* VM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = VM.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
                E18E3A570DF9278C00D90B34 /* VM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = VM.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
-               E30677971B8BC6F5003F87F0 /* ModuleLoaderObject.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = ModuleLoaderObject.js; sourceTree = "<group>"; };
+               E30677971B8BC6F5003F87F0 /* ModuleLoaderPrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = ModuleLoaderPrototype.js; sourceTree = "<group>"; };
                E318CBBE1B8AEF5100A2929D /* JSModuleNamespaceObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSModuleNamespaceObject.cpp; sourceTree = "<group>"; };
                E318CBBF1B8AEF5100A2929D /* JSModuleNamespaceObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSModuleNamespaceObject.h; sourceTree = "<group>"; };
                E33637A31B63220200EE0840 /* ReflectObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReflectObject.cpp; sourceTree = "<group>"; };
                E33F50861B8449EF00413856 /* JSInternalPromiseConstructor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInternalPromiseConstructor.lut.h; sourceTree = "<group>"; };
                E33F50881B844A1A00413856 /* InternalPromiseConstructor.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = InternalPromiseConstructor.js; 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>"; };
+               E355F3501B7DC85300C50DC5 /* ModuleLoaderPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModuleLoaderPrototype.cpp; sourceTree = "<group>"; };
+               E355F3511B7DC85300C50DC5 /* ModuleLoaderPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleLoaderPrototype.h; 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>"; };
                FEDA50D51B97F4D9009A3B4F /* PingPongStackOverflowTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PingPongStackOverflowTest.h; path = API/tests/PingPongStackOverflowTest.h; sourceTree = "<group>"; };
                FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompareAndSwapTest.cpp; path = API/tests/CompareAndSwapTest.cpp; sourceTree = "<group>"; };
                FEF040521AAEC4ED00BD28B0 /* CompareAndSwapTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompareAndSwapTest.h; path = API/tests/CompareAndSwapTest.h; sourceTree = "<group>"; };
+               77B25CB2C3094A92A38E1DB3 /* JSModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSModuleLoader.h; path = JSModuleLoader.h; sourceTree = "<group>"; };
+               1879510614C540FFB561C124 /* JSModuleLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSModuleLoader.cpp; path = JSModuleLoader.cpp; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
                                BC18C52D0E16FCE100B34460 /* Lexer.lut.h */,
                                70DE9A081BE7D670005D89D9 /* LLIntAssembly.h */,
                                7035587E1C418458004BD7BF /* MapPrototype.lut.h */,
-                               996B730C1BD9FA2C00331B84 /* ModuleLoaderObject.lut.h */,
+                               996B730C1BD9FA2C00331B84 /* ModuleLoaderPrototype.lut.h */,
                                BC2680E60E16D52300A06E92 /* NumberConstructor.lut.h */,
                                996B730D1BD9FA2C00331B84 /* NumberPrototype.lut.h */,
                                996B730E1BD9FA2C00331B84 /* ObjectConstructor.lut.h */,
                                90213E3B123A40C200D422F3 /* MemoryStatistics.cpp */,
                                90213E3C123A40C200D422F3 /* MemoryStatistics.h */,
                                7C008CE5187631B600955C24 /* Microtask.h */,
-                               E355F3501B7DC85300C50DC5 /* ModuleLoaderObject.cpp */,
-                               E355F3511B7DC85300C50DC5 /* ModuleLoaderObject.h */,
+                               E355F3501B7DC85300C50DC5 /* ModuleLoaderPrototype.cpp */,
+                               E355F3511B7DC85300C50DC5 /* ModuleLoaderPrototype.h */,
                                BC02E9080E1839DB000F9297 /* NativeErrorConstructor.cpp */,
                                BC02E9090E1839DB000F9297 /* NativeErrorConstructor.h */,
                                BC02E90A0E1839DB000F9297 /* NativeErrorPrototype.cpp */,
                                709FB8661AE335C60039D069 /* WeakSetPrototype.h */,
                                A7DCB77912E3D90500911940 /* WriteBarrier.h */,
                                C2B6D75218A33793004A9301 /* WriteBarrierInlines.h */,
+                               77B25CB2C3094A92A38E1DB3 /* JSModuleLoader.h */,
+                               1879510614C540FFB561C124 /* JSModuleLoader.cpp */,
                        );
                        path = runtime;
                        sourceTree = "<group>";
                                E33F50881B844A1A00413856 /* InternalPromiseConstructor.js */,
                                7CF9BC5B1B65D9A3009DB1EF /* IteratorPrototype.js */,
                                7035587C1C418419004BD7BF /* MapPrototype.js */,
-                               E30677971B8BC6F5003F87F0 /* ModuleLoaderObject.js */,
+                               E30677971B8BC6F5003F87F0 /* ModuleLoaderPrototype.js */,
                                A52704861D027C8800354C37 /* NumberConstructor.js */,
                                A15DE5C51C0FBF8D0089133D /* NumberPrototype.js */,
                                7CF9BC5C1B65D9B1009DB1EF /* ObjectConstructor.js */,
                                86C568E211A213EE0007F7F0 /* MIPSAssembler.h in Headers */,
                                C4703CD7192844CC0013FBEA /* models.py in Headers */,
                                E3794E761B77EB97005543AE /* ModuleAnalyzer.h in Headers */,
-                               E355F3531B7DC85300C50DC5 /* ModuleLoaderObject.h in Headers */,
-                               996B73201BDA08EF00331B84 /* ModuleLoaderObject.lut.h in Headers */,
+                               E355F3531B7DC85300C50DC5 /* ModuleLoaderPrototype.h in Headers */,
+                               996B73201BDA08EF00331B84 /* ModuleLoaderPrototype.lut.h in Headers */,
                                BC02E9110E1839DB000F9297 /* NativeErrorConstructor.h in Headers */,
                                BC02E9130E1839DB000F9297 /* NativeErrorPrototype.h in Headers */,
                                E33E8D211B9013DE00346B52 /* NativeStdFunctionCell.h in Headers */,
                                262D85B71C0D650F006ACB61 /* AirFixPartialRegisterStalls.h in Headers */,
                                86704B4312DB8A8100A9FE7B /* YarrSyntaxChecker.h in Headers */,
                                A79D3ED9C5064DD0A8466A3A /* ModuleScopeData.h in Headers */,
+                               D9722752DC54459B9125B539 /* JSModuleLoader.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                90213E3D123A40C200D422F3 /* MemoryStatistics.cpp in Sources */,
                                0FB5467D14F5CFD6002C2989 /* MethodOfGettingAValueProfile.cpp in Sources */,
                                E3794E751B77EB97005543AE /* ModuleAnalyzer.cpp in Sources */,
-                               E355F3521B7DC85300C50DC5 /* ModuleLoaderObject.cpp in Sources */,
+                               E355F3521B7DC85300C50DC5 /* ModuleLoaderPrototype.cpp in Sources */,
                                0F338E0B1BF0276C0013C88F /* B3Compilation.cpp in Sources */,
                                14469DE0107EC7E700650446 /* NativeErrorConstructor.cpp in Sources */,
                                79160DBD1C8E3EC8008C085A /* ProxyRevoke.cpp in Sources */,
                                86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */,
                                86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */,
                                0F2BBD991C5FF3F50023EF23 /* B3VariableValue.cpp in Sources */,
+                               13FECE06D3B445FCB6C93461 /* JSModuleLoader.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 2781593..47a6d7e 100644 (file)
@@ -32,8 +32,8 @@
 #include "BytecodeGenerator.h"
 #include "JSCJSValueInlines.h"
 #include "JSGeneratorFunction.h"
+#include "JSModuleLoader.h"
 #include "JSPromise.h"
-#include "ModuleLoaderObject.h"
 #include "Nodes.h"
 #include "StrongInlines.h"
 
@@ -55,12 +55,12 @@ BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry(VM& vm)
     m_arrayIterationKindKeyValue.set(m_vm, jsNumber(ArrayIterateKeyValue));
     m_MAX_STRING_LENGTH.set(m_vm, jsNumber(JSString::MaxLength));
     m_MAX_SAFE_INTEGER.set(m_vm, jsDoubleNumber(maxSafeInteger()));
-    m_ModuleFetch.set(m_vm, jsNumber(static_cast<unsigned>(ModuleLoaderObject::Status::Fetch)));
-    m_ModuleTranslate.set(m_vm, jsNumber(static_cast<unsigned>(ModuleLoaderObject::Status::Translate)));
-    m_ModuleInstantiate.set(m_vm, jsNumber(static_cast<unsigned>(ModuleLoaderObject::Status::Instantiate)));
-    m_ModuleResolveDependencies.set(m_vm, jsNumber(static_cast<unsigned>(ModuleLoaderObject::Status::ResolveDependencies)));
-    m_ModuleLink.set(m_vm, jsNumber(static_cast<unsigned>(ModuleLoaderObject::Status::Link)));
-    m_ModuleReady.set(m_vm, jsNumber(static_cast<unsigned>(ModuleLoaderObject::Status::Ready)));
+    m_ModuleFetch.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Fetch)));
+    m_ModuleTranslate.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Translate)));
+    m_ModuleInstantiate.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Instantiate)));
+    m_ModuleResolveDependencies.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::ResolveDependencies)));
+    m_ModuleLink.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Link)));
+    m_ModuleReady.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Ready)));
     m_promiseStatePending.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Pending)));
     m_promiseStateFulfilled.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Fulfilled)));
     m_promiseStateRejected.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Rejected)));
index ecd2d25..9a56aad 100644 (file)
@@ -881,8 +881,8 @@ protected:
         putDirect(vm, identifier, JSFunction::create(vm, this, arguments, identifier.string(), function, NoIntrinsic, function));
     }
 
-    static JSInternalPromise* moduleLoaderResolve(JSGlobalObject*, ExecState*, JSValue, JSValue);
-    static JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, ExecState*, JSValue);
+    static JSInternalPromise* moduleLoaderResolve(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
+    static JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue);
 };
 
 const ClassInfo GlobalObject::s_info = { "global", &JSGlobalObject::s_info, nullptr, CREATE_METHOD_TABLE(GlobalObject) };
@@ -1013,7 +1013,7 @@ static String resolvePath(const DirectoryName& directoryName, const ModuleName&
     return builder.toString();
 }
 
-JSInternalPromise* GlobalObject::moduleLoaderResolve(JSGlobalObject* globalObject, ExecState* exec, JSValue keyValue, JSValue referrerValue)
+JSInternalPromise* GlobalObject::moduleLoaderResolve(JSGlobalObject* globalObject, ExecState* exec, JSModuleLoader*, JSValue keyValue, JSValue referrerValue)
 {
     JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
     const Identifier key = keyValue.toPropertyKey(exec);
@@ -1118,7 +1118,7 @@ static bool fetchModuleFromLocalFileSystem(const String& fileName, Vector<char>&
     return result;
 }
 
-JSInternalPromise* GlobalObject::moduleLoaderFetch(JSGlobalObject* globalObject, ExecState* exec, JSValue key)
+JSInternalPromise* GlobalObject::moduleLoaderFetch(JSGlobalObject* globalObject, ExecState* exec, JSModuleLoader*, JSValue key)
 {
     JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
     String moduleKey = key.toWTFString(exec);
index dec5553..952683d 100644 (file)
 #include "JSInternalPromise.h"
 #include "JSInternalPromiseDeferred.h"
 #include "JSLock.h"
+#include "JSModuleLoader.h"
 #include "JSModuleRecord.h"
 #include "JSWithScope.h"
 #include "ModuleAnalyzer.h"
-#include "ModuleLoaderObject.h"
 #include "Parser.h"
 #include "ScriptProfilingScope.h"
 #include <wtf/WTFThreadData.h>
@@ -186,7 +186,7 @@ JSInternalPromise* loadAndEvaluateModule(ExecState* exec, const SourceCode& sour
     JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
 
     // Insert the given source code to the ModuleLoader registry as the fetched registry entry.
-    globalObject->moduleLoader()->provide(exec, key, ModuleLoaderObject::Status::Fetch, source.view().toString());
+    globalObject->moduleLoader()->provide(exec, key, JSModuleLoader::Status::Fetch, source.view().toString());
     if (exec->hadException())
         return rejectPromise(exec, globalObject);
 
@@ -223,7 +223,7 @@ JSInternalPromise* loadModule(ExecState* exec, const SourceCode& source)
     JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
 
     // Insert the given source code to the ModuleLoader registry as the fetched registry entry.
-    globalObject->moduleLoader()->provide(exec, key, ModuleLoaderObject::Status::Fetch, source.view().toString());
+    globalObject->moduleLoader()->provide(exec, key, JSModuleLoader::Status::Fetch, source.view().toString());
     if (exec->hadException())
         return rejectPromise(exec, globalObject);
 
index 81928d2..c7fad30 100644 (file)
@@ -88,6 +88,7 @@
 #include "JSMap.h"
 #include "JSMapIterator.h"
 #include "JSModuleEnvironment.h"
+#include "JSModuleLoader.h"
 #include "JSModuleNamespaceObject.h"
 #include "JSModuleRecord.h"
 #include "JSNativeStdFunction.h"
 #include "MapPrototype.h"
 #include "MathObject.h"
 #include "Microtask.h"
-#include "ModuleLoaderObject.h"
+#include "ModuleLoaderPrototype.h"
 #include "NativeErrorConstructor.h"
 #include "NativeErrorPrototype.h"
 #include "NullGetterFunction.h"
@@ -549,6 +550,7 @@ m_ ## properName ## Structure.set(vm, this, instanceType::createStructure(vm, th
 
     m_propertyNameIteratorStructure.set(vm, this, JSPropertyNameIterator::createStructure(vm, this, m_iteratorPrototype.get()));
     m_generatorPrototype.set(vm, this, GeneratorPrototype::create(vm, this, GeneratorPrototype::createStructure(vm, this, m_iteratorPrototype.get())));
+    m_moduleLoaderPrototype.set(vm, this, ModuleLoaderPrototype::create(vm, this, ModuleLoaderPrototype::createStructure(vm, this, m_objectPrototype.get())));
     
     // Constructors
 
@@ -638,7 +640,8 @@ putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct
     ReflectObject* reflectObject = ReflectObject::create(vm, this, ReflectObject::createStructure(vm, this, m_objectPrototype.get()));
     putDirectWithoutTransition(vm, vm.propertyNames->Reflect, reflectObject, DontEnum);
 
-    m_moduleLoader.set(vm, this, ModuleLoaderObject::create(vm, this, ModuleLoaderObject::createStructure(vm, this, m_objectPrototype.get())));
+    m_moduleLoaderStructure.set(vm, this, JSModuleLoader::createStructure(vm, this, m_moduleLoaderPrototype.get()));
+    m_moduleLoader.set(vm, this, JSModuleLoader::create(vm, this, m_moduleLoaderStructure.get()));
     if (Options::exposeInternalModuleLoader())
         putDirectWithoutTransition(vm, vm.propertyNames->Loader, m_moduleLoader.get(), DontEnum);
 
@@ -1053,6 +1056,7 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
     visitor.append(&thisObject->m_iteratorPrototype);
     visitor.append(&thisObject->m_generatorFunctionPrototype);
     visitor.append(&thisObject->m_generatorPrototype);
+    visitor.append(&thisObject->m_moduleLoaderPrototype);
 
     thisObject->m_debuggerScopeStructure.visit(visitor);
     thisObject->m_withScopeStructure.visit(visitor);
@@ -1096,6 +1100,7 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
     visitor.append(&thisObject->m_proxyObjectStructure);
     visitor.append(&thisObject->m_callableProxyObjectStructure);
     visitor.append(&thisObject->m_proxyRevokeStructure);
+    visitor.append(&thisObject->m_moduleLoaderStructure);
 
 #define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName) \
     visitor.append(&thisObject->m_ ## lowerName ## Prototype); \
index 547c832..f567116 100644 (file)
@@ -74,6 +74,7 @@ class GlobalCodeBlock;
 class InputCursor;
 class JSGlobalObjectDebuggable;
 class JSInternalPromise;
+class JSModuleLoader;
 class JSPromise;
 class JSPromiseConstructor;
 class JSPromisePrototype;
@@ -81,7 +82,7 @@ class JSTypedArrayViewConstructor;
 class JSTypedArrayViewPrototype;
 class LLIntOffsetsExtractor;
 class Microtask;
-class ModuleLoaderObject;
+class ModuleLoaderPrototype;
 class ModuleProgramExecutable;
 class NativeErrorConstructor;
 class NullGetterFunction;
@@ -165,19 +166,19 @@ struct GlobalObjectMethodTable {
     typedef bool (*ShouldInterruptScriptBeforeTimeoutPtr)(const JSGlobalObject*);
     ShouldInterruptScriptBeforeTimeoutPtr shouldInterruptScriptBeforeTimeout;
 
-    typedef JSInternalPromise* (*ModuleLoaderResolvePtr)(JSGlobalObject*, ExecState*, JSValue, JSValue);
+    typedef JSInternalPromise* (*ModuleLoaderResolvePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
     ModuleLoaderResolvePtr moduleLoaderResolve;
 
-    typedef JSInternalPromise* (*ModuleLoaderFetchPtr)(JSGlobalObject*, ExecState*, JSValue);
+    typedef JSInternalPromise* (*ModuleLoaderFetchPtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue);
     ModuleLoaderFetchPtr moduleLoaderFetch;
 
-    typedef JSInternalPromise* (*ModuleLoaderTranslatePtr)(JSGlobalObject*, ExecState*, JSValue, JSValue);
+    typedef JSInternalPromise* (*ModuleLoaderTranslatePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
     ModuleLoaderTranslatePtr moduleLoaderTranslate;
 
-    typedef JSInternalPromise* (*ModuleLoaderInstantiatePtr)(JSGlobalObject*, ExecState*, JSValue, JSValue);
+    typedef JSInternalPromise* (*ModuleLoaderInstantiatePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
     ModuleLoaderInstantiatePtr moduleLoaderInstantiate;
 
-    typedef JSValue (*ModuleLoaderEvaluatePtr)(JSGlobalObject*, ExecState*, JSValue, JSValue);
+    typedef JSValue (*ModuleLoaderEvaluatePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
     ModuleLoaderEvaluatePtr moduleLoaderEvaluate;
 
     typedef String (*DefaultLanguageFunctionPtr)();
@@ -251,7 +252,7 @@ public:
     WriteBarrier<JSObject> m_regExpProtoUnicodeGetter;
     LazyProperty<JSGlobalObject, GetterSetter> m_throwTypeErrorArgumentsCalleeAndCallerGetterSetter;
 
-    WriteBarrier<ModuleLoaderObject> m_moduleLoader;
+    WriteBarrier<JSModuleLoader> m_moduleLoader;
 
     WriteBarrier<ObjectPrototype> m_objectPrototype;
     WriteBarrier<FunctionPrototype> m_functionPrototype;
@@ -260,6 +261,7 @@ public:
     WriteBarrier<IteratorPrototype> m_iteratorPrototype;
     WriteBarrier<GeneratorFunctionPrototype> m_generatorFunctionPrototype;
     WriteBarrier<GeneratorPrototype> m_generatorPrototype;
+    WriteBarrier<ModuleLoaderPrototype> m_moduleLoaderPrototype;
 
     LazyProperty<JSGlobalObject, Structure> m_debuggerScopeStructure;
     LazyProperty<JSGlobalObject, Structure> m_withScopeStructure;
@@ -307,6 +309,7 @@ public:
     WriteBarrier<Structure> m_proxyObjectStructure;
     WriteBarrier<Structure> m_callableProxyObjectStructure;
     WriteBarrier<Structure> m_proxyRevokeStructure;
+    WriteBarrier<Structure> m_moduleLoaderStructure;
 
 #define DEFINE_STORAGE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
     WriteBarrier<capitalName ## Prototype> m_ ## lowerName ## Prototype; \
@@ -496,7 +499,7 @@ public:
         return m_throwTypeErrorArgumentsCalleeAndCallerGetterSetter.get(this);
     }
     
-    ModuleLoaderObject* moduleLoader() const { return m_moduleLoader.get(); }
+    JSModuleLoader* moduleLoader() const { return m_moduleLoader.get(); }
 
     ObjectPrototype* objectPrototype() const { return m_objectPrototype.get(); }
     FunctionPrototype* functionPrototype() const { return m_functionPrototype.get(); }
@@ -580,6 +583,7 @@ public:
     Structure* proxyObjectStructure() const { return m_proxyObjectStructure.get(); }
     Structure* callableProxyObjectStructure() const { return m_callableProxyObjectStructure.get(); }
     Structure* proxyRevokeStructure() const { return m_proxyRevokeStructure.get(); }
+    Structure* moduleLoaderStructure() const { return m_moduleLoaderStructure.get(); }
 
     JS_EXPORT_PRIVATE void setRemoteDebuggingEnabled(bool);
     JS_EXPORT_PRIVATE bool remoteDebuggingEnabled() const;
diff --git a/Source/JavaScriptCore/runtime/JSModuleLoader.cpp b/Source/JavaScriptCore/runtime/JSModuleLoader.cpp
new file mode 100644 (file)
index 0000000..d3b5a6a
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2016 Yusuke Suzuki <utatane.tea@gmail.com>.
+ *
+ * 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 "JSModuleLoader.h"
+
+#include "BuiltinNames.h"
+#include "CodeProfiling.h"
+#include "Error.h"
+#include "Exception.h"
+#include "JSCInlines.h"
+#include "JSGlobalObjectFunctions.h"
+#include "JSInternalPromise.h"
+#include "JSInternalPromiseDeferred.h"
+#include "JSMap.h"
+#include "JSModuleEnvironment.h"
+#include "JSModuleRecord.h"
+#include "ModuleAnalyzer.h"
+#include "ModuleLoaderPrototype.h"
+#include "Nodes.h"
+#include "Parser.h"
+#include "ParserError.h"
+
+namespace JSC {
+
+STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSModuleLoader);
+
+const ClassInfo JSModuleLoader::s_info = { "ModuleLoader", &Base::s_info, nullptr, CREATE_METHOD_TABLE(JSModuleLoader) };
+
+JSModuleLoader::JSModuleLoader(VM& vm, Structure* structure)
+    : JSNonFinalObject(vm, structure)
+{
+}
+
+void JSModuleLoader::finishCreation(VM& vm, JSGlobalObject* globalObject)
+{
+    Base::finishCreation(vm);
+    ASSERT(inherits(info()));
+    putDirect(vm, Identifier::fromString(&vm, "registry"), JSMap::create(vm, globalObject->mapStructure()));
+}
+
+// ------------------------------ Functions --------------------------------
+
+static String printableModuleKey(ExecState* exec, JSValue key)
+{
+    if (key.isString() || key.isSymbol())
+        return key.toPropertyKey(exec).impl();
+    return exec->propertyNames().emptyIdentifier.impl();
+}
+
+JSValue JSModuleLoader::provide(ExecState* exec, JSValue key, Status status, const String& source)
+{
+    JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().providePublicName()));
+    CallData callData;
+    CallType callType = JSC::getCallData(function, callData);
+    ASSERT(callType != CallType::None);
+
+    MarkedArgumentBuffer arguments;
+    arguments.append(key);
+    arguments.append(jsNumber(status));
+    arguments.append(jsString(exec, source));
+
+    return call(exec, function, callType, callData, this, arguments);
+}
+
+JSInternalPromise* JSModuleLoader::loadAndEvaluateModule(ExecState* exec, JSValue moduleName, JSValue referrer)
+{
+    JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().loadAndEvaluateModulePublicName()));
+    CallData callData;
+    CallType callType = JSC::getCallData(function, callData);
+    ASSERT(callType != CallType::None);
+
+    MarkedArgumentBuffer arguments;
+    arguments.append(moduleName);
+    arguments.append(referrer);
+
+    return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
+}
+
+JSInternalPromise* JSModuleLoader::loadModule(ExecState* exec, JSValue moduleName, JSValue referrer)
+{
+    JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().loadModulePublicName()));
+    CallData callData;
+    CallType callType = JSC::getCallData(function, callData);
+    ASSERT(callType != CallType::None);
+
+    MarkedArgumentBuffer arguments;
+    arguments.append(moduleName);
+    arguments.append(referrer);
+
+    return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
+}
+
+JSInternalPromise* JSModuleLoader::linkAndEvaluateModule(ExecState* exec, JSValue moduleKey)
+{
+    JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().linkAndEvaluateModulePublicName()));
+    CallData callData;
+    CallType callType = JSC::getCallData(function, callData);
+    ASSERT(callType != CallType::None);
+
+    MarkedArgumentBuffer arguments;
+    arguments.append(moduleKey);
+
+    return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
+}
+
+JSInternalPromise* JSModuleLoader::resolve(ExecState* exec, JSValue name, JSValue referrer)
+{
+    if (Options::dumpModuleLoadingState())
+        dataLog("Loader [resolve] ", printableModuleKey(exec, name), "\n");
+
+    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
+    if (globalObject->globalObjectMethodTable()->moduleLoaderResolve)
+        return globalObject->globalObjectMethodTable()->moduleLoaderResolve(globalObject, exec, this, name, referrer);
+    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
+    deferred->resolve(exec, name);
+    return deferred->promise();
+}
+
+JSInternalPromise* JSModuleLoader::fetch(ExecState* exec, JSValue key)
+{
+    if (Options::dumpModuleLoadingState())
+        dataLog("Loader [fetch] ", printableModuleKey(exec, key), "\n");
+
+    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
+    if (globalObject->globalObjectMethodTable()->moduleLoaderFetch)
+        return globalObject->globalObjectMethodTable()->moduleLoaderFetch(globalObject, exec, this, key);
+    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::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();
+}
+
+JSInternalPromise* JSModuleLoader::translate(ExecState* exec, JSValue key, JSValue payload)
+{
+    if (Options::dumpModuleLoadingState())
+        dataLog("Loader [translate] ", printableModuleKey(exec, key), "\n");
+
+    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
+    if (globalObject->globalObjectMethodTable()->moduleLoaderTranslate)
+        return globalObject->globalObjectMethodTable()->moduleLoaderTranslate(globalObject, exec, this, key, payload);
+    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
+    deferred->resolve(exec, payload);
+    return deferred->promise();
+}
+
+JSInternalPromise* JSModuleLoader::instantiate(ExecState* exec, JSValue key, JSValue source)
+{
+    if (Options::dumpModuleLoadingState())
+        dataLog("Loader [instantiate] ", printableModuleKey(exec, key), "\n");
+
+    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
+    if (globalObject->globalObjectMethodTable()->moduleLoaderInstantiate)
+        return globalObject->globalObjectMethodTable()->moduleLoaderInstantiate(globalObject, exec, this, key, source);
+    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
+    deferred->resolve(exec, jsUndefined());
+    return deferred->promise();
+}
+
+JSValue JSModuleLoader::evaluate(ExecState* exec, JSValue key, JSValue moduleRecordValue)
+{
+    if (Options::dumpModuleLoadingState())
+        dataLog("Loader [evaluate] ", printableModuleKey(exec, key), "\n");
+
+    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
+    if (globalObject->globalObjectMethodTable()->moduleLoaderEvaluate)
+        return globalObject->globalObjectMethodTable()->moduleLoaderEvaluate(globalObject, exec, this, key, moduleRecordValue);
+
+    JSModuleRecord* moduleRecord = jsDynamicCast<JSModuleRecord*>(moduleRecordValue);
+    if (!moduleRecord)
+        return jsUndefined();
+    return moduleRecord->evaluate(exec);
+}
+
+} // namespace JSC
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2015 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2016 Yusuke Suzuki <utatane.tea@gmail.com>.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -23,8 +24,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef ModuleLoaderObject_h
-#define ModuleLoaderObject_h
+#pragma once
 
 #include "JSObject.h"
 
@@ -32,12 +32,11 @@ namespace JSC {
 
 class JSInternalPromise;
 
-class ModuleLoaderObject : public JSNonFinalObject {
+class JSModuleLoader : public JSNonFinalObject {
 private:
-    ModuleLoaderObject(VM&, Structure*);
+    JSModuleLoader(VM&, Structure*);
 public:
     typedef JSNonFinalObject Base;
-    static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
 
     enum Status {
         Fetch = 1,
@@ -48,9 +47,9 @@ public:
         Ready = 6,
     };
 
-    static ModuleLoaderObject* create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
+    static JSModuleLoader* create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
     {
-        ModuleLoaderObject* object = new (NotNull, allocateCell<ModuleLoaderObject>(vm.heap)) ModuleLoaderObject(vm, structure);
+        JSModuleLoader* object = new (NotNull, allocateCell<JSModuleLoader>(vm.heap)) JSModuleLoader(vm, structure);
         object->finishCreation(vm, globalObject);
         return object;
     }
@@ -82,5 +81,3 @@ protected:
 };
 
 } // namespace JSC
-
-#endif // ModuleLoaderObject_h
index 9313409..c424309 100644 (file)
@@ -206,7 +206,7 @@ private:
     WriteBarrier<JSModuleEnvironment> m_moduleEnvironment;
     WriteBarrier<JSModuleNamespaceObject> m_moduleNamespaceObject;
 
-    // We assume that all the JSModuleRecord are retained by ModuleLoaderObject's registry.
+    // We assume that all the JSModuleRecord are retained by JSModuleLoader's registry.
     // So here, we don't visit each object for GC. The resolution cache map caches the once
     // looked up correctly resolved resolution, since (1) we rarely looked up the non-resolved one,
     // and (2) if we cache all the attempts the size of the map becomes infinitely large.
diff --git a/Source/JavaScriptCore/runtime/ModuleLoaderObject.cpp b/Source/JavaScriptCore/runtime/ModuleLoaderObject.cpp
deleted file mode 100644 (file)
index 5747560..0000000
+++ /dev/null
@@ -1,382 +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 "ModuleLoaderObject.h"
-
-#include "BuiltinNames.h"
-#include "CodeProfiling.h"
-#include "Error.h"
-#include "Exception.h"
-#include "JSCInlines.h"
-#include "JSGlobalObjectFunctions.h"
-#include "JSInternalPromise.h"
-#include "JSInternalPromiseDeferred.h"
-#include "JSMap.h"
-#include "JSModuleEnvironment.h"
-#include "JSModuleRecord.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 moduleLoaderObjectEvaluate(ExecState*);
-static EncodedJSValue JSC_HOST_CALL moduleLoaderObjectModuleDeclarationInstantiation(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                  JSBuiltin                                        DontEnum|Function 2
-    newRegistryEntry               JSBuiltin                                        DontEnum|Function 1
-    ensureRegistered               JSBuiltin                                        DontEnum|Function 1
-    forceFulfillPromise            JSBuiltin                                        DontEnum|Function 2
-    fulfillFetch                   JSBuiltin                                        DontEnum|Function 2
-    fulfillTranslate               JSBuiltin                                        DontEnum|Function 2
-    fulfillInstantiate             JSBuiltin                                        DontEnum|Function 2
-    commitInstantiated             JSBuiltin                                        DontEnum|Function 3
-    instantiation                  JSBuiltin                                        DontEnum|Function 3
-    requestFetch                   JSBuiltin                                        DontEnum|Function 1
-    requestTranslate               JSBuiltin                                        DontEnum|Function 1
-    requestInstantiate             JSBuiltin                                        DontEnum|Function 1
-    requestResolveDependencies     JSBuiltin                                        DontEnum|Function 1
-    requestInstantiateAll          JSBuiltin                                        DontEnum|Function 1
-    requestLink                    JSBuiltin                                        DontEnum|Function 1
-    requestReady                   JSBuiltin                                        DontEnum|Function 1
-    link                           JSBuiltin                                        DontEnum|Function 1
-    moduleDeclarationInstantiation moduleLoaderObjectModuleDeclarationInstantiation DontEnum|Function 2
-    moduleEvaluation               JSBuiltin                                        DontEnum|Function 2
-    evaluate                       moduleLoaderObjectEvaluate                       DontEnum|Function 2
-    provide                        JSBuiltin                                        DontEnum|Function 3
-    loadAndEvaluateModule          JSBuiltin                                        DontEnum|Function 2
-    loadModule                     JSBuiltin                                        DontEnum|Function 2
-    linkAndEvaluateModule          JSBuiltin                                        DontEnum|Function 1
-    parseModule                    moduleLoaderObjectParseModule                    DontEnum|Function 2
-    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()));
-    putDirectWithoutTransition(vm, Identifier::fromString(&vm, "registry"), JSMap::create(vm, globalObject->mapStructure()));
-}
-
-// ------------------------------ Functions --------------------------------
-
-static String printableModuleKey(ExecState* exec, JSValue key)
-{
-    if (key.isString() || key.isSymbol())
-        return key.toPropertyKey(exec).impl();
-    return exec->propertyNames().emptyIdentifier.impl();
-}
-
-JSValue ModuleLoaderObject::provide(ExecState* exec, JSValue key, Status status, const String& source)
-{
-    JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().providePublicName()));
-    CallData callData;
-    CallType callType = JSC::getCallData(function, callData);
-    ASSERT(callType != CallType::None);
-
-    MarkedArgumentBuffer arguments;
-    arguments.append(key);
-    arguments.append(jsNumber(status));
-    arguments.append(jsString(exec, source));
-
-    return call(exec, function, callType, callData, this, arguments);
-}
-
-JSInternalPromise* ModuleLoaderObject::loadAndEvaluateModule(ExecState* exec, JSValue moduleName, JSValue referrer)
-{
-    JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().loadAndEvaluateModulePublicName()));
-    CallData callData;
-    CallType callType = JSC::getCallData(function, callData);
-    ASSERT(callType != CallType::None);
-
-    MarkedArgumentBuffer arguments;
-    arguments.append(moduleName);
-    arguments.append(referrer);
-
-    return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
-}
-
-JSInternalPromise* ModuleLoaderObject::loadModule(ExecState* exec, JSValue moduleName, JSValue referrer)
-{
-    JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().loadModulePublicName()));
-    CallData callData;
-    CallType callType = JSC::getCallData(function, callData);
-    ASSERT(callType != CallType::None);
-
-    MarkedArgumentBuffer arguments;
-    arguments.append(moduleName);
-    arguments.append(referrer);
-
-    return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
-}
-
-JSInternalPromise* ModuleLoaderObject::linkAndEvaluateModule(ExecState* exec, JSValue moduleKey)
-{
-    JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().linkAndEvaluateModulePublicName()));
-    CallData callData;
-    CallType callType = JSC::getCallData(function, callData);
-    ASSERT(callType != CallType::None);
-
-    MarkedArgumentBuffer arguments;
-    arguments.append(moduleKey);
-
-    return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
-}
-
-JSInternalPromise* ModuleLoaderObject::resolve(ExecState* exec, JSValue name, JSValue referrer)
-{
-    if (Options::dumpModuleLoadingState())
-        dataLog("Loader [resolve] ", printableModuleKey(exec, name), "\n");
-
-    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
-    if (globalObject->globalObjectMethodTable()->moduleLoaderResolve)
-        return globalObject->globalObjectMethodTable()->moduleLoaderResolve(globalObject, exec, name, referrer);
-    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
-    deferred->resolve(exec, name);
-    return deferred->promise();
-}
-
-JSInternalPromise* ModuleLoaderObject::fetch(ExecState* exec, JSValue key)
-{
-    if (Options::dumpModuleLoadingState())
-        dataLog("Loader [fetch] ", printableModuleKey(exec, key), "\n");
-
-    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
-    if (globalObject->globalObjectMethodTable()->moduleLoaderFetch)
-        return globalObject->globalObjectMethodTable()->moduleLoaderFetch(globalObject, exec, key);
-    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::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();
-}
-
-JSInternalPromise* ModuleLoaderObject::translate(ExecState* exec, JSValue key, JSValue payload)
-{
-    if (Options::dumpModuleLoadingState())
-        dataLog("Loader [translate] ", printableModuleKey(exec, key), "\n");
-
-    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
-    if (globalObject->globalObjectMethodTable()->moduleLoaderTranslate)
-        return globalObject->globalObjectMethodTable()->moduleLoaderTranslate(globalObject, exec, key, payload);
-    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
-    deferred->resolve(exec, payload);
-    return deferred->promise();
-}
-
-JSInternalPromise* ModuleLoaderObject::instantiate(ExecState* exec, JSValue key, JSValue source)
-{
-    if (Options::dumpModuleLoadingState())
-        dataLog("Loader [instantiate] ", printableModuleKey(exec, key), "\n");
-
-    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
-    if (globalObject->globalObjectMethodTable()->moduleLoaderInstantiate)
-        return globalObject->globalObjectMethodTable()->moduleLoaderInstantiate(globalObject, exec, key, source);
-    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
-    deferred->resolve(exec, jsUndefined());
-    return deferred->promise();
-}
-
-JSValue ModuleLoaderObject::evaluate(ExecState* exec, JSValue key, JSValue moduleRecordValue)
-{
-    if (Options::dumpModuleLoadingState())
-        dataLog("Loader [evaluate] ", printableModuleKey(exec, key), "\n");
-
-    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
-    if (globalObject->globalObjectMethodTable()->moduleLoaderEvaluate)
-        return globalObject->globalObjectMethodTable()->moduleLoaderEvaluate(globalObject, exec, key, moduleRecordValue);
-
-    JSModuleRecord* moduleRecord = jsDynamicCast<JSModuleRecord*>(moduleRecordValue);
-    if (!moduleRecord)
-        return jsUndefined();
-    return moduleRecord->evaluate(exec);
-}
-
-EncodedJSValue JSC_HOST_CALL moduleLoaderObjectParseModule(ExecState* exec)
-{
-    VM& vm = exec->vm();
-    const Identifier moduleKey = exec->argument(0).toPropertyKey(exec);
-    if (exec->hadException())
-        return JSValue::encode(jsUndefined());
-
-    String source = exec->argument(1).toString(exec)->value(exec);
-    if (exec->hadException())
-        return JSValue::encode(jsUndefined());
-
-    SourceCode sourceCode = makeSource(source, moduleKey.impl());
-
-    CodeProfiling profile(sourceCode);
-
-    ParserError error;
-    std::unique_ptr<ModuleProgramNode> moduleProgramNode = parse<ModuleProgramNode>(
-        &vm, sourceCode, Identifier(), JSParserBuiltinMode::NotBuiltin,
-        JSParserStrictMode::Strict, SourceParseMode::ModuleAnalyzeMode, SuperBinding::NotNeeded, error);
-
-    if (error.isValid()) {
-        throwVMError(exec, error.toErrorObject(exec->lexicalGlobalObject(), sourceCode));
-        return JSValue::encode(jsUndefined());
-    }
-    ASSERT(moduleProgramNode);
-
-    ModuleAnalyzer moduleAnalyzer(exec, moduleKey, sourceCode, moduleProgramNode->varDeclarations(), moduleProgramNode->lexicalVariables());
-    JSModuleRecord* moduleRecord = moduleAnalyzer.analyze(*moduleProgramNode);
-
-    return JSValue::encode(moduleRecord);
-}
-
-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());
-    if (UNLIKELY(exec->hadException()))
-        JSValue::encode(jsUndefined());
-    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 moduleLoaderObjectModuleDeclarationInstantiation(ExecState* exec)
-{
-    JSModuleRecord* moduleRecord = jsDynamicCast<JSModuleRecord*>(exec->argument(0));
-    if (!moduleRecord)
-        return JSValue::encode(jsUndefined());
-
-    if (Options::dumpModuleLoadingState())
-        dataLog("Loader [link] ", moduleRecord->moduleKey(), "\n");
-
-    moduleRecord->link(exec);
-    if (exec->hadException())
-        return JSValue::encode(jsUndefined());
-
-    return JSValue::encode(jsUndefined());
-}
-
-// ------------------------------ Hook Functions ---------------------------
-
-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.
-    // For example, JavaScriptCore shell can provide the hook fetching the resource
-    // from the local file system.
-    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.
-    // Typically it is used by the transpilers.
-    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, and instantiate the module record
-    // by parsing the module 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)));
-}
-
-// ------------------- Additional Hook Functions ---------------------------
-
-EncodedJSValue JSC_HOST_CALL moduleLoaderObjectEvaluate(ExecState* exec)
-{
-    // To instrument and retrieve the errors raised from the module execution,
-    // we inserted the hook point here.
-
-    ModuleLoaderObject* loader = jsDynamicCast<ModuleLoaderObject*>(exec->thisValue());
-    if (!loader)
-        return JSValue::encode(jsUndefined());
-    return JSValue::encode(loader->evaluate(exec, exec->argument(0), exec->argument(1)));
-}
-
-} // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp b/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp
new file mode 100644 (file)
index 0000000..900d63e
--- /dev/null
@@ -0,0 +1,239 @@
+/*
+ * 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 "ModuleLoaderPrototype.h"
+
+#include "BuiltinNames.h"
+#include "CodeProfiling.h"
+#include "Error.h"
+#include "Exception.h"
+#include "JSCInlines.h"
+#include "JSGlobalObjectFunctions.h"
+#include "JSInternalPromise.h"
+#include "JSInternalPromiseDeferred.h"
+#include "JSMap.h"
+#include "JSModuleEnvironment.h"
+#include "JSModuleLoader.h"
+#include "JSModuleRecord.h"
+#include "ModuleAnalyzer.h"
+#include "Nodes.h"
+#include "Parser.h"
+#include "ParserError.h"
+
+namespace JSC {
+
+static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeParseModule(ExecState*);
+static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeRequestedModules(ExecState*);
+static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeEvaluate(ExecState*);
+static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeModuleDeclarationInstantiation(ExecState*);
+static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeResolve(ExecState*);
+static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeFetch(ExecState*);
+static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeTranslate(ExecState*);
+static EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeInstantiate(ExecState*);
+
+}
+
+#include "ModuleLoaderPrototype.lut.h"
+
+namespace JSC {
+
+STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(ModuleLoaderPrototype);
+
+const ClassInfo ModuleLoaderPrototype::s_info = { "ModuleLoader", &Base::s_info, &moduleLoaderPrototypeTable, CREATE_METHOD_TABLE(ModuleLoaderPrototype) };
+
+/* Source for ModuleLoaderPrototype.lut.h
+@begin moduleLoaderPrototypeTable
+    setStateToMax                  JSBuiltin                                        DontEnum|Function 2
+    newRegistryEntry               JSBuiltin                                        DontEnum|Function 1
+    ensureRegistered               JSBuiltin                                        DontEnum|Function 1
+    forceFulfillPromise            JSBuiltin                                        DontEnum|Function 2
+    fulfillFetch                   JSBuiltin                                        DontEnum|Function 2
+    fulfillTranslate               JSBuiltin                                        DontEnum|Function 2
+    fulfillInstantiate             JSBuiltin                                        DontEnum|Function 2
+    commitInstantiated             JSBuiltin                                        DontEnum|Function 3
+    instantiation                  JSBuiltin                                        DontEnum|Function 3
+    requestFetch                   JSBuiltin                                        DontEnum|Function 1
+    requestTranslate               JSBuiltin                                        DontEnum|Function 1
+    requestInstantiate             JSBuiltin                                        DontEnum|Function 1
+    requestResolveDependencies     JSBuiltin                                        DontEnum|Function 1
+    requestInstantiateAll          JSBuiltin                                        DontEnum|Function 1
+    requestLink                    JSBuiltin                                        DontEnum|Function 1
+    requestReady                   JSBuiltin                                        DontEnum|Function 1
+    link                           JSBuiltin                                        DontEnum|Function 1
+    moduleDeclarationInstantiation moduleLoaderPrototypeModuleDeclarationInstantiation DontEnum|Function 2
+    moduleEvaluation               JSBuiltin                                        DontEnum|Function 2
+    evaluate                       moduleLoaderPrototypeEvaluate                       DontEnum|Function 2
+    provide                        JSBuiltin                                        DontEnum|Function 3
+    loadAndEvaluateModule          JSBuiltin                                        DontEnum|Function 2
+    loadModule                     JSBuiltin                                        DontEnum|Function 2
+    linkAndEvaluateModule          JSBuiltin                                        DontEnum|Function 1
+    parseModule                    moduleLoaderPrototypeParseModule                    DontEnum|Function 2
+    requestedModules               moduleLoaderPrototypeRequestedModules               DontEnum|Function 1
+    resolve                        moduleLoaderPrototypeResolve                        DontEnum|Function 1
+    fetch                          moduleLoaderPrototypeFetch                          DontEnum|Function 1
+    translate                      moduleLoaderPrototypeTranslate                      DontEnum|Function 2
+    instantiate                    moduleLoaderPrototypeInstantiate                    DontEnum|Function 2
+@end
+*/
+
+ModuleLoaderPrototype::ModuleLoaderPrototype(VM& vm, Structure* structure)
+    : JSNonFinalObject(vm, structure)
+{
+}
+
+// ------------------------------ Functions --------------------------------
+
+EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeParseModule(ExecState* exec)
+{
+    VM& vm = exec->vm();
+    const Identifier moduleKey = exec->argument(0).toPropertyKey(exec);
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    String source = exec->argument(1).toString(exec)->value(exec);
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    SourceCode sourceCode = makeSource(source, moduleKey.impl());
+
+    CodeProfiling profile(sourceCode);
+
+    ParserError error;
+    std::unique_ptr<ModuleProgramNode> moduleProgramNode = parse<ModuleProgramNode>(
+        &vm, sourceCode, Identifier(), JSParserBuiltinMode::NotBuiltin,
+        JSParserStrictMode::Strict, SourceParseMode::ModuleAnalyzeMode, SuperBinding::NotNeeded, error);
+
+    if (error.isValid()) {
+        throwVMError(exec, error.toErrorObject(exec->lexicalGlobalObject(), sourceCode));
+        return JSValue::encode(jsUndefined());
+    }
+    ASSERT(moduleProgramNode);
+
+    ModuleAnalyzer moduleAnalyzer(exec, moduleKey, sourceCode, moduleProgramNode->varDeclarations(), moduleProgramNode->lexicalVariables());
+    JSModuleRecord* moduleRecord = moduleAnalyzer.analyze(*moduleProgramNode);
+
+    return JSValue::encode(moduleRecord);
+}
+
+EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeRequestedModules(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());
+    if (UNLIKELY(exec->hadException()))
+        JSValue::encode(jsUndefined());
+    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 moduleLoaderPrototypeModuleDeclarationInstantiation(ExecState* exec)
+{
+    JSModuleRecord* moduleRecord = jsDynamicCast<JSModuleRecord*>(exec->argument(0));
+    if (!moduleRecord)
+        return JSValue::encode(jsUndefined());
+
+    if (Options::dumpModuleLoadingState())
+        dataLog("Loader [link] ", moduleRecord->moduleKey(), "\n");
+
+    moduleRecord->link(exec);
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    return JSValue::encode(jsUndefined());
+}
+
+// ------------------------------ Hook Functions ---------------------------
+
+EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeResolve(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.
+    JSModuleLoader* loader = jsDynamicCast<JSModuleLoader*>(exec->thisValue());
+    if (!loader)
+        return JSValue::encode(jsUndefined());
+    return JSValue::encode(loader->resolve(exec, exec->argument(0), exec->argument(1)));
+}
+
+EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeFetch(ExecState* exec)
+{
+    // Hook point, Loader.fetch
+    // https://whatwg.github.io/loader/#browser-fetch
+    // Take the key and fetch the resource actually.
+    // For example, JavaScriptCore shell can provide the hook fetching the resource
+    // from the local file system.
+    JSModuleLoader* loader = jsDynamicCast<JSModuleLoader*>(exec->thisValue());
+    if (!loader)
+        return JSValue::encode(jsUndefined());
+    return JSValue::encode(loader->fetch(exec, exec->argument(0)));
+}
+
+EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeTranslate(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.
+    // Typically it is used by the transpilers.
+    JSModuleLoader* loader = jsDynamicCast<JSModuleLoader*>(exec->thisValue());
+    if (!loader)
+        return JSValue::encode(jsUndefined());
+    return JSValue::encode(loader->translate(exec, exec->argument(0), exec->argument(1)));
+}
+
+EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeInstantiate(ExecState* exec)
+{
+    // Hook point, Loader.instantiate
+    // https://whatwg.github.io/loader/#browser-instantiate
+    // Take the key and the translated source code, and instantiate the module record
+    // by parsing the module source code.
+    // It has the chance to provide the optional module instance that is different from
+    // the ordinary one.
+    JSModuleLoader* loader = jsDynamicCast<JSModuleLoader*>(exec->thisValue());
+    if (!loader)
+        return JSValue::encode(jsUndefined());
+    return JSValue::encode(loader->instantiate(exec, exec->argument(0), exec->argument(1)));
+}
+
+// ------------------- Additional Hook Functions ---------------------------
+
+EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeEvaluate(ExecState* exec)
+{
+    // To instrument and retrieve the errors raised from the module execution,
+    // we inserted the hook point here.
+
+    JSModuleLoader* loader = jsDynamicCast<JSModuleLoader*>(exec->thisValue());
+    if (!loader)
+        return JSValue::encode(jsUndefined());
+    return JSValue::encode(loader->evaluate(exec, exec->argument(0), exec->argument(1)));
+}
+
+} // namespace JSC
diff --git a/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.h b/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.h
new file mode 100644 (file)
index 0000000..9f93eac
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2016 Yusuke Suzuki <utatane.tea@gmail.com>.
+ *
+ * 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.
+ */
+
+#pragma once
+
+#include "JSObject.h"
+
+namespace JSC {
+
+class JSInternalPromise;
+
+class ModuleLoaderPrototype : public JSNonFinalObject {
+private:
+    ModuleLoaderPrototype(VM&, Structure*);
+public:
+    typedef JSNonFinalObject Base;
+    static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
+
+    static ModuleLoaderPrototype* create(VM& vm, JSGlobalObject*, Structure* structure)
+    {
+        ModuleLoaderPrototype* object = new (NotNull, allocateCell<ModuleLoaderPrototype>(vm.heap)) ModuleLoaderPrototype(vm, structure);
+        object->finishCreation(vm);
+        return object;
+    }
+
+    DECLARE_INFO;
+
+    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+    {
+        return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
+    }
+};
+
+} // namespace JSC
index 97b74a5..a7661a9 100644 (file)
@@ -1,3 +1,24 @@
+2016-08-10  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [ES6] Add ModuleLoaderPrototype and move methods to it
+        https://bugs.webkit.org/show_bug.cgi?id=160633
+
+        Reviewed by Saam Barati.
+
+        No behavior change.
+
+        * ForwardingHeaders/runtime/JSModuleLoader.h: Added.
+        * bindings/js/JSDOMWindowBase.cpp:
+        (WebCore::JSDOMWindowBase::moduleLoaderResolve):
+        (WebCore::JSDOMWindowBase::moduleLoaderFetch):
+        (WebCore::JSDOMWindowBase::moduleLoaderEvaluate):
+        * bindings/js/JSDOMWindowBase.h:
+        * bindings/js/JSModuleLoader.cpp:
+        (WebCore::JSModuleLoader::resolve):
+        (WebCore::JSModuleLoader::fetch):
+        (WebCore::JSModuleLoader::evaluate):
+        * bindings/js/JSModuleLoader.h:
+
 2016-08-10  Per Arne Vollan  <pvollan@apple.com>
 
         [Win] Warning fix.
diff --git a/Source/WebCore/ForwardingHeaders/runtime/JSModuleLoader.h b/Source/WebCore/ForwardingHeaders/runtime/JSModuleLoader.h
new file mode 100644 (file)
index 0000000..0ba8eac
--- /dev/null
@@ -0,0 +1,2 @@
+#pragma once
+#include <JavaScriptCore/JSModuleLoader.h>
index 9148d35..69074f7 100644 (file)
@@ -323,29 +323,29 @@ void JSDOMWindowBase::fireFrameClearedWatchpointsForWindow(DOMWindow* window)
 }
 
 
-JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderResolve(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSValue moduleName, JSC::JSValue importerModuleKey)
+JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderResolve(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleName, JSC::JSValue importerModuleKey)
 {
     JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
     if (RefPtr<Document> document = thisObject->wrapped().document())
-        return document->moduleLoader()->resolve(globalObject, exec, moduleName, importerModuleKey);
+        return document->moduleLoader()->resolve(globalObject, exec, moduleLoader, moduleName, importerModuleKey);
     JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject);
     return deferred->reject(exec, jsUndefined());
 }
 
-JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderFetch(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSValue moduleKey)
+JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderFetch(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey)
 {
     JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
     if (RefPtr<Document> document = thisObject->wrapped().document())
-        return document->moduleLoader()->fetch(globalObject, exec, moduleKey);
+        return document->moduleLoader()->fetch(globalObject, exec, moduleLoader, moduleKey);
     JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject);
     return deferred->reject(exec, jsUndefined());
 }
 
-JSC::JSValue JSDOMWindowBase::moduleLoaderEvaluate(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSValue moduleKey, JSC::JSValue moduleRecord)
+JSC::JSValue JSDOMWindowBase::moduleLoaderEvaluate(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey, JSC::JSValue moduleRecord)
 {
     JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
     if (RefPtr<Document> document = thisObject->wrapped().document())
-        return document->moduleLoader()->evaluate(globalObject, exec, moduleKey, moduleRecord);
+        return document->moduleLoader()->evaluate(globalObject, exec, moduleLoader, moduleKey, moduleRecord);
     return JSC::jsUndefined();
 }
 
index 1c02e62..80d9608 100644 (file)
@@ -78,9 +78,9 @@ namespace WebCore {
         JSC::WatchpointSet m_windowCloseWatchpoints;
 
     private:
-        static JSC::JSInternalPromise* moduleLoaderResolve(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSValue, JSC::JSValue);
-        static JSC::JSInternalPromise* moduleLoaderFetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSValue);
-        static JSC::JSValue moduleLoaderEvaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSValue, JSC::JSValue);
+        static JSC::JSInternalPromise* moduleLoaderResolve(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue);
+        static JSC::JSInternalPromise* moduleLoaderFetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue);
+        static JSC::JSValue moduleLoaderEvaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue);
 
         RefPtr<DOMWindow> m_wrapped;
         JSDOMWindowShell* m_shell;
index 4669425..ba1e3ec 100644 (file)
@@ -42,7 +42,7 @@ JSModuleLoader::JSModuleLoader(Document& document)
 {
 }
 
-JSC::JSInternalPromise* JSModuleLoader::resolve(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSValue moduleNameValue, JSC::JSValue importerModuleKey)
+JSC::JSInternalPromise* JSModuleLoader::resolve(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleNameValue, JSC::JSValue importerModuleKey)
 {
     JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject);
 
@@ -82,7 +82,7 @@ JSC::JSInternalPromise* JSModuleLoader::resolve(JSC::JSGlobalObject* globalObjec
     return deferred->resolve(exec, jsString(exec, completedUrl.string()));
 }
 
-JSC::JSInternalPromise* JSModuleLoader::fetch(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSValue moduleKeyValue)
+JSC::JSInternalPromise* JSModuleLoader::fetch(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleKeyValue)
 {
     JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject);
 
@@ -101,7 +101,7 @@ JSC::JSInternalPromise* JSModuleLoader::fetch(JSC::JSGlobalObject* globalObject,
     return deferred->promise();
 }
 
-JSC::JSValue JSModuleLoader::evaluate(JSC::JSGlobalObject*, JSC::ExecState* exec, JSC::JSValue moduleKeyValue, JSC::JSValue moduleRecordValue)
+JSC::JSValue JSModuleLoader::evaluate(JSC::JSGlobalObject*, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleKeyValue, JSC::JSValue moduleRecordValue)
 {
     // FIXME: Currently, we only support JSModuleRecord.
     // Once the reflective part of the module loader is supported, we will handle arbitrary values.
index 2eaf832..69a501a 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef JSModuleLoader_h
-#define JSModuleLoader_h
+#pragma once
 
 #include <runtime/JSCJSValue.h>
 #include <wtf/Noncopyable.h>
@@ -34,6 +33,7 @@ namespace JSC {
 class ExecState;
 class JSGlobalObject;
 class JSInternalPromise;
+class JSModuleLoader;
 
 }
 
@@ -48,14 +48,12 @@ public:
 
     Document& document() { return m_document; }
 
-    JSC::JSInternalPromise* resolve(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSValue moduleName, JSC::JSValue importerModuleKey);
-    JSC::JSInternalPromise* fetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSValue moduleKey);
-    JSC::JSValue evaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSValue moduleKey, JSC::JSValue moduleRecord);
+    JSC::JSInternalPromise* resolve(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleName, JSC::JSValue importerModuleKey);
+    JSC::JSInternalPromise* fetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleKey);
+    JSC::JSValue evaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleKey, JSC::JSValue moduleRecord);
 
 private:
     Document& m_document;
 };
 
 } // namespace WebCore
-
-#endif // JSModuleLoader_h