WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-149129-20150914151132.patch (text/plain), 28.82 KB, created by
Yusuke Suzuki
on 2015-09-14 15:11:41 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2015-09-14 15:11:41 PDT
Size:
28.82 KB
patch
obsolete
>Subversion Revision: 189748 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index d051e5e1c4a326e6432858f0855499581a89330e..cbd79cb15ab2cd83f29f753509fc7405b4f91a92 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,5 +1,56 @@ > 2015-09-14 Yusuke Suzuki <utatane.tea@gmail.com> > >+ [ES6] Add more fine-grained APIs and additional hooks to control module loader from WebCore >+ https://bugs.webkit.org/show_bug.cgi?id=149129 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No behavior change. >+ >+ Module tag `<script type="module>` will be executed asynchronously. >+ But we would like to fetch the resources before when the postTask-ed task is performed. >+ So instead of 1 API that fetch, instantiate and execute the module graph, >+ we need 2 fine-grained APIs. >+ >+ 1. Fetch and initialize a module graph, but not execute it yet. >+ 2. Link and execute a module graph specified by the key (this will be invoked asynchronously). >+ >+ And to instrument the script execution (like reporting the execution time of the module to >+ the inspector), we need a hook to inject code around an execution of a module body. >+ >+ * builtins/ModuleLoaderObject.js: >+ (moduleEvaluation): >+ (loadModuleGraph): >+ (prepareModuleGraph): >+ (linkAndEvaluateModuleGraph): >+ (loadModule): Deleted. >+ * jsc.cpp: >+ (functionLoadModule): >+ (runWithScripts): >+ * runtime/Completion.cpp: >+ (JSC::identifierToJSValue): >+ (JSC::loadModuleGraph): >+ (JSC::prepareModuleGraph): >+ (JSC::linkAndEvaluateModuleGraph): >+ (JSC::evaluateModule): Deleted. >+ * runtime/Completion.h: >+ * runtime/JSGlobalObject.cpp: >+ * runtime/JSGlobalObject.h: >+ * runtime/JSModuleRecord.cpp: >+ (JSC::JSModuleRecord::evaluate): >+ (JSC::JSModuleRecord::execute): Deleted. >+ * runtime/JSModuleRecord.h: >+ * runtime/ModuleLoaderObject.cpp: >+ (JSC::ModuleLoaderObject::loadModuleGraph): >+ (JSC::ModuleLoaderObject::prepareModuleGraph): >+ (JSC::ModuleLoaderObject::linkAndEvaluateModuleGraph): >+ (JSC::ModuleLoaderObject::evaluate): >+ (JSC::moduleLoaderObjectEvaluate): >+ (JSC::ModuleLoaderObject::loadModule): Deleted. >+ * runtime/ModuleLoaderObject.h: >+ >+2015-09-14 Yusuke Suzuki <utatane.tea@gmail.com> >+ > [ES6] Cache the resolution result in JSModuleRecord > https://bugs.webkit.org/show_bug.cgi?id=148896 > >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index f8243d0cf76570182cdbd929132b314dbdb5f984..44345ce26bf0af1046e856d1d1a9b76c741caf62 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,15 @@ >+2015-09-14 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ [ES6] Add more fine-grained APIs and additional hooks to control module loader from WebCore >+ https://bugs.webkit.org/show_bug.cgi?id=149129 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No behavior change. >+ >+ * bindings/js/JSDOMWindowBase.cpp: >+ * bindings/js/JSWorkerGlobalScopeBase.cpp: >+ > 2015-09-14 Brady Eidson <beidson@apple.com> > > Rename current concrete IDB implementation to "Legacy". >diff --git a/Source/JavaScriptCore/builtins/ModuleLoaderObject.js b/Source/JavaScriptCore/builtins/ModuleLoaderObject.js >index 16062e6d74da3b76e81b585fee1cefc300cc5135..2e086b04e607808a097c705717814087f00d500a 100644 >--- a/Source/JavaScriptCore/builtins/ModuleLoaderObject.js >+++ b/Source/JavaScriptCore/builtins/ModuleLoaderObject.js >@@ -483,22 +483,10 @@ function moduleEvaluation(moduleRecord) > var requiredModuleRecord = pair.value; > this.moduleEvaluation(requiredModuleRecord); > } >- this.evaluate(moduleRecord); >+ this.evaluate(entry.key, moduleRecord); > } > >-function loadModule(moduleName, referrer) >-{ >- "use strict"; >- >- var loader = this; >- // Loader.resolve hook point. >- // resolve: moduleName => Promise(moduleKey) >- // 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. >- return this.resolve(moduleName, referrer).then(function (key) { >- return loader.requestReady(key); >- }); >-} >+// APIs to control the module loader. > > function provide(key, stage, value) > { >@@ -535,3 +523,40 @@ function provide(key, stage, value) > > throw new @TypeError("Requested module is already ready to be executed."); > } >+ >+function loadModuleGraph(moduleName, referrer) >+{ >+ "use strict"; >+ >+ var loader = this; >+ // Loader.resolve hook point. >+ // resolve: moduleName => Promise(moduleKey) >+ // 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. >+ return this.resolve(moduleName, referrer).then(function (key) { >+ return loader.requestReady(key); >+ }); >+} >+ >+function prepareModuleGraph(moduleName, referrer) >+{ >+ "use strict"; >+ >+ var loader = this; >+ // Loader.resolve hook point. >+ // resolve: moduleName => Promise(moduleKey) >+ // 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. >+ return this.resolve(moduleName, referrer).then(function (key) { >+ return loader.requestInstantiateAll(key); >+ }).then(function (entry) { >+ return entry.key; >+ }); >+} >+ >+function linkAndEvaluateModuleGraph(key) >+{ >+ "use strict"; >+ >+ return this.requestReady(key); >+} >diff --git a/Source/JavaScriptCore/jsc.cpp b/Source/JavaScriptCore/jsc.cpp >index 5cd9278842f6dd55e4f8824b1da053b8a7dcf2ae..8be9842c705b9a3f60bf6db1d5c47b608ccef78c 100644 >--- a/Source/JavaScriptCore/jsc.cpp >+++ b/Source/JavaScriptCore/jsc.cpp >@@ -709,7 +709,7 @@ class GlobalObject : public JSGlobalObject { > }; > > const ClassInfo GlobalObject::s_info = { "global", &JSGlobalObject::s_info, nullptr, CREATE_METHOD_TABLE(GlobalObject) }; >-const GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, 0, &shouldInterruptScriptBeforeTimeout, &moduleLoaderResolve, &moduleLoaderFetch, nullptr, nullptr }; >+const GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, 0, &shouldInterruptScriptBeforeTimeout, &moduleLoaderResolve, &moduleLoaderFetch, nullptr, nullptr, nullptr }; > > > GlobalObject::GlobalObject(VM& vm, Structure* structure) >@@ -1473,7 +1473,7 @@ EncodedJSValue JSC_HOST_CALL functionLoadModule(ExecState* exec) > if (!fetchScriptFromLocalFileSystem(fileName, script)) > return JSValue::encode(exec->vm().throwException(exec, createError(exec, ASCIILiteral("Could not open file.")))); > >- JSInternalPromise* promise = evaluateModule(exec, fileName); >+ JSInternalPromise* promise = loadModuleGraph(exec, fileName); > if (exec->hadException()) > return JSValue::encode(jsUndefined()); > >@@ -1646,7 +1646,7 @@ static bool runWithScripts(GlobalObject* globalObject, const Vector<Script>& scr > if (scripts[i].isFile) { > fileName = scripts[i].argument; > if (module) >- promise = evaluateModule(globalObject->globalExec(), fileName); >+ promise = loadModuleGraph(globalObject->globalExec(), fileName); > else { > if (!fetchScriptFromLocalFileSystem(fileName, scriptBuffer)) > return false; // fail early so we can catch missing files >@@ -1662,7 +1662,7 @@ static bool runWithScripts(GlobalObject* globalObject, const Vector<Script>& scr > > if (module) { > if (!promise) >- promise = evaluateModule(globalObject->globalExec(), jscSource(scriptBuffer, fileName)); >+ promise = loadModuleGraph(globalObject->globalExec(), jscSource(scriptBuffer, fileName)); > globalObject->globalExec()->clearException(); > promise->then(globalObject->globalExec(), nullptr, errorHandler); > globalObject->vm().drainMicrotasks(); >diff --git a/Source/JavaScriptCore/runtime/Completion.cpp b/Source/JavaScriptCore/runtime/Completion.cpp >index b5f623acda523051187d0db5688521262d86248c..bfcf6e24dfdcbe6585cb72674a005fd98992a0bc 100644 >--- a/Source/JavaScriptCore/runtime/Completion.cpp >+++ b/Source/JavaScriptCore/runtime/Completion.cpp >@@ -113,23 +113,77 @@ JSValue evaluate(ExecState* exec, const SourceCode& source, JSValue thisValue, N > return result; > } > >-static JSInternalPromise* evaluateModule(const JSLockHolder&, ExecState* exec, JSGlobalObject* globalObject, JSValue moduleName, JSValue referrer) >+static inline JSValue identifierToJSValue(VM& vm, const Identifier& identifier) > { >- return globalObject->moduleLoader()->loadModule(exec, moduleName, referrer); >+ if (identifier.isSymbol()) >+ return Symbol::create(vm, static_cast<SymbolImpl&>(*identifier.impl())); >+ return jsString(&vm, identifier.impl()); > } > >-static JSInternalPromise* evaluateModule(const JSLockHolder& lock, ExecState* exec, JSGlobalObject* globalObject, const Identifier& moduleName) >+static JSInternalPromise* loadModuleGraph(const JSLockHolder&, ExecState* exec, JSGlobalObject* globalObject, JSValue moduleName, JSValue referrer) > { >- JSValue moduleNameValue; >- if (moduleName.isSymbol()) >- moduleNameValue = Symbol::create(exec->vm(), static_cast<SymbolImpl&>(*moduleName.impl())); >- else >- moduleNameValue = jsString(&exec->vm(), moduleName.impl()); >+ return globalObject->moduleLoader()->loadModuleGraph(exec, moduleName, referrer); >+} >+ >+static JSInternalPromise* loadModuleGraph(const JSLockHolder& lock, ExecState* exec, JSGlobalObject* globalObject, const Identifier& moduleName) >+{ >+ return loadModuleGraph(lock, exec, globalObject, identifierToJSValue(exec->vm(), moduleName), jsUndefined()); >+} >+ >+JSInternalPromise* loadModuleGraph(ExecState* exec, const SourceCode& source) >+{ >+ JSLockHolder lock(exec); >+ RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable()); >+ RELEASE_ASSERT(!exec->vm().isCollectorBusy()); >+ >+ JSGlobalObject* globalObject = exec->vmEntryGlobalObject(); >+ >+ // Generate the unique key for the source-provided module. >+ PrivateName privateName(PrivateName::Description, "EntryPointModule"); >+ Symbol* key = Symbol::create(exec->vm(), *privateName.uid()); >+ >+ // Insert the given source code to the ModuleLoader registry as the fetched registry entry. >+ globalObject->moduleLoader()->provide(exec, key, ModuleLoaderObject::Status::Fetch, source.toString()); >+ if (exec->hadException()) { >+ JSValue exception = exec->exception()->value(); >+ exec->clearException(); >+ JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject); >+ deferred->reject(exec, exception); >+ return deferred->promise(); >+ } >+ >+ return loadModuleGraph(lock, exec, globalObject, key, jsUndefined()); >+} >+ >+JSInternalPromise* loadModuleGraph(ExecState* exec, const Identifier& moduleName) >+{ >+ JSLockHolder lock(exec); >+ RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable()); >+ RELEASE_ASSERT(!exec->vm().isCollectorBusy()); >+ >+ return loadModuleGraph(lock, exec, exec->vmEntryGlobalObject(), moduleName); >+} >+ >+JSInternalPromise* loadModuleGraph(ExecState* exec, const String& moduleName) >+{ >+ JSLockHolder lock(exec); >+ RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable()); >+ RELEASE_ASSERT(!exec->vm().isCollectorBusy()); >+ >+ return loadModuleGraph(lock, exec, exec->vmEntryGlobalObject(), Identifier::fromString(exec, moduleName)); >+} >+ >+static JSInternalPromise* prepareModuleGraph(const JSLockHolder&, ExecState* exec, JSGlobalObject* globalObject, JSValue moduleName, JSValue referrer) >+{ >+ return globalObject->moduleLoader()->prepareModuleGraph(exec, moduleName, referrer); >+} > >- return evaluateModule(lock, exec, globalObject, moduleNameValue, jsUndefined()); >+static JSInternalPromise* prepareModuleGraph(const JSLockHolder& lock, ExecState* exec, JSGlobalObject* globalObject, const Identifier& moduleName) >+{ >+ return prepareModuleGraph(lock, exec, globalObject, identifierToJSValue(exec->vm(), moduleName), jsUndefined()); > } > >-JSInternalPromise* evaluateModule(ExecState* exec, const SourceCode& source) >+JSInternalPromise* prepareModuleGraph(ExecState* exec, const SourceCode& source) > { > JSLockHolder lock(exec); > RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable()); >@@ -151,25 +205,28 @@ JSInternalPromise* evaluateModule(ExecState* exec, const SourceCode& source) > return deferred->promise(); > } > >- return evaluateModule(lock, exec, globalObject, key, jsUndefined()); >+ return prepareModuleGraph(lock, exec, globalObject, key, jsUndefined()); > } > >-JSInternalPromise* evaluateModule(ExecState* exec, const Identifier& moduleName) >+JSInternalPromise* prepareModuleGraph(ExecState* exec, const String& moduleName) > { > JSLockHolder lock(exec); > RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable()); > RELEASE_ASSERT(!exec->vm().isCollectorBusy()); > >- return evaluateModule(lock, exec, exec->vmEntryGlobalObject(), moduleName); >+ return prepareModuleGraph(lock, exec, exec->vmEntryGlobalObject(), Identifier::fromString(exec, moduleName)); > } > >-JSInternalPromise* evaluateModule(ExecState* exec, const String& moduleName) >+ >+JSInternalPromise* linkAndEvaluateModuleGraph(ExecState* exec, const Identifier& moduleKey) > { > JSLockHolder lock(exec); > RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable()); > RELEASE_ASSERT(!exec->vm().isCollectorBusy()); > >- return evaluateModule(lock, exec, exec->vmEntryGlobalObject(), Identifier::fromString(exec, moduleName)); >+ JSGlobalObject* globalObject = exec->vmEntryGlobalObject(); >+ >+ return globalObject->moduleLoader()->linkAndEvaluateModuleGraph(exec, identifierToJSValue(exec->vm(), moduleKey)); > } > > } // namespace JSC >diff --git a/Source/JavaScriptCore/runtime/Completion.h b/Source/JavaScriptCore/runtime/Completion.h >index cb091ff164b228dc02c223dd1ed8cd6482915a65..21fd8da009d0a4b7a0868e71deea4cae953b549e 100644 >--- a/Source/JavaScriptCore/runtime/Completion.h >+++ b/Source/JavaScriptCore/runtime/Completion.h >@@ -45,9 +45,18 @@ inline JSValue evaluate(ExecState* exec, const SourceCode& sourceCode, JSValue t > NakedPtr<Exception> unused; > return evaluate(exec, sourceCode, thisValue, unused); > } >-JS_EXPORT_PRIVATE JSInternalPromise* evaluateModule(ExecState*, const SourceCode&); >-JS_EXPORT_PRIVATE JSInternalPromise* evaluateModule(ExecState*, const Identifier& moduleName); >-JS_EXPORT_PRIVATE JSInternalPromise* evaluateModule(ExecState*, const String& moduleName); >+ >+// Load the module source and evaluate it. >+JS_EXPORT_PRIVATE JSInternalPromise* loadModuleGraph(ExecState*, const SourceCode&); >+JS_EXPORT_PRIVATE JSInternalPromise* loadModuleGraph(ExecState*, const Identifier& moduleName); >+JS_EXPORT_PRIVATE JSInternalPromise* loadModuleGraph(ExecState*, const String& moduleName); >+ >+// Fetch the module source, and instantiate the module record. >+JS_EXPORT_PRIVATE JSInternalPromise* prepareModuleGraph(ExecState*, const SourceCode&); >+JS_EXPORT_PRIVATE JSInternalPromise* prepareModuleGraph(ExecState*, const String& moduleName); >+ >+// Link and evaluate the already linked module. >+JS_EXPORT_PRIVATE JSInternalPromise* linkAndEvaluateModuleGraph(ExecState*, const Identifier& moduleKey); > > } // namespace JSC > >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >index 299106498287df28906518d3da27122fb8c7c1cc..df26325fc5515be56e905390b14ffe56b2d420e9 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >@@ -165,7 +165,7 @@ namespace JSC { > > const ClassInfo JSGlobalObject::s_info = { "GlobalObject", &Base::s_info, &globalObjectTable, CREATE_METHOD_TABLE(JSGlobalObject) }; > >-const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, nullptr, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr }; >+const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, nullptr, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr }; > > /* Source for JSGlobalObject.lut.h > @begin globalObjectTable >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.h b/Source/JavaScriptCore/runtime/JSGlobalObject.h >index dcb3a087f799bf6bd2c4a66368608431f1bb4ded..5461ceb5286dd6d2d2a1ad34c8b81f5ec06a7a46 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObject.h >+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.h >@@ -170,6 +170,9 @@ struct GlobalObjectMethodTable { > > typedef JSInternalPromise* (*ModuleLoaderInstantiatePtr)(JSGlobalObject*, ExecState*, JSValue, JSValue); > ModuleLoaderInstantiatePtr moduleLoaderInstantiate; >+ >+ typedef JSValue (*ModuleLoaderEvaluatePtr)(JSGlobalObject*, ExecState*, JSValue, JSValue); >+ ModuleLoaderEvaluatePtr moduleLoaderEvaluate; > }; > > class JSGlobalObject : public JSSegmentedVariableObject { >diff --git a/Source/JavaScriptCore/runtime/JSModuleRecord.cpp b/Source/JavaScriptCore/runtime/JSModuleRecord.cpp >index 843c94e18046d1f48f95de76cc5190da32d28625..1cc49375d4f2cf2ec7e2e01bba7bb8a9147f84ff 100644 >--- a/Source/JavaScriptCore/runtime/JSModuleRecord.cpp >+++ b/Source/JavaScriptCore/runtime/JSModuleRecord.cpp >@@ -844,7 +844,7 @@ void JSModuleRecord::instantiateDeclarations(ExecState* exec, ModuleProgramExecu > m_moduleEnvironment.set(vm, this, moduleEnvironment); > } > >-JSValue JSModuleRecord::execute(ExecState* exec) >+JSValue JSModuleRecord::evaluate(ExecState* exec) > { > if (!m_moduleProgramExecutable) > return jsUndefined(); >diff --git a/Source/JavaScriptCore/runtime/JSModuleRecord.h b/Source/JavaScriptCore/runtime/JSModuleRecord.h >index 30de7f5c5fe133e8aa54c0c9204e76a3db10a185..b82a9e1d57aaa4e68a7f28058755e077b5b1026b 100644 >--- a/Source/JavaScriptCore/runtime/JSModuleRecord.h >+++ b/Source/JavaScriptCore/runtime/JSModuleRecord.h >@@ -123,7 +123,7 @@ class JSModuleRecord : public JSDestructibleObject { > } > > void link(ExecState*); >- JSValue execute(ExecState*); >+ JS_EXPORT_PRIVATE JSValue evaluate(ExecState*); > > ModuleProgramExecutable* moduleProgramExecutable() const { return m_moduleProgramExecutable.get(); } > >diff --git a/Source/JavaScriptCore/runtime/ModuleLoaderObject.cpp b/Source/JavaScriptCore/runtime/ModuleLoaderObject.cpp >index 6e6f9f9a6da61812e3c21ad4366fd87b7cd147d8..8351c4b5df8cf27953814805d3e7db32d36e96e1 100644 >--- a/Source/JavaScriptCore/runtime/ModuleLoaderObject.cpp >+++ b/Source/JavaScriptCore/runtime/ModuleLoaderObject.cpp >@@ -85,8 +85,10 @@ const ClassInfo ModuleLoaderObject::s_info = { "ModuleLoader", &Base::s_info, &m > moduleDeclarationInstantiation moduleLoaderObjectModuleDeclarationInstantiation DontEnum|Function 2 > moduleEvaluation moduleLoaderObjectModuleEvaluation DontEnum|Function 2 > evaluate moduleLoaderObjectEvaluate DontEnum|Function 2 >- loadModule moduleLoaderObjectLoadModule DontEnum|Function 2 > provide moduleLoaderObjectProvide DontEnum|Function 3 >+ loadModuleGraph moduleLoaderObjectLoadModuleGraph DontEnum|Function 2 >+ prepareModuleGraph moduleLoaderObjectPrepareModuleGraph DontEnum|Function 2 >+ linkAndEvaluateModuleGraph moduleLoaderObjectLinkAndEvaluateModuleGraph DontEnum|Function 1 > parseModule moduleLoaderObjectParseModule DontEnum|Function 2 > requestedModules moduleLoaderObjectRequestedModules DontEnum|Function 1 > resolve moduleLoaderObjectResolve DontEnum|Function 1 >@@ -146,9 +148,9 @@ JSValue ModuleLoaderObject::provide(ExecState* exec, JSValue key, Status status, > return call(exec, function, callType, callData, this, arguments); > } > >-JSInternalPromise* ModuleLoaderObject::loadModule(ExecState* exec, JSValue moduleName, JSValue referrer) >+JSInternalPromise* ModuleLoaderObject::loadModuleGraph(ExecState* exec, JSValue moduleName, JSValue referrer) > { >- JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().loadModulePublicName())); >+ JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().loadModuleGraphPublicName())); > CallData callData; > CallType callType = JSC::getCallData(function, callData); > ASSERT(callType != CallTypeNone); >@@ -160,6 +162,33 @@ JSInternalPromise* ModuleLoaderObject::loadModule(ExecState* exec, JSValue modul > return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments)); > } > >+JSInternalPromise* ModuleLoaderObject::prepareModuleGraph(ExecState* exec, JSValue moduleName, JSValue referrer) >+{ >+ JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().prepareModuleGraphPublicName())); >+ CallData callData; >+ CallType callType = JSC::getCallData(function, callData); >+ ASSERT(callType != CallTypeNone); >+ >+ MarkedArgumentBuffer arguments; >+ arguments.append(moduleName); >+ arguments.append(referrer); >+ >+ return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments)); >+} >+ >+JSInternalPromise* ModuleLoaderObject::linkAndEvaluateModuleGraph(ExecState* exec, JSValue moduleKey) >+{ >+ JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().linkAndEvaluateModuleGraphPublicName())); >+ CallData callData; >+ CallType callType = JSC::getCallData(function, callData); >+ ASSERT(callType != CallTypeNone); >+ >+ 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()) >@@ -219,6 +248,21 @@ JSInternalPromise* ModuleLoaderObject::instantiate(ExecState* exec, JSValue key, > 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(); >@@ -281,18 +325,6 @@ EncodedJSValue JSC_HOST_CALL moduleLoaderObjectModuleDeclarationInstantiation(Ex > return JSValue::encode(jsUndefined()); > } > >-EncodedJSValue JSC_HOST_CALL moduleLoaderObjectEvaluate(ExecState* exec) >-{ >- JSModuleRecord* moduleRecord = jsDynamicCast<JSModuleRecord*>(exec->argument(0)); >- if (!moduleRecord) >- return JSValue::encode(jsUndefined()); >- >- if (Options::dumpModuleLoadingState()) >- dataLog("Loader [evaluate] ", moduleRecord->moduleKey(), "\n"); >- >- return JSValue::encode(moduleRecord->execute(exec)); >-} >- > // ------------------------------ Hook Functions --------------------------- > > EncodedJSValue JSC_HOST_CALL moduleLoaderObjectResolve(ExecState* exec) >@@ -346,4 +378,17 @@ EncodedJSValue JSC_HOST_CALL moduleLoaderObjectInstantiate(ExecState* exec) > 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/ModuleLoaderObject.h b/Source/JavaScriptCore/runtime/ModuleLoaderObject.h >index 12cfe56eebb6c427c0ef79021f997c6b0d384a1f..19497524fa6f494e394ad5000274c0a34891ba54 100644 >--- a/Source/JavaScriptCore/runtime/ModuleLoaderObject.h >+++ b/Source/JavaScriptCore/runtime/ModuleLoaderObject.h >@@ -64,7 +64,9 @@ class ModuleLoaderObject : public JSNonFinalObject { > > // APIs to control the module loader. > JSValue provide(ExecState*, JSValue key, Status, const String&); >- JSInternalPromise* loadModule(ExecState*, JSValue moduleName, JSValue referrer); >+ JSInternalPromise* loadModuleGraph(ExecState*, JSValue moduleName, JSValue referrer); >+ JSInternalPromise* prepareModuleGraph(ExecState*, JSValue moduleName, JSValue referrer); >+ JSInternalPromise* linkAndEvaluateModuleGraph(ExecState*, JSValue moduleKey); > > // Platform dependent hooked APIs. > JSInternalPromise* resolve(ExecState*, JSValue name, JSValue referrer); >@@ -72,6 +74,9 @@ class ModuleLoaderObject : public JSNonFinalObject { > JSInternalPromise* translate(ExecState*, JSValue key, JSValue payload); > JSInternalPromise* instantiate(ExecState*, JSValue key, JSValue source); > >+ // Additional platform dependent hooked APIs. >+ JSValue evaluate(ExecState*, JSValue key, JSValue moduleRecord); >+ > static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&); > > protected: >diff --git a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp b/Source/WebCore/bindings/js/JSDOMWindowBase.cpp >index d4f001d28fbd3e9893f319b8b3002d1c0129eb80..79b740be5e1a2600c41d73212515f8ff112be966 100644 >--- a/Source/WebCore/bindings/js/JSDOMWindowBase.cpp >+++ b/Source/WebCore/bindings/js/JSDOMWindowBase.cpp >@@ -56,7 +56,7 @@ static bool shouldAllowAccessFrom(const JSGlobalObject* thisObject, ExecState* e > > const ClassInfo JSDOMWindowBase::s_info = { "Window", &JSDOMGlobalObject::s_info, 0, CREATE_METHOD_TABLE(JSDOMWindowBase) }; > >-const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &shouldAllowAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr }; >+const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &shouldAllowAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr }; > > JSDOMWindowBase::JSDOMWindowBase(VM& vm, Structure* structure, PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell) > : JSDOMGlobalObject(vm, structure, &shell->world(), &s_globalObjectMethodTable) >diff --git a/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp b/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp >index 5044bc1783513b9b1a26bd3bd1cb5c00b70a10d0..acd617e8698929075376e5832ab283f2d2fa7900 100644 >--- a/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp >+++ b/Source/WebCore/bindings/js/JSWorkerGlobalScopeBase.cpp >@@ -43,7 +43,7 @@ namespace WebCore { > > const ClassInfo JSWorkerGlobalScopeBase::s_info = { "WorkerGlobalScope", &JSDOMGlobalObject::s_info, 0, CREATE_METHOD_TABLE(JSWorkerGlobalScopeBase) }; > >-const GlobalObjectMethodTable JSWorkerGlobalScopeBase::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr }; >+const GlobalObjectMethodTable JSWorkerGlobalScopeBase::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, &queueTaskToEventLoop, &shouldInterruptScriptBeforeTimeout, nullptr, nullptr, nullptr, nullptr, nullptr }; > > JSWorkerGlobalScopeBase::JSWorkerGlobalScopeBase(JSC::VM& vm, JSC::Structure* structure, PassRefPtr<WorkerGlobalScope> impl) > : JSDOMGlobalObject(vm, structure, &normalWorld(vm), &s_globalObjectMethodTable)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 149129
:
261135
|
261366