Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (205277 => 205278)
--- trunk/Source/_javascript_Core/ChangeLog 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-09-01 03:48:34 UTC (rev 205278)
@@ -1,5 +1,69 @@
2016-08-31 Yusuke Suzuki <[email protected]>
+ [JSC] Add initiator parameter to module pipeline
+ https://bugs.webkit.org/show_bug.cgi?id=161470
+
+ Reviewed by Saam Barati.
+
+ 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):
+
+2016-08-31 Yusuke Suzuki <[email protected]>
+
[JSC] linking and evaluating the modules are done in a sync manner
https://bugs.webkit.org/show_bug.cgi?id=161467
Modified: trunk/Source/_javascript_Core/builtins/ModuleLoaderPrototype.js (205277 => 205278)
--- trunk/Source/_javascript_Core/builtins/ModuleLoaderPrototype.js 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/_javascript_Core/builtins/ModuleLoaderPrototype.js 2016-09-01 03:48:34 UTC (rev 205278)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -69,11 +69,11 @@
// b. If the status is Instantiate and there is the entry.translate promise, the entry is just instantiating
// the module record.
//
- // 4. ResolveDependencies (not in the draft) https://github.com/whatwg/loader/issues/68
+ // 4. Satisfy
// Ready to request the dependent modules (or now requesting & resolving).
// Without this state, the current draft causes infinite recursion when there is circular dependency.
- // a. If the status is ResolveDependencies and there is no entry.resolveDependencies promise, the entry is ready to resolve the dependencies.
- // b. If the status is ResolveDependencies and there is the entry.resolveDependencies promise, the entry is just resolving
+ // a. If the status is Satisfy and there is no entry.satisfy promise, the entry is ready to resolve the dependencies.
+ // b. If the status is Satisfy and there is the entry.satisfy promise, the entry is just resolving
// the dependencies.
//
// 5. Link
@@ -83,7 +83,7 @@
// 6. Ready
// The module is linked, so the module is ready to be executed.
//
- // Each registry entry has the 4 promises; "fetch", "translate", "instantiate" and "resolveDependencies".
+ // Each registry entry has the 4 promises; "fetch", "translate", "instantiate" and "satisfy".
// They are assigned when starting the each phase. And they are fulfilled when the each phase is completed.
//
// In the current module draft, linking will be performed after the whole modules are instantiated and the dependencies are resolved.
@@ -102,7 +102,7 @@
fetch: @undefined,
translate: @undefined,
instantiate: @undefined,
- resolveDependencies: @undefined,
+ satisfy: @undefined,
dependencies: [], // To keep the module order, we store the module keys in the array.
dependenciesMap: @undefined,
module: @undefined, // JSModuleRecord
@@ -201,13 +201,13 @@
key: depKey,
value: @undefined
};
- @putByValDirect(dependencies, i, pair);
+ dependencies.@push(pair);
dependenciesMap.@set(depKey, pair);
}
entry.dependencies = dependencies;
entry.dependenciesMap = dependenciesMap;
entry.module = moduleRecord;
- this.setStateToMax(entry, @ModuleResolveDependencies);
+ this.setStateToMax(entry, @ModuleSatisfy);
}
function instantiation(result, source, entry)
@@ -223,7 +223,7 @@
// Loader.
-function requestFetch(key)
+function requestFetch(key, initiator)
{
// https://whatwg.github.io/loader/#request-fetch
@@ -239,8 +239,6 @@
if (entry.fetch)
return entry.fetch;
- var loader = this;
-
// Hook point.
// 2. Loader.fetch
// https://whatwg.github.io/loader/#browser-fetch
@@ -247,8 +245,8 @@
// Take the key and fetch the resource actually.
// For example, _javascript_Core shell can provide the hook fetching the resource
// from the local file system.
- var fetchPromise = this.fetch(key).then(function (payload) {
- loader.setStateToMax(entry, @ModuleTranslate);
+ var fetchPromise = this.fetch(key, initiator).then((payload) => {
+ this.setStateToMax(entry, @ModuleTranslate);
return payload;
});
entry.fetch = fetchPromise;
@@ -255,7 +253,7 @@
return fetchPromise;
}
-function requestTranslate(key)
+function requestTranslate(key, initiator)
{
// https://whatwg.github.io/loader/#request-translate
@@ -271,15 +269,14 @@
if (entry.translate)
return entry.translate;
- var loader = this;
- var translatePromise = this.requestFetch(key).then(function (payload) {
+ var translatePromise = this.requestFetch(key, initiator).then((payload) => {
// Hook point.
// 3. 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.
- return loader.translate(key, payload).then(function (source) {
- loader.setStateToMax(entry, @ModuleInstantiate);
+ return this.translate(key, payload, initiator).then((source) => {
+ this.setStateToMax(entry, @ModuleInstantiate);
return source;
});
});
@@ -287,7 +284,7 @@
return translatePromise;
}
-function requestInstantiate(key)
+function requestInstantiate(key, initiator)
{
// https://whatwg.github.io/loader/#request-instantiate
@@ -303,8 +300,7 @@
if (entry.instantiate)
return entry.instantiate;
- var loader = this;
- var instantiatePromise = this.requestTranslate(key).then(function (source) {
+ var instantiatePromise = this.requestTranslate(key, initiator).then((source) => {
// Hook point.
// 4. Loader.instantiate
// https://whatwg.github.io/loader/#browser-instantiate
@@ -312,8 +308,8 @@
// by parsing the module source code.
// It has the chance to provide the optional module instance that is different from
// the ordinary one.
- return loader.instantiate(key, source).then(function (optionalInstance) {
- loader.commitInstantiated(entry, optionalInstance, source);
+ return this.instantiate(key, source, initiator).then((optionalInstance) => {
+ this.commitInstantiated(entry, optionalInstance, source);
return entry;
});
});
@@ -321,17 +317,9 @@
return instantiatePromise;
}
-function requestResolveDependencies(key)
+function requestSatisfy(key, initiator)
{
- // FIXME: In the spec, after requesting instantiation, we will resolve
- // the dependencies without any status change. As a result, when there
- // is circular dependencies, instantiation is done only once, but
- // repeatedly resolving the dependencies. This means that infinite
- // recursion occur when the given modules have circular dependency. To
- // avoid this situation, we introduce new state, "ResolveDependencies". This means
- // "Now the module is instantiated, so ready to resolve the dependencies
- // or now resolving them".
- // https://github.com/whatwg/loader/issues/68
+ // https://whatwg.github.io/loader/#satisfy-instance
"use strict";
@@ -342,11 +330,10 @@
return deferred.@promise;
}
- if (entry.resolveDependencies)
- return entry.resolveDependencies;
+ if (entry.satisfy)
+ return entry.satisfy;
- var loader = this;
- var resolveDependenciesPromise = this.requestInstantiate(key).then(function (entry) {
+ var satisfyPromise = this.requestInstantiate(key, initiator).then((entry) => {
var depLoads = [];
for (var i = 0, length = entry.dependencies.length; i < length; ++i) {
let pair = entry.dependencies[i];
@@ -356,8 +343,8 @@
// 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.
- var promise = loader.resolve(pair.key, key).then(function (depKey) {
- var depEntry = loader.ensureRegistered(depKey);
+ var promise = this.resolve(pair.key, key, initiator).then((depKey) => {
+ var depEntry = this.ensureRegistered(depKey);
// Recursive resolving. The dependencies of this entry is being resolved or already resolved.
// Stop tracing the circular dependencies.
@@ -365,44 +352,44 @@
// we need to wait for the instantiation for the dependent module.
// For example, reaching here, the module is starting resolving the dependencies.
// But the module may or may not reach the instantiation phase in the loader's pipeline.
- // If we wait for the ResolveDependencies for this module, it construct the circular promise chain and
+ // If we wait for the Satisfy for this module, it construct the circular promise chain and
// rejected by the Promises runtime. Since only we need is the instantiated module, instead of waiting
- // the ResolveDependencies for this module, we just wait Instantiate for this.
- if (depEntry.resolveDependencies) {
- return depEntry.instantiate.then(function (entry) {
+ // the Satisfy for this module, we just wait Instantiate for this.
+ if (depEntry.satisfy) {
+ return depEntry.instantiate.then((entry) => {
pair.value = entry.module;
return entry;
});
}
- return loader.requestResolveDependencies(depKey).then(function (entry) {
+ return this.requestSatisfy(depKey, initiator).then((entry) => {
pair.value = entry.module;
return entry;
});
});
- @putByValDirect(depLoads, i, promise);
+ depLoads.@push(promise);
}
- return @InternalPromise.internalAll(depLoads).then(function (modules) {
- loader.setStateToMax(entry, @ModuleLink);
+ return @InternalPromise.internalAll(depLoads).then((modules) => {
+ this.setStateToMax(entry, @ModuleLink);
return entry;
});
});
- entry.resolveDependencies = resolveDependenciesPromise;
- return resolveDependenciesPromise;
+ entry.satisfy = satisfyPromise;
+ return satisfyPromise;
}
-function requestInstantiateAll(key)
+function requestInstantiateAll(key, initiator)
{
// https://whatwg.github.io/loader/#request-instantiate-all
"use strict";
- return this.requestResolveDependencies(key);
+ return this.requestSatisfy(key, initiator);
}
-function requestLink(key)
+function requestLink(key, initiator)
{
// https://whatwg.github.io/loader/#request-link
@@ -411,32 +398,30 @@
var entry = this.ensureRegistered(key);
if (entry.state > @ModuleLink) {
var deferred = @newPromiseCapability(@InternalPromise);
- deferred.@resolve.@call(@undefined, entry.module);
+ deferred.@resolve.@call(@undefined, entry);
return deferred.@promise;
}
- var loader = this;
- return this.requestInstantiateAll(key).then(function (entry) {
- loader.link(entry);
+ return this.requestInstantiateAll(key, initiator).then((entry) => {
+ this.link(entry, initiator);
return entry;
});
}
-function requestReady(key)
+function requestReady(key, initiator)
{
// https://whatwg.github.io/loader/#request-ready
"use strict";
- var loader = this;
- return this.requestLink(key).then(function (entry) {
- loader.moduleEvaluation(entry.module);
+ return this.requestLink(key, initiator).then((entry) => {
+ this.moduleEvaluation(entry.module, initiator);
});
}
// Linking semantics.
-function link(entry)
+function link(entry, initiator)
{
// https://whatwg.github.io/loader/#link
@@ -456,15 +441,15 @@
var dependencies = entry.dependencies;
for (var i = 0, length = dependencies.length; i < length; ++i) {
var pair = dependencies[i];
- this.link(pair.value.registryEntry);
+ this.link(pair.value.registryEntry, initiator);
}
- this.moduleDeclarationInstantiation(entry.module);
+ this.moduleDeclarationInstantiation(entry.module, initiator);
}
// Module semantics.
-function moduleEvaluation(moduleRecord)
+function moduleEvaluation(moduleRecord, initiator)
{
// http://www.ecma-international.org/ecma-262/6.0/#sec-moduleevaluation
@@ -481,9 +466,9 @@
for (var i = 0, length = dependencies.length; i < length; ++i) {
var pair = dependencies[i];
var requiredModuleRecord = pair.value;
- this.moduleEvaluation(requiredModuleRecord);
+ this.moduleEvaluation(requiredModuleRecord, initiator);
}
- this.evaluate(entry.key, moduleRecord);
+ this.evaluate(entry.key, moduleRecord, initiator);
}
// APIs to control the module loader.
@@ -495,7 +480,7 @@
var entry = this.ensureRegistered(key);
if (stage === @ModuleFetch) {
- if (entry.status > @ModuleFetch)
+ if (entry.state > @ModuleFetch)
throw new @TypeError("Requested module is already fetched.");
this.fulfillFetch(entry, value);
return;
@@ -502,7 +487,7 @@
}
if (stage === @ModuleTranslate) {
- if (entry.status > @ModuleTranslate)
+ if (entry.state > @ModuleTranslate)
throw new @TypeError("Requested module is already translated.");
this.fulfillFetch(entry, @undefined);
this.fulfillTranslate(entry, value);
@@ -510,13 +495,12 @@
}
if (stage === @ModuleInstantiate) {
- if (entry.status > @ModuleInstantiate)
+ if (entry.state > @ModuleInstantiate)
throw new @TypeError("Requested module is already instantiated.");
this.fulfillFetch(entry, @undefined);
this.fulfillTranslate(entry, value);
- var loader = this;
- entry.translate.then(function (source) {
- loader.fulfillInstantiate(entry, value, source);
+ entry.translate.then((source) => {
+ this.fulfillInstantiate(entry, value, source);
});
return;
}
@@ -524,37 +508,35 @@
throw new @TypeError("Requested module is already ready to be executed.");
}
-function loadAndEvaluateModule(moduleName, referrer)
+function loadAndEvaluateModule(moduleName, referrer, initiator)
{
"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);
+ return this.resolve(moduleName, referrer, initiator).then((key) => {
+ return this.requestReady(key, initiator);
});
}
-function loadModule(moduleName, referrer)
+function loadModule(moduleName, referrer, initiator)
{
"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 this.resolve(moduleName, referrer, initiator).then((key) => {
+ return this.requestInstantiateAll(key, initiator);
+ }).then((entry) => {
return entry.key;
});
}
-function linkAndEvaluateModule(key)
+function linkAndEvaluateModule(key, initiator)
{
"use strict";
@@ -562,6 +544,6 @@
if (entry.state < @ModuleLink)
throw new @TypeError("Requested module is not instantiated yet.");
- this.link(entry);
- return this.moduleEvaluation(entry.module);
+ this.link(entry, initiator);
+ return this.moduleEvaluation(entry.module, initiator);
}
Modified: trunk/Source/_javascript_Core/bytecode/BytecodeIntrinsicRegistry.cpp (205277 => 205278)
--- trunk/Source/_javascript_Core/bytecode/BytecodeIntrinsicRegistry.cpp 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeIntrinsicRegistry.cpp 2016-09-01 03:48:34 UTC (rev 205278)
@@ -58,7 +58,7 @@
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_ModuleSatisfy.set(m_vm, jsNumber(static_cast<unsigned>(JSModuleLoader::Status::Satisfy)));
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)));
Modified: trunk/Source/_javascript_Core/bytecode/BytecodeIntrinsicRegistry.h (205277 => 205278)
--- trunk/Source/_javascript_Core/bytecode/BytecodeIntrinsicRegistry.h 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeIntrinsicRegistry.h 2016-09-01 03:48:34 UTC (rev 205278)
@@ -61,7 +61,7 @@
macro(ModuleFetch) \
macro(ModuleTranslate) \
macro(ModuleInstantiate) \
- macro(ModuleResolveDependencies) \
+ macro(ModuleSatisfy) \
macro(ModuleLink) \
macro(ModuleReady) \
macro(promiseStatePending) \
Modified: trunk/Source/_javascript_Core/jsc.cpp (205277 => 205278)
--- trunk/Source/_javascript_Core/jsc.cpp 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/_javascript_Core/jsc.cpp 2016-09-01 03:48:34 UTC (rev 205278)
@@ -896,8 +896,8 @@
putDirect(vm, identifier, JSFunction::create(vm, this, arguments, identifier.string(), function, NoIntrinsic, function));
}
- static JSInternalPromise* moduleLoaderResolve(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
- static JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue);
+ static JSInternalPromise* moduleLoaderResolve(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue, JSValue);
+ static JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
};
const ClassInfo GlobalObject::s_info = { "global", &JSGlobalObject::s_info, nullptr, CREATE_METHOD_TABLE(GlobalObject) };
@@ -1028,7 +1028,7 @@
return builder.toString();
}
-JSInternalPromise* GlobalObject::moduleLoaderResolve(JSGlobalObject* globalObject, ExecState* exec, JSModuleLoader*, JSValue keyValue, JSValue referrerValue)
+JSInternalPromise* GlobalObject::moduleLoaderResolve(JSGlobalObject* globalObject, ExecState* exec, JSModuleLoader*, JSValue keyValue, JSValue referrerValue, JSValue)
{
JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
const Identifier key = keyValue.toPropertyKey(exec);
@@ -1133,7 +1133,7 @@
return result;
}
-JSInternalPromise* GlobalObject::moduleLoaderFetch(JSGlobalObject* globalObject, ExecState* exec, JSModuleLoader*, JSValue key)
+JSInternalPromise* GlobalObject::moduleLoaderFetch(JSGlobalObject* globalObject, ExecState* exec, JSModuleLoader*, JSValue key, JSValue)
{
JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
String moduleKey = key.toWTFString(exec);
Modified: trunk/Source/_javascript_Core/runtime/Completion.cpp (205277 => 205278)
--- trunk/Source/_javascript_Core/runtime/Completion.cpp 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/_javascript_Core/runtime/Completion.cpp 2016-09-01 03:48:34 UTC (rev 205278)
@@ -155,26 +155,26 @@
return deferred->promise();
}
-static JSInternalPromise* loadAndEvaluateModule(const JSLockHolder&, ExecState* exec, JSGlobalObject* globalObject, JSValue moduleName, JSValue referrer)
+static JSInternalPromise* loadAndEvaluateModule(const JSLockHolder&, ExecState* exec, JSGlobalObject* globalObject, JSValue moduleName, JSValue referrer, JSValue initiator)
{
- return globalObject->moduleLoader()->loadAndEvaluateModule(exec, moduleName, referrer);
+ return globalObject->moduleLoader()->loadAndEvaluateModule(exec, moduleName, referrer, initiator);
}
-static JSInternalPromise* loadAndEvaluateModule(const JSLockHolder& lock, ExecState* exec, JSGlobalObject* globalObject, const Identifier& moduleName)
+static JSInternalPromise* loadAndEvaluateModule(const JSLockHolder& lock, ExecState* exec, JSGlobalObject* globalObject, const Identifier& moduleName, JSValue initiator)
{
- return loadAndEvaluateModule(lock, exec, globalObject, identifierToJSValue(exec->vm(), moduleName), jsUndefined());
+ return loadAndEvaluateModule(lock, exec, globalObject, identifierToJSValue(exec->vm(), moduleName), jsUndefined(), initiator);
}
-JSInternalPromise* loadAndEvaluateModule(ExecState* exec, const String& moduleName)
+JSInternalPromise* loadAndEvaluateModule(ExecState* exec, const String& moduleName, JSValue initiator)
{
JSLockHolder lock(exec);
RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable());
RELEASE_ASSERT(!exec->vm().isCollectorBusy());
- return loadAndEvaluateModule(lock, exec, exec->vmEntryGlobalObject(), Identifier::fromString(exec, moduleName));
+ return loadAndEvaluateModule(lock, exec, exec->vmEntryGlobalObject(), Identifier::fromString(exec, moduleName), initiator);
}
-JSInternalPromise* loadAndEvaluateModule(ExecState* exec, const SourceCode& source)
+JSInternalPromise* loadAndEvaluateModule(ExecState* exec, const SourceCode& source, JSValue initiator)
{
JSLockHolder lock(exec);
RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable());
@@ -189,29 +189,29 @@
if (exec->hadException())
return rejectPromise(exec, globalObject);
- return loadAndEvaluateModule(lock, exec, globalObject, key, jsUndefined());
+ return loadAndEvaluateModule(lock, exec, globalObject, key, jsUndefined(), initiator);
}
-static JSInternalPromise* loadModule(const JSLockHolder&, ExecState* exec, JSGlobalObject* globalObject, JSValue moduleName, JSValue referrer)
+static JSInternalPromise* loadModule(const JSLockHolder&, ExecState* exec, JSGlobalObject* globalObject, JSValue moduleName, JSValue referrer, JSValue initiator)
{
- return globalObject->moduleLoader()->loadModule(exec, moduleName, referrer);
+ return globalObject->moduleLoader()->loadModule(exec, moduleName, referrer, initiator);
}
-static JSInternalPromise* loadModule(const JSLockHolder& lock, ExecState* exec, JSGlobalObject* globalObject, const Identifier& moduleName)
+static JSInternalPromise* loadModule(const JSLockHolder& lock, ExecState* exec, JSGlobalObject* globalObject, const Identifier& moduleName, JSValue initiator)
{
- return loadModule(lock, exec, globalObject, identifierToJSValue(exec->vm(), moduleName), jsUndefined());
+ return loadModule(lock, exec, globalObject, identifierToJSValue(exec->vm(), moduleName), jsUndefined(), initiator);
}
-JSInternalPromise* loadModule(ExecState* exec, const String& moduleName)
+JSInternalPromise* loadModule(ExecState* exec, const String& moduleName, JSValue initiator)
{
JSLockHolder lock(exec);
RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable());
RELEASE_ASSERT(!exec->vm().isCollectorBusy());
- return loadModule(lock, exec, exec->vmEntryGlobalObject(), Identifier::fromString(exec, moduleName));
+ return loadModule(lock, exec, exec->vmEntryGlobalObject(), Identifier::fromString(exec, moduleName), initiator);
}
-JSInternalPromise* loadModule(ExecState* exec, const SourceCode& source)
+JSInternalPromise* loadModule(ExecState* exec, const SourceCode& source, JSValue initiator)
{
JSLockHolder lock(exec);
RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable());
@@ -222,14 +222,15 @@
JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
// Insert the given source code to the ModuleLoader registry as the fetched registry entry.
+ // FIXME: Introduce JSSourceCode object to wrap around this source.
globalObject->moduleLoader()->provide(exec, key, JSModuleLoader::Status::Fetch, source.view().toString());
if (exec->hadException())
return rejectPromise(exec, globalObject);
- return loadModule(lock, exec, globalObject, key, jsUndefined());
+ return loadModule(lock, exec, globalObject, key, jsUndefined(), initiator);
}
-JSValue linkAndEvaluateModule(ExecState* exec, const Identifier& moduleKey)
+JSValue linkAndEvaluateModule(ExecState* exec, const Identifier& moduleKey, JSValue initiator)
{
JSLockHolder lock(exec);
RELEASE_ASSERT(exec->vm().atomicStringTable() == wtfThreadData().atomicStringTable());
@@ -236,7 +237,7 @@
RELEASE_ASSERT(!exec->vm().isCollectorBusy());
JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
- return globalObject->moduleLoader()->linkAndEvaluateModule(exec, identifierToJSValue(exec->vm(), moduleKey));
+ return globalObject->moduleLoader()->linkAndEvaluateModule(exec, identifierToJSValue(exec->vm(), moduleKey), initiator);
}
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/Completion.h (205277 => 205278)
--- trunk/Source/_javascript_Core/runtime/Completion.h 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/_javascript_Core/runtime/Completion.h 2016-09-01 03:48:34 UTC (rev 205278)
@@ -58,15 +58,15 @@
JS_EXPORT_PRIVATE JSValue evaluateWithScopeExtension(ExecState*, const SourceCode&, JSObject* scopeExtension, NakedPtr<Exception>& returnedException);
// Load the module source and evaluate it.
-JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(ExecState*, const String& moduleName);
-JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(ExecState*, const SourceCode&);
+JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(ExecState*, const String& moduleName, JSValue initiator = jsUndefined());
+JS_EXPORT_PRIVATE JSInternalPromise* loadAndEvaluateModule(ExecState*, const SourceCode&, JSValue initiator = jsUndefined());
// Fetch the module source, and instantiate the module record.
-JS_EXPORT_PRIVATE JSInternalPromise* loadModule(ExecState*, const String& moduleName);
-JS_EXPORT_PRIVATE JSInternalPromise* loadModule(ExecState*, const SourceCode&);
+JS_EXPORT_PRIVATE JSInternalPromise* loadModule(ExecState*, const String& moduleName, JSValue initiator = jsUndefined());
+JS_EXPORT_PRIVATE JSInternalPromise* loadModule(ExecState*, const SourceCode&, JSValue initiator = jsUndefined());
// Link and evaluate the already linked module. This function is called in a sync manner.
-JS_EXPORT_PRIVATE JSValue linkAndEvaluateModule(ExecState*, const Identifier& moduleKey);
+JS_EXPORT_PRIVATE JSValue linkAndEvaluateModule(ExecState*, const Identifier& moduleKey, JSValue initiator = jsUndefined());
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObject.h (205277 => 205278)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObject.h 2016-09-01 03:48:34 UTC (rev 205278)
@@ -166,19 +166,19 @@
typedef bool (*ShouldInterruptScriptBeforeTimeoutPtr)(const JSGlobalObject*);
ShouldInterruptScriptBeforeTimeoutPtr shouldInterruptScriptBeforeTimeout;
- typedef JSInternalPromise* (*ModuleLoaderResolvePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
+ typedef JSInternalPromise* (*ModuleLoaderResolvePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue, JSValue);
ModuleLoaderResolvePtr moduleLoaderResolve;
- typedef JSInternalPromise* (*ModuleLoaderFetchPtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue);
+ typedef JSInternalPromise* (*ModuleLoaderFetchPtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
ModuleLoaderFetchPtr moduleLoaderFetch;
- typedef JSInternalPromise* (*ModuleLoaderTranslatePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
+ typedef JSInternalPromise* (*ModuleLoaderTranslatePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue, JSValue);
ModuleLoaderTranslatePtr moduleLoaderTranslate;
- typedef JSInternalPromise* (*ModuleLoaderInstantiatePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
+ typedef JSInternalPromise* (*ModuleLoaderInstantiatePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue, JSValue);
ModuleLoaderInstantiatePtr moduleLoaderInstantiate;
- typedef JSValue (*ModuleLoaderEvaluatePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue);
+ typedef JSValue (*ModuleLoaderEvaluatePtr)(JSGlobalObject*, ExecState*, JSModuleLoader*, JSValue, JSValue, JSValue);
ModuleLoaderEvaluatePtr moduleLoaderEvaluate;
typedef String (*DefaultLanguageFunctionPtr)();
Modified: trunk/Source/_javascript_Core/runtime/JSModuleLoader.cpp (205277 => 205278)
--- trunk/Source/_javascript_Core/runtime/JSModuleLoader.cpp 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/_javascript_Core/runtime/JSModuleLoader.cpp 2016-09-01 03:48:34 UTC (rev 205278)
@@ -86,7 +86,7 @@
return call(exec, function, callType, callData, this, arguments);
}
-JSInternalPromise* JSModuleLoader::loadAndEvaluateModule(ExecState* exec, JSValue moduleName, JSValue referrer)
+JSInternalPromise* JSModuleLoader::loadAndEvaluateModule(ExecState* exec, JSValue moduleName, JSValue referrer, JSValue initiator)
{
JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().loadAndEvaluateModulePublicName()));
CallData callData;
@@ -96,11 +96,12 @@
MarkedArgumentBuffer arguments;
arguments.append(moduleName);
arguments.append(referrer);
+ arguments.append(initiator);
return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
}
-JSInternalPromise* JSModuleLoader::loadModule(ExecState* exec, JSValue moduleName, JSValue referrer)
+JSInternalPromise* JSModuleLoader::loadModule(ExecState* exec, JSValue moduleName, JSValue referrer, JSValue initiator)
{
JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().loadModulePublicName()));
CallData callData;
@@ -110,11 +111,12 @@
MarkedArgumentBuffer arguments;
arguments.append(moduleName);
arguments.append(referrer);
+ arguments.append(initiator);
return jsCast<JSInternalPromise*>(call(exec, function, callType, callData, this, arguments));
}
-JSValue JSModuleLoader::linkAndEvaluateModule(ExecState* exec, JSValue moduleKey)
+JSValue JSModuleLoader::linkAndEvaluateModule(ExecState* exec, JSValue moduleKey, JSValue initiator)
{
JSObject* function = jsCast<JSObject*>(get(exec, exec->propertyNames().builtinNames().linkAndEvaluateModulePublicName()));
CallData callData;
@@ -123,11 +125,12 @@
MarkedArgumentBuffer arguments;
arguments.append(moduleKey);
+ arguments.append(initiator);
return call(exec, function, callType, callData, this, arguments);
}
-JSInternalPromise* JSModuleLoader::resolve(ExecState* exec, JSValue name, JSValue referrer)
+JSInternalPromise* JSModuleLoader::resolve(ExecState* exec, JSValue name, JSValue referrer, JSValue initiator)
{
if (Options::dumpModuleLoadingState())
dataLog("Loader [resolve] ", printableModuleKey(exec, name), "\n");
@@ -134,13 +137,13 @@
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
if (globalObject->globalObjectMethodTable()->moduleLoaderResolve)
- return globalObject->globalObjectMethodTable()->moduleLoaderResolve(globalObject, exec, this, name, referrer);
+ return globalObject->globalObjectMethodTable()->moduleLoaderResolve(globalObject, exec, this, name, referrer, initiator);
JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
deferred->resolve(exec, name);
return deferred->promise();
}
-JSInternalPromise* JSModuleLoader::fetch(ExecState* exec, JSValue key)
+JSInternalPromise* JSModuleLoader::fetch(ExecState* exec, JSValue key, JSValue initiator)
{
if (Options::dumpModuleLoadingState())
dataLog("Loader [fetch] ", printableModuleKey(exec, key), "\n");
@@ -147,7 +150,7 @@
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
if (globalObject->globalObjectMethodTable()->moduleLoaderFetch)
- return globalObject->globalObjectMethodTable()->moduleLoaderFetch(globalObject, exec, this, key);
+ return globalObject->globalObjectMethodTable()->moduleLoaderFetch(globalObject, exec, this, key, initiator);
JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
String moduleKey = key.toString(exec)->value(exec);
if (exec->hadException()) {
@@ -160,7 +163,7 @@
return deferred->promise();
}
-JSInternalPromise* JSModuleLoader::translate(ExecState* exec, JSValue key, JSValue payload)
+JSInternalPromise* JSModuleLoader::translate(ExecState* exec, JSValue key, JSValue payload, JSValue initiator)
{
if (Options::dumpModuleLoadingState())
dataLog("Loader [translate] ", printableModuleKey(exec, key), "\n");
@@ -167,13 +170,13 @@
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
if (globalObject->globalObjectMethodTable()->moduleLoaderTranslate)
- return globalObject->globalObjectMethodTable()->moduleLoaderTranslate(globalObject, exec, this, key, payload);
+ return globalObject->globalObjectMethodTable()->moduleLoaderTranslate(globalObject, exec, this, key, payload, initiator);
JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
deferred->resolve(exec, payload);
return deferred->promise();
}
-JSInternalPromise* JSModuleLoader::instantiate(ExecState* exec, JSValue key, JSValue source)
+JSInternalPromise* JSModuleLoader::instantiate(ExecState* exec, JSValue key, JSValue source, JSValue initiator)
{
if (Options::dumpModuleLoadingState())
dataLog("Loader [instantiate] ", printableModuleKey(exec, key), "\n");
@@ -180,13 +183,13 @@
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
if (globalObject->globalObjectMethodTable()->moduleLoaderInstantiate)
- return globalObject->globalObjectMethodTable()->moduleLoaderInstantiate(globalObject, exec, this, key, source);
+ return globalObject->globalObjectMethodTable()->moduleLoaderInstantiate(globalObject, exec, this, key, source, initiator);
JSInternalPromiseDeferred* deferred = JSInternalPromiseDeferred::create(exec, globalObject);
deferred->resolve(exec, jsUndefined());
return deferred->promise();
}
-JSValue JSModuleLoader::evaluate(ExecState* exec, JSValue key, JSValue moduleRecordValue)
+JSValue JSModuleLoader::evaluate(ExecState* exec, JSValue key, JSValue moduleRecordValue, JSValue initiator)
{
if (Options::dumpModuleLoadingState())
dataLog("Loader [evaluate] ", printableModuleKey(exec, key), "\n");
@@ -193,7 +196,7 @@
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
if (globalObject->globalObjectMethodTable()->moduleLoaderEvaluate)
- return globalObject->globalObjectMethodTable()->moduleLoaderEvaluate(globalObject, exec, this, key, moduleRecordValue);
+ return globalObject->globalObjectMethodTable()->moduleLoaderEvaluate(globalObject, exec, this, key, moduleRecordValue, initiator);
JSModuleRecord* moduleRecord = jsDynamicCast<JSModuleRecord*>(moduleRecordValue);
if (!moduleRecord)
Modified: trunk/Source/_javascript_Core/runtime/JSModuleLoader.h (205277 => 205278)
--- trunk/Source/_javascript_Core/runtime/JSModuleLoader.h 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/_javascript_Core/runtime/JSModuleLoader.h 2016-09-01 03:48:34 UTC (rev 205278)
@@ -42,7 +42,7 @@
Fetch = 1,
Translate = 2,
Instantiate = 3,
- ResolveDependencies = 4,
+ Satisfy = 4,
Link = 5,
Ready = 6,
};
@@ -63,18 +63,18 @@
// APIs to control the module loader.
JSValue provide(ExecState*, JSValue key, Status, const String&);
- JSInternalPromise* loadAndEvaluateModule(ExecState*, JSValue moduleName, JSValue referrer);
- JSInternalPromise* loadModule(ExecState*, JSValue moduleName, JSValue referrer);
- JSValue linkAndEvaluateModule(ExecState*, JSValue moduleKey);
+ JSInternalPromise* loadAndEvaluateModule(ExecState*, JSValue moduleName, JSValue referrer, JSValue initiator);
+ JSInternalPromise* loadModule(ExecState*, JSValue moduleName, JSValue referrer, JSValue initiator);
+ JSValue linkAndEvaluateModule(ExecState*, JSValue moduleKey, JSValue initiator);
// Platform dependent hooked APIs.
- JSInternalPromise* resolve(ExecState*, JSValue name, JSValue referrer);
- JSInternalPromise* fetch(ExecState*, JSValue key);
- JSInternalPromise* translate(ExecState*, JSValue key, JSValue payload);
- JSInternalPromise* instantiate(ExecState*, JSValue key, JSValue source);
+ JSInternalPromise* resolve(ExecState*, JSValue name, JSValue referrer, JSValue initiator);
+ JSInternalPromise* fetch(ExecState*, JSValue key, JSValue initiator);
+ JSInternalPromise* translate(ExecState*, JSValue key, JSValue payload, JSValue initiator);
+ JSInternalPromise* instantiate(ExecState*, JSValue key, JSValue source, JSValue initiator);
// Additional platform dependent hooked APIs.
- JSValue evaluate(ExecState*, JSValue key, JSValue moduleRecord);
+ JSValue evaluate(ExecState*, JSValue key, JSValue moduleRecord, JSValue initiator);
protected:
void finishCreation(VM&, JSGlobalObject*);
Modified: trunk/Source/_javascript_Core/runtime/ModuleLoaderPrototype.cpp (205277 => 205278)
--- trunk/Source/_javascript_Core/runtime/ModuleLoaderPrototype.cpp 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/_javascript_Core/runtime/ModuleLoaderPrototype.cpp 2016-09-01 03:48:34 UTC (rev 205278)
@@ -66,36 +66,36 @@
/* 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
+ 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 2
+ requestTranslate JSBuiltin DontEnum|Function 2
+ requestInstantiate JSBuiltin DontEnum|Function 2
+ requestSatisfy JSBuiltin DontEnum|Function 2
+ requestInstantiateAll JSBuiltin DontEnum|Function 2
+ requestLink JSBuiltin DontEnum|Function 2
+ requestReady JSBuiltin DontEnum|Function 2
+ link JSBuiltin DontEnum|Function 2
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
+ moduleEvaluation JSBuiltin DontEnum|Function 2
+ evaluate moduleLoaderPrototypeEvaluate DontEnum|Function 3
+ provide JSBuiltin DontEnum|Function 3
+ loadAndEvaluateModule JSBuiltin DontEnum|Function 3
+ loadModule JSBuiltin DontEnum|Function 3
+ linkAndEvaluateModule JSBuiltin DontEnum|Function 2
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
+ resolve moduleLoaderPrototypeResolve DontEnum|Function 2
+ fetch moduleLoaderPrototypeFetch DontEnum|Function 2
+ translate moduleLoaderPrototypeTranslate DontEnum|Function 3
+ instantiate moduleLoaderPrototypeInstantiate DontEnum|Function 3
@end
*/
@@ -183,7 +183,7 @@
JSModuleLoader* loader = jsDynamicCast<JSModuleLoader*>(exec->thisValue());
if (!loader)
return JSValue::encode(jsUndefined());
- return JSValue::encode(loader->resolve(exec, exec->argument(0), exec->argument(1)));
+ return JSValue::encode(loader->resolve(exec, exec->argument(0), exec->argument(1), exec->argument(2)));
}
EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeFetch(ExecState* exec)
@@ -196,7 +196,7 @@
JSModuleLoader* loader = jsDynamicCast<JSModuleLoader*>(exec->thisValue());
if (!loader)
return JSValue::encode(jsUndefined());
- return JSValue::encode(loader->fetch(exec, exec->argument(0)));
+ return JSValue::encode(loader->fetch(exec, exec->argument(0), exec->argument(1)));
}
EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeTranslate(ExecState* exec)
@@ -208,7 +208,7 @@
JSModuleLoader* loader = jsDynamicCast<JSModuleLoader*>(exec->thisValue());
if (!loader)
return JSValue::encode(jsUndefined());
- return JSValue::encode(loader->translate(exec, exec->argument(0), exec->argument(1)));
+ return JSValue::encode(loader->translate(exec, exec->argument(0), exec->argument(1), exec->argument(2)));
}
EncodedJSValue JSC_HOST_CALL moduleLoaderPrototypeInstantiate(ExecState* exec)
@@ -222,7 +222,7 @@
JSModuleLoader* loader = jsDynamicCast<JSModuleLoader*>(exec->thisValue());
if (!loader)
return JSValue::encode(jsUndefined());
- return JSValue::encode(loader->instantiate(exec, exec->argument(0), exec->argument(1)));
+ return JSValue::encode(loader->instantiate(exec, exec->argument(0), exec->argument(1), exec->argument(2)));
}
// ------------------- Additional Hook Functions ---------------------------
@@ -235,7 +235,7 @@
JSModuleLoader* loader = jsDynamicCast<JSModuleLoader*>(exec->thisValue());
if (!loader)
return JSValue::encode(jsUndefined());
- return JSValue::encode(loader->evaluate(exec, exec->argument(0), exec->argument(1)));
+ return JSValue::encode(loader->evaluate(exec, exec->argument(0), exec->argument(1), exec->argument(2)));
}
} // namespace JSC
Modified: trunk/Source/WebCore/CMakeLists.txt (205277 => 205278)
--- trunk/Source/WebCore/CMakeLists.txt 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-09-01 03:48:34 UTC (rev 205278)
@@ -1208,7 +1208,6 @@
bindings/js/JSMessageChannelCustom.cpp
bindings/js/JSMessageEventCustom.cpp
bindings/js/JSMessagePortCustom.cpp
- bindings/js/JSModuleLoader.cpp
bindings/js/JSMutationCallback.cpp
bindings/js/JSMutationObserverCustom.cpp
bindings/js/JSNamedNodeMapCustom.cpp
@@ -1257,6 +1256,7 @@
bindings/js/ScriptCachedFrameData.cpp
bindings/js/ScriptController.cpp
bindings/js/ScriptGlobalObject.cpp
+ bindings/js/ScriptModuleLoader.cpp
bindings/js/ScriptState.cpp
bindings/js/StructuredClone.cpp
bindings/js/SerializedScriptValue.cpp
Modified: trunk/Source/WebCore/ChangeLog (205277 => 205278)
--- trunk/Source/WebCore/ChangeLog 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/WebCore/ChangeLog 2016-09-01 03:48:34 UTC (rev 205278)
@@ -1,3 +1,46 @@
+2016-08-31 Yusuke Suzuki <[email protected]>
+
+ [JSC] Add initiator parameter to module pipeline
+ https://bugs.webkit.org/show_bug.cgi?id=161470
+
+ Reviewed by Saam Barati.
+
+ 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):
+
2016-08-31 Zalan Bujtas <[email protected]>
ASSERTION FAILED: !flow->layer() && !flow->isInlineElementContinuation() in WebCore::RenderBlock::addContinuationWithOutline
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (205277 => 205278)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-09-01 03:48:34 UTC (rev 205278)
@@ -6091,8 +6091,8 @@
E1FF57A60F01256B00891EBB /* ThreadGlobalData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF57A50F01256B00891EBB /* ThreadGlobalData.cpp */; };
E1FF8F6C180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FF8F6A180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp */; };
E1FF8F6D180DB5BE00132674 /* CryptoAlgorithmRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */; };
- E38838981BAD145F00D62EE3 /* JSModuleLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38838941BAD145F00D62EE3 /* JSModuleLoader.cpp */; };
- E38838991BAD145F00D62EE3 /* JSModuleLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = E38838951BAD145F00D62EE3 /* JSModuleLoader.h */; };
+ E38838981BAD145F00D62EE3 /* ScriptModuleLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38838941BAD145F00D62EE3 /* ScriptModuleLoader.cpp */; };
+ E38838991BAD145F00D62EE3 /* ScriptModuleLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */; };
E3FA38641D71812D00AA5950 /* PendingScriptClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E3FA38611D716E7600AA5950 /* PendingScriptClient.h */; };
E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; settings = {ATTRIBUTES = (Private, ); }; };
E401E0A41C3C0B8300F34D10 /* StyleChange.h in Headers */ = {isa = PBXBuildFile; fileRef = E401E0A31C3C0B8300F34D10 /* StyleChange.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -13660,8 +13660,8 @@
E1FF8F661807460800132674 /* JSWebKitSubtleCryptoCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitSubtleCryptoCustom.cpp; sourceTree = "<group>"; };
E1FF8F6A180DB5BE00132674 /* CryptoAlgorithmRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmRegistry.cpp; sourceTree = "<group>"; };
E1FF8F6B180DB5BE00132674 /* CryptoAlgorithmRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoAlgorithmRegistry.h; sourceTree = "<group>"; };
- E38838941BAD145F00D62EE3 /* JSModuleLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSModuleLoader.cpp; sourceTree = "<group>"; };
- E38838951BAD145F00D62EE3 /* JSModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSModuleLoader.h; sourceTree = "<group>"; };
+ E38838941BAD145F00D62EE3 /* ScriptModuleLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptModuleLoader.cpp; sourceTree = "<group>"; };
+ E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptModuleLoader.h; sourceTree = "<group>"; };
E3FA38611D716E7600AA5950 /* PendingScriptClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PendingScriptClient.h; sourceTree = "<group>"; };
E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementIteratorAssertions.h; sourceTree = "<group>"; };
E401E0A31C3C0B8300F34D10 /* StyleChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleChange.h; sourceTree = "<group>"; };
@@ -20973,8 +20973,8 @@
8F934D841189F1EE00508D5D /* JSMainThreadExecState.cpp */,
8F934D831189F1EE00508D5D /* JSMainThreadExecState.h */,
B56576E417DA599F00A56BDC /* JSMainThreadExecStateInstrumentation.h */,
- E38838941BAD145F00D62EE3 /* JSModuleLoader.cpp */,
- E38838951BAD145F00D62EE3 /* JSModuleLoader.h */,
+ E38838941BAD145F00D62EE3 /* ScriptModuleLoader.cpp */,
+ E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */,
C6F420A016B7164E0052A9F2 /* JSMutationCallback.cpp */,
C6F420A116B7164E0052A9F2 /* JSMutationCallback.h */,
7C91A38D1B498ABE003F9EFA /* JSNodeOrString.cpp */,
@@ -25090,7 +25090,7 @@
E1ADEDDA0E76BD93004A1A5E /* JSMessagePort.h in Headers */,
41F584C7104652CB009CAA64 /* JSMessagePortCustom.h in Headers */,
2D6F3E951C1F85550061DBD4 /* JSMockPageOverlay.h in Headers */,
- E38838991BAD145F00D62EE3 /* JSModuleLoader.h in Headers */,
+ E38838991BAD145F00D62EE3 /* ScriptModuleLoader.h in Headers */,
A86629D109DA2B48009633A5 /* JSMouseEvent.h in Headers */,
C6F420A316B7164E0052A9F2 /* JSMutationCallback.h in Headers */,
65DF31FC09D1CC60000BE325 /* JSMutationEvent.h in Headers */,
@@ -25556,6 +25556,7 @@
CE1252411A16B1B600864480 /* MediaPlayerSPI.h in Headers */,
52E2CAFC19FF0207001EEB4F /* MediaProducer.h in Headers */,
4E19592A0A39DACC00220FE5 /* MediaQuery.h in Headers */,
+ E38838991BAD145F00D62EE3 /* ScriptModuleLoader.h in Headers */,
4E19592C0A39DACC00220FE5 /* MediaQueryEvaluator.h in Headers */,
4E19592E0A39DACC00220FE5 /* MediaQueryExp.h in Headers */,
D3A94A39122DABAC00A37BBC /* MediaQueryList.h in Headers */,
@@ -28770,7 +28771,7 @@
410B7E721045FAB000D8224F /* JSMessageEventCustom.cpp in Sources */,
E1ADEDDB0E76BD93004A1A5E /* JSMessagePort.cpp in Sources */,
E1ADED470E76B8DD004A1A5E /* JSMessagePortCustom.cpp in Sources */,
- E38838981BAD145F00D62EE3 /* JSModuleLoader.cpp in Sources */,
+ E38838981BAD145F00D62EE3 /* ScriptModuleLoader.cpp in Sources */,
A86629D209DA2B48009633A5 /* JSMouseEvent.cpp in Sources */,
C6F420A216B7164E0052A9F2 /* JSMutationCallback.cpp in Sources */,
65DF31FB09D1CC60000BE325 /* JSMutationEvent.cpp in Sources */,
Modified: trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp (205277 => 205278)
--- trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp 2016-09-01 03:48:34 UTC (rev 205278)
@@ -107,7 +107,6 @@
#include "JSMessageChannelCustom.cpp"
#include "JSMessageEventCustom.cpp"
#include "JSMessagePortCustom.cpp"
-#include "JSModuleLoader.cpp"
#include "JSMutationCallback.cpp"
#include "JSMutationObserverCustom.cpp"
#include "JSNamedNodeMapCustom.cpp"
@@ -147,6 +146,7 @@
#include "ScriptCachedFrameData.cpp"
#include "ScriptController.cpp"
#include "ScriptGlobalObject.cpp"
+#include "ScriptModuleLoader.cpp"
#include "ScriptState.cpp"
#include "SerializedScriptValue.cpp"
#include "WebCoreTypedArrayController.cpp"
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp (205277 => 205278)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp 2016-09-01 03:48:34 UTC (rev 205278)
@@ -32,7 +32,6 @@
#include "JSDOMGlobalObjectTask.h"
#include "JSDOMWindowCustom.h"
#include "JSMainThreadExecState.h"
-#include "JSModuleLoader.h"
#include "JSNode.h"
#include "Language.h"
#include "Logging.h"
@@ -39,6 +38,7 @@
#include "Page.h"
#include "RuntimeApplicationChecks.h"
#include "ScriptController.h"
+#include "ScriptModuleLoader.h"
#include "SecurityOrigin.h"
#include "Settings.h"
#include "WebCoreJSClientData.h"
@@ -323,29 +323,29 @@
}
-JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderResolve(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, 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, JSC::JSValue initiator)
{
JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
if (RefPtr<Document> document = thisObject->wrapped().document())
- return document->moduleLoader()->resolve(globalObject, exec, moduleLoader, moduleName, importerModuleKey);
+ return document->moduleLoader()->resolve(globalObject, exec, moduleLoader, moduleName, importerModuleKey, initiator);
JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject);
return deferred->reject(exec, jsUndefined());
}
-JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderFetch(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey)
+JSC::JSInternalPromise* JSDOMWindowBase::moduleLoaderFetch(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, JSC::JSValue moduleKey, JSC::JSValue initiator)
{
JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
if (RefPtr<Document> document = thisObject->wrapped().document())
- return document->moduleLoader()->fetch(globalObject, exec, moduleLoader, moduleKey);
+ return document->moduleLoader()->fetch(globalObject, exec, moduleLoader, moduleKey, initiator);
JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject);
return deferred->reject(exec, jsUndefined());
}
-JSC::JSValue JSDOMWindowBase::moduleLoaderEvaluate(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader* moduleLoader, 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, JSC::JSValue initiator)
{
JSDOMWindowBase* thisObject = JSC::jsCast<JSDOMWindowBase*>(globalObject);
if (RefPtr<Document> document = thisObject->wrapped().document())
- return document->moduleLoader()->evaluate(globalObject, exec, moduleLoader, moduleKey, moduleRecord);
+ return document->moduleLoader()->evaluate(globalObject, exec, moduleLoader, moduleKey, moduleRecord, initiator);
return JSC::jsUndefined();
}
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h (205277 => 205278)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h 2016-09-01 03:48:34 UTC (rev 205278)
@@ -78,9 +78,9 @@
JSC::WatchpointSet m_windowCloseWatchpoints;
private:
- 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);
+ static JSC::JSInternalPromise* moduleLoaderResolve(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
+ static JSC::JSInternalPromise* moduleLoaderFetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue);
+ static JSC::JSValue moduleLoaderEvaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue);
RefPtr<DOMWindow> m_wrapped;
JSDOMWindowShell* m_shell;
Modified: trunk/Source/WebCore/bindings/js/JSMainThreadExecState.h (205277 => 205278)
--- trunk/Source/WebCore/bindings/js/JSMainThreadExecState.h 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/WebCore/bindings/js/JSMainThreadExecState.h 2016-09-01 03:48:34 UTC (rev 205278)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -92,6 +93,30 @@
task.run(exec);
}
+ static JSC::JSInternalPromise* loadModule(JSC::ExecState* exec, const String& moduleName, JSC::JSValue initiator)
+ {
+ JSMainThreadExecState currentState(exec);
+ return JSC::loadModule(exec, moduleName, initiator);
+ }
+
+ static JSC::JSInternalPromise* loadModule(JSC::ExecState* exec, const JSC::SourceCode& sourceCode, JSC::JSValue initiator)
+ {
+ JSMainThreadExecState currentState(exec);
+ return JSC::loadModule(exec, sourceCode, initiator);
+ }
+
+ static JSC::JSValue linkAndEvaluateModule(JSC::ExecState* exec, const JSC::Identifier& moduleKey, JSC::JSValue initiator, NakedPtr<JSC::Exception>& returnedException)
+ {
+ JSMainThreadExecState currentState(exec);
+ JSC::JSValue returnValue = JSC::linkAndEvaluateModule(exec, moduleKey, initiator);
+ if (exec->hadException()) {
+ returnedException = exec->vm().exception();
+ exec->clearException();
+ return JSC::jsUndefined();
+ }
+ return returnValue;
+ }
+
static InspectorInstrumentationCookie instrumentFunctionCall(ScriptExecutionContext*, JSC::CallType, const JSC::CallData&);
static InspectorInstrumentationCookie instrumentFunctionConstruct(ScriptExecutionContext*, JSC::ConstructType, const JSC::ConstructData&);
Deleted: trunk/Source/WebCore/bindings/js/JSModuleLoader.cpp (205277 => 205278)
--- trunk/Source/WebCore/bindings/js/JSModuleLoader.cpp 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/WebCore/bindings/js/JSModuleLoader.cpp 2016-09-01 03:48:34 UTC (rev 205278)
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2015, 2016 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. AND ITS CONTRIBUTORS ``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 ITS 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 "Document.h"
-#include "ExceptionCode.h"
-#include "Frame.h"
-#include "JSDOMBinding.h"
-#include <runtime/JSInternalPromiseDeferred.h>
-#include <runtime/JSModuleRecord.h>
-#include <runtime/JSString.h>
-#include <runtime/Symbol.h>
-
-namespace WebCore {
-
-JSModuleLoader::JSModuleLoader(Document& document)
- : m_document(document)
-{
-}
-
-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);
-
- // We use a Symbol as a special purpose; It means this module is an inline module.
- // So there is no correct URL to retrieve the module source code. If the module name
- // value is a Symbol, it is used directly as a module key.
- //
- // FIXME: Using symbols for an inline module is a current implementation details of WebKit.
- // Once the spec of this part is specified, we will recast these part.
- if (moduleNameValue.isSymbol())
- return deferred->resolve(exec, moduleNameValue);
-
- if (!moduleNameValue.isString())
- return deferred->reject(exec, JSC::createTypeError(exec, "Module name is not Symbol or String."));
-
- String moduleName = asString(moduleNameValue)->value(exec);
-
- // Now, we consider the given moduleName as the same to the `import "..."` in the module code.
- // We use the completed URL as the unique module key.
- URL completedUrl;
-
- if (importerModuleKey.isSymbol())
- completedUrl = m_document.completeURL(moduleName);
- else if (importerModuleKey.isUndefined())
- completedUrl = m_document.completeURL(moduleName);
- else if (importerModuleKey.isString()) {
- URL importerModuleUrl(URL(), asString(importerModuleKey)->value(exec));
- if (!importerModuleUrl.isValid())
- return deferred->reject(exec, JSC::createTypeError(exec, "Importer module key is an invalid URL."));
- completedUrl = m_document.completeURL(moduleName, importerModuleUrl);
- } else
- return deferred->reject(exec, JSC::createTypeError(exec, "Importer module key is not Symbol or String."));
-
- if (!completedUrl.isValid())
- return deferred->reject(exec, JSC::createTypeError(exec, "Module name constructs an invalid URL."));
-
- return deferred->resolve(exec, jsString(exec, completedUrl.string()));
-}
-
-JSC::JSInternalPromise* JSModuleLoader::fetch(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleKeyValue)
-{
- JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject);
-
- if (moduleKeyValue.isSymbol())
- return deferred->reject(exec, JSC::createTypeError(exec, "Symbol module key should be already fulfilled with the inlined resource."));
-
- if (!moduleKeyValue.isString())
- return deferred->reject(exec, JSC::createTypeError(exec, "Module key is not Symbol or String."));
-
- URL completedUrl(URL(), asString(moduleKeyValue)->value(exec));
- if (!completedUrl.isValid())
- return deferred->reject(exec, JSC::createTypeError(exec, "Module key is an invalid URL."));
-
- // FIXME: Implement the module fetcher.
-
- return deferred->promise();
-}
-
-JSC::JSValue JSModuleLoader::evaluate(JSC::JSGlobalObject*, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleKeyValue, JSC::JSValue moduleRecordValue)
-{
- JSC::VM& vm = exec->vm();
- auto scope = DECLARE_THROW_SCOPE(vm);
-
- // FIXME: Currently, we only support JSModuleRecord.
- // Once the reflective part of the module loader is supported, we will handle arbitrary values.
- // https://whatwg.github.io/loader/#registry-prototype-provide
- JSC::JSModuleRecord* moduleRecord = JSC::jsDynamicCast<JSC::JSModuleRecord*>(moduleRecordValue);
- if (!moduleRecord)
- return JSC::jsUndefined();
-
- URL sourceUrl;
- if (moduleKeyValue.isSymbol())
- sourceUrl = m_document.url();
- else if (moduleKeyValue.isString())
- sourceUrl = URL(URL(), asString(moduleKeyValue)->value(exec));
- else
- return JSC::throwTypeError(exec, scope, ASCIILiteral("Module key is not Symbol or String."));
-
- if (!sourceUrl.isValid())
- return JSC::throwTypeError(exec, scope, ASCIILiteral("Module key is an invalid URL."));
-
- // FIXME: Implement evaluating module code.
-
- return JSC::jsUndefined();
-}
-
-}
Deleted: trunk/Source/WebCore/bindings/js/JSModuleLoader.h (205277 => 205278)
--- trunk/Source/WebCore/bindings/js/JSModuleLoader.h 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/WebCore/bindings/js/JSModuleLoader.h 2016-09-01 03:48:34 UTC (rev 205278)
@@ -1,59 +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. AND ITS CONTRIBUTORS ``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 ITS 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 <runtime/JSCJSValue.h>
-#include <wtf/Noncopyable.h>
-
-namespace JSC {
-
-class ExecState;
-class JSGlobalObject;
-class JSInternalPromise;
-class JSModuleLoader;
-
-}
-
-namespace WebCore {
-
-class Document;
-
-class JSModuleLoader {
- WTF_MAKE_NONCOPYABLE(JSModuleLoader); WTF_MAKE_FAST_ALLOCATED;
-public:
- explicit JSModuleLoader(Document&);
-
- Document& document() { return m_document; }
-
- 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
Copied: trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp (from rev 205277, trunk/Source/WebCore/bindings/js/JSModuleLoader.cpp) (0 => 205278)
--- trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/js/ScriptModuleLoader.cpp 2016-09-01 03:48:34 UTC (rev 205278)
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2015, 2016 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. AND ITS CONTRIBUTORS ``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 ITS 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 "ScriptModuleLoader.h"
+
+#include "Document.h"
+#include "ExceptionCode.h"
+#include "Frame.h"
+#include "JSDOMBinding.h"
+#include <runtime/JSInternalPromiseDeferred.h>
+#include <runtime/JSModuleRecord.h>
+#include <runtime/JSString.h>
+#include <runtime/Symbol.h>
+
+namespace WebCore {
+
+ScriptModuleLoader::ScriptModuleLoader(Document& document)
+ : m_document(document)
+{
+}
+
+JSC::JSInternalPromise* ScriptModuleLoader::resolve(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleNameValue, JSC::JSValue importerModuleKey, JSC::JSValue)
+{
+ JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject);
+
+ // We use a Symbol as a special purpose; It means this module is an inline module.
+ // So there is no correct URL to retrieve the module source code. If the module name
+ // value is a Symbol, it is used directly as a module key.
+ //
+ // FIXME: Using symbols for an inline module is a current implementation details of WebKit.
+ // Once the spec of this part is specified, we will recast these part.
+ if (moduleNameValue.isSymbol())
+ return deferred->resolve(exec, moduleNameValue);
+
+ if (!moduleNameValue.isString())
+ return deferred->reject(exec, JSC::createTypeError(exec, "Module name is not Symbol or String."));
+
+ String moduleName = asString(moduleNameValue)->value(exec);
+
+ // Now, we consider the given moduleName as the same to the `import "..."` in the module code.
+ // We use the completed URL as the unique module key.
+ URL completedUrl;
+
+ if (importerModuleKey.isSymbol())
+ completedUrl = m_document.completeURL(moduleName);
+ else if (importerModuleKey.isUndefined())
+ completedUrl = m_document.completeURL(moduleName);
+ else if (importerModuleKey.isString()) {
+ URL importerModuleUrl(URL(), asString(importerModuleKey)->value(exec));
+ if (!importerModuleUrl.isValid())
+ return deferred->reject(exec, JSC::createTypeError(exec, "Importer module key is an invalid URL."));
+ completedUrl = m_document.completeURL(moduleName, importerModuleUrl);
+ } else
+ return deferred->reject(exec, JSC::createTypeError(exec, "Importer module key is not Symbol or String."));
+
+ if (!completedUrl.isValid())
+ return deferred->reject(exec, JSC::createTypeError(exec, "Module name constructs an invalid URL."));
+
+ return deferred->resolve(exec, jsString(exec, completedUrl.string()));
+}
+
+JSC::JSInternalPromise* ScriptModuleLoader::fetch(JSC::JSGlobalObject* globalObject, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleKeyValue, JSC::JSValue)
+{
+ JSC::JSInternalPromiseDeferred* deferred = JSC::JSInternalPromiseDeferred::create(exec, globalObject);
+
+ if (moduleKeyValue.isSymbol())
+ return deferred->reject(exec, JSC::createTypeError(exec, "Symbol module key should be already fulfilled with the inlined resource."));
+
+ if (!moduleKeyValue.isString())
+ return deferred->reject(exec, JSC::createTypeError(exec, "Module key is not Symbol or String."));
+
+ URL completedUrl(URL(), asString(moduleKeyValue)->value(exec));
+ if (!completedUrl.isValid())
+ return deferred->reject(exec, JSC::createTypeError(exec, "Module key is an invalid URL."));
+
+ // FIXME: Implement the module fetcher.
+
+ return deferred->promise();
+}
+
+JSC::JSValue ScriptModuleLoader::evaluate(JSC::JSGlobalObject*, JSC::ExecState* exec, JSC::JSModuleLoader*, JSC::JSValue moduleKeyValue, JSC::JSValue moduleRecordValue, JSC::JSValue)
+{
+ JSC::VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ // FIXME: Currently, we only support JSModuleRecord.
+ // Once the reflective part of the module loader is supported, we will handle arbitrary values.
+ // https://whatwg.github.io/loader/#registry-prototype-provide
+ JSC::JSModuleRecord* moduleRecord = JSC::jsDynamicCast<JSC::JSModuleRecord*>(moduleRecordValue);
+ if (!moduleRecord)
+ return JSC::jsUndefined();
+
+ URL sourceUrl;
+ if (moduleKeyValue.isSymbol())
+ sourceUrl = m_document.url();
+ else if (moduleKeyValue.isString())
+ sourceUrl = URL(URL(), asString(moduleKeyValue)->value(exec));
+ else
+ return JSC::throwTypeError(exec, scope, ASCIILiteral("Module key is not Symbol or String."));
+
+ if (!sourceUrl.isValid())
+ return JSC::throwTypeError(exec, scope, ASCIILiteral("Module key is an invalid URL."));
+
+ // FIXME: Implement evaluating module code.
+
+ return JSC::jsUndefined();
+}
+
+}
Copied: trunk/Source/WebCore/bindings/js/ScriptModuleLoader.h (from rev 205277, trunk/Source/WebCore/bindings/js/JSModuleLoader.h) (0 => 205278)
--- trunk/Source/WebCore/bindings/js/ScriptModuleLoader.h (rev 0)
+++ trunk/Source/WebCore/bindings/js/ScriptModuleLoader.h 2016-09-01 03:48:34 UTC (rev 205278)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2015, 2016 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. AND ITS CONTRIBUTORS ``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 ITS 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 <runtime/JSCJSValue.h>
+#include <wtf/Noncopyable.h>
+
+namespace JSC {
+
+class ExecState;
+class JSGlobalObject;
+class JSInternalPromise;
+class JSModuleLoader;
+
+}
+
+namespace WebCore {
+
+class Document;
+
+class ScriptModuleLoader {
+ WTF_MAKE_NONCOPYABLE(ScriptModuleLoader); WTF_MAKE_FAST_ALLOCATED;
+public:
+ explicit ScriptModuleLoader(Document&);
+
+ Document& document() { return m_document; }
+
+ JSC::JSInternalPromise* resolve(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleName, JSC::JSValue importerModuleKey, JSC::JSValue initiator);
+ JSC::JSInternalPromise* fetch(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleKey, JSC::JSValue initiator);
+ JSC::JSValue evaluate(JSC::JSGlobalObject*, JSC::ExecState*, JSC::JSModuleLoader*, JSC::JSValue moduleKey, JSC::JSValue moduleRecord, JSC::JSValue initiator);
+
+private:
+ Document& m_document;
+};
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/dom/Document.cpp (205277 => 205278)
--- trunk/Source/WebCore/dom/Document.cpp 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/WebCore/dom/Document.cpp 2016-09-01 03:48:34 UTC (rev 205278)
@@ -103,7 +103,6 @@
#include "InspectorInstrumentation.h"
#include "JSCustomElementInterface.h"
#include "JSLazyEventListener.h"
-#include "JSModuleLoader.h"
#include "KeyboardEvent.h"
#include "Language.h"
#include "LoaderStrategy.h"
@@ -153,6 +152,7 @@
#include "SchemeRegistry.h"
#include "ScopedEventQueue.h"
#include "ScriptController.h"
+#include "ScriptModuleLoader.h"
#include "ScriptRunner.h"
#include "ScriptSourceCode.h"
#include "ScrollingCoordinator.h"
@@ -480,7 +480,7 @@
, m_startTime(std::chrono::steady_clock::now())
, m_overMinimumLayoutThreshold(false)
, m_scriptRunner(std::make_unique<ScriptRunner>(*this))
- , m_moduleLoader(std::make_unique<JSModuleLoader>(*this))
+ , m_moduleLoader(std::make_unique<ScriptModuleLoader>(*this))
, m_xmlVersion(ASCIILiteral("1.0"))
, m_xmlStandalone(StandaloneUnspecified)
, m_hasXMLDeclaration(false)
Modified: trunk/Source/WebCore/dom/Document.h (205277 => 205278)
--- trunk/Source/WebCore/dom/Document.h 2016-09-01 03:34:36 UTC (rev 205277)
+++ trunk/Source/WebCore/dom/Document.h 2016-09-01 03:48:34 UTC (rev 205278)
@@ -124,7 +124,7 @@
class LayoutPoint;
class LayoutRect;
class LiveNodeList;
-class JSModuleLoader;
+class ScriptModuleLoader;
class JSNode;
class Locale;
class Location;
@@ -133,6 +133,7 @@
class MediaPlaybackTargetClient;
class MediaQueryList;
class MediaQueryMatcher;
+class ScriptModuleLoader;
class MouseEventWithHitTestResults;
class NamedFlowCollection;
class NodeFilter;
@@ -947,7 +948,7 @@
Document& topDocument() const;
ScriptRunner* scriptRunner() { return m_scriptRunner.get(); }
- JSModuleLoader* moduleLoader() { return m_moduleLoader.get(); }
+ ScriptModuleLoader* moduleLoader() { return m_moduleLoader.get(); }
HTMLScriptElement* currentScript() const { return !m_currentScriptStack.isEmpty() ? m_currentScriptStack.last().get() : nullptr; }
void pushCurrentScript(HTMLScriptElement*);
@@ -1551,7 +1552,7 @@
bool m_overMinimumLayoutThreshold;
std::unique_ptr<ScriptRunner> m_scriptRunner;
- std::unique_ptr<JSModuleLoader> m_moduleLoader;
+ std::unique_ptr<ScriptModuleLoader> m_moduleLoader;
Vector<RefPtr<HTMLScriptElement>> m_currentScriptStack;