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 { |
11 namespace wasm { | 11 namespace wasm { |
12 | 12 |
13 class WasmMacroGenTest : public TestWithZone {}; | 13 class WasmMacroGenTest : public TestWithZone {}; |
14 | 14 |
15 #define EXPECT_SIZE(size, ...) \ | 15 #define EXPECT_SIZE(size, ...) \ |
16 do { \ | 16 do { \ |
17 byte code[] = {__VA_ARGS__}; \ | 17 byte code[] = {__VA_ARGS__}; \ |
18 EXPECT_EQ(size, sizeof(code)); \ | 18 EXPECT_EQ(size, sizeof(code)); \ |
19 } while (false) | 19 } while (false) |
20 | 20 |
21 | 21 |
22 TEST_F(WasmMacroGenTest, Constants) { | 22 TEST_F(WasmMacroGenTest, Constants) { |
23 EXPECT_SIZE(2, WASM_ONE); | 23 EXPECT_SIZE(2, WASM_ONE); |
24 EXPECT_SIZE(2, WASM_ZERO); | 24 EXPECT_SIZE(2, WASM_ZERO); |
25 | 25 |
26 EXPECT_SIZE(2, WASM_I8(122)); | 26 EXPECT_SIZE(2, WASM_I8(122)); |
27 EXPECT_SIZE(2, WASM_I8(254)); | 27 EXPECT_SIZE(2, WASM_I8(254)); |
28 | 28 |
29 EXPECT_SIZE(2, WASM_I32V_1(1)); | 29 EXPECT_SIZE(2, WASM_I32V_1(1)); |
30 EXPECT_SIZE(3, WASM_I32V_2(200)); | |
30 EXPECT_SIZE(4, WASM_I32V_3(10000)); | 31 EXPECT_SIZE(4, WASM_I32V_3(10000)); |
31 EXPECT_SIZE(5, WASM_I32V_4(-9828934)); | 32 EXPECT_SIZE(5, WASM_I32V_4(-9828934)); |
33 EXPECT_SIZE(6, WASM_I32V_5(-1119828934)); | |
Mircea Trofin
2016/03/11 17:15:41
Do these numbers mean anything? Should they be a c
titzer
2016/03/11 17:17:35
They're just random values with no semantic meanin
| |
32 | 34 |
33 EXPECT_SIZE(2, WASM_I64V_1(1)); | 35 EXPECT_SIZE(2, WASM_I64V_1(1)); |
36 EXPECT_SIZE(3, WASM_I64V_2(300)); | |
34 EXPECT_SIZE(4, WASM_I64V_3(10000)); | 37 EXPECT_SIZE(4, WASM_I64V_3(10000)); |
35 EXPECT_SIZE(5, WASM_I64V_4(-9828934)); | 38 EXPECT_SIZE(5, WASM_I64V_4(-9828934)); |
39 EXPECT_SIZE(6, WASM_I64V_5(-1119828934)); | |
36 EXPECT_SIZE(10, WASM_I64V_9(0x123456789abcdef0ULL)); | 40 EXPECT_SIZE(10, WASM_I64V_9(0x123456789abcdef0ULL)); |
37 | 41 |
38 EXPECT_SIZE(5, WASM_F32(1.0f)); | 42 EXPECT_SIZE(5, WASM_F32(1.0f)); |
39 EXPECT_SIZE(5, WASM_F32(10000.0f)); | 43 EXPECT_SIZE(5, WASM_F32(10000.0f)); |
40 EXPECT_SIZE(5, WASM_F32(-9828934.0f)); | 44 EXPECT_SIZE(5, WASM_F32(-9828934.0f)); |
41 | 45 |
42 EXPECT_SIZE(9, WASM_F64(1.5)); | 46 EXPECT_SIZE(9, WASM_F64(1.5)); |
43 EXPECT_SIZE(9, WASM_F64(10200.0)); | 47 EXPECT_SIZE(9, WASM_F64(10200.0)); |
44 EXPECT_SIZE(9, WASM_F64(-9818934.0)); | 48 EXPECT_SIZE(9, WASM_F64(-9818934.0)); |
45 } | 49 } |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 EXPECT_SIZE(5, WASM_LOAD_MEM_OFFSET(kMemTypes[i], 11, WASM_ZERO)); | 319 EXPECT_SIZE(5, WASM_LOAD_MEM_OFFSET(kMemTypes[i], 11, WASM_ZERO)); |
316 } | 320 } |
317 for (size_t i = 0; i < arraysize(kMemTypes); i++) { | 321 for (size_t i = 0; i < arraysize(kMemTypes); i++) { |
318 EXPECT_SIZE(7, WASM_STORE_MEM_OFFSET(kMemTypes[i], 13, WASM_ZERO, | 322 EXPECT_SIZE(7, WASM_STORE_MEM_OFFSET(kMemTypes[i], 13, WASM_ZERO, |
319 WASM_GET_LOCAL(0))); | 323 WASM_GET_LOCAL(0))); |
320 } | 324 } |
321 } | 325 } |
322 } // namespace wasm | 326 } // namespace wasm |
323 } // namespace internal | 327 } // namespace internal |
324 } // namespace v8 | 328 } // namespace v8 |
OLD | NEW |