Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: test/unittests/wasm/function-body-decoder-unittest.cc

Issue 2670673002: [wasm] Implement polymorphic checking, matching the reference interpreter. (Closed)
Patch Set: Fix test-run-simd Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/wasm/unreachable-validation.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/wasm/function-body-decoder-unittest.cc
diff --git a/test/unittests/wasm/function-body-decoder-unittest.cc b/test/unittests/wasm/function-body-decoder-unittest.cc
index 14a74f7b22721a41d8f8a58fb7755505cefee68a..82fdaf986699589205b47fa2dd14f6fda0f6c946 100644
--- a/test/unittests/wasm/function-body-decoder-unittest.cc
+++ b/test/unittests/wasm/function-body-decoder-unittest.cc
@@ -671,7 +671,7 @@ TEST_F(FunctionBodyDecoderTest, Block3_continue) {
}
TEST_F(FunctionBodyDecoderTest, NestedBlock_return) {
- EXPECT_VERIFIES(i_i, B1(B1(WASM_RETURN1(WASM_ZERO))));
+ EXPECT_VERIFIES(i_i, B1(B1(WASM_RETURN1(WASM_ZERO))), WASM_ZERO);
}
TEST_F(FunctionBodyDecoderTest, BlockBrBinop) {
@@ -861,13 +861,18 @@ TEST_F(FunctionBodyDecoderTest, Loop2_break) {
EXPECT_VERIFIES(v_i, WASM_LOOP(WASM_SET_LOCAL(0, WASM_ZERO), WASM_BR(1)));
}
-TEST_F(FunctionBodyDecoderTest, InfiniteLoop) {
- EXPECT_VERIFIES(i_i, WASM_LOOP(WASM_BR(0)));
- EXPECT_VERIFIES(i_i, WASM_LOOP(WASM_BRV(1, WASM_ZERO)));
+TEST_F(FunctionBodyDecoderTest, InfiniteLoop1) {
+ EXPECT_VERIFIES(i_i, WASM_LOOP(WASM_BR(0)), WASM_ZERO);
+ EXPECT_VERIFIES(i_i, WASM_LOOP(WASM_BR(0)), WASM_ZERO);
+ EXPECT_VERIFIES(i_i, WASM_LOOP_I(WASM_BRV(1, WASM_ZERO)));
+}
+
+TEST_F(FunctionBodyDecoderTest, InfiniteLoop2) {
+ EXPECT_FAILURE(i_i, WASM_LOOP(WASM_BR(0), WASM_ZERO), WASM_ZERO);
}
TEST_F(FunctionBodyDecoderTest, Loop2_unreachable) {
- EXPECT_VERIFIES(i_i, WASM_LOOP(WASM_BR(0), WASM_NOP));
+ EXPECT_VERIFIES(i_i, WASM_LOOP_I(WASM_BR(0), WASM_NOP));
}
TEST_F(FunctionBodyDecoderTest, LoopType) {
@@ -926,25 +931,45 @@ TEST_F(FunctionBodyDecoderTest, ReturnVoid3) {
}
TEST_F(FunctionBodyDecoderTest, Unreachable1) {
- EXPECT_VERIFIES(v_v, kExprUnreachable);
- EXPECT_VERIFIES(v_v, kExprUnreachable, kExprUnreachable);
- EXPECT_VERIFIES(v_v, B2(WASM_UNREACHABLE, WASM_ZERO));
- EXPECT_VERIFIES(v_v, B2(WASM_BR(0), WASM_ZERO));
- EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_UNREACHABLE, WASM_ZERO));
- EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_BR(0), WASM_ZERO));
+ EXPECT_VERIFIES(v_v, WASM_UNREACHABLE);
+ EXPECT_VERIFIES(v_v, WASM_UNREACHABLE, WASM_UNREACHABLE);
+ EXPECT_VERIFIES(i_i, WASM_UNREACHABLE, WASM_ZERO);
+}
+
+TEST_F(FunctionBodyDecoderTest, Unreachable2) {
+ EXPECT_FAILURE(v_v, B2(WASM_UNREACHABLE, WASM_ZERO));
+ EXPECT_FAILURE(v_v, B2(WASM_BR(0), WASM_ZERO));
}
-TEST_F(FunctionBodyDecoderTest, Unreachable_binop) {
+TEST_F(FunctionBodyDecoderTest, UnreachableLoop1) {
+ EXPECT_FAILURE(v_v, WASM_LOOP(WASM_UNREACHABLE, WASM_ZERO));
+ EXPECT_FAILURE(v_v, WASM_LOOP(WASM_BR(0), WASM_ZERO));
+ EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_UNREACHABLE, WASM_NOP));
+ EXPECT_VERIFIES(v_v, WASM_LOOP(WASM_BR(0), WASM_NOP));
+}
+
+TEST_F(FunctionBodyDecoderTest, Unreachable_binop1) {
EXPECT_VERIFIES(i_i, WASM_I32_AND(WASM_ZERO, WASM_UNREACHABLE));
EXPECT_VERIFIES(i_i, WASM_I32_AND(WASM_UNREACHABLE, WASM_ZERO));
}
-TEST_F(FunctionBodyDecoderTest, Unreachable_select) {
+TEST_F(FunctionBodyDecoderTest, Unreachable_binop2) {
+ EXPECT_VERIFIES(i_i, WASM_I32_AND(WASM_F32(0.0), WASM_UNREACHABLE));
+ EXPECT_FAILURE(i_i, WASM_I32_AND(WASM_UNREACHABLE, WASM_F32(0.0)));
+}
+
+TEST_F(FunctionBodyDecoderTest, Unreachable_select1) {
EXPECT_VERIFIES(i_i, WASM_SELECT(WASM_UNREACHABLE, WASM_ZERO, WASM_ZERO));
EXPECT_VERIFIES(i_i, WASM_SELECT(WASM_ZERO, WASM_UNREACHABLE, WASM_ZERO));
EXPECT_VERIFIES(i_i, WASM_SELECT(WASM_ZERO, WASM_ZERO, WASM_UNREACHABLE));
}
+TEST_F(FunctionBodyDecoderTest, Unreachable_select2) {
+ EXPECT_VERIFIES(i_i, WASM_SELECT(WASM_F32(0.0), WASM_UNREACHABLE, WASM_ZERO));
+ EXPECT_FAILURE(i_i, WASM_SELECT(WASM_UNREACHABLE, WASM_F32(0.0), WASM_ZERO));
+ EXPECT_FAILURE(i_i, WASM_SELECT(WASM_UNREACHABLE, WASM_ZERO, WASM_F32(0.0)));
+}
+
TEST_F(FunctionBodyDecoderTest, If1) {
EXPECT_VERIFIES(
i_i, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_I32V_1(9), WASM_I32V_1(8)));
@@ -2133,15 +2158,20 @@ TEST_F(FunctionBodyDecoderTest, BrTable_invalid_br2) {
}
}
-TEST_F(FunctionBodyDecoderTest, BrUnreachable) {
- static byte code[] = {WASM_GET_LOCAL(0), kExprBrTable, 0,
- BR_TARGET(0), kExprSetLocal, 0};
- EXPECT_VERIFIES_C(v_i, code);
+TEST_F(FunctionBodyDecoderTest, BrUnreachable1) {
+ EXPECT_VERIFIES(v_i, WASM_GET_LOCAL(0), kExprBrTable, 0, BR_TARGET(0));
+}
+
+TEST_F(FunctionBodyDecoderTest, BrUnreachable2) {
+ EXPECT_VERIFIES(v_i, WASM_GET_LOCAL(0), kExprBrTable, 0, BR_TARGET(0),
+ WASM_NOP);
+ EXPECT_FAILURE(v_i, WASM_GET_LOCAL(0), kExprBrTable, 0, BR_TARGET(0),
+ WASM_ZERO);
}
TEST_F(FunctionBodyDecoderTest, Brv1) {
EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_BRV(0, WASM_ZERO)));
- EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_LOOP(WASM_BRV(2, WASM_ZERO))));
+ EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_LOOP_I(WASM_BRV(2, WASM_ZERO))));
}
TEST_F(FunctionBodyDecoderTest, Brv1_type) {
« no previous file with comments | « test/mjsunit/wasm/unreachable-validation.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698