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/wasm/wasm-macro-gen.h" | 7 #include "src/wasm/wasm-macro-gen.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 EXPECT_SIZE(4, WASM_STORE_GLOBAL(0, WASM_ZERO)); | 57 EXPECT_SIZE(4, WASM_STORE_GLOBAL(0, WASM_ZERO)); |
58 | 58 |
59 EXPECT_SIZE(7, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, WASM_ZERO)); | 59 EXPECT_SIZE(7, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, WASM_ZERO)); |
60 | 60 |
61 EXPECT_SIZE(5, WASM_IF(WASM_ZERO, WASM_NOP)); | 61 EXPECT_SIZE(5, WASM_IF(WASM_ZERO, WASM_NOP)); |
62 | 62 |
63 EXPECT_SIZE(7, WASM_IF_ELSE(WASM_ZERO, WASM_NOP, WASM_NOP)); | 63 EXPECT_SIZE(7, WASM_IF_ELSE(WASM_ZERO, WASM_NOP, WASM_NOP)); |
64 | 64 |
65 EXPECT_SIZE(5, WASM_SELECT(WASM_ZERO, WASM_NOP, WASM_NOP)); | 65 EXPECT_SIZE(5, WASM_SELECT(WASM_ZERO, WASM_NOP, WASM_NOP)); |
66 | 66 |
67 EXPECT_SIZE(4, WASM_BR(0)); | 67 EXPECT_SIZE(3, WASM_BR(0)); |
68 EXPECT_SIZE(5, WASM_BR_IF(0, WASM_ZERO)); | 68 EXPECT_SIZE(5, WASM_BR_IF(0, WASM_ZERO)); |
69 | 69 |
70 EXPECT_SIZE(3, WASM_BLOCK(1, WASM_NOP)); | 70 EXPECT_SIZE(3, WASM_BLOCK(1, WASM_NOP)); |
71 EXPECT_SIZE(4, WASM_BLOCK(2, WASM_NOP, WASM_NOP)); | 71 EXPECT_SIZE(4, WASM_BLOCK(2, WASM_NOP, WASM_NOP)); |
72 EXPECT_SIZE(5, WASM_BLOCK(3, WASM_NOP, WASM_NOP, WASM_NOP)); | 72 EXPECT_SIZE(5, WASM_BLOCK(3, WASM_NOP, WASM_NOP, WASM_NOP)); |
73 | 73 |
74 EXPECT_SIZE(6, WASM_INFINITE_LOOP); | 74 EXPECT_SIZE(5, WASM_INFINITE_LOOP); |
75 | 75 |
76 EXPECT_SIZE(3, WASM_LOOP(1, WASM_NOP)); | 76 EXPECT_SIZE(3, WASM_LOOP(1, WASM_NOP)); |
77 EXPECT_SIZE(4, WASM_LOOP(2, WASM_NOP, WASM_NOP)); | 77 EXPECT_SIZE(4, WASM_LOOP(2, WASM_NOP, WASM_NOP)); |
78 EXPECT_SIZE(5, WASM_LOOP(3, WASM_NOP, WASM_NOP, WASM_NOP)); | 78 EXPECT_SIZE(5, WASM_LOOP(3, WASM_NOP, WASM_NOP, WASM_NOP)); |
79 EXPECT_SIZE(6, WASM_LOOP(1, WASM_BR(0))); | 79 EXPECT_SIZE(5, WASM_LOOP(1, WASM_BR(0))); |
80 EXPECT_SIZE(7, WASM_LOOP(1, WASM_BR_IF(0, WASM_ZERO))); | 80 EXPECT_SIZE(7, WASM_LOOP(1, WASM_BR_IF(0, WASM_ZERO))); |
81 | 81 |
82 EXPECT_SIZE(2, WASM_RETURN0); | 82 EXPECT_SIZE(2, WASM_RETURN0); |
83 EXPECT_SIZE(4, WASM_RETURN1(WASM_ZERO)); | 83 EXPECT_SIZE(4, WASM_RETURN1(WASM_ZERO)); |
84 | 84 |
85 EXPECT_SIZE(1, WASM_UNREACHABLE); | 85 EXPECT_SIZE(1, WASM_UNREACHABLE); |
86 } | 86 } |
87 | 87 |
88 | 88 |
89 TEST_F(WasmMacroGenTest, MacroStatements) { | 89 TEST_F(WasmMacroGenTest, MacroStatements) { |
90 EXPECT_SIZE(10, WASM_WHILE(WASM_I8(0), WASM_NOP)); | 90 EXPECT_SIZE(10, WASM_WHILE(WASM_I8(0), WASM_NOP)); |
91 EXPECT_SIZE(7, WASM_INC_LOCAL(0)); | 91 EXPECT_SIZE(7, WASM_INC_LOCAL(0)); |
92 EXPECT_SIZE(7, WASM_INC_LOCAL_BY(0, 3)); | 92 EXPECT_SIZE(7, WASM_INC_LOCAL_BY(0, 3)); |
93 | 93 |
94 EXPECT_SIZE(4, WASM_BREAK(0)); | 94 EXPECT_SIZE(3, WASM_BREAK(0)); |
95 EXPECT_SIZE(4, WASM_CONTINUE(0)); | 95 EXPECT_SIZE(3, WASM_CONTINUE(0)); |
96 } | 96 } |
97 | 97 |
98 TEST_F(WasmMacroGenTest, BrTable) { | 98 TEST_F(WasmMacroGenTest, BrTable) { |
99 EXPECT_SIZE(9, WASM_BR_TABLE(WASM_ZERO, 1, BR_TARGET(1))); | 99 EXPECT_SIZE(9, WASM_BR_TABLE(WASM_ZERO, 1, BR_TARGET(1))); |
100 EXPECT_SIZE(11, WASM_BR_TABLEV(WASM_ZERO, WASM_ZERO, 1, BR_TARGET(1))); | 100 EXPECT_SIZE(11, WASM_BR_TABLEV(WASM_ZERO, WASM_ZERO, 1, BR_TARGET(1))); |
101 } | 101 } |
102 | 102 |
103 | 103 |
104 TEST_F(WasmMacroGenTest, Expressions) { | 104 TEST_F(WasmMacroGenTest, Expressions) { |
105 EXPECT_SIZE(2, WASM_GET_LOCAL(0)); | 105 EXPECT_SIZE(2, WASM_GET_LOCAL(0)); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 EXPECT_SIZE(5, WASM_LOAD_MEM_OFFSET(kMemTypes[i], 11, WASM_ZERO)); | 322 EXPECT_SIZE(5, WASM_LOAD_MEM_OFFSET(kMemTypes[i], 11, WASM_ZERO)); |
323 } | 323 } |
324 for (size_t i = 0; i < arraysize(kMemTypes); i++) { | 324 for (size_t i = 0; i < arraysize(kMemTypes); i++) { |
325 EXPECT_SIZE(7, WASM_STORE_MEM_OFFSET(kMemTypes[i], 13, WASM_ZERO, | 325 EXPECT_SIZE(7, WASM_STORE_MEM_OFFSET(kMemTypes[i], 13, WASM_ZERO, |
326 WASM_GET_LOCAL(0))); | 326 WASM_GET_LOCAL(0))); |
327 } | 327 } |
328 } | 328 } |
329 } // namespace wasm | 329 } // namespace wasm |
330 } // namespace internal | 330 } // namespace internal |
331 } // namespace v8 | 331 } // namespace v8 |
OLD | NEW |