[webkit-changes] [WebKit/WebKit] 29e1ce: [JSC] Fix satisfy cache in module loader

Commit Queue noreply at github.com
Fri Jul 14 04:24:34 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 29e1ceddc500bd7379bc86081b8b0ab76cbee4c2
      https://github.com/WebKit/WebKit/commit/29e1ceddc500bd7379bc86081b8b0ab76cbee4c2
  Author: Yijia Huang <yijia_huang at apple.com>
  Date:   2023-07-14 (Fri, 14 Jul 2023)

  Changed paths:
    M Source/JavaScriptCore/builtins/ModuleLoader.js
    M Source/JavaScriptCore/runtime/JSModuleLoader.cpp

  Log Message:
  -----------
  [JSC] Fix satisfy cache in module loader
https://bugs.webkit.org/show_bug.cgi?id=258540
rdar://110339520

Reviewed by Yusuke Suzuki.

Current satisfy cache in ModuleLoader.js is problematic when
module entries who encounter some visited children in requestSatisfy.
This is because the way we use to break infinitely looping is to
return a promise of instantiation for the visited children.
In that case, when all children's promises are fulfilled, we should
not mark the entry as satisfied since we don't know whether the visited
module entry is satisfied or not.

Current spec doesn't have concept satisfy before link phase see:
1. https://tc39.es/ecma262/#sec-import-calls
2. https://tc39.es/ecma262/#sec-ContinueDynamicImport
3. https://tc39.es/ecma262/#sec-LoadRequestedModules
4. https://tc39.es/ecma262/#sec-InnerModuleLoading

Ideally we should use DFS (https://tc39.es/ecma262/#sec-moduledeclarationlinking)
to track strongly connected component (SCC). If the requestSatisfyUtil
promise for the start entry of the SCC is fulfilled, then we can mark all entries
of the SCC satisfied. However, current requestSatisfyUtil cannot guarantee DFS due
to various requestInstantiate time for children. And we don't prefer to force DFS.
This is because if one child requests a lot of time in requestInstantiate, then the
other children have to wait for it. And this is expensive. This patch fixes this
issue by updating those "satisfying entries" after the root entry is resolved
in satisfy phase.

* Source/JavaScriptCore/builtins/ModuleLoader.js:
(linkTimeConstant.newRegistryEntry):
(visibility.PrivateRecursive.requestSatisfy):
(async visibility.PrivateRecursive.requestSatisfyUtil):
(visibility.PrivateRecursive.link):
(visibility.PrivateRecursive.linkAndEvaluateModule):
* Source/JavaScriptCore/runtime/JSModuleLoader.cpp:
(JSC::JSModuleLoader::finishCreation):

Canonical link: https://commits.webkit.org/266063@main




More information about the webkit-changes mailing list