Ignore:
Timestamp:
Aug 31, 2016, 8:48:34 PM (9 years ago)
Author:
Yusuke Suzuki
Message:

[JSC] Add initiator parameter to module pipeline
https://bugs.webkit.org/show_bug.cgi?id=161470

Reviewed by Saam Barati.

Source/JavaScriptCore:

The fetching semantics of the <script type="module"> tag has per module-tag context.
For example, "nonce", "crossorigin" etc. attributes are shared in the fetching requests
issued from the module-tag. To transfer this information, we add a new parameter "initiator"
to the module loader pipeline. We are planning to transfer information by this parameter.

At the same time, we also perform some clean up.

  • Use arrow function in ModuleLoaderPrototype.js.
  • Rename "ResolveDependencies" to "Satisfy" to align to the loader spec.
  • builtins/ModuleLoaderPrototype.js:

(newRegistryEntry):
(commitInstantiated):
(requestFetch):
(requestTranslate):
(requestInstantiate):
(requestSatisfy):
(requestInstantiateAll):
(requestLink):
(moduleEvaluation):
(provide):
(loadAndEvaluateModule):
(requestResolveDependencies.): Deleted.
(requestResolveDependencies): Deleted.
(requestReady): Deleted.
(link): Deleted.
(loadModule): Deleted.
(linkAndEvaluateModule): Deleted.

  • bytecode/BytecodeIntrinsicRegistry.cpp:

(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):

  • bytecode/BytecodeIntrinsicRegistry.h:
  • jsc.cpp:

(GlobalObject::moduleLoaderResolve):
(GlobalObject::moduleLoaderFetch):

  • runtime/Completion.cpp:

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

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

