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/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/wasm/wasm-macro-gen.h" | 10 #include "src/wasm/wasm-macro-gen.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 WASM_EXEC_TEST(I64Sub) { | 140 WASM_EXEC_TEST(I64Sub) { |
141 REQUIRE(I64Sub); | 141 REQUIRE(I64Sub); |
142 WasmRunner<int64_t> r(execution_mode, MachineType::Int64(), | 142 WasmRunner<int64_t> r(execution_mode, MachineType::Int64(), |
143 MachineType::Int64()); | 143 MachineType::Int64()); |
144 BUILD(r, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 144 BUILD(r, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
145 FOR_INT64_INPUTS(i) { | 145 FOR_INT64_INPUTS(i) { |
146 FOR_INT64_INPUTS(j) { CHECK_EQ(*i - *j, r.Call(*i, *j)); } | 146 FOR_INT64_INPUTS(j) { CHECK_EQ(*i - *j, r.Call(*i, *j)); } |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 WASM_EXEC_TEST(I64AddUseOnlyLowWord) { | |
titzer
2016/10/19 09:20:42
Can you also add tests for using only the high wor
ahaas
2016/10/19 09:59:19
I cannot do that in a WebAssembly test at the mome
| |
151 REQUIRE(I64Add); | |
152 REQUIRE(I32ConvertI64); | |
153 WasmRunner<int32_t> r(execution_mode, MachineType::Int64(), | |
154 MachineType::Int64()); | |
155 BUILD(r, WASM_I32_CONVERT_I64( | |
156 WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); | |
157 FOR_INT64_INPUTS(i) { | |
158 FOR_INT64_INPUTS(j) { | |
159 CHECK_EQ(static_cast<int32_t>(*i + *j), r.Call(*i, *j)); | |
160 } | |
161 } | |
162 } | |
163 | |
164 WASM_EXEC_TEST(I64SubUseOnlyLowWord) { | |
165 REQUIRE(I64Sub); | |
166 REQUIRE(I32ConvertI64); | |
167 WasmRunner<int32_t> r(execution_mode, MachineType::Int64(), | |
168 MachineType::Int64()); | |
169 BUILD(r, WASM_I32_CONVERT_I64( | |
170 WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); | |
171 FOR_INT64_INPUTS(i) { | |
172 FOR_INT64_INPUTS(j) { | |
173 CHECK_EQ(static_cast<int32_t>(*i - *j), r.Call(*i, *j)); | |
174 } | |
175 } | |
176 } | |
177 | |
178 WASM_EXEC_TEST(I64MulUseOnlyLowWord) { | |
179 REQUIRE(I64Mul); | |
180 REQUIRE(I32ConvertI64); | |
181 WasmRunner<int32_t> r(execution_mode, MachineType::Int64(), | |
182 MachineType::Int64()); | |
183 BUILD(r, WASM_I32_CONVERT_I64( | |
184 WASM_I64_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); | |
185 FOR_INT64_INPUTS(i) { | |
186 FOR_INT64_INPUTS(j) { | |
187 CHECK_EQ(static_cast<int32_t>(*i * *j), r.Call(*i, *j)); | |
188 } | |
189 } | |
190 } | |
191 | |
192 WASM_EXEC_TEST(I64ShlUseOnlyLowWord) { | |
193 REQUIRE(I64Shl); | |
194 REQUIRE(I32ConvertI64); | |
195 WasmRunner<int32_t> r(execution_mode, MachineType::Int64(), | |
196 MachineType::Int64()); | |
197 BUILD(r, WASM_I32_CONVERT_I64( | |
198 WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); | |
199 FOR_INT64_INPUTS(i) { | |
200 FOR_INT64_INPUTS(j) { | |
201 uint64_t expected = static_cast<int32_t>((*i) << (*j & 0x3f)); | |
202 CHECK_EQ(expected, r.Call(*i, *j)); | |
203 } | |
204 } | |
205 } | |
206 | |
207 WASM_EXEC_TEST(I64ShrUseOnlyLowWord) { | |
208 REQUIRE(I64ShrU); | |
209 REQUIRE(I32ConvertI64); | |
210 WasmRunner<int32_t> r(execution_mode, MachineType::Int64(), | |
211 MachineType::Int64()); | |
212 BUILD(r, WASM_I32_CONVERT_I64( | |
213 WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); | |
214 FOR_UINT64_INPUTS(i) { | |
215 FOR_UINT64_INPUTS(j) { | |
216 uint64_t expected = static_cast<int32_t>((*i) >> (*j & 0x3f)); | |
217 CHECK_EQ(expected, r.Call(*i, *j)); | |
218 } | |
219 } | |
220 } | |
221 | |
222 WASM_EXEC_TEST(I64SarUseOnlyLowWord) { | |
223 REQUIRE(I64ShrS); | |
224 REQUIRE(I32ConvertI64); | |
225 WasmRunner<int32_t> r(execution_mode, MachineType::Int64(), | |
226 MachineType::Int64()); | |
227 BUILD(r, WASM_I32_CONVERT_I64( | |
228 WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); | |
229 FOR_INT64_INPUTS(i) { | |
230 FOR_INT64_INPUTS(j) { | |
231 uint64_t expected = static_cast<int32_t>((*i) >> (*j & 0x3f)); | |
232 CHECK_EQ(expected, r.Call(*i, *j)); | |
233 } | |
234 } | |
235 } | |
236 | |
150 WASM_EXEC_TEST(I64DivS) { | 237 WASM_EXEC_TEST(I64DivS) { |
151 REQUIRE(I64DivS); | 238 REQUIRE(I64DivS); |
152 WasmRunner<int64_t> r(execution_mode, MachineType::Int64(), | 239 WasmRunner<int64_t> r(execution_mode, MachineType::Int64(), |
153 MachineType::Int64()); | 240 MachineType::Int64()); |
154 BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 241 BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
155 FOR_INT64_INPUTS(i) { | 242 FOR_INT64_INPUTS(i) { |
156 FOR_INT64_INPUTS(j) { | 243 FOR_INT64_INPUTS(j) { |
157 if (*j == 0) { | 244 if (*j == 0) { |
158 CHECK_TRAP64(r.Call(*i, *j)); | 245 CHECK_TRAP64(r.Call(*i, *j)); |
159 } else if (*j == -1 && *i == std::numeric_limits<int64_t>::min()) { | 246 } else if (*j == -1 && *i == std::numeric_limits<int64_t>::min()) { |
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1567 CHECK_EQ(expected, result); | 1654 CHECK_EQ(expected, result); |
1568 } | 1655 } |
1569 } | 1656 } |
1570 } | 1657 } |
1571 } | 1658 } |
1572 | 1659 |
1573 WASM_EXEC_TEST(MixedCall_i64_0) { Run_WasmMixedCall_N(execution_mode, 0); } | 1660 WASM_EXEC_TEST(MixedCall_i64_0) { Run_WasmMixedCall_N(execution_mode, 0); } |
1574 WASM_EXEC_TEST(MixedCall_i64_1) { Run_WasmMixedCall_N(execution_mode, 1); } | 1661 WASM_EXEC_TEST(MixedCall_i64_1) { Run_WasmMixedCall_N(execution_mode, 1); } |
1575 WASM_EXEC_TEST(MixedCall_i64_2) { Run_WasmMixedCall_N(execution_mode, 2); } | 1662 WASM_EXEC_TEST(MixedCall_i64_2) { Run_WasmMixedCall_N(execution_mode, 2); } |
1576 WASM_EXEC_TEST(MixedCall_i64_3) { Run_WasmMixedCall_N(execution_mode, 3); } | 1663 WASM_EXEC_TEST(MixedCall_i64_3) { Run_WasmMixedCall_N(execution_mode, 3); } |
OLD | NEW |