Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v14.x] Backport Apple silicon support #38051

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e0b3523
deps: cherry-pick f4376ec801e1ded from V8 upstream
danbev Feb 4, 2021
292dffe
test: add arm64 arch to test-worker-prof status
danbev Feb 4, 2021
15ed780
deps: V8: cherry-pick beebee4f80ff
psmarshall Aug 5, 2020
69057eb
test: add cpu-profiler-crash test
santigimeno Feb 9, 2021
a7acd72
worker: add eventLoopUtilization()
trevnorris Oct 14, 2020
78c42ac
test: correct test-worker-eventlooputil
Flarna Oct 31, 2020
b297c11
doc: upgrade stability status of report API
gireeshpunathil Oct 15, 2020
44d6862
doc: fix YAML lint error on master
Trott Oct 19, 2020
1ca213c
dns: add setLocalAddress to Resolver
daguej Aug 18, 2020
c5a61d3
test: refactor coverage logic
bcoe Oct 23, 2020
772afde
doc: fix typo in BUILDING.md
RaisinTen Oct 26, 2020
a2a3b70
child_process: add ChildProcess 'spawn' event
zenflow Sep 27, 2020
372fa0f
tools: add msvc /P output to .gitignore
gengjiawen Oct 21, 2020
4594961
src: add loop idle time in diagnostic report
gireeshpunathil Nov 3, 2020
e8ec2a6
deps: upgrade to libuv 1.41.0
cjihrig Feb 13, 2021
2b33ec4
deps: update ICU to 68.1
targos Nov 20, 2020
0d2752e
tools: fix md5 hash for ICU 68.1 src
richardlau Jan 4, 2021
966eee7
deps: update ICU to 68.2
targos Jan 18, 2021
efb88ee
doc: fix maintaining ICU guide
targos Jan 18, 2021
8899f47
tools: cleanup old ICU version-specific fixes
targos Jan 18, 2021
6562506
errors: print original exception context
bcoe Mar 10, 2021
cb9ec6d
deps: upgrade npm to 6.14.12
ruyadorno Mar 25, 2021
fe5e2e3
deps: v8 backport 9689b17687b
guybedford Mar 22, 2021
697d6a0
deps: V8: cherry-pick c6ec36a6
oleavr Nov 6, 2020
68f8f4b
deps: V8: cherry-pick 086eecbd96b6
oleavr Nov 6, 2020
6be68ce
deps: V8: cherry-pick 4e077ff0444a
oleavr Nov 6, 2020
bb7e82e
deps: V8: cherry-pick 1d0f426311d4i
oleavr Nov 6, 2020
c2d8aef
test: add SIGTRAP to test-signal-handler
Dec 3, 2020
62f250d
deps: V8: cherry-pick 0c8b6e415c30
matinzd Feb 8, 2021
270801c
deps: cherry-pick 8957d4677aa794c230577f234071af0 from V8 upstream
aduh95 Jan 4, 2021
83501fd
deps: v8: cherry-pick cf71540c
a60814billy Apr 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
deps: v8 backport 9689b17687b
[top-level-await] Implement spec fix for cycle root detection

Refs: http://github.com/v8/v8/commit/9689b17687b21c800c3f7400df4255c55b9c6ec0
PR-URL: #37865
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
guybedford committed Mar 29, 2021
commit fe5e2e3bb58097ff2d3517d413fe649d85d70891
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.19',
'v8_embedder_string': '-node.20',

##### V8 defaults for Node.js #####

Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/diagnostics/objects-printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,7 @@ void SourceTextModule::SourceTextModulePrint(std::ostream& os) { // NOLINT
os << "\n - requested_modules: " << Brief(requested_modules());
os << "\n - script: " << Brief(script());
os << "\n - import_meta: " << Brief(import_meta());
os << "\n - cycle_root: " << Brief(cycle_root());
os << "\n";
}

Expand Down
1 change: 1 addition & 0 deletions deps/v8/src/heap/factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,7 @@ Handle<SourceTextModule> Factory::NewSourceTextModule(
module->set_flags(0);
module->set_async(IsAsyncModule(code->kind()));
module->set_async_evaluating(false);
module->set_cycle_root(roots.the_hole_value());
module->set_async_parent_modules(*async_parent_modules);
module->set_pending_async_dependencies(0);
return module;
Expand Down
8 changes: 8 additions & 0 deletions deps/v8/src/objects/module-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ class UnorderedModuleSet
ZoneAllocator<Handle<Module>>(zone)) {}
};

Handle<SourceTextModule> SourceTextModule::GetCycleRoot(
Isolate* isolate) const {
CHECK_GE(status(), kEvaluated);
DCHECK(!cycle_root().IsTheHole(isolate));
Handle<SourceTextModule> root(SourceTextModule::cast(cycle_root()), isolate);
return root;
}

void SourceTextModule::AddAsyncParentModule(Isolate* isolate,
Handle<SourceTextModule> module,
Handle<SourceTextModule> parent) {
Expand Down
71 changes: 14 additions & 57 deletions deps/v8/src/objects/source-text-module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ bool SourceTextModule::MaybeTransitionComponent(
DCHECK_LE(module->dfs_ancestor_index(), module->dfs_index());
if (module->dfs_ancestor_index() == module->dfs_index()) {
// This is the root of its strongly connected component.
Handle<SourceTextModule> cycle_root = module;
Handle<SourceTextModule> ancestor;
do {
ancestor = stack->front();
Expand All @@ -407,6 +408,9 @@ bool SourceTextModule::MaybeTransitionComponent(
if (new_status == kInstantiated) {
if (!SourceTextModule::RunInitializationCode(isolate, ancestor))
return false;
} else if (new_status == kEvaluated) {
DCHECK(ancestor->cycle_root().IsTheHole(isolate));
ancestor->set_cycle_root(*cycle_root);
}
ancestor->SetStatus(new_status);
} while (*ancestor != *module);
Expand Down Expand Up @@ -617,9 +621,9 @@ MaybeHandle<Object> SourceTextModule::EvaluateMaybeAsync(
CHECK(module->status() == kInstantiated || module->status() == kEvaluated);

// 3. If module.[[Status]] is "evaluated", set module to
// GetAsyncCycleRoot(module).
// module.[[CycleRoot]].
if (module->status() == kEvaluated) {
module = GetAsyncCycleRoot(isolate, module);
module = module->GetCycleRoot(isolate);
}

// 4. If module.[[TopLevelCapability]] is not undefined, then
Expand Down Expand Up @@ -734,37 +738,27 @@ void SourceTextModule::AsyncModuleExecutionFulfilled(
for (int i = 0; i < module->AsyncParentModuleCount(); i++) {
Handle<SourceTextModule> m = module->GetAsyncParentModule(isolate, i);

// a. If module.[[DFSIndex]] is not equal to module.[[DFSAncestorIndex]],
// then
if (module->dfs_index() != module->dfs_ancestor_index()) {
// i. Assert: m.[[DFSAncestorIndex]] is equal to
// module.[[DFSAncestorIndex]].
DCHECK_LE(m->dfs_ancestor_index(), module->dfs_ancestor_index());
}
// b. Decrement m.[[PendingAsyncDependencies]] by 1.
// a. Decrement m.[[PendingAsyncDependencies]] by 1.
m->DecrementPendingAsyncDependencies();

// c. If m.[[PendingAsyncDependencies]] is 0 and m.[[EvaluationError]] is
// b. If m.[[PendingAsyncDependencies]] is 0 and m.[[EvaluationError]] is
// undefined, then
if (!m->HasPendingAsyncDependencies() && m->status() == kEvaluated) {
// i. Assert: m.[[AsyncEvaluating]] is true.
DCHECK(m->async_evaluating());

// ii. Let cycleRoot be ! GetAsyncCycleRoot(m).
auto cycle_root = GetAsyncCycleRoot(isolate, m);

// iii. If cycleRoot.[[EvaluationError]] is not undefined,
// ii. If m.[[CycleRoot]].[[EvaluationError]] is not undefined,
// return undefined.
if (cycle_root->status() == kErrored) {
if (m->GetCycleRoot(isolate)->status() == kErrored) {
return;
}

// iv. If m.[[Async]] is true, then
// iii. If m.[[Async]] is true, then
if (m->async()) {
// 1. Perform ! ExecuteAsyncModule(m).
ExecuteAsyncModule(isolate, m);
} else {
// v. Otherwise,
// iv. Otherwise,
// 1. Let result be m.ExecuteModule().
// 2. If result is a normal completion,
Handle<Object> unused_result;
Expand Down Expand Up @@ -1044,8 +1038,8 @@ MaybeHandle<Object> SourceTextModule::InnerModuleEvaluation(
required_module->dfs_ancestor_index()));
} else {
// iv. Otherwise,
// 1. Set requiredModule to GetAsyncCycleRoot(requiredModule).
required_module = GetAsyncCycleRoot(isolate, required_module);
// 1. Set requiredModule to requiredModule.[[CycleRoot]].
required_module = required_module->GetCycleRoot(isolate);

// 2. Assert: requiredModule.[[Status]] is "evaluated".
CHECK_GE(required_module->status(), kEvaluated);
Expand Down Expand Up @@ -1103,43 +1097,6 @@ MaybeHandle<Object> SourceTextModule::InnerModuleEvaluation(
return result;
}

Handle<SourceTextModule> SourceTextModule::GetAsyncCycleRoot(
Isolate* isolate, Handle<SourceTextModule> module) {
// 1. Assert: module.[[Status]] is "evaluated".
CHECK_GE(module->status(), kEvaluated);

// 2. If module.[[AsyncParentModules]] is an empty List, return module.
if (module->AsyncParentModuleCount() == 0) {
return module;
}

// 3. Repeat, while module.[[DFSIndex]] is greater than
// module.[[DFSAncestorIndex]],
while (module->dfs_index() > module->dfs_ancestor_index()) {
// a. Assert: module.[[AsyncParentModules]] is a non-empty List.
DCHECK_GT(module->AsyncParentModuleCount(), 0);

// b. Let nextCycleModule be the first element of
// module.[[AsyncParentModules]].
Handle<SourceTextModule> next_cycle_module =
module->GetAsyncParentModule(isolate, 0);

// c. Assert: nextCycleModule.[[DFSAncestorIndex]] is less than or equal
// to module.[[DFSAncestorIndex]].
DCHECK_LE(next_cycle_module->dfs_ancestor_index(),
module->dfs_ancestor_index());

// d. Set module to nextCycleModule
module = next_cycle_module;
}

// 4. Assert: module.[[DFSIndex]] is equal to module.[[DFSAncestorIndex]].
DCHECK_EQ(module->dfs_index(), module->dfs_ancestor_index());

// 5. Return module.
return module;
}

void SourceTextModule::Reset(Isolate* isolate,
Handle<SourceTextModule> module) {
Factory* factory = isolate->factory();
Expand Down
7 changes: 3 additions & 4 deletions deps/v8/src/objects/source-text-module.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class SourceTextModule
Handle<SourceTextModule> module,
Handle<SourceTextModule> parent);

// Get the non-hole cycle root. Only valid when status >= kEvaluated.
inline Handle<SourceTextModule> GetCycleRoot(Isolate* isolate) const;

// Returns a SourceTextModule, the
// ith parent in depth first traversal order of a given async child.
inline Handle<SourceTextModule> GetAsyncParentModule(Isolate* isolate,
Expand Down Expand Up @@ -163,10 +166,6 @@ class SourceTextModule
Isolate* isolate, Handle<SourceTextModule> module,
ZoneForwardList<Handle<SourceTextModule>>* stack, Status new_status);

// Implementation of spec GetAsyncCycleRoot.
static V8_WARN_UNUSED_RESULT Handle<SourceTextModule> GetAsyncCycleRoot(
Isolate* isolate, Handle<SourceTextModule> module);

// Implementation of spec ExecuteModule is broken up into
// InnerExecuteAsyncModule for asynchronous modules and ExecuteModule
// for synchronous modules.
Expand Down
5 changes: 5 additions & 0 deletions deps/v8/src/objects/source-text-module.tq
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ extern class SourceTextModule extends Module {
// a JSObject afterwards.
import_meta: TheHole|JSObject;

// The first visited module of a cycle. For modules not in a cycle, this is
// the module itself. It's the hole before the module state transitions to
// kEvaluated.
cycle_root: SourceTextModule|TheHole;

async_parent_modules: ArrayList;
top_level_capability: JSPromise|Undefined;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --harmony-top-level-await

import "modules-skip-async-cycle-start.mjs"

assertEquals(globalThis.test_order, [
'2', 'async before', 'async after', '1',
'3', 'start',
]);
14 changes: 14 additions & 0 deletions deps/v8/test/mjsunit/harmony/modules-skip-async-cycle-1.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --harmony-top-level-await

import "modules-skip-async-cycle-2.mjs";
import "modules-skip-async-cycle-leaf.mjs";

if (globalThis.test_order === undefined) {
globalThis.test_order = [];
}
globalThis.test_order.push('1');

12 changes: 12 additions & 0 deletions deps/v8/test/mjsunit/harmony/modules-skip-async-cycle-2.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --harmony-top-level-await

import "modules-skip-async-cycle-1.mjs";

if (globalThis.test_order === undefined) {
globalThis.test_order = [];
}
globalThis.test_order.push('2');
12 changes: 12 additions & 0 deletions deps/v8/test/mjsunit/harmony/modules-skip-async-cycle-3.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --harmony-top-level-await

import "modules-skip-async-cycle-2.mjs";

if (globalThis.test_order === undefined) {
globalThis.test_order = [];
}
globalThis.test_order.push('3');
13 changes: 13 additions & 0 deletions deps/v8/test/mjsunit/harmony/modules-skip-async-cycle-leaf.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --harmony-top-level-await

if (globalThis.test_order === undefined) {
globalThis.test_order = [];
}

globalThis.test_order.push('async before');
await 0;
globalThis.test_order.push('async after');
13 changes: 13 additions & 0 deletions deps/v8/test/mjsunit/harmony/modules-skip-async-cycle-start.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Flags: --harmony-top-level-await

import "modules-skip-async-cycle-1.mjs";
import "modules-skip-async-cycle-3.mjs";

if (globalThis.test_order === undefined) {
globalThis.test_order = [];
}
globalThis.test_order.push('start');