Ignore:
Timestamp:
Sep 17, 2015, 3:26:18 PM (10 years ago)
Author:
Yusuke Suzuki
Message:

[ES6] Add more fine-grained APIs and additional hooks to control module loader from WebCore
https://bugs.webkit.org/show_bug.cgi?id=149129

Reviewed by Saam Barati.

No behavior change.

Source/JavaScriptCore:

Module tag <script type="module> will be executed asynchronously.
But we would like to fetch the resources before when the postTask-ed task is performed.
So instead of 1 API that fetch, instantiate and execute the module,
we need 2 fine-grained APIs.

  1. Fetch and initialize a module, but not execute it yet.
  2. Link and execute a module specified by the key (this will be invoked asynchronously).

And to instrument the script execution (like reporting the execution time of the module to
the inspector), we need a hook to inject code around an execution of a module body.

  • builtins/ModuleLoaderObject.js:

(moduleEvaluation):
(loadAndEvaluateModule):
(loadModule):
(linkAndEvaluateModule):

  • jsc.cpp:

(functionLoadModule):
(runWithScripts):

  • runtime/Completion.cpp:

(JSC::identifierToJSValue):
(JSC::createSymbolForEntryPointModule):
(JSC::rejectPromise):
(JSC::loadAndEvaluateModule):
(JSC::loadModule):
(JSC::linkAndEvaluateModule):
(JSC::evaluateModule): Deleted.

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

(JSC::JSModuleRecord::evaluate):
(JSC::JSModuleRecord::execute): Deleted.

  • runtime/JSModuleRecord.h:
  • runtime/ModuleLoaderObject.cpp:

(JSC::ModuleLoaderObject::loadAndEvaluateModule):
(JSC::ModuleLoaderObject::linkAndEvaluateModule):
(JSC::ModuleLoaderObject::evaluate):
(JSC::moduleLoaderObjectEvaluate):

  • runtime/ModuleLoaderObject.h:

Source/WebCore:

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

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r189888 r189941  
    708708
    709709const ClassInfo GlobalObject::s_info = { "global", &JSGlobalObject::s_info, nullptr, CREATE_METHOD_TABLE(GlobalObject) };
    710 const GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, 0, &shouldInterruptScriptBeforeTimeout, &moduleLoaderResolve, &moduleLoaderFetch, nullptr, nullptr };
     710const GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptRuntimeFlags, 0, &shouldInterruptScriptBeforeTimeout, &moduleLoaderResolve, &moduleLoaderFetch, nullptr, nullptr, nullptr };
    711711
    712712
     
    14671467        return JSValue::encode(exec->vm().throwException(exec, createError(exec, ASCIILiteral("Could not open file."))));
    14681468
    1469     JSInternalPromise* promise = evaluateModule(exec, fileName);
     1469    JSInternalPromise* promise = loadAndEvaluateModule(exec, fileName);
    14701470    if (exec->hadException())
    14711471        return JSValue::encode(jsUndefined());
     
    16401640            fileName = scripts[i].argument;
    16411641            if (module)
    1642                 promise = evaluateModule(globalObject->globalExec(), fileName);
     1642                promise = loadAndEvaluateModule(globalObject->globalExec(), fileName);
    16431643            else {
    16441644                if (!fetchScriptFromLocalFileSystem(fileName, scriptBuffer))
     
    16561656        if (module) {
    16571657            if (!promise)
    1658                 promise = evaluateModule(globalObject->globalExec(), jscSource(scriptBuffer, fileName));
     1658                promise = loadAndEvaluateModule(globalObject->globalExec(), jscSource(scriptBuffer, fileName));
    16591659            globalObject->globalExec()->clearException();
    16601660            promise->then(globalObject->globalExec(), nullptr, errorHandler);
Note: See TracChangeset for help on using the changeset viewer.