(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:
  • runtime/ModuleLoaderPrototype.cpp:

(JSC::moduleLoaderPrototypeResolve):
(JSC::moduleLoaderPrototypeFetch):
(JSC::moduleLoaderPrototypeTranslate):
(JSC::moduleLoaderPrototypeInstantiate):
(JSC::moduleLoaderPrototypeEvaluate):

Source/WebCore:

No user-observable behavior change.

We rename JSModuleLoader to ScriptModuleLoader.
The name "JSModuleLoader" is misleading since it seems like this is a JS object.
"ModuleLoader" is not good since there is CSS modules.

  • CMakeLists.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/JSBindingsAllInOne.cpp:
  • bindings/js/JSDOMWindowBase.cpp:

(WebCore::JSDOMWindowBase::moduleLoaderResolve):
(WebCore::JSDOMWindowBase::moduleLoaderFetch):
(WebCore::JSDOMWindowBase::moduleLoaderEvaluate):

  • bindings/js/JSDOMWindowBase.h:
  • bindings/js/JSMainThreadExecState.h:

(WebCore::JSMainThreadExecState::loadModule):
(WebCore::JSMainThreadExecState::linkAndEvaluateModule):

  • bindings/js/JSModuleLoader.cpp:

(WebCore::JSModuleLoader::JSModuleLoader): Deleted.
(WebCore::JSModuleLoader::resolve): Deleted.
(WebCore::JSModuleLoader::fetch): Deleted.
(WebCore::JSModuleLoader::evaluate): Deleted.

  • bindings/js/JSModuleLoader.h:

(WebCore::JSModuleLoader::document): Deleted.

  • bindings/js/ScriptModuleLoader.cpp: Renamed from Source/WebCore/bindings/js/JSModuleLoader.cpp.

(WebCore::ScriptModuleLoader::ScriptModuleLoader):
(WebCore::ScriptModuleLoader::resolve):
(WebCore::ScriptModuleLoader::fetch):
(WebCore::ScriptModuleLoader::evaluate):

  • bindings/js/ScriptModuleLoader.h: Renamed from Source/WebCore/bindings/js/JSModuleLoader.h.

(WebCore::ScriptModuleLoader::document):

  • dom/Document.cpp:

(WebCore::Document::Document):

  • dom/Document.h:

(WebCore::Document::moduleLoader):

File:
1 edited

Legend:

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

    r205276 r205278  
    8787}
    8888
    89 JSInternalPromise* JSModuleLoader::loadAndEvaluateModule(ExecState* exec, JSValue moduleName, JSValue referrer)
     89JSInternalPromise* JSModuleLoader::loadAndEvaluateModule(ExecState* exec, JSValue moduleName, JSValue referrer, JSValue initiator)
    9090{
    9191    JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().loadAndEvaluateModulePublicName()));
     
    9797    arguments.append(moduleName);
    9898    arguments.append(referrer);
     99    arguments.append(initiator);
    99100
    100101    return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
    101102}
    102103
    103 JSInternalPromise* JSModuleLoader::loadModule(ExecState* exec, JSValue moduleName, JSValue referrer)
     104JSInternalPromise* JSModuleLoader::loadModule(ExecState* exec, JSValue moduleName, JSValue referrer, JSValue initiator)
    104105{
    105106    JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().loadModulePublicName()));
     
    111112    arguments.append(moduleName);
    112113    arguments.append(referrer);
     114    arguments.append(initiator);
    113115
    114116    return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
    115117}
    116118
    117 JSValue JSModuleLoader::linkAndEvaluateModule(ExecState* exec, JSValue moduleKey)
     119JSValue JSModuleLoader::linkAndEvaluateModule(ExecState* exec, JSValue moduleKey, JSValue initiator)
    118120{
    119121    JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().linkAndEvaluateModulePublicName()));
     
    124126    MarkedArgumentBuffer arguments;
    125127    arguments.append(moduleKey);
     128    arguments.append(initiator);
    126129
    127130    return call(exec, function, callType, callData, this, arguments);
    128131}
    129132
    130 JSInternalPromise* JSModuleLoader::resolve(ExecState* exec, JSValue name, JSValue referrer)
     133JSInternalPromise* JSModuleLoader::resolve(ExecState* exec, JSValue name, JSValue referrer, JSValue initiator)
    131134{
    132135    if (Options::dumpModuleLoadingState())
     
    135138    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    136139    if (globalObject->globalObjectMethodTable()->moduleLoaderResolve)
    137         return globalObject->globalObjectMethodTable()->moduleLoaderResolve(globalObject, exec, this, name, referrer);
     140        return globalObject->globalObjectMethodTable()->moduleLoaderResolve(globalObject, exec, this, name, referrer, initiator);
    138141    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
    139142    deferred->resolve(exec, name);
     
    141144}
    142145
    143 JSInternalPromise* JSModuleLoader::fetch(ExecState* exec, JSValue key)
     146JSInternalPromise* JSModuleLoader::fetch(ExecState* exec, JSValue key, JSValue initiator)
    144147{
    145148    if (Options::dumpModuleLoadingState())
     
    148151    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    149152    if (globalObject->globalObjectMethodTable()->moduleLoaderFetch)
    150         return globalObject->globalObjectMethodTable()->moduleLoaderFetch(globalObject, exec, this, key);
     153        return globalObject->globalObjectMethodTable()->moduleLoaderFetch(globalObject, exec, this, key, initiator);
    151154    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
    152155    String moduleKey = key.toString(exec)->value(exec);
     
    161164}
    162165
    163 JSInternalPromise* JSModuleLoader::translate(ExecState* exec, JSValue key, JSValue payload)
     166JSInternalPromise* JSModuleLoader::translate(ExecState* exec, JSValue key, JSValue payload, JSValue initiator)
    164167{
    165168    if (Options::dumpModuleLoadingState())
     
    168171    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    169172    if (globalObject->globalObjectMethodTable()->moduleLoaderTranslate)
    170         return globalObject->globalObjectMethodTable()->moduleLoaderTranslate(globalObject, exec, this, key, payload);
     173        return globalObject->globalObjectMethodTable()->moduleLoaderTranslate(globalObject, exec, this, key, payload, initiator);
    171174    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
    172175    deferred->resolve(exec, payload);
     
    174177}
    175178
    176 JSInternalPromise* JSModuleLoader::instantiate(ExecState* exec, JSValue key, JSValue source)
     179JSInternalPromise* JSModuleLoader::instantiate(ExecState* exec, JSValue key, JSValue source, JSValue initiator)
    177180{
    178181    if (Options::dumpModuleLoadingState())
     
    181184    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    182185    if (globalObject->globalObjectMethodTable()->moduleLoaderInstantiate)
    183         return globalObject->globalObjectMethodTable()->moduleLoaderInstantiate(globalObject, exec, this, key, source);
     186        return globalObject->globalObjectMethodTable()->moduleLoaderInstantiate(globalObject, exec, this, key, source, initiator);
    184187    JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
    185188    deferred->resolve(exec, jsUndefined());
     
    187190}
    188191
    189 JSValue JSModuleLoader::evaluate(ExecState* exec, JSValue key, JSValue moduleRecordValue)
     192JSValue JSModuleLoader::evaluate(ExecState* exec, JSValue key, JSValue moduleRecordValue, JSValue initiator)
    190193{
    191194    if (Options::dumpModuleLoadingState())
     
    194197    JSGlobalObject* globalObject = exec->lexicalGlobalObject();
    195198    if (globalObject->globalObjectMethodTable()->moduleLoaderEvaluate)
    196         return globalObject->globalObjectMethodTable()->moduleLoaderEvaluate(globalObject, exec, this, key, moduleRecordValue);
     199        return globalObject->globalObjectMethodTable()->moduleLoaderEvaluate(globalObject, exec, this, key, moduleRecordValue, initiator);
    197200
    198201    JSModuleRecord* moduleRecord = jsDynamicCast<JSModuleRecord*>(moduleRecordValue);
Note: See TracChangeset for help on using the changeset viewer.