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

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

Issue 2336303002: [V8][Wasm] Removes references to finally in wasm. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates comment Created 4 years, 3 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/wasm-opcodes.h ('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/cctest/wasm/test-signatures.h" 9 #include "test/cctest/wasm/test-signatures.h"
10 10
(...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 WASM_I32V(0)); 1996 WASM_I32V(0));
1997 EXPECT_FAILURE_INLINE(sigs.i_f(), WASM_GET_LOCAL(0), kExprThrow, 1997 EXPECT_FAILURE_INLINE(sigs.i_f(), WASM_GET_LOCAL(0), kExprThrow,
1998 WASM_I32V(0)); 1998 WASM_I32V(0));
1999 EXPECT_FAILURE_INLINE(sigs.l_l(), WASM_GET_LOCAL(0), kExprThrow, 1999 EXPECT_FAILURE_INLINE(sigs.l_l(), WASM_GET_LOCAL(0), kExprThrow,
2000 WASM_I64V(0)); 2000 WASM_I64V(0));
2001 } 2001 }
2002 2002
2003 #define WASM_CATCH(local) kExprCatch, static_cast<byte>(local) 2003 #define WASM_CATCH(local) kExprCatch, static_cast<byte>(local)
2004 TEST_F(AstDecoderTest, TryCatch) { 2004 TEST_F(AstDecoderTest, TryCatch) {
2005 FLAG_wasm_eh_prototype = true; 2005 FLAG_wasm_eh_prototype = true;
2006 EXPECT_VERIFIES_INLINE(sigs.v_i(), kExprTryCatch, WASM_CATCH(0), kExprEnd); 2006 EXPECT_VERIFIES_INLINE(sigs.v_i(), kExprTry, WASM_CATCH(0), kExprEnd);
2007 2007
2008 // Missing catch. 2008 // Missing catch.
2009 EXPECT_FAILURE_INLINE(sigs.v_v(), kExprTryCatch, kExprEnd); 2009 EXPECT_FAILURE_INLINE(sigs.v_v(), kExprTry, kExprEnd);
2010 2010
2011 // Missing end. 2011 // Missing end.
2012 EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatch, WASM_CATCH(0)); 2012 EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTry, WASM_CATCH(0));
2013 2013
2014 // Double catch. 2014 // Double catch.
2015 EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatch, WASM_CATCH(0), WASM_CATCH(0), 2015 EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTry, WASM_CATCH(0), WASM_CATCH(0),
2016 kExprEnd);
2017
2018 // Unexpected finally.
2019 EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatch, WASM_CATCH(0), kExprFinally,
2020 kExprEnd); 2016 kExprEnd);
2021 } 2017 }
2022 2018
2023 TEST_F(AstDecoderTest, TryFinally) {
2024 FLAG_wasm_eh_prototype = true;
2025 EXPECT_VERIFIES_INLINE(sigs.v_v(), kExprTryFinally, kExprFinally, kExprEnd);
2026
2027 // Mising finally.
2028 EXPECT_FAILURE_INLINE(sigs.v_v(), kExprTryFinally, kExprEnd);
2029
2030 // Missing end.
2031 EXPECT_FAILURE_INLINE(sigs.v_v(), kExprTryFinally, kExprFinally);
2032
2033 // Double finally.
2034 EXPECT_FAILURE_INLINE(sigs.v_v(), kExprTryFinally, kExprFinally, kExprFinally,
2035 kExprEnd);
2036
2037 // Unexpected catch.
2038 EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatch, WASM_CATCH(0), kExprFinally,
2039 kExprEnd);
2040 }
2041
2042 TEST_F(AstDecoderTest, TryCatchFinally) {
2043 FLAG_wasm_eh_prototype = true;
2044 EXPECT_VERIFIES_INLINE(sigs.v_i(), kExprTryCatchFinally, WASM_CATCH(0),
2045 kExprFinally, kExprEnd);
2046
2047 // Missing catch.
2048 EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, kExprFinally,
2049 kExprEnd);
2050
2051 // Double catch.
2052 EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, WASM_CATCH(0),
2053 WASM_CATCH(0), kExprFinally, kExprEnd);
2054
2055 // Missing finally.
2056 EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, WASM_CATCH(0),
2057 kExprEnd);
2058
2059 // Double finally.
2060 EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, WASM_CATCH(0),
2061 kExprFinally, kExprFinally, kExprEnd);
2062
2063 // Finally before catch.
2064 EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, kExprFinally,
2065 WASM_CATCH(0), kExprEnd);
2066
2067 // Missing both try and finally.
2068 EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, kExprEnd);
2069
2070 // Missing end.
2071 EXPECT_FAILURE_INLINE(sigs.v_i(), kExprTryCatchFinally, WASM_CATCH(0),
2072 kExprFinally);
2073 }
2074
2075 class WasmOpcodeLengthTest : public TestWithZone { 2019 class WasmOpcodeLengthTest : public TestWithZone {
2076 public: 2020 public:
2077 WasmOpcodeLengthTest() : TestWithZone() {} 2021 WasmOpcodeLengthTest() : TestWithZone() {}
2078 }; 2022 };
2079 2023
2080 #define EXPECT_LENGTH(expected, opcode) \ 2024 #define EXPECT_LENGTH(expected, opcode) \
2081 { \ 2025 { \
2082 static const byte code[] = {opcode, 0, 0, 0, 0, 0, 0, 0, 0}; \ 2026 static const byte code[] = {opcode, 0, 0, 0, 0, 0, 0, 0, 0}; \
2083 EXPECT_EQ(expected, OpcodeLength(code, code + sizeof(code))); \ 2027 EXPECT_EQ(expected, OpcodeLength(code, code + sizeof(code))); \
2084 } 2028 }
2085 2029
2086 #define EXPECT_LENGTH_N(expected, ...) \ 2030 #define EXPECT_LENGTH_N(expected, ...) \
2087 { \ 2031 { \
2088 static const byte code[] = {__VA_ARGS__}; \ 2032 static const byte code[] = {__VA_ARGS__}; \
2089 EXPECT_EQ(expected, OpcodeLength(code, code + sizeof(code))); \ 2033 EXPECT_EQ(expected, OpcodeLength(code, code + sizeof(code))); \
2090 } 2034 }
2091 2035
2092 TEST_F(WasmOpcodeLengthTest, Statements) { 2036 TEST_F(WasmOpcodeLengthTest, Statements) {
2093 EXPECT_LENGTH(1, kExprNop); 2037 EXPECT_LENGTH(1, kExprNop);
2094 EXPECT_LENGTH(1, kExprBlock); 2038 EXPECT_LENGTH(1, kExprBlock);
2095 EXPECT_LENGTH(1, kExprLoop); 2039 EXPECT_LENGTH(1, kExprLoop);
2096 EXPECT_LENGTH(1, kExprIf); 2040 EXPECT_LENGTH(1, kExprIf);
2097 EXPECT_LENGTH(1, kExprElse); 2041 EXPECT_LENGTH(1, kExprElse);
2098 EXPECT_LENGTH(1, kExprEnd); 2042 EXPECT_LENGTH(1, kExprEnd);
2099 EXPECT_LENGTH(1, kExprSelect); 2043 EXPECT_LENGTH(1, kExprSelect);
2100 EXPECT_LENGTH(3, kExprBr); 2044 EXPECT_LENGTH(3, kExprBr);
2101 EXPECT_LENGTH(3, kExprBrIf); 2045 EXPECT_LENGTH(3, kExprBrIf);
2102 EXPECT_LENGTH(1, kExprThrow); 2046 EXPECT_LENGTH(1, kExprThrow);
2103 EXPECT_LENGTH(1, kExprTryCatch); 2047 EXPECT_LENGTH(1, kExprTry);
2104 EXPECT_LENGTH(1, kExprTryFinally);
2105 EXPECT_LENGTH(1, kExprTryCatchFinally);
2106 EXPECT_LENGTH(2, kExprCatch); 2048 EXPECT_LENGTH(2, kExprCatch);
2107 EXPECT_LENGTH(1, kExprFinally);
2108 } 2049 }
2109 2050
2110 TEST_F(WasmOpcodeLengthTest, MiscExpressions) { 2051 TEST_F(WasmOpcodeLengthTest, MiscExpressions) {
2111 EXPECT_LENGTH(2, kExprI8Const); 2052 EXPECT_LENGTH(2, kExprI8Const);
2112 EXPECT_LENGTH(5, kExprF32Const); 2053 EXPECT_LENGTH(5, kExprF32Const);
2113 EXPECT_LENGTH(9, kExprF64Const); 2054 EXPECT_LENGTH(9, kExprF64Const);
2114 EXPECT_LENGTH(2, kExprGetLocal); 2055 EXPECT_LENGTH(2, kExprGetLocal);
2115 EXPECT_LENGTH(2, kExprSetLocal); 2056 EXPECT_LENGTH(2, kExprSetLocal);
2116 EXPECT_LENGTH(2, kExprGetGlobal); 2057 EXPECT_LENGTH(2, kExprGetGlobal);
2117 EXPECT_LENGTH(2, kExprSetGlobal); 2058 EXPECT_LENGTH(2, kExprSetGlobal);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 EXPECT_ARITY(1, kExprBr, ARITY_1); 2282 EXPECT_ARITY(1, kExprBr, ARITY_1);
2342 EXPECT_ARITY(2, kExprBrIf, ARITY_1); 2283 EXPECT_ARITY(2, kExprBrIf, ARITY_1);
2343 EXPECT_ARITY(2, kExprBrTable, ARITY_1); 2284 EXPECT_ARITY(2, kExprBrTable, ARITY_1);
2344 2285
2345 { 2286 {
2346 EXPECT_ARITY(0, kExprReturn, ARITY_0); 2287 EXPECT_ARITY(0, kExprReturn, ARITY_0);
2347 EXPECT_ARITY(1, kExprReturn, ARITY_1); 2288 EXPECT_ARITY(1, kExprReturn, ARITY_1);
2348 } 2289 }
2349 2290
2350 EXPECT_ARITY(0, kExprThrow); 2291 EXPECT_ARITY(0, kExprThrow);
2351 EXPECT_ARITY(0, kExprTryCatch); 2292 EXPECT_ARITY(0, kExprTry);
2352 EXPECT_ARITY(0, kExprTryFinally);
2353 EXPECT_ARITY(0, kExprTryCatchFinally);
2354 EXPECT_ARITY(1, kExprCatch, 2); 2293 EXPECT_ARITY(1, kExprCatch, 2);
2355 EXPECT_ARITY(0, kExprFinally);
2356 } 2294 }
2357 2295
2358 TEST_F(WasmOpcodeArityTest, Misc) { 2296 TEST_F(WasmOpcodeArityTest, Misc) {
2359 EXPECT_ARITY(0, kExprI8Const); 2297 EXPECT_ARITY(0, kExprI8Const);
2360 EXPECT_ARITY(0, kExprI32Const); 2298 EXPECT_ARITY(0, kExprI32Const);
2361 EXPECT_ARITY(0, kExprF32Const); 2299 EXPECT_ARITY(0, kExprF32Const);
2362 EXPECT_ARITY(0, kExprI64Const); 2300 EXPECT_ARITY(0, kExprI64Const);
2363 EXPECT_ARITY(0, kExprF64Const); 2301 EXPECT_ARITY(0, kExprF64Const);
2364 EXPECT_ARITY(0, kExprGetLocal); 2302 EXPECT_ARITY(0, kExprGetLocal);
2365 EXPECT_ARITY(1, kExprSetLocal); 2303 EXPECT_ARITY(1, kExprSetLocal);
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
2720 iter.next(); 2658 iter.next();
2721 EXPECT_TRUE(iter.has_next()); 2659 EXPECT_TRUE(iter.has_next());
2722 EXPECT_EQ(kExprI8Const, iter.current()); 2660 EXPECT_EQ(kExprI8Const, iter.current());
2723 iter.next(); 2661 iter.next();
2724 EXPECT_FALSE(iter.has_next()); 2662 EXPECT_FALSE(iter.has_next());
2725 } 2663 }
2726 2664
2727 } // namespace wasm 2665 } // namespace wasm
2728 } // namespace internal 2666 } // namespace internal
2729 } // namespace v8 2667 } // namespace v8
OLDNEW
« no previous file with comments | « src/wasm/wasm-opcodes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698