@@ -117,6 +117,36 @@ Isolate::ExceptionScope::~ExceptionScope() {
117
117
isolate_->set_pending_exception (*pending_exception_);
118
118
}
119
119
120
+ void Isolate::DidFinishModuleAsyncEvaluation (unsigned ordinal) {
121
+ // To address overflow, the ordinal is reset when the async module with the
122
+ // largest vended ordinal finishes evaluating. Modules are evaluated in
123
+ // ascending order of their async_evaluating_ordinal.
124
+ //
125
+ // While the specification imposes a global total ordering, the intention is
126
+ // that for each async module, all its parents are totally ordered by when
127
+ // they first had their [[AsyncEvaluating]] bit set.
128
+ //
129
+ // The module with largest vended ordinal finishes evaluating implies that the
130
+ // async dependency as well as all other modules in that module's graph
131
+ // depending on async dependencies are finished evaluating.
132
+ //
133
+ // If the async dependency participates in other module graphs (e.g. via
134
+ // dynamic import, or other <script type=module> tags), those module graphs
135
+ // must have been evaluated either before or after the async dependency is
136
+ // settled, as the concrete Evaluate() method on cyclic module records is
137
+ // neither reentrant nor performs microtask checkpoints during its
138
+ // evaluation. If before, then all modules that depend on the async
139
+ // dependencies were given an ordinal that ensure they are relatively ordered,
140
+ // before the global ordinal was reset. If after, then the async evaluating
141
+ // ordering does not apply, as the dependency is no longer asynchronous.
142
+ //
143
+ // https://tc39.es/ecma262/#sec-moduleevaluation
144
+ if (ordinal + 1 == next_module_async_evaluating_ordinal_) {
145
+ next_module_async_evaluating_ordinal_ =
146
+ SourceTextModule::kFirstAsyncEvaluatingOrdinal ;
147
+ }
148
+ }
149
+
120
150
#define NATIVE_CONTEXT_FIELD_ACCESSOR (index, type, name ) \
121
151
Handle <type> Isolate::name () { \
122
152
return Handle <type>(raw_native_context ().name (), this ); \
0 commit comments