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