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

Side by Side Diff: test/cctest/wasm/test-run-wasm.cc

Issue 1682443002: [wasm] Put the condition last in kExprBrIf. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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-macro-gen.h ('k') | test/unittests/wasm/ast-decoder-unittest.cc » ('j') | 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 <stdint.h> 5 #include <stdint.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "src/wasm/wasm-macro-gen.h" 9 #include "src/wasm/wasm-macro-gen.h"
10 10
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 WASM_I8(52))); // -- 1313 WASM_I8(52))); // --
1314 FOR_INT32_INPUTS(i) { 1314 FOR_INT32_INPUTS(i) {
1315 int32_t expected = *i ? 51 : 52; 1315 int32_t expected = *i ? 51 : 52;
1316 CHECK_EQ(expected, r.Call(*i)); 1316 CHECK_EQ(expected, r.Call(*i));
1317 } 1317 }
1318 } 1318 }
1319 1319
1320 1320
1321 TEST(Run_Wasm_Block_BrIf_P) { 1321 TEST(Run_Wasm_Block_BrIf_P) {
1322 WasmRunner<int32_t> r(MachineType::Int32()); 1322 WasmRunner<int32_t> r(MachineType::Int32());
1323 BUILD(r, WASM_BLOCK(2, WASM_BRV_IF(0, WASM_GET_LOCAL(0), WASM_I8(51)), 1323 BUILD(r, WASM_BLOCK(2, WASM_BRV_IF(0, WASM_I8(51), WASM_GET_LOCAL(0)),
1324 WASM_I8(52))); 1324 WASM_I8(52)));
1325 FOR_INT32_INPUTS(i) { 1325 FOR_INT32_INPUTS(i) {
1326 int32_t expected = *i ? 51 : 52; 1326 int32_t expected = *i ? 51 : 52;
1327 CHECK_EQ(expected, r.Call(*i)); 1327 CHECK_EQ(expected, r.Call(*i));
1328 } 1328 }
1329 } 1329 }
1330 1330
1331 1331
1332 TEST(Run_Wasm_Block_IfElse_P_assign) { 1332 TEST(Run_Wasm_Block_IfElse_P_assign) {
1333 WasmRunner<int32_t> r(MachineType::Int32()); 1333 WasmRunner<int32_t> r(MachineType::Int32());
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 BUILD(r, 2047 BUILD(r,
2048 WASM_BLOCK(1, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_I8(45)), 2048 WASM_BLOCK(1, WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_I8(45)),
2049 WASM_INFINITE_LOOP))); 2049 WASM_INFINITE_LOOP)));
2050 // Run the code, but don't go into the infinite loop. 2050 // Run the code, but don't go into the infinite loop.
2051 CHECK_EQ(45, r.Call(1)); 2051 CHECK_EQ(45, r.Call(1));
2052 } 2052 }
2053 2053
2054 2054
2055 TEST(Run_Wasm_Infinite_Loop_not_taken2_brif) { 2055 TEST(Run_Wasm_Infinite_Loop_not_taken2_brif) {
2056 WasmRunner<int32_t> r(MachineType::Int32()); 2056 WasmRunner<int32_t> r(MachineType::Int32());
2057 BUILD(r, WASM_BLOCK(2, WASM_BRV_IF(0, WASM_GET_LOCAL(0), WASM_I8(45)), 2057 BUILD(r, WASM_BLOCK(2, WASM_BRV_IF(0, WASM_I8(45), WASM_GET_LOCAL(0)),
2058 WASM_INFINITE_LOOP)); 2058 WASM_INFINITE_LOOP));
2059 // Run the code, but don't go into the infinite loop. 2059 // Run the code, but don't go into the infinite loop.
2060 CHECK_EQ(45, r.Call(1)); 2060 CHECK_EQ(45, r.Call(1));
2061 } 2061 }
2062 2062
2063 2063
2064 static void TestBuildGraphForSimpleExpression(WasmOpcode opcode) { 2064 static void TestBuildGraphForSimpleExpression(WasmOpcode opcode) {
2065 if (!WasmOpcodes::IsSupported(opcode)) return; 2065 if (!WasmOpcodes::IsSupported(opcode)) return;
2066 2066
2067 Zone zone; 2067 Zone zone;
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
2718 WasmRunner<int32_t> r(MachineType::Int32()); 2718 WasmRunner<int32_t> r(MachineType::Int32());
2719 BUILD(r, WASM_BLOCK(2, WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_I8(1))), 2719 BUILD(r, WASM_BLOCK(2, WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_I8(1))),
2720 WASM_I8(2))); 2720 WASM_I8(2)));
2721 CHECK_EQ(2, r.Call(0)); 2721 CHECK_EQ(2, r.Call(0));
2722 CHECK_EQ(1, r.Call(1)); 2722 CHECK_EQ(1, r.Call(1));
2723 } 2723 }
2724 2724
2725 2725
2726 TEST(Run_Wasm_ExprBlock2c) { 2726 TEST(Run_Wasm_ExprBlock2c) {
2727 WasmRunner<int32_t> r(MachineType::Int32()); 2727 WasmRunner<int32_t> r(MachineType::Int32());
2728 BUILD(r, WASM_BLOCK(2, WASM_BRV_IF(0, WASM_GET_LOCAL(0), WASM_I8(1)), 2728 BUILD(r, WASM_BLOCK(2, WASM_BRV_IF(0, WASM_I8(1), WASM_GET_LOCAL(0)),
2729 WASM_I8(1))); 2729 WASM_I8(1)));
2730 CHECK_EQ(1, r.Call(0)); 2730 CHECK_EQ(1, r.Call(0));
2731 CHECK_EQ(1, r.Call(1)); 2731 CHECK_EQ(1, r.Call(1));
2732 } 2732 }
2733 2733
2734 2734
2735 TEST(Run_Wasm_ExprBlock2d) { 2735 TEST(Run_Wasm_ExprBlock2d) {
2736 WasmRunner<int32_t> r(MachineType::Int32()); 2736 WasmRunner<int32_t> r(MachineType::Int32());
2737 BUILD(r, WASM_BLOCK(2, WASM_BRV_IF(0, WASM_GET_LOCAL(0), WASM_I8(1)), 2737 BUILD(r, WASM_BLOCK(2, WASM_BRV_IF(0, WASM_I8(1), WASM_GET_LOCAL(0)),
2738 WASM_I8(2))); 2738 WASM_I8(2)));
2739 CHECK_EQ(2, r.Call(0)); 2739 CHECK_EQ(2, r.Call(0));
2740 CHECK_EQ(1, r.Call(1)); 2740 CHECK_EQ(1, r.Call(1));
2741 } 2741 }
2742 2742
2743 2743
2744 TEST(Run_Wasm_ExprBlock_ManualSwitch) { 2744 TEST(Run_Wasm_ExprBlock_ManualSwitch) {
2745 WasmRunner<int32_t> r(MachineType::Int32()); 2745 WasmRunner<int32_t> r(MachineType::Int32());
2746 BUILD(r, WASM_BLOCK(6, WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1)), 2746 BUILD(r, WASM_BLOCK(6, WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1)),
2747 WASM_BRV(0, WASM_I8(11))), 2747 WASM_BRV(0, WASM_I8(11))),
(...skipping 12 matching lines...) Expand all
2760 CHECK_EQ(13, r.Call(3)); 2760 CHECK_EQ(13, r.Call(3));
2761 CHECK_EQ(14, r.Call(4)); 2761 CHECK_EQ(14, r.Call(4));
2762 CHECK_EQ(15, r.Call(5)); 2762 CHECK_EQ(15, r.Call(5));
2763 CHECK_EQ(99, r.Call(6)); 2763 CHECK_EQ(99, r.Call(6));
2764 } 2764 }
2765 2765
2766 2766
2767 TEST(Run_Wasm_ExprBlock_ManualSwitch_brif) { 2767 TEST(Run_Wasm_ExprBlock_ManualSwitch_brif) {
2768 WasmRunner<int32_t> r(MachineType::Int32()); 2768 WasmRunner<int32_t> r(MachineType::Int32());
2769 BUILD(r, 2769 BUILD(r,
2770 WASM_BLOCK(6, WASM_BRV_IF(0, WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1)), 2770 WASM_BLOCK(6, WASM_BRV_IF(0, WASM_I8(11),
2771 WASM_I8(11)), 2771 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(1))),
2772 WASM_BRV_IF(0, WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2)), 2772 WASM_BRV_IF(0, WASM_I8(12),
2773 WASM_I8(12)), 2773 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(2))),
2774 WASM_BRV_IF(0, WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3)), 2774 WASM_BRV_IF(0, WASM_I8(13),
2775 WASM_I8(13)), 2775 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(3))),
2776 WASM_BRV_IF(0, WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4)), 2776 WASM_BRV_IF(0, WASM_I8(14),
2777 WASM_I8(14)), 2777 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(4))),
2778 WASM_BRV_IF(0, WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5)), 2778 WASM_BRV_IF(0, WASM_I8(15),
2779 WASM_I8(15)), 2779 WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I8(5))),
2780 WASM_I8(99))); 2780 WASM_I8(99)));
2781 CHECK_EQ(99, r.Call(0)); 2781 CHECK_EQ(99, r.Call(0));
2782 CHECK_EQ(11, r.Call(1)); 2782 CHECK_EQ(11, r.Call(1));
2783 CHECK_EQ(12, r.Call(2)); 2783 CHECK_EQ(12, r.Call(2));
2784 CHECK_EQ(13, r.Call(3)); 2784 CHECK_EQ(13, r.Call(3));
2785 CHECK_EQ(14, r.Call(4)); 2785 CHECK_EQ(14, r.Call(4));
2786 CHECK_EQ(15, r.Call(5)); 2786 CHECK_EQ(15, r.Call(5));
2787 CHECK_EQ(99, r.Call(6)); 2787 CHECK_EQ(99, r.Call(6));
2788 } 2788 }
2789 2789
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
3423 3423
3424 #if WASM_64 3424 #if WASM_64
3425 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } 3425 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); }
3426 #endif 3426 #endif
3427 3427
3428 3428
3429 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } 3429 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); }
3430 3430
3431 3431
3432 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } 3432 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); }
OLDNEW
« no previous file with comments | « src/wasm/wasm-macro-gen.h ('k') | test/unittests/wasm/ast-decoder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698