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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 | 47 |
48 TEST_F(WasmMacroGenTest, Statements) { | 48 TEST_F(WasmMacroGenTest, Statements) { |
49 EXPECT_SIZE(1, WASM_NOP); | 49 EXPECT_SIZE(1, WASM_NOP); |
50 | 50 |
51 EXPECT_SIZE(4, WASM_SET_LOCAL(0, WASM_ZERO)); | 51 EXPECT_SIZE(4, WASM_SET_LOCAL(0, WASM_ZERO)); |
52 | 52 |
53 EXPECT_SIZE(4, WASM_STORE_GLOBAL(0, WASM_ZERO)); | 53 EXPECT_SIZE(4, WASM_STORE_GLOBAL(0, WASM_ZERO)); |
54 | 54 |
55 EXPECT_SIZE(6, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, WASM_ZERO)); | 55 EXPECT_SIZE(7, WASM_STORE_MEM(MachineType::Int32(), WASM_ZERO, WASM_ZERO)); |
56 | 56 |
57 EXPECT_SIZE(4, WASM_IF(WASM_ZERO, WASM_NOP)); | 57 EXPECT_SIZE(4, WASM_IF(WASM_ZERO, WASM_NOP)); |
58 | 58 |
59 EXPECT_SIZE(5, WASM_IF_ELSE(WASM_ZERO, WASM_NOP, WASM_NOP)); | 59 EXPECT_SIZE(5, WASM_IF_ELSE(WASM_ZERO, WASM_NOP, WASM_NOP)); |
60 | 60 |
61 EXPECT_SIZE(5, WASM_SELECT(WASM_ZERO, WASM_NOP, WASM_NOP)); | 61 EXPECT_SIZE(5, WASM_SELECT(WASM_ZERO, WASM_NOP, WASM_NOP)); |
62 | 62 |
63 EXPECT_SIZE(3, WASM_BR(0)); | 63 EXPECT_SIZE(3, WASM_BR(0)); |
64 EXPECT_SIZE(5, WASM_BR_IF(0, WASM_ZERO)); | 64 EXPECT_SIZE(5, WASM_BR_IF(0, WASM_ZERO)); |
65 | 65 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 TEST_F(WasmMacroGenTest, Expressions) { | 100 TEST_F(WasmMacroGenTest, Expressions) { |
101 EXPECT_SIZE(2, WASM_GET_LOCAL(0)); | 101 EXPECT_SIZE(2, WASM_GET_LOCAL(0)); |
102 EXPECT_SIZE(2, WASM_GET_LOCAL(1)); | 102 EXPECT_SIZE(2, WASM_GET_LOCAL(1)); |
103 EXPECT_SIZE(2, WASM_GET_LOCAL(12)); | 103 EXPECT_SIZE(2, WASM_GET_LOCAL(12)); |
104 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(0)); | 104 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(0)); |
105 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(1)); | 105 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(1)); |
106 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(12)); | 106 EXPECT_SIZE(2, WASM_LOAD_GLOBAL(12)); |
107 EXPECT_SIZE(4, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)); | 107 EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Int32(), WASM_ZERO)); |
108 EXPECT_SIZE(4, WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)); | 108 EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float64(), WASM_ZERO)); |
109 EXPECT_SIZE(4, WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)); | 109 EXPECT_SIZE(5, WASM_LOAD_MEM(MachineType::Float32(), WASM_ZERO)); |
110 | 110 |
111 EXPECT_SIZE(3, WASM_NOT(WASM_ZERO)); | 111 EXPECT_SIZE(3, WASM_NOT(WASM_ZERO)); |
112 | 112 |
113 EXPECT_SIZE(4, WASM_BRV(1, WASM_ZERO)); | 113 EXPECT_SIZE(4, WASM_BRV(1, WASM_ZERO)); |
114 EXPECT_SIZE(6, WASM_BRV_IF(1, WASM_ZERO, WASM_ZERO)); | 114 EXPECT_SIZE(6, WASM_BRV_IF(1, WASM_ZERO, WASM_ZERO)); |
115 | 115 |
116 EXPECT_SIZE(4, WASM_BLOCK(1, WASM_ZERO)); | 116 EXPECT_SIZE(4, WASM_BLOCK(1, WASM_ZERO)); |
117 EXPECT_SIZE(5, WASM_BLOCK(2, WASM_NOP, WASM_ZERO)); | 117 EXPECT_SIZE(5, WASM_BLOCK(2, WASM_NOP, WASM_ZERO)); |
118 EXPECT_SIZE(6, WASM_BLOCK(3, WASM_NOP, WASM_NOP, WASM_ZERO)); | 118 EXPECT_SIZE(6, WASM_BLOCK(3, WASM_NOP, WASM_NOP, WASM_ZERO)); |
119 | 119 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 295 } |
296 | 296 |
297 static const MachineType kMemTypes[] = { | 297 static const MachineType kMemTypes[] = { |
298 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(), | 298 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(), |
299 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(), | 299 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(), |
300 MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(), | 300 MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(), |
301 MachineType::Float64()}; | 301 MachineType::Float64()}; |
302 | 302 |
303 TEST_F(WasmMacroGenTest, LoadsAndStores) { | 303 TEST_F(WasmMacroGenTest, LoadsAndStores) { |
304 for (size_t i = 0; i < arraysize(kMemTypes); i++) { | 304 for (size_t i = 0; i < arraysize(kMemTypes); i++) { |
305 EXPECT_SIZE(4, WASM_LOAD_MEM(kMemTypes[i], WASM_ZERO)); | 305 EXPECT_SIZE(5, WASM_LOAD_MEM(kMemTypes[i], WASM_ZERO)); |
306 } | 306 } |
307 for (size_t i = 0; i < arraysize(kMemTypes); i++) { | 307 for (size_t i = 0; i < arraysize(kMemTypes); i++) { |
308 EXPECT_SIZE(6, WASM_STORE_MEM(kMemTypes[i], WASM_ZERO, WASM_GET_LOCAL(0))); | 308 EXPECT_SIZE(7, WASM_STORE_MEM(kMemTypes[i], WASM_ZERO, WASM_GET_LOCAL(0))); |
309 } | 309 } |
310 } | 310 } |
311 | 311 |
312 | 312 |
313 TEST_F(WasmMacroGenTest, LoadsAndStoresWithOffset) { | 313 TEST_F(WasmMacroGenTest, LoadsAndStoresWithOffset) { |
314 for (size_t i = 0; i < arraysize(kMemTypes); i++) { | 314 for (size_t i = 0; i < arraysize(kMemTypes); i++) { |
315 EXPECT_SIZE(5, WASM_LOAD_MEM_OFFSET(kMemTypes[i], 11, WASM_ZERO)); | 315 EXPECT_SIZE(5, WASM_LOAD_MEM_OFFSET(kMemTypes[i], 11, WASM_ZERO)); |
316 } | 316 } |
317 for (size_t i = 0; i < arraysize(kMemTypes); i++) { | 317 for (size_t i = 0; i < arraysize(kMemTypes); i++) { |
318 EXPECT_SIZE(7, WASM_STORE_MEM_OFFSET(kMemTypes[i], 13, WASM_ZERO, | 318 EXPECT_SIZE(7, WASM_STORE_MEM_OFFSET(kMemTypes[i], 13, WASM_ZERO, |
319 WASM_GET_LOCAL(0))); | 319 WASM_GET_LOCAL(0))); |
320 } | 320 } |
321 } | 321 } |
322 } // namespace wasm | 322 } // namespace wasm |
323 } // namespace internal | 323 } // namespace internal |
324 } // namespace v8 | 324 } // namespace v8 |
OLD | NEW |