Skip to content

Commit ef3e716

Browse files
Editorial: Do not use [[DFSAncestorIndex]] in InnerModuleLinking
[[DFSAncestorIndex]] index is only set once per module during a given traversal process, and it represents the module's index in _stack_. Instead explicitly storing it, we can compute it given _stack_ when needed (i.e. when we process an edge that "closes" a loop).
1 parent dd1809c commit ef3e716

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

spec.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27162,7 +27162,7 @@ <h1>
2716227162
</h1>
2716327163
<dl class="header">
2716427164
<dt>description</dt>
27165-
<dd>It is used by Link to perform the actual linking process for _module_, as well as recursively on all other modules in the dependency graph. The _stack_ parameter, as well as a module's [[DFSAncestorIndex]] field, keep track of the depth-first search (DFS) traversal. In particular, [[DFSAncestorIndex]] is used to discover strongly connected components (SCCs), such that all modules in an SCC transition to ~linked~ together.</dd>
27165+
<dd>It is used by Link to perform the actual linking process for _module_, as well as recursively on all other modules in the dependency graph. The _stack_ parameter keeps track of the depth-first search (DFS) traversal and, together with the return value, it is used to discover strongly connected components (SCCs), such that all modules in an SCC transition to ~linked~ together.</dd>
2716627166
</dl>
2716727167

2716827168
<emu-alg>
@@ -27174,12 +27174,11 @@ <h1>
2717427174
1. Return _moduleIndex_.
2717527175
1. If _module_.[[Status]] is ~linking~, then
2717627176
1. Assert: _module_ occurs exactly once in _stack_.
27177-
1. Assert: _module_.[[DFSAncestorIndex]] is not ~empty~.
27178-
1. Return _module_.[[DFSAncestorIndex]].
27177+
1. NOTE: Once a _module_ is added to _stack_, its index never changes. Implementations may thus cache _module_'s index when it's first inserted, rather than computing it here.
27178+
1. Return the integer _i_ such that _stack_[_i_] = _module_.
2717927179
1. Assert: _module_.[[Status]] is ~unlinked~.
2718027180
1. Set _module_.[[Status]] to ~linking~.
2718127181
1. Let _sccAncestorIndex_ be _moduleIndex_.
27182-
1. Set _module_.[[DFSAncestorIndex]] to _sccAncestorIndex_.
2718327182
1. Append _module_ to _stack_.
2718427183
1. For each ModuleRequest Record _request_ of _module_.[[RequestedModules]], do
2718527184
1. Let _requiredModule_ be GetImportedModule(_module_, _request_).

0 commit comments

Comments
 (0)