Changeset 211018 in webkit
- Timestamp:
- Jan 21, 2017 2:22:54 PM (7 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r211017 r211018 1 2017-01-21 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [JSC] export JSC::importModule API for WebCore dynamic import 4 https://bugs.webkit.org/show_bug.cgi?id=167099 5 6 Reviewed by Darin Adler. 7 8 We newly expose JSC::importModule API. This can be used later 9 from WebCore to implement WebCore side dynamic import. 10 And JSC shell also uses this API. 11 12 And this patch also cleans up module loader a bit: 13 Dropping requestInstantiateAll. 14 15 * builtins/BuiltinNames.h: 16 * builtins/ModuleLoaderPrototype.js: 17 (requestLink): 18 (requestImportModule): 19 (requestInstantiateAll): Deleted. 20 (importModule): Deleted. 21 * jsc.cpp: 22 (GlobalObject::moduleLoaderImportModule): 23 * runtime/Completion.cpp: 24 (JSC::importModule): 25 * runtime/Completion.h: 26 * runtime/JSModuleLoader.cpp: 27 (JSC::JSModuleLoader::requestImportModule): 28 * runtime/JSModuleLoader.h: 29 * runtime/ModuleLoaderPrototype.cpp: 30 1 31 2017-01-21 Yusuke Suzuki <utatane.tea@gmail.com> 2 32 -
trunk/Source/JavaScriptCore/builtins/BuiltinNames.h
r210028 r211018 161 161 macro(makeBoundFunction) \ 162 162 macro(hasOwnLengthProperty) \ 163 macro(importModule) \ 163 164 macro(WebAssembly) \ 164 165 macro(Module) \ -
trunk/Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js
r210585 r211018 313 313 } 314 314 315 function requestInstantiateAll(key, fetcher)316 {317 // https://whatwg.github.io/loader/#request-instantiate-all318 319 "use strict";320 321 return this.requestSatisfy(key, fetcher);322 }323 324 315 function requestLink(key, fetcher) 325 316 { … … 335 326 } 336 327 337 return this.request InstantiateAll(key, fetcher).then((entry) => {328 return this.requestSatisfy(key, fetcher).then((entry) => { 338 329 this.link(entry, fetcher); 339 330 return entry; … … 454 445 // For example, take the "jquery" and return the URL for the resource. 455 446 return this.resolve(moduleName, referrer, fetcher).then((key) => { 456 return this.request InstantiateAll(key, fetcher);447 return this.requestSatisfy(key, fetcher); 457 448 }).then((entry) => { 458 449 return entry.key; … … 472 463 } 473 464 474 function importModule(moduleName, referrer, fetcher) 475 { 476 "use strict"; 477 478 // Loader.resolve hook point. 479 // resolve: moduleName => Promise(moduleKey) 480 // Take the name and resolve it to the unique identifier for the resource location. 481 // For example, take the "jquery" and return the URL for the resource. 482 return this.resolve(moduleName, referrer, fetcher).then((key) => { 483 return this.requestInstantiateAll(key, fetcher); 484 }).then((entry) => { 465 function requestImportModule(key, fetcher) 466 { 467 "use strict"; 468 469 return this.requestSatisfy(key, fetcher).then((entry) => { 485 470 this.linkAndEvaluateModule(entry.key, fetcher); 486 471 return this.getModuleNamespaceObject(entry.module); -
trunk/Source/JavaScriptCore/jsc.cpp
r210912 r211018 1431 1431 } 1432 1432 1433 JSInternalPromise* GlobalObject::moduleLoaderImportModule(JSGlobalObject*, ExecState* exec, JSModuleLoader* moduleLoader, JSString* moduleName, const SourceOrigin& sourceOrigin) 1434 { 1435 auto* function = jsCast<JSObject*>(moduleLoader->get(exec, exec->propertyNames().builtinNames().importModulePublicName())); 1436 CallData callData; 1437 auto callType = JSC::getCallData(function, callData); 1438 ASSERT(callType != CallType::None); 1439 1440 MarkedArgumentBuffer arguments; 1441 arguments.append(moduleName); 1442 arguments.append(jsString(exec, sourceOrigin.string())); 1443 arguments.append(jsUndefined()); 1444 1445 return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, moduleLoader, arguments)); 1433 JSInternalPromise* GlobalObject::moduleLoaderImportModule(JSGlobalObject* globalObject, ExecState* exec, JSModuleLoader*, JSString* moduleNameValue, const SourceOrigin& sourceOrigin) 1434 { 1435 VM& vm = globalObject->vm(); 1436 auto scope = DECLARE_CATCH_SCOPE(vm); 1437 1438 auto rejectPromise = [&] (JSValue error) { 1439 return JSInternalPromiseDeferred::create(exec, globalObject)->reject(exec, error); 1440 }; 1441 1442 auto referrer = sourceOrigin.string(); 1443 auto moduleName = moduleNameValue->value(exec); 1444 if (UNLIKELY(scope.exception())) { 1445 JSValue exception = scope.exception(); 1446 scope.clearException(); 1447 return rejectPromise(exception); 1448 } 1449 1450 auto directoryName = extractDirectoryName(referrer.impl()); 1451 if (!directoryName) 1452 return rejectPromise(createError(exec, makeString("Could not resolve the referrer name '", String(referrer.impl()), "'."))); 1453 1454 return JSC::importModule(exec, Identifier::fromString(&vm, resolvePath(directoryName.value(), ModuleName(moduleName))), jsUndefined()); 1446 1455 } 1447 1456 -
trunk/Source/JavaScriptCore/runtime/Completion.cpp
r210585 r211018 249 249 } 250 250 251 JSInternalPromise* importModule(ExecState* exec, const Identifier& moduleKey, JSValue scriptFetcher) 252 { 253 JSLockHolder lock(exec); 254 RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable()); 255 RELEASE_ASSERT(!exec->vm().isCollectorBusyOnCurrentThread()); 256 257 return exec->vmEntryGlobalObject()->moduleLoader()->requestImportModule(exec, moduleKey, scriptFetcher); 258 } 259 251 260 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/Completion.h
r210585 r211018 68 68 JS_EXPORT_PRIVATE JSValue linkAndEvaluateModule(ExecState*, const Identifier& moduleKey, JSValue scriptFetcher = jsUndefined()); 69 69 70 JS_EXPORT_PRIVATE JSInternalPromise* importModule(ExecState*, const Identifier& moduleKey, JSValue scriptFetcher); 71 70 72 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp
r210585 r211018 138 138 } 139 139 140 JSInternalPromise* JSModuleLoader::requestImportModule(ExecState* exec, const Identifier& moduleKey, JSValue scriptFetcher) 141 { 142 auto* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().requestImportModulePublicName())); 143 CallData callData; 144 auto callType = JSC::getCallData(function, callData); 145 ASSERT(callType != CallType::None); 146 147 MarkedArgumentBuffer arguments; 148 arguments.append(jsString(exec, moduleKey.impl())); 149 arguments.append(scriptFetcher); 150 151 return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments)); 152 } 153 140 154 JSInternalPromise* JSModuleLoader::importModule(ExecState* exec, JSString* moduleName, const SourceOrigin& referrer) 141 155 { -
trunk/Source/JavaScriptCore/runtime/JSModuleLoader.h
r210585 r211018 68 68 JSInternalPromise* loadModule(ExecState*, JSValue moduleName, JSValue referrer, JSValue scriptFetcher); 69 69 JSValue linkAndEvaluateModule(ExecState*, JSValue moduleKey, JSValue scriptFetcher); 70 JSInternalPromise* requestImportModule(ExecState*, const Identifier&, JSValue scriptFetcher); 70 71 71 72 // Platform dependent hooked APIs. -
trunk/Source/JavaScriptCore/runtime/ModuleLoaderPrototype.cpp
r210573 r211018 78 78 requestInstantiate JSBuiltin DontEnum|Function 2 79 79 requestSatisfy JSBuiltin DontEnum|Function 2 80 requestInstantiateAll JSBuiltin DontEnum|Function 281 80 requestLink JSBuiltin DontEnum|Function 2 82 81 requestReady JSBuiltin DontEnum|Function 2 … … 89 88 loadModule JSBuiltin DontEnum|Function 3 90 89 linkAndEvaluateModule JSBuiltin DontEnum|Function 2 91 importModule JSBuiltin DontEnum|Function 390 requestImportModule JSBuiltin DontEnum|Function 2 92 91 getModuleNamespaceObject moduleLoaderPrototypeGetModuleNamespaceObject DontEnum|Function 1 93 92 parseModule moduleLoaderPrototypeParseModule DontEnum|Function 2
Note: See TracChangeset
for help on using the changeset viewer.