Chromium Code Reviews| 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 <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/base/platform/elapsed-timer.h" | 9 #include "src/base/platform/elapsed-timer.h" |
| 10 | 10 |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 // if (p0) return 11; else return 22; | 681 // if (p0) return 11; else return 22; |
| 682 BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), // -- | 682 BUILD(r, WASM_IF_ELSE(WASM_GET_LOCAL(0), // -- |
| 683 WASM_I8(11), // -- | 683 WASM_I8(11), // -- |
| 684 WASM_I8(22))); // -- | 684 WASM_I8(22))); // -- |
| 685 FOR_INT32_INPUTS(i) { | 685 FOR_INT32_INPUTS(i) { |
| 686 int32_t expected = *i ? 11 : 22; | 686 int32_t expected = *i ? 11 : 22; |
| 687 CHECK_EQ(expected, r.Call(*i)); | 687 CHECK_EQ(expected, r.Call(*i)); |
| 688 } | 688 } |
| 689 } | 689 } |
| 690 | 690 |
| 691 TEST(Run_Wasm_If_empty1) { | |
| 692 WasmRunner<int32_t> r(MachineType::Int32()); | |
| 693 BUILD(r, WASM_GET_LOCAL(0), kExprIf, kExprEnd, WASM_GET_LOCAL(0)); | |
|
ahaas
2016/05/09 14:02:59
Could you use WASM_GET_LOCAL(0) and WASM_GET_LOCAL
titzer
2016/05/09 14:18:52
Done.
| |
| 694 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } | |
| 695 } | |
| 696 | |
| 697 TEST(Run_Wasm_IfElse_empty1) { | |
| 698 WasmRunner<int32_t> r(MachineType::Int32()); | |
| 699 BUILD(r, WASM_GET_LOCAL(0), kExprIf, kExprElse, kExprEnd, WASM_GET_LOCAL(0)); | |
| 700 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } | |
| 701 } | |
| 702 | |
| 703 TEST(Run_Wasm_IfElse_empty2) { | |
| 704 WasmRunner<int32_t> r(MachineType::Int32()); | |
| 705 BUILD(r, WASM_GET_LOCAL(0), kExprIf, WASM_ZERO, kExprElse, kExprEnd, | |
| 706 WASM_GET_LOCAL(0)); | |
| 707 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } | |
| 708 } | |
| 709 | |
| 710 TEST(Run_Wasm_IfElse_empty3) { | |
| 711 WasmRunner<int32_t> r(MachineType::Int32()); | |
| 712 BUILD(r, WASM_GET_LOCAL(0), kExprIf, kExprElse, WASM_ZERO, kExprEnd, | |
| 713 WASM_GET_LOCAL(0)); | |
| 714 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } | |
| 715 } | |
| 716 | |
| 691 TEST(Run_Wasm_If_chain) { | 717 TEST(Run_Wasm_If_chain) { |
| 692 WasmRunner<int32_t> r(MachineType::Int32()); | 718 WasmRunner<int32_t> r(MachineType::Int32()); |
| 693 // if (p0) 13; if (p0) 14; 15 | 719 // if (p0) 13; if (p0) 14; 15 |
| 694 BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_I8(13)), | 720 BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_I8(13)), |
| 695 WASM_IF(WASM_GET_LOCAL(0), WASM_I8(14)), WASM_I8(15)); | 721 WASM_IF(WASM_GET_LOCAL(0), WASM_I8(14)), WASM_I8(15)); |
| 696 FOR_INT32_INPUTS(i) { CHECK_EQ(15, r.Call(*i)); } | 722 FOR_INT32_INPUTS(i) { CHECK_EQ(15, r.Call(*i)); } |
| 697 } | 723 } |
| 698 | 724 |
| 699 TEST(Run_Wasm_If_chain_set) { | 725 TEST(Run_Wasm_If_chain_set) { |
| 700 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); | 726 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1081 | 1107 |
| 1082 const int32_t kExpected = -414444; | 1108 const int32_t kExpected = -414444; |
| 1083 // Build the calling function. | 1109 // Build the calling function. |
| 1084 WasmRunner<int32_t> r(&module); | 1110 WasmRunner<int32_t> r(&module); |
| 1085 BUILD(r, B2(WASM_CALL_FUNCTION0(index), WASM_I32V_3(kExpected))); | 1111 BUILD(r, B2(WASM_CALL_FUNCTION0(index), WASM_I32V_3(kExpected))); |
| 1086 | 1112 |
| 1087 int32_t result = r.Call(); | 1113 int32_t result = r.Call(); |
| 1088 CHECK_EQ(kExpected, result); | 1114 CHECK_EQ(kExpected, result); |
| 1089 } | 1115 } |
| 1090 | 1116 |
| 1117 TEST(Run_Wasm_Block_empty) { | |
| 1118 WasmRunner<int32_t> r(MachineType::Int32()); | |
| 1119 BUILD(r, kExprBlock, kExprEnd, WASM_GET_LOCAL(0)); | |
| 1120 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } | |
| 1121 } | |
| 1122 | |
| 1123 TEST(Run_Wasm_Block_empty_br1) { | |
| 1124 WasmRunner<int32_t> r(MachineType::Int32()); | |
| 1125 BUILD(r, B1(WASM_BR(0)), WASM_GET_LOCAL(0)); | |
| 1126 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } | |
| 1127 } | |
| 1128 | |
| 1129 TEST(Run_Wasm_Block_empty_brif1) { | |
| 1130 WasmRunner<int32_t> r(MachineType::Int32()); | |
| 1131 BUILD(r, B1(WASM_BR_IF(0, WASM_ZERO)), WASM_GET_LOCAL(0)); | |
| 1132 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } | |
| 1133 } | |
| 1134 | |
| 1135 TEST(Run_Wasm_Block_br2) { | |
| 1136 WasmRunner<int32_t> r(MachineType::Int32()); | |
| 1137 BUILD(r, B1(WASM_BRV(0, WASM_GET_LOCAL(0)))); | |
| 1138 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } | |
| 1139 } | |
| 1091 | 1140 |
| 1092 TEST(Run_Wasm_Block_If_P) { | 1141 TEST(Run_Wasm_Block_If_P) { |
| 1093 WasmRunner<int32_t> r(MachineType::Int32()); | 1142 WasmRunner<int32_t> r(MachineType::Int32()); |
| 1094 // { if (p0) return 51; return 52; } | 1143 // { if (p0) return 51; return 52; } |
| 1095 BUILD(r, B2( // -- | 1144 BUILD(r, B2( // -- |
| 1096 WASM_IF(WASM_GET_LOCAL(0), // -- | 1145 WASM_IF(WASM_GET_LOCAL(0), // -- |
| 1097 WASM_BRV(1, WASM_I8(51))), // -- | 1146 WASM_BRV(1, WASM_I8(51))), // -- |
| 1098 WASM_I8(52))); // -- | 1147 WASM_I8(52))); // -- |
| 1099 FOR_INT32_INPUTS(i) { | 1148 FOR_INT32_INPUTS(i) { |
| 1100 int32_t expected = *i ? 51 : 52; | 1149 int32_t expected = *i ? 51 : 52; |
| 1101 CHECK_EQ(expected, r.Call(*i)); | 1150 CHECK_EQ(expected, r.Call(*i)); |
| 1102 } | 1151 } |
| 1103 } | 1152 } |
| 1104 | 1153 |
| 1154 TEST(Run_Wasm_Loop_empty) { | |
| 1155 WasmRunner<int32_t> r(MachineType::Int32()); | |
| 1156 BUILD(r, kExprLoop, kExprEnd, WASM_GET_LOCAL(0)); | |
| 1157 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } | |
| 1158 } | |
| 1159 | |
| 1160 TEST(Run_Wasm_Loop_empty_br1) { | |
| 1161 WasmRunner<int32_t> r(MachineType::Int32()); | |
| 1162 BUILD(r, WASM_LOOP(1, WASM_BR(0)), WASM_GET_LOCAL(0)); | |
| 1163 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } | |
| 1164 } | |
| 1165 | |
| 1166 TEST(Run_Wasm_Loop_empty_brif1) { | |
| 1167 WasmRunner<int32_t> r(MachineType::Int32()); | |
| 1168 BUILD(r, WASM_LOOP(1, WASM_BR_IF(0, WASM_ZERO)), WASM_GET_LOCAL(0)); | |
| 1169 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } | |
| 1170 } | |
| 1105 | 1171 |
| 1106 TEST(Run_Wasm_Block_BrIf_P) { | 1172 TEST(Run_Wasm_Block_BrIf_P) { |
| 1107 WasmRunner<int32_t> r(MachineType::Int32()); | 1173 WasmRunner<int32_t> r(MachineType::Int32()); |
| 1108 BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(51), WASM_GET_LOCAL(0)), WASM_I8(52))); | 1174 BUILD(r, B2(WASM_BRV_IF(0, WASM_I8(51), WASM_GET_LOCAL(0)), WASM_I8(52))); |
| 1109 FOR_INT32_INPUTS(i) { | 1175 FOR_INT32_INPUTS(i) { |
| 1110 int32_t expected = *i ? 51 : 52; | 1176 int32_t expected = *i ? 51 : 52; |
| 1111 CHECK_EQ(expected, r.Call(*i)); | 1177 CHECK_EQ(expected, r.Call(*i)); |
| 1112 } | 1178 } |
| 1113 } | 1179 } |
| 1114 | 1180 |
| (...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2861 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); | 2927 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); |
| 2862 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO); | 2928 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO); |
| 2863 const int32_t kMin = std::numeric_limits<int32_t>::min(); | 2929 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
| 2864 CHECK_EQ(0, r.Call(133, 100)); | 2930 CHECK_EQ(0, r.Call(133, 100)); |
| 2865 CHECK_EQ(0, r.Call(kMin, -1)); | 2931 CHECK_EQ(0, r.Call(kMin, -1)); |
| 2866 CHECK_EQ(0, r.Call(0, 1)); | 2932 CHECK_EQ(0, r.Call(0, 1)); |
| 2867 CHECK_TRAP(r.Call(100, 0)); | 2933 CHECK_TRAP(r.Call(100, 0)); |
| 2868 CHECK_TRAP(r.Call(-1001, 0)); | 2934 CHECK_TRAP(r.Call(-1001, 0)); |
| 2869 CHECK_TRAP(r.Call(kMin, 0)); | 2935 CHECK_TRAP(r.Call(kMin, 0)); |
| 2870 } | 2936 } |
| OLD | NEW |