Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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.48',
'v8_embedder_string': '-node.49',

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

Expand Down
9 changes: 6 additions & 3 deletions deps/v8/src/maglev/maglev-graph-builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ NodeType StaticTypeForNode(compiler::JSHeapBroker* broker,
struct CatchBlockDetails {
BasicBlockRef* ref = nullptr;
bool exception_handler_was_used = false;
bool block_already_exists = false;
int deopt_frame_distance = 0;
};

Expand Down Expand Up @@ -1220,7 +1221,8 @@ class MaglevGraphBuilder {
}

DCHECK_IMPLIES(!IsInsideTryBlock(), is_inline());
if (!IsInsideTryBlock() && !is_eager_inline()) {
if (catch_block.block_already_exists) {
DCHECK(!IsInsideTryBlock());
// If we are inlining a function non-eagerly and we are not inside a
// try block, then the catch block already exists.
new (node->exception_handler_info()) ExceptionHandlerInfo(
Expand Down Expand Up @@ -1276,7 +1278,7 @@ class MaglevGraphBuilder {
// Inside a try-block.
int offset = catch_block_stack_.top().handler;
return {&jump_targets_[offset],
merge_states_[offset]->exception_handler_was_used(), 0};
merge_states_[offset]->exception_handler_was_used(), false, 0};
}
if (!is_inline()) {
return CatchBlockDetails{};
Expand All @@ -1286,7 +1288,8 @@ class MaglevGraphBuilder {

CatchBlockDetails GetTryCatchBlockFromInfo(ExceptionHandlerInfo* info) {
if (IsInsideTryBlock()) {
return {info->catch_block_ref_address(), !info->ShouldLazyDeopt(), 0};
return {info->catch_block_ref_address(), !info->ShouldLazyDeopt(), true,
0};
}
if (!is_inline()) {
return CatchBlockDetails{};
Expand Down
36 changes: 36 additions & 0 deletions deps/v8/test/mjsunit/regress-417768368.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2025 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: --allow-natives-syntax

function bar(a) {
function in_bar(a, b) {
a % b; // This emit a generic mod that can throw.
return a;
}
%PrepareFunctionForOptimization(in_bar);
in_bar({});
if (a) {
throw_before_this_function_is_not_defined();
}
}

function foo() {
try {
function const_42() {
return 42;
}
%PrepareFunctionForOptimization(const_42);
const_42();
bar(true);
} catch {
}
}

%PrepareFunctionForOptimization(bar);
%PrepareFunctionForOptimization(foo);
foo();

%OptimizeMaglevOnNextCall(foo);
foo();
Loading