Skip to content

Commit 7cb6188

Browse files
thibaudmichaudV8 LUCI CQ
authored andcommitted
[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 <thibaudm@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/main@{#96637}
1 parent 47766a7 commit 7cb6188

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/wasm/function-body-decoder-impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3308,7 +3308,7 @@ class WasmFullDecoder : public WasmDecoder<ValidationTag, decoding_mode> {
33083308
}
33093309
if (catch_case.kind == kCatchRef || catch_case.kind == kCatchAllRef) {
33103310
stack_.EnsureMoreCapacity(1, this->zone_);
3311-
Push(kWasmExnRef);
3311+
Push(ValueType::Ref(HeapType::kExn));
33123312
push_count += 1;
33133313
}
33143314
Control* target = control_at(catch_case.br_imm.depth);
@@ -3534,7 +3534,7 @@ class WasmFullDecoder : public WasmDecoder<ValidationTag, decoding_mode> {
35343534
}
35353535
if (catch_case.kind == kCatchRef || catch_case.kind == kCatchAllRef) {
35363536
stack_.EnsureMoreCapacity(1, this->zone_);
3537-
Push(kWasmExnRef);
3537+
Push(ValueType::Ref(HeapType::kExn));
35383538
push_count += 1;
35393539
}
35403540
base::Vector<Value> values(

src/wasm/graph-builder-interface.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ class WasmGraphBuildingInterface {
14061406

14071407
if (catch_case.kind == kCatchAll || catch_case.kind == kCatchAllRef) {
14081408
if (catch_case.kind == kCatchAllRef) {
1409-
DCHECK_EQ(values[0].type, kWasmExnRef);
1409+
DCHECK_EQ(values[0].type, ValueType::Ref(HeapType::kExn));
14101410
values[0].node = block->try_info->exception;
14111411
}
14121412
BrOrRet(decoder, catch_case.br_imm.depth);
@@ -1473,7 +1473,7 @@ class WasmGraphBuildingInterface {
14731473
}
14741474

14751475
if (catch_case.kind == kCatchRef) {
1476-
DCHECK_EQ(values.last().type, kWasmExnRef);
1476+
DCHECK_EQ(values.last().type, ValueType::Ref(HeapType::kExn));
14771477
values.last().node = block->try_info->exception;
14781478
}
14791479
BrOrRet(decoder, catch_case.br_imm.depth);

test/unittests/wasm/function-body-decoder-unittest.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2997,20 +2997,29 @@ TEST_F(FunctionBodyDecoderTest, TryTable) {
29972997
U32V_1(1), CatchKind::kCatchAllRef, U32V_1(0), kExprEnd,
29982998
kExprUnreachable, kExprEnd, kExprDrop},
29992999
kAppendEnd);
3000-
// // Duplicate catch-all.
3000+
// Duplicate catch-all.
30013001
ExpectValidates(
30023002
sigs.v_v(),
30033003
{kExprBlock, kExnRefCode, WASM_TRY_TABLE_OP, U32V_1(4),
30043004
CatchKind::kCatchAll, U32V_1(1), CatchKind::kCatchAll, U32V_1(1),
30053005
CatchKind::kCatchAllRef, U32V_1(0), CatchKind::kCatchAllRef, U32V_1(0),
30063006
kExprEnd, kExprUnreachable, kExprEnd, kExprDrop},
30073007
kAppendEnd);
3008-
// // Catch-all before catch.
3008+
// Catch-all before catch.
30093009
ExpectValidates(
30103010
sigs.v_v(),
30113011
{WASM_TRY_TABLE_OP, U32V_1(2), CatchKind::kCatchAll, U32V_1(0),
30123012
CatchKind::kCatch, ex, U32V_1(0), kExprEnd, kExprUnreachable},
30133013
kAppendEnd);
3014+
// Non-nullable exnref.
3015+
ValueType kNonNullableExnRef = ValueType::Ref(HeapType::kExn);
3016+
auto sig = FixedSizeSignature<ValueType>::Returns(kNonNullableExnRef);
3017+
uint8_t sig_id = builder.AddSignature(&sig);
3018+
ExpectValidates(
3019+
sigs.v_v(),
3020+
{kExprBlock, sig_id, WASM_TRY_TABLE_OP, U32V_1(1), CatchKind::kCatchRef,
3021+
ex, U32V_1(0), kExprEnd, kExprUnreachable, kExprEnd, kExprDrop},
3022+
kAppendEnd);
30143023

30153024
constexpr uint8_t kInvalidCatchKind = kLastCatchKind + 1;
30163025
ExpectFailure(sigs.v_v(),

0 commit comments

Comments
 (0)