From 2268567237ed30b22f85f366b063f21b2ef8a2fd Mon Sep 17 00:00:00 2001 From: Thibaud Michaud Date: Wed, 16 Oct 2024 18:28:30 +0200 Subject: [PATCH] deps: V8: cherry-pick 7cb6188cf913 Original commit message: [wasm][exnref] Accept non-nullable exn catch type R=jkummerow@chromium.org Fixed: 373681572 Change-Id: Iecfc86d2ce6592a6f442bc3504ddde58ff236f64 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5938956 Commit-Queue: Thibaud Michaud Reviewed-by: Jakob Kummerow Cr-Commit-Position: refs/heads/main@{#96637} Refs: https://github.com/v8/v8/commit/7cb6188cf9132d43e6c631befb0584a47a0e7d69 PR-URL: https://github.com/nodejs/node/pull/62783 Reviewed-By: Xuguang Mei Reviewed-By: James M Snell --- common.gypi | 2 +- deps/v8/src/wasm/function-body-decoder-impl.h | 4 ++-- deps/v8/src/wasm/graph-builder-interface.cc | 4 ++-- .../wasm/function-body-decoder-unittest.cc | 13 +++++++++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/common.gypi b/common.gypi index 19e3cb8b101..7bf76ad7048 100644 --- a/common.gypi +++ b/common.gypi @@ -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.51', + 'v8_embedder_string': '-node.52', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/wasm/function-body-decoder-impl.h b/deps/v8/src/wasm/function-body-decoder-impl.h index 5df75d84d13..290660104a5 100644 --- a/deps/v8/src/wasm/function-body-decoder-impl.h +++ b/deps/v8/src/wasm/function-body-decoder-impl.h @@ -3280,7 +3280,7 @@ class WasmFullDecoder : public WasmDecoder { } if (catch_case.kind == kCatchRef || catch_case.kind == kCatchAllRef) { stack_.EnsureMoreCapacity(1, this->zone_); - Push(kWasmExnRef); + Push(ValueType::Ref(HeapType::kExn)); push_count += 1; } Control* target = control_at(catch_case.br_imm.depth); @@ -3506,7 +3506,7 @@ class WasmFullDecoder : public WasmDecoder { } if (catch_case.kind == kCatchRef || catch_case.kind == kCatchAllRef) { stack_.EnsureMoreCapacity(1, this->zone_); - Push(kWasmExnRef); + Push(ValueType::Ref(HeapType::kExn)); push_count += 1; } base::Vector values( diff --git a/deps/v8/src/wasm/graph-builder-interface.cc b/deps/v8/src/wasm/graph-builder-interface.cc index 458d8d859c2..96a9acb3419 100644 --- a/deps/v8/src/wasm/graph-builder-interface.cc +++ b/deps/v8/src/wasm/graph-builder-interface.cc @@ -1406,7 +1406,7 @@ class WasmGraphBuildingInterface { if (catch_case.kind == kCatchAll || catch_case.kind == kCatchAllRef) { if (catch_case.kind == kCatchAllRef) { - DCHECK_EQ(values[0].type, kWasmExnRef); + DCHECK_EQ(values[0].type, ValueType::Ref(HeapType::kExn)); values[0].node = block->try_info->exception; } BrOrRet(decoder, catch_case.br_imm.depth); @@ -1473,7 +1473,7 @@ class WasmGraphBuildingInterface { } if (catch_case.kind == kCatchRef) { - DCHECK_EQ(values.last().type, kWasmExnRef); + DCHECK_EQ(values.last().type, ValueType::Ref(HeapType::kExn)); values.last().node = block->try_info->exception; } BrOrRet(decoder, catch_case.br_imm.depth); diff --git a/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc b/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc index 873b855bb4d..2e7979a4e9f 100644 --- a/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc +++ b/deps/v8/test/unittests/wasm/function-body-decoder-unittest.cc @@ -2994,7 +2994,7 @@ TEST_F(FunctionBodyDecoderTest, TryTable) { U32V_1(1), CatchKind::kCatchAllRef, U32V_1(0), kExprEnd, kExprUnreachable, kExprEnd, kExprDrop}, kAppendEnd); - // // Duplicate catch-all. + // Duplicate catch-all. ExpectValidates( sigs.v_v(), {kExprBlock, kExnRefCode, WASM_TRY_TABLE_OP, U32V_1(4), @@ -3002,12 +3002,21 @@ TEST_F(FunctionBodyDecoderTest, TryTable) { CatchKind::kCatchAllRef, U32V_1(0), CatchKind::kCatchAllRef, U32V_1(0), kExprEnd, kExprUnreachable, kExprEnd, kExprDrop}, kAppendEnd); - // // Catch-all before catch. + // Catch-all before catch. ExpectValidates( sigs.v_v(), {WASM_TRY_TABLE_OP, U32V_1(2), CatchKind::kCatchAll, U32V_1(0), CatchKind::kCatch, ex, U32V_1(0), kExprEnd, kExprUnreachable}, kAppendEnd); + // Non-nullable exnref. + ValueType kNonNullableExnRef = ValueType::Ref(HeapType::kExn); + auto sig = FixedSizeSignature::Returns(kNonNullableExnRef); + uint8_t sig_id = builder.AddSignature(&sig); + ExpectValidates( + sigs.v_v(), + {kExprBlock, sig_id, WASM_TRY_TABLE_OP, U32V_1(1), CatchKind::kCatchRef, + ex, U32V_1(0), kExprEnd, kExprUnreachable, kExprEnd, kExprDrop}, + kAppendEnd); constexpr uint8_t kInvalidCatchKind = kLastCatchKind + 1; ExpectFailure(sigs.v_v(),