Skip to content

Commit 8b8f77b

Browse files
committed
Detect missing legacy exception handling support
1 parent beac8e9 commit 8b8f77b

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

wasm/src/org.graalvm.wasm.test/src/org/graalvm/wasm/test/suites/validation/ValidationSuite.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ public static Collection<Object[]> data() {
968968
null),
969969

970970
binaryCase("Invalid instruction",
971-
"Unknown opcode: 0x06",
971+
"Legacy exception handling is not supported (opcode: 0x06)",
972972

973973
// (module
974974
// (func

wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/BinaryParser.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,14 @@ private CodeEntry readFunction(int functionIndex, int[] locals, int sourceCodeEn
996996
state.setUnreachable();
997997
break;
998998
}
999+
case Instructions.TRY:
1000+
case Instructions.RETHROW:
1001+
case Instructions.CATCH:
1002+
case Instructions.DELEGATE:
1003+
case Instructions.CATCH_ALL: {
1004+
checkLegacyExceptionHandlingSupport(opcode);
1005+
break;
1006+
}
9991007
case Instructions.LOCAL_GET: {
10001008
final int localIndex = readLocalIndex();
10011009
assertUnsignedIntLess(localIndex, locals.length, Failure.UNKNOWN_LOCAL);
@@ -2805,6 +2813,10 @@ private void checkRelaxedSIMDSupport(int vectorOpcode) {
28052813
checkContextOption(wasmContext.getContextOptions().supportRelaxedSIMD(), "Relaxed vector instructions are not enabled (opcode: 0x%02x 0x%x)", Instructions.VECTOR, vectorOpcode);
28062814
}
28072815

2816+
private static void checkLegacyExceptionHandlingSupport(int opcode) {
2817+
Assert.fail(Failure.UNSPECIFIED_MALFORMED, "Legacy exception handling is not supported (opcode: 0x%02x)", opcode);
2818+
}
2819+
28082820
private void checkExceptionHandlingSupport(int opcode) {
28092821
checkContextOption(wasmContext.getContextOptions().supportExceptions(), "Exception handling is not enabled (opcode: 0x%02x)", opcode);
28102822
}

wasm/src/org.graalvm.wasm/src/org/graalvm/wasm/constants/Instructions.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public final class Instructions {
5454
public static final int IF = 0x04;
5555
public static final int ELSE = 0x05;
5656

57+
public static final int TRY = 0x06;
58+
public static final int CATCH = 0x07;
5759
public static final int THROW = 0x08;
60+
public static final int RETHROW = 0x09;
5861
public static final int THROW_REF = 0x0A;
5962

6063
public static final int END = 0x0B;
@@ -68,6 +71,9 @@ public final class Instructions {
6871
public static final int CALL_INDIRECT = 0x11;
6972
public static final int CALL_REF = 0x14;
7073

74+
public static final int DELEGATE = 0x18;
75+
public static final int CATCH_ALL = 0x19;
76+
7177
public static final int DROP = 0x1A;
7278
public static final int SELECT = 0x1B;
7379
public static final int SELECT_T = 0x1C;

0 commit comments

Comments
 (0)