Ignore:
Timestamp:
Oct 11, 2017, 5:30:37 AM (8 years ago)
Author:
Yusuke Suzuki
Message:

[JSC] Drop Instantiate hook in ES6 module loader
https://bugs.webkit.org/show_bug.cgi?id=178162

Reviewed by Sam Weinig.

Source/JavaScriptCore:

This patch is a part of patch series for module loader refactoring to adopt
integrity="" parameters and introduce new whatwg module import mechanism.

In this patch, we drop instantiate hook in module loader. This hook is originally
introduced because it is defined in whatwg/loader spec. But this hook is not
used in our implementation, and this hook won't be used since (1) whatwg/loader
spec is abandoned, and (2) this type of hooks should be done in Service Workers.

In addition, this patch applies some cleaning up of our module loader JS code
to simplify things. This change paves the way to more efficient loader implementation
with great flexibility to adopt integrity="" parameters.

  • builtins/ModuleLoaderPrototype.js:

(requestInstantiate):
(provideFetch):
provide is changed to provideFetch since we only used this function with Fetch stage parameter.

(fulfillInstantiate): Deleted.
(commitInstantiated): Deleted.
(instantiation): Deleted.
They are merged into requestInstantiate code. This is simpler.

(provide): Deleted.

  • jsc.cpp:
  • runtime/Completion.cpp:

(JSC::loadAndEvaluateModule):
(JSC::loadModule):

  • runtime/JSGlobalObject.cpp:
  • runtime/JSGlobalObject.h:
  • runtime/JSModuleLoader.cpp:

(JSC::JSModuleLoader::provideFetch):
(JSC::JSModuleLoader::provide): Deleted.
Changed to provideFetch.

(JSC::JSModuleLoader::instantiate): Deleted.
Drop this hook.

  • runtime/JSModuleLoader.h:
  • runtime/ModuleLoaderPrototype.cpp:

(JSC::moduleLoaderPrototypeInstantiate): Deleted.
Drop this hook.

Source/WebCore:

Drop instantiate hooks.
No behavior change.

  • bindings/js/JSDOMWindowBase.cpp:
  • bindings/js/JSWorkerGlobalScopeBase.cpp:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp

    r222895 r223173  
    8080}
    8181
    82 JSValue JSModuleLoader::provide(ExecState* exec, JSValue key, Status status, const SourceCode& sourceCode)
    83 {
    84     VM& vm = exec->vm();
    85     auto scope = DECLARE_THROW_SCOPE(vm);
    86 
    87     JSObject* function = jsCast<JSObject*>(get(exec, vm.propertyNames->builtinNames().providePublicName()));
     82JSValue JSModuleLoader::provideFetch(ExecState* exec, JSValue key, const SourceCode& sourceCode)
     83{
     84    VM& vm = exec->vm();
     85    auto scope = DECLARE_THROW_SCOPE(vm);
     86
     87    JSObject* function = jsCast<JSObject*>(get(exec, vm.propertyNames->builtinNames().provideFetchPublicName()));
    8888    RETURN_IF_EXCEPTION(scope, { });
    8989    CallData callData;
     
    9494    MarkedArgumentBuffer arguments;
    9595    arguments.append(key);
    96     arguments.append(jsNumber(status));
    9796    arguments.append(JSSourceCode::create(vm, WTFMove(source)));
    9897
     
    238237}
    239238
    240 JSInternalPromise* JSModuleLoader::instantiate(ExecState* exec, JSValue key, JSValue source, JSValue scriptFetcher)
    241 {
    242     if (Options::dumpModuleLoadingState())
    243         dataLog("Loader [instantiate] ", printableModuleKey(exec, key), "\n");
    244 
    245     JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    246     if (globalObject->globalObjectMethodTable()->moduleLoaderInstantiate)
    247         return globalObject->globalObjectMethodTable()->moduleLoaderInstantiate(globalObject, exec, this, key, source, scriptFetcher);
    248     JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
    249     deferred->resolve(exec, jsUndefined());
    250     return deferred->promise();
    251 }
    252 
    253239JSObject* JSModuleLoader::createImportMetaProperties(ExecState* exec, JSValue key, JSModuleRecord* moduleRecord, JSValue scriptFetcher)
    254240{
Note: See TracChangeset for help on using the changeset viewer.