OLD | NEW |
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/handles.h" | 7 #include "src/handles.h" |
8 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
9 #include "src/wasm/module-decoder.h" | 9 #include "src/wasm/module-decoder.h" |
10 #include "src/wasm/wasm-macro-gen.h" | 10 #include "src/wasm/wasm-macro-gen.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 SECTION(Type, 1 + 3 * (count)), U32V_1(count), __VA_ARGS__ | 40 SECTION(Type, 1 + 3 * (count)), U32V_1(count), __VA_ARGS__ |
41 #define FUNCTION_SIGNATURES_SECTION(count, ...) \ | 41 #define FUNCTION_SIGNATURES_SECTION(count, ...) \ |
42 SECTION(Function, 1 + (count)), U32V_1(count), __VA_ARGS__ | 42 SECTION(Function, 1 + (count)), U32V_1(count), __VA_ARGS__ |
43 | 43 |
44 #define FOO_STRING 3, 'f', 'o', 'o' | 44 #define FOO_STRING 3, 'f', 'o', 'o' |
45 #define NO_LOCAL_NAMES 0 | 45 #define NO_LOCAL_NAMES 0 |
46 | 46 |
47 #define EMPTY_SIGNATURES_SECTION SECTION(Type, 1), 0 | 47 #define EMPTY_SIGNATURES_SECTION SECTION(Type, 1), 0 |
48 #define EMPTY_FUNCTION_SIGNATURES_SECTION SECTION(Function, 1), 0 | 48 #define EMPTY_FUNCTION_SIGNATURES_SECTION SECTION(Function, 1), 0 |
49 #define EMPTY_FUNCTION_BODIES_SECTION SECTION(Code, 1), 0 | 49 #define EMPTY_FUNCTION_BODIES_SECTION SECTION(Code, 1), 0 |
50 #define SECTION_NAMES(size) \ | 50 #define SECTION_NAMES(size) SECTION(Unknown, size + 5), 4, 'n', 'a', 'm', 'e' |
51 kUnknownSectionCode, U32V_1(size + 5), 4, 'n', 'a', 'm', 'e' | |
52 #define EMPTY_NAMES_SECTION SECTION_NAMES(1), 0 | 51 #define EMPTY_NAMES_SECTION SECTION_NAMES(1), 0 |
53 | 52 |
54 #define X1(...) __VA_ARGS__ | 53 #define X1(...) __VA_ARGS__ |
55 #define X2(...) __VA_ARGS__, __VA_ARGS__ | 54 #define X2(...) __VA_ARGS__, __VA_ARGS__ |
56 #define X3(...) __VA_ARGS__, __VA_ARGS__, __VA_ARGS__ | 55 #define X3(...) __VA_ARGS__, __VA_ARGS__, __VA_ARGS__ |
57 #define X4(...) __VA_ARGS__, __VA_ARGS__, __VA_ARGS__, __VA_ARGS__ | 56 #define X4(...) __VA_ARGS__, __VA_ARGS__, __VA_ARGS__, __VA_ARGS__ |
58 | 57 |
59 #define ONE_EMPTY_FUNCTION SECTION(Function, 1 + 1 * 1), 1, X1(0) | 58 #define ONE_EMPTY_FUNCTION SECTION(Function, 1 + 1 * 1), 1, X1(0) |
60 | 59 |
61 #define TWO_EMPTY_FUNCTIONS SECTION(Function, 1 + 2 * 1), 2, X2(0) | 60 #define TWO_EMPTY_FUNCTIONS SECTION(Function, 1 + 2 * 1), 2, X2(0) |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 EXPECT_INIT_EXPR_FAIL(WASM_IF_ELSE(WASM_ZERO, WASM_ZERO, WASM_ZERO)); | 1280 EXPECT_INIT_EXPR_FAIL(WASM_IF_ELSE(WASM_ZERO, WASM_ZERO, WASM_ZERO)); |
1282 } | 1281 } |
1283 | 1282 |
1284 TEST_F(WasmModuleVerifyTest, InitExpr_global) { | 1283 TEST_F(WasmModuleVerifyTest, InitExpr_global) { |
1285 static const byte data[] = {WASM_INIT_EXPR_GLOBAL(37)}; | 1284 static const byte data[] = {WASM_INIT_EXPR_GLOBAL(37)}; |
1286 WasmInitExpr expr = DecodeWasmInitExprForTesting(data, data + sizeof(data)); | 1285 WasmInitExpr expr = DecodeWasmInitExprForTesting(data, data + sizeof(data)); |
1287 EXPECT_EQ(WasmInitExpr::kGlobalIndex, expr.kind); | 1286 EXPECT_EQ(WasmInitExpr::kGlobalIndex, expr.kind); |
1288 EXPECT_EQ(37, expr.val.global_index); | 1287 EXPECT_EQ(37, expr.val.global_index); |
1289 } | 1288 } |
1290 | 1289 |
| 1290 TEST_F(WasmModuleVerifyTest, Multiple_Named_Sections) { |
| 1291 static const byte data[] = { |
| 1292 SECTION(Unknown, 4), 1, 'X', 17, 18, // -- |
| 1293 SECTION(Unknown, 9), 3, 'f', 'o', 'o', 5, 6, 7, 8, 9, // -- |
| 1294 SECTION(Unknown, 8), 5, 'o', 't', 'h', 'e', 'r', 7, 8, // -- |
| 1295 }; |
| 1296 EXPECT_VERIFIES(data); |
| 1297 } |
| 1298 |
1291 } // namespace wasm | 1299 } // namespace wasm |
1292 } // namespace internal | 1300 } // namespace internal |
1293 } // namespace v8 | 1301 } // namespace v8 |
OLD | NEW |