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

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

Issue 2646093003: [wasm] Unreachability fix for br_table. (Closed)
Patch Set: [wasm] Unreachability fix for br_table. 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 unified diff | Download patch
« no previous file with comments | « src/wasm/function-body-decoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "test/unittests/test-utils.h" 5 #include "test/unittests/test-utils.h"
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "test/common/wasm/test-signatures.h" 9 #include "test/common/wasm/test-signatures.h"
10 10
(...skipping 2115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 byte code[] = { 2126 byte code[] = {
2127 WASM_LOOP(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(depth)))}; 2127 WASM_LOOP(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(depth)))};
2128 if (depth < 2) { 2128 if (depth < 2) {
2129 EXPECT_VERIFIES_C(v_i, code); 2129 EXPECT_VERIFIES_C(v_i, code);
2130 } else { 2130 } else {
2131 EXPECT_FAILURE_C(v_i, code); 2131 EXPECT_FAILURE_C(v_i, code);
2132 } 2132 }
2133 } 2133 }
2134 } 2134 }
2135 2135
2136 TEST_F(FunctionBodyDecoderTest, BrUnreachable) {
2137 static byte code[] = {WASM_GET_LOCAL(0), kExprBrTable, 0,
2138 BR_TARGET(0), kExprSetLocal, 0};
2139 EXPECT_VERIFIES_C(v_i, code);
2140 }
2141
2136 TEST_F(FunctionBodyDecoderTest, Brv1) { 2142 TEST_F(FunctionBodyDecoderTest, Brv1) {
2137 EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_BRV(0, WASM_ZERO))); 2143 EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_BRV(0, WASM_ZERO)));
2138 EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_LOOP(WASM_BRV(2, WASM_ZERO)))); 2144 EXPECT_VERIFIES(i_i, WASM_BLOCK_I(WASM_LOOP(WASM_BRV(2, WASM_ZERO))));
2139 } 2145 }
2140 2146
2141 TEST_F(FunctionBodyDecoderTest, Brv1_type) { 2147 TEST_F(FunctionBodyDecoderTest, Brv1_type) {
2142 EXPECT_VERIFIES(i_ii, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0)))); 2148 EXPECT_VERIFIES(i_ii, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0))));
2143 EXPECT_VERIFIES(l_ll, WASM_BLOCK_L(WASM_BRV(0, WASM_GET_LOCAL(0)))); 2149 EXPECT_VERIFIES(l_ll, WASM_BLOCK_L(WASM_BRV(0, WASM_GET_LOCAL(0))));
2144 EXPECT_VERIFIES(f_ff, WASM_BLOCK_F(WASM_BRV(0, WASM_GET_LOCAL(0)))); 2150 EXPECT_VERIFIES(f_ff, WASM_BLOCK_F(WASM_BRV(0, WASM_GET_LOCAL(0))));
2145 EXPECT_VERIFIES(d_dd, WASM_BLOCK_D(WASM_BRV(0, WASM_GET_LOCAL(0)))); 2151 EXPECT_VERIFIES(d_dd, WASM_BLOCK_D(WASM_BRV(0, WASM_GET_LOCAL(0))));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 2224
2219 TEST_F(FunctionBodyDecoderTest, Throw) { 2225 TEST_F(FunctionBodyDecoderTest, Throw) {
2220 FLAG_wasm_eh_prototype = true; 2226 FLAG_wasm_eh_prototype = true;
2221 EXPECT_VERIFIES(v_i, WASM_GET_LOCAL(0), kExprThrow); 2227 EXPECT_VERIFIES(v_i, WASM_GET_LOCAL(0), kExprThrow);
2222 2228
2223 EXPECT_FAILURE(i_d, WASM_GET_LOCAL(0), kExprThrow, WASM_I32V(0)); 2229 EXPECT_FAILURE(i_d, WASM_GET_LOCAL(0), kExprThrow, WASM_I32V(0));
2224 EXPECT_FAILURE(i_f, WASM_GET_LOCAL(0), kExprThrow, WASM_I32V(0)); 2230 EXPECT_FAILURE(i_f, WASM_GET_LOCAL(0), kExprThrow, WASM_I32V(0));
2225 EXPECT_FAILURE(l_l, WASM_GET_LOCAL(0), kExprThrow, WASM_I64V(0)); 2231 EXPECT_FAILURE(l_l, WASM_GET_LOCAL(0), kExprThrow, WASM_I64V(0));
2226 } 2232 }
2227 2233
2234 TEST_F(FunctionBodyDecoderTest, ThrowUnreachable) {
2235 // TODO(titzer): unreachable code after throw should validate.
2236 // FLAG_wasm_eh_prototype = true;
2237 // EXPECT_VERIFIES(v_i, WASM_GET_LOCAL(0), kExprThrow, kExprSetLocal, 0);
2238 }
2239
2228 #define WASM_TRY_OP kExprTry, kLocalVoid 2240 #define WASM_TRY_OP kExprTry, kLocalVoid
2229 2241
2230 #define WASM_CATCH(local) kExprCatch, static_cast<byte>(local) 2242 #define WASM_CATCH(local) kExprCatch, static_cast<byte>(local)
2231 2243
2232 TEST_F(FunctionBodyDecoderTest, TryCatch) { 2244 TEST_F(FunctionBodyDecoderTest, TryCatch) {
2233 FLAG_wasm_eh_prototype = true; 2245 FLAG_wasm_eh_prototype = true;
2234 EXPECT_VERIFIES(v_i, WASM_TRY_OP, WASM_CATCH(0), kExprEnd); 2246 EXPECT_VERIFIES(v_i, WASM_TRY_OP, WASM_CATCH(0), kExprEnd);
2235 2247
2236 // Missing catch. 2248 // Missing catch.
2237 EXPECT_FAILURE(v_v, WASM_TRY_OP, kExprEnd); 2249 EXPECT_FAILURE(v_v, WASM_TRY_OP, kExprEnd);
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
2765 iter.next(); 2777 iter.next();
2766 EXPECT_TRUE(iter.has_next()); 2778 EXPECT_TRUE(iter.has_next());
2767 EXPECT_EQ(kExprI32Const, iter.current()); 2779 EXPECT_EQ(kExprI32Const, iter.current());
2768 iter.next(); 2780 iter.next();
2769 EXPECT_FALSE(iter.has_next()); 2781 EXPECT_FALSE(iter.has_next());
2770 } 2782 }
2771 2783
2772 } // namespace wasm 2784 } // namespace wasm
2773 } // namespace internal 2785 } // namespace internal
2774 } // namespace v8 2786 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/function-body-decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698