| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3c37f89 commit a92ecf0
13 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ | |||
| 36 | 36 | ||
| 37 | 37 | # Reset this number to 0 on major V8 upgrades. | |
| 38 | 38 | # Increment by one for each non-official patch applied to deps/v8. | |
| 39 | - 'v8_embedder_string': '-node.19', | ||
| 39 | + 'v8_embedder_string': '-node.20', | ||
| 40 | 40 | ||
| 41 | 41 | ##### V8 defaults for Node.js ##### | |
| 42 | 42 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1621,6 +1621,7 @@ void SourceTextModule::SourceTextModulePrint(std::ostream& os) { // NOLINT | |||
| 1621 | 1621 | os << "\n - requested_modules: " << Brief(requested_modules()); | |
| 1622 | 1622 | os << "\n - script: " << Brief(script()); | |
| 1623 | 1623 | os << "\n - import_meta: " << Brief(import_meta()); | |
| 1624 | + os << "\n - cycle_root: " << Brief(cycle_root()); | ||
| 1624 | 1625 | os << "\n"; | |
| 1625 | 1626 | } | |
| 1626 | 1627 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2486,6 +2486,7 @@ Handle<SourceTextModule> Factory::NewSourceTextModule( | |||
| 2486 | 2486 | module->set_flags(0); | |
| 2487 | 2487 | module->set_async(IsAsyncModule(code->kind())); | |
| 2488 | 2488 | module->set_async_evaluating(false); | |
| 2489 | + module->set_cycle_root(roots.the_hole_value()); | ||
| 2489 | 2490 | module->set_async_parent_modules(*async_parent_modules); | |
| 2490 | 2491 | module->set_pending_async_dependencies(0); | |
| 2491 | 2492 | return module; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -111,6 +111,14 @@ class UnorderedModuleSet | |||
| 111 | 111 | ZoneAllocator<Handle<Module>>(zone)) {} | |
| 112 | 112 | }; | |
| 113 | 113 | ||
| 114 | + Handle<SourceTextModule> SourceTextModule::GetCycleRoot( | ||
| 115 | + Isolate* isolate) const { | ||
| 116 | + CHECK_GE(status(), kEvaluated); | ||
| 117 | + DCHECK(!cycle_root().IsTheHole(isolate)); | ||
| 118 | + Handle<SourceTextModule> root(SourceTextModule::cast(cycle_root()), isolate); | ||
| 119 | + return root; | ||
| 120 | + } | ||
| 121 | + | ||
| 114 | 122 | void SourceTextModule::AddAsyncParentModule(Isolate* isolate, | |
| 115 | 123 | Handle<SourceTextModule> module, | |
| 116 | 124 | Handle<SourceTextModule> parent) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -398,6 +398,7 @@ bool SourceTextModule::MaybeTransitionComponent( | |||
| 398 | 398 | DCHECK_LE(module->dfs_ancestor_index(), module->dfs_index()); | |
| 399 | 399 | if (module->dfs_ancestor_index() == module->dfs_index()) { | |
| 400 | 400 | // This is the root of its strongly connected component. | |
| 401 | + Handle<SourceTextModule> cycle_root = module; | ||
| 401 | 402 | Handle<SourceTextModule> ancestor; | |
| 402 | 403 | do { | |
| 403 | 404 | ancestor = stack->front(); | |
@@ -407,6 +408,9 @@ bool SourceTextModule::MaybeTransitionComponent( | |||
| 407 | 408 | if (new_status == kInstantiated) { | |
| 408 | 409 | if (!SourceTextModule::RunInitializationCode(isolate, ancestor)) | |
| 409 | 410 | return false; | |
| 411 | + } else if (new_status == kEvaluated) { | ||
| 412 | + DCHECK(ancestor->cycle_root().IsTheHole(isolate)); | ||
| 413 | + ancestor->set_cycle_root(*cycle_root); | ||
| 410 | 414 | } | |
| 411 | 415 | ancestor->SetStatus(new_status); | |
| 412 | 416 | } while (*ancestor != *module); | |
@@ -617,9 +621,9 @@ MaybeHandle<Object> SourceTextModule::EvaluateMaybeAsync( | |||
| 617 | 621 | CHECK(module->status() == kInstantiated || module->status() == kEvaluated); | |
| 618 | 622 | ||
| 619 | 623 | // 3. If module.[[Status]] is "evaluated", set module to | |
| 620 | - // GetAsyncCycleRoot(module). | ||
| 624 | + // module.[[CycleRoot]]. | ||
| 621 | 625 | if (module->status() == kEvaluated) { | |
| 622 | - module = GetAsyncCycleRoot(isolate, module); | ||
| 626 | + module = module->GetCycleRoot(isolate); | ||
| 623 | 627 | } | |
| 624 | 628 | ||
| 625 | 629 | // 4. If module.[[TopLevelCapability]] is not undefined, then | |
@@ -734,37 +738,27 @@ void SourceTextModule::AsyncModuleExecutionFulfilled( | |||
| 734 | 738 | for (int i = 0; i < module->AsyncParentModuleCount(); i++) { | |
| 735 | 739 | Handle<SourceTextModule> m = module->GetAsyncParentModule(isolate, i); | |
| 736 | 740 | ||
| 737 | - // a. If module.[[DFSIndex]] is not equal to module.[[DFSAncestorIndex]], | ||
| 738 | - // then | ||
| 739 | - if (module->dfs_index() != module->dfs_ancestor_index()) { | ||
| 740 | - // i. Assert: m.[[DFSAncestorIndex]] is equal to | ||
| 741 | - // module.[[DFSAncestorIndex]]. | ||
| 742 | - DCHECK_LE(m->dfs_ancestor_index(), module->dfs_ancestor_index()); | ||
| 743 | - } | ||
| 744 | - // b. Decrement m.[[PendingAsyncDependencies]] by 1. | ||
| 741 | + // a. Decrement m.[[PendingAsyncDependencies]] by 1. | ||
| 745 | 742 | m->DecrementPendingAsyncDependencies(); | |
| 746 | 743 | ||
| 747 | - // c. If m.[[PendingAsyncDependencies]] is 0 and m.[[EvaluationError]] is | ||
| 744 | + // b. If m.[[PendingAsyncDependencies]] is 0 and m.[[EvaluationError]] is | ||
| 748 | 745 | // undefined, then | |
| 749 | 746 | if (!m->HasPendingAsyncDependencies() && m->status() == kEvaluated) { | |
| 750 | 747 | // i. Assert: m.[[AsyncEvaluating]] is true. | |
| 751 | 748 | DCHECK(m->async_evaluating()); | |
| 752 | 749 | ||
| 753 | - // ii. Let cycleRoot be ! GetAsyncCycleRoot(m). | ||
| 754 | - auto cycle_root = GetAsyncCycleRoot(isolate, m); | ||
| 755 | - | ||
| 756 | - // iii. If cycleRoot.[[EvaluationError]] is not undefined, | ||
| 750 | + // ii. If m.[[CycleRoot]].[[EvaluationError]] is not undefined, | ||
| 757 | 751 | // return undefined. | |
| 758 | - if (cycle_root->status() == kErrored) { | ||
| 752 | + if (m->GetCycleRoot(isolate)->status() == kErrored) { | ||
| 759 | 753 | return; | |
| 760 | 754 | } | |
| 761 | 755 | ||
| 762 | - // iv. If m.[[Async]] is true, then | ||
| 756 | + // iii. If m.[[Async]] is true, then | ||
| 763 | 757 | if (m->async()) { | |
| 764 | 758 | // 1. Perform ! ExecuteAsyncModule(m). | |
| 765 | 759 | ExecuteAsyncModule(isolate, m); | |
| 766 | 760 | } else { | |
| 767 | - // v. Otherwise, | ||
| 761 | + // iv. Otherwise, | ||
| 768 | 762 | // 1. Let result be m.ExecuteModule(). | |
| 769 | 763 | // 2. If result is a normal completion, | |
| 770 | 764 | Handle<Object> unused_result; | |
@@ -1044,8 +1038,8 @@ MaybeHandle<Object> SourceTextModule::InnerModuleEvaluation( | |||
| 1044 | 1038 | required_module->dfs_ancestor_index())); | |
| 1045 | 1039 | } else { | |
| 1046 | 1040 | // iv. Otherwise, | |
| 1047 | - // 1. Set requiredModule to GetAsyncCycleRoot(requiredModule). | ||
| 1048 | - required_module = GetAsyncCycleRoot(isolate, required_module); | ||
| 1041 | + // 1. Set requiredModule to requiredModule.[[CycleRoot]]. | ||
| 1042 | + required_module = required_module->GetCycleRoot(isolate); | ||
| 1049 | 1043 | ||
| 1050 | 1044 | // 2. Assert: requiredModule.[[Status]] is "evaluated". | |
| 1051 | 1045 | CHECK_GE(required_module->status(), kEvaluated); | |
@@ -1103,43 +1097,6 @@ MaybeHandle<Object> SourceTextModule::InnerModuleEvaluation( | |||
| 1103 | 1097 | return result; | |
| 1104 | 1098 | } | |
| 1105 | 1099 | ||
| 1106 | - Handle<SourceTextModule> SourceTextModule::GetAsyncCycleRoot( | ||
| 1107 | - Isolate* isolate, Handle<SourceTextModule> module) { | ||
| 1108 | - // 1. Assert: module.[[Status]] is "evaluated". | ||
| 1109 | - CHECK_GE(module->status(), kEvaluated); | ||
| 1110 | - | ||
| 1111 | - // 2. If module.[[AsyncParentModules]] is an empty List, return module. | ||
| 1112 | - if (module->AsyncParentModuleCount() == 0) { | ||
| 1113 | - return module; | ||
| 1114 | - } | ||
| 1115 | - | ||
| 1116 | - // 3. Repeat, while module.[[DFSIndex]] is greater than | ||
| 1117 | - // module.[[DFSAncestorIndex]], | ||
| 1118 | - while (module->dfs_index() > module->dfs_ancestor_index()) { | ||
| 1119 | - // a. Assert: module.[[AsyncParentModules]] is a non-empty List. | ||
| 1120 | - DCHECK_GT(module->AsyncParentModuleCount(), 0); | ||
| 1121 | - | ||
| 1122 | - // b. Let nextCycleModule be the first element of | ||
| 1123 | - // module.[[AsyncParentModules]]. | ||
| 1124 | - Handle<SourceTextModule> next_cycle_module = | ||
| 1125 | - module->GetAsyncParentModule(isolate, 0); | ||
| 1126 | - | ||
| 1127 | - // c. Assert: nextCycleModule.[[DFSAncestorIndex]] is less than or equal | ||
| 1128 | - // to module.[[DFSAncestorIndex]]. | ||
| 1129 | - DCHECK_LE(next_cycle_module->dfs_ancestor_index(), | ||
| 1130 | - module->dfs_ancestor_index()); | ||
| 1131 | - | ||
| 1132 | - // d. Set module to nextCycleModule | ||
| 1133 | - module = next_cycle_module; | ||
| 1134 | - } | ||
| 1135 | - | ||
| 1136 | - // 4. Assert: module.[[DFSIndex]] is equal to module.[[DFSAncestorIndex]]. | ||
| 1137 | - DCHECK_EQ(module->dfs_index(), module->dfs_ancestor_index()); | ||
| 1138 | - | ||
| 1139 | - // 5. Return module. | ||
| 1140 | - return module; | ||
| 1141 | - } | ||
| 1142 | - | ||
| 1143 | 1100 | void SourceTextModule::Reset(Isolate* isolate, | |
| 1144 | 1101 | Handle<SourceTextModule> module) { | |
| 1145 | 1102 | Factory* factory = isolate->factory(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -78,6 +78,9 @@ class SourceTextModule | |||
| 78 | 78 | Handle<SourceTextModule> module, | |
| 79 | 79 | Handle<SourceTextModule> parent); | |
| 80 | 80 | ||
| 81 | + // Get the non-hole cycle root. Only valid when status >= kEvaluated. | ||
| 82 | + inline Handle<SourceTextModule> GetCycleRoot(Isolate* isolate) const; | ||
| 83 | + | ||
| 81 | 84 | // Returns a SourceTextModule, the | |
| 82 | 85 | // ith parent in depth first traversal order of a given async child. | |
| 83 | 86 | inline Handle<SourceTextModule> GetAsyncParentModule(Isolate* isolate, | |
@@ -163,10 +166,6 @@ class SourceTextModule | |||
| 163 | 166 | Isolate* isolate, Handle<SourceTextModule> module, | |
| 164 | 167 | ZoneForwardList<Handle<SourceTextModule>>* stack, Status new_status); | |
| 165 | 168 | ||
| 166 | - // Implementation of spec GetAsyncCycleRoot. | ||
| 167 | - static V8_WARN_UNUSED_RESULT Handle<SourceTextModule> GetAsyncCycleRoot( | ||
| 168 | - Isolate* isolate, Handle<SourceTextModule> module); | ||
| 169 | - | ||
| 170 | 169 | // Implementation of spec ExecuteModule is broken up into | |
| 171 | 170 | // InnerExecuteAsyncModule for asynchronous modules and ExecuteModule | |
| 172 | 171 | // for synchronous modules. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,6 +29,11 @@ extern class SourceTextModule extends Module { | |||
| 29 | 29 | // a JSObject afterwards. | |
| 30 | 30 | import_meta: TheHole|JSObject; | |
| 31 | 31 | ||
| 32 | + // The first visited module of a cycle. For modules not in a cycle, this is | ||
| 33 | + // the module itself. It's the hole before the module state transitions to | ||
| 34 | + // kEvaluated. | ||
| 35 | + cycle_root: SourceTextModule|TheHole; | ||
| 36 | + | ||
| 32 | 37 | async_parent_modules: ArrayList; | |
| 33 | 38 | top_level_capability: JSPromise|Undefined; | |
| 34 | 39 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,12 @@ | |||
| 1 | + // Copyright 2021 the V8 project authors. All rights reserved. | ||
| 2 | + // Use of this source code is governed by a BSD-style license that can be | ||
| 3 | + // found in the LICENSE file. | ||
| 4 | + | ||
| 5 | + // Flags: --harmony-top-level-await | ||
| 6 | + | ||
| 7 | + import "modules-skip-async-cycle-start.mjs" | ||
| 8 | + | ||
| 9 | + assertEquals(globalThis.test_order, [ | ||
| 10 | + '2', 'async before', 'async after', '1', | ||
| 11 | + '3', 'start', | ||
| 12 | + ]); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,14 @@ | |||
| 1 | + // Copyright 2021 the V8 project authors. All rights reserved. | ||
| 2 | + // Use of this source code is governed by a BSD-style license that can be | ||
| 3 | + // found in the LICENSE file. | ||
| 4 | + | ||
| 5 | + // Flags: --harmony-top-level-await | ||
| 6 | + | ||
| 7 | + import "modules-skip-async-cycle-2.mjs"; | ||
| 8 | + import "modules-skip-async-cycle-leaf.mjs"; | ||
| 9 | + | ||
| 10 | + if (globalThis.test_order === undefined) { | ||
| 11 | + globalThis.test_order = []; | ||
| 12 | + } | ||
| 13 | + globalThis.test_order.push('1'); | ||
| 14 | + | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,12 @@ | |||
| 1 | + // Copyright 2021 the V8 project authors. All rights reserved. | ||
| 2 | + // Use of this source code is governed by a BSD-style license that can be | ||
| 3 | + // found in the LICENSE file. | ||
| 4 | + | ||
| 5 | + // Flags: --harmony-top-level-await | ||
| 6 | + | ||
| 7 | + import "modules-skip-async-cycle-1.mjs"; | ||
| 8 | + | ||
| 9 | + if (globalThis.test_order === undefined) { | ||
| 10 | + globalThis.test_order = []; | ||
| 11 | + } | ||
| 12 | + globalThis.test_order.push('2'); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments