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

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

Issue 2562393002: [wasm] Introduce the TrapIf and TrapUnless operators to generate trap code. (Closed)
Patch Set: Rename UseSourcePosition to IsSourcePositionUsed Created 4 years 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 | « test/cctest/wasm/test-run-wasm.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('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/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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 BUILD(r, WASM_I32_CONVERT_I64( 227 BUILD(r, WASM_I32_CONVERT_I64(
228 WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); 228 WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))));
229 FOR_INT64_INPUTS(i) { 229 FOR_INT64_INPUTS(i) {
230 FOR_INT64_INPUTS(j) { 230 FOR_INT64_INPUTS(j) {
231 int32_t expected = static_cast<int32_t>((*i) >> (*j & 0x3f)); 231 int32_t expected = static_cast<int32_t>((*i) >> (*j & 0x3f));
232 CHECK_EQ(expected, r.Call(*i, *j)); 232 CHECK_EQ(expected, r.Call(*i, *j));
233 } 233 }
234 } 234 }
235 } 235 }
236 236
237 WASM_EXEC_TEST(I64DivS) { 237 WASM_EXEC_TEST_WITH_TRAP(I64DivS) {
238 REQUIRE(I64DivS); 238 REQUIRE(I64DivS);
239 WasmRunner<int64_t> r(execution_mode, MachineType::Int64(), 239 WasmRunner<int64_t> r(execution_mode, MachineType::Int64(),
240 MachineType::Int64()); 240 MachineType::Int64());
241 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)));
242 FOR_INT64_INPUTS(i) { 242 FOR_INT64_INPUTS(i) {
243 FOR_INT64_INPUTS(j) { 243 FOR_INT64_INPUTS(j) {
244 if (*j == 0) { 244 if (*j == 0) {
245 CHECK_TRAP64(r.Call(*i, *j)); 245 CHECK_TRAP64(r.Call(*i, *j));
246 } else if (*j == -1 && *i == std::numeric_limits<int64_t>::min()) { 246 } else if (*j == -1 && *i == std::numeric_limits<int64_t>::min()) {
247 CHECK_TRAP64(r.Call(*i, *j)); 247 CHECK_TRAP64(r.Call(*i, *j));
248 } else { 248 } else {
249 CHECK_EQ(*i / *j, r.Call(*i, *j)); 249 CHECK_EQ(*i / *j, r.Call(*i, *j));
250 } 250 }
251 } 251 }
252 } 252 }
253 } 253 }
254 254
255 WASM_EXEC_TEST(I64DivS_Trap) { 255 WASM_EXEC_TEST_WITH_TRAP(I64DivS_Trap) {
256 REQUIRE(I64DivS); 256 REQUIRE(I64DivS);
257 WasmRunner<int64_t> r(execution_mode, MachineType::Int64(), 257 WasmRunner<int64_t> r(execution_mode, MachineType::Int64(),
258 MachineType::Int64()); 258 MachineType::Int64());
259 BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 259 BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
260 CHECK_EQ(0, r.Call(asi64(0), asi64(100))); 260 CHECK_EQ(0, r.Call(asi64(0), asi64(100)));
261 CHECK_TRAP64(r.Call(asi64(100), asi64(0))); 261 CHECK_TRAP64(r.Call(asi64(100), asi64(0)));
262 CHECK_TRAP64(r.Call(asi64(-1001), asi64(0))); 262 CHECK_TRAP64(r.Call(asi64(-1001), asi64(0)));
263 CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(-1))); 263 CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(-1)));
264 CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(0))); 264 CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(0)));
265 } 265 }
266 266
267 WASM_EXEC_TEST(I64DivS_Byzero_Const) { 267 WASM_EXEC_TEST_WITH_TRAP(I64DivS_Byzero_Const) {
268 REQUIRE(I64DivS); 268 REQUIRE(I64DivS);
269 for (int8_t denom = -2; denom < 8; denom++) { 269 for (int8_t denom = -2; denom < 8; denom++) {
270 WasmRunner<int64_t> r(execution_mode, MachineType::Int64()); 270 WasmRunner<int64_t> r(execution_mode, MachineType::Int64());
271 BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64V_1(denom))); 271 BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64V_1(denom)));
272 for (int64_t val = -7; val < 8; val++) { 272 for (int64_t val = -7; val < 8; val++) {
273 if (denom == 0) { 273 if (denom == 0) {
274 CHECK_TRAP64(r.Call(val)); 274 CHECK_TRAP64(r.Call(val));
275 } else { 275 } else {
276 CHECK_EQ(val / denom, r.Call(val)); 276 CHECK_EQ(val / denom, r.Call(val));
277 } 277 }
278 } 278 }
279 } 279 }
280 } 280 }
281 281
282 WASM_EXEC_TEST(I64DivU) { 282 WASM_EXEC_TEST_WITH_TRAP(I64DivU) {
283 REQUIRE(I64DivU); 283 REQUIRE(I64DivU);
284 WasmRunner<uint64_t> r(execution_mode, MachineType::Uint64(), 284 WasmRunner<uint64_t> r(execution_mode, MachineType::Uint64(),
285 MachineType::Uint64()); 285 MachineType::Uint64());
286 BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 286 BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
287 FOR_UINT64_INPUTS(i) { 287 FOR_UINT64_INPUTS(i) {
288 FOR_UINT64_INPUTS(j) { 288 FOR_UINT64_INPUTS(j) {
289 if (*j == 0) { 289 if (*j == 0) {
290 CHECK_TRAP64(r.Call(*i, *j)); 290 CHECK_TRAP64(r.Call(*i, *j));
291 } else { 291 } else {
292 CHECK_EQ(*i / *j, r.Call(*i, *j)); 292 CHECK_EQ(*i / *j, r.Call(*i, *j));
293 } 293 }
294 } 294 }
295 } 295 }
296 } 296 }
297 297
298 WASM_EXEC_TEST(I64DivU_Trap) { 298 WASM_EXEC_TEST_WITH_TRAP(I64DivU_Trap) {
299 REQUIRE(I64DivU); 299 REQUIRE(I64DivU);
300 WasmRunner<uint64_t> r(execution_mode, MachineType::Uint64(), 300 WasmRunner<uint64_t> r(execution_mode, MachineType::Uint64(),
301 MachineType::Uint64()); 301 MachineType::Uint64());
302 BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 302 BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
303 CHECK_EQ(0u, r.Call(asu64(0), asu64(100))); 303 CHECK_EQ(0u, r.Call(asu64(0), asu64(100)));
304 CHECK_TRAP64(r.Call(asu64(100), asu64(0))); 304 CHECK_TRAP64(r.Call(asu64(100), asu64(0)));
305 CHECK_TRAP64(r.Call(asu64(1001), asu64(0))); 305 CHECK_TRAP64(r.Call(asu64(1001), asu64(0)));
306 CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0))); 306 CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0)));
307 } 307 }
308 308
309 WASM_EXEC_TEST(I64DivU_Byzero_Const) { 309 WASM_EXEC_TEST_WITH_TRAP(I64DivU_Byzero_Const) {
310 REQUIRE(I64DivU); 310 REQUIRE(I64DivU);
311 for (uint64_t denom = 0xfffffffffffffffe; denom < 8; denom++) { 311 for (uint64_t denom = 0xfffffffffffffffe; denom < 8; denom++) {
312 WasmRunner<uint64_t> r(execution_mode, MachineType::Uint64()); 312 WasmRunner<uint64_t> r(execution_mode, MachineType::Uint64());
313 BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_I64V_1(denom))); 313 BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_I64V_1(denom)));
314 314
315 for (uint64_t val = 0xfffffffffffffff0; val < 8; val++) { 315 for (uint64_t val = 0xfffffffffffffff0; val < 8; val++) {
316 if (denom == 0) { 316 if (denom == 0) {
317 CHECK_TRAP64(r.Call(val)); 317 CHECK_TRAP64(r.Call(val));
318 } else { 318 } else {
319 CHECK_EQ(val / denom, r.Call(val)); 319 CHECK_EQ(val / denom, r.Call(val));
320 } 320 }
321 } 321 }
322 } 322 }
323 } 323 }
324 324
325 WASM_EXEC_TEST(I64RemS) { 325 WASM_EXEC_TEST_WITH_TRAP(I64RemS) {
326 REQUIRE(I64RemS); 326 REQUIRE(I64RemS);
327 WasmRunner<int64_t> r(execution_mode, MachineType::Int64(), 327 WasmRunner<int64_t> r(execution_mode, MachineType::Int64(),
328 MachineType::Int64()); 328 MachineType::Int64());
329 BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 329 BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
330 FOR_INT64_INPUTS(i) { 330 FOR_INT64_INPUTS(i) {
331 FOR_INT64_INPUTS(j) { 331 FOR_INT64_INPUTS(j) {
332 if (*j == 0) { 332 if (*j == 0) {
333 CHECK_TRAP64(r.Call(*i, *j)); 333 CHECK_TRAP64(r.Call(*i, *j));
334 } else { 334 } else {
335 CHECK_EQ(*i % *j, r.Call(*i, *j)); 335 CHECK_EQ(*i % *j, r.Call(*i, *j));
336 } 336 }
337 } 337 }
338 } 338 }
339 } 339 }
340 340
341 WASM_EXEC_TEST(I64RemS_Trap) { 341 WASM_EXEC_TEST_WITH_TRAP(I64RemS_Trap) {
342 REQUIRE(I64RemS); 342 REQUIRE(I64RemS);
343 WasmRunner<int64_t> r(execution_mode, MachineType::Int64(), 343 WasmRunner<int64_t> r(execution_mode, MachineType::Int64(),
344 MachineType::Int64()); 344 MachineType::Int64());
345 BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 345 BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
346 CHECK_EQ(33, r.Call(asi64(133), asi64(100))); 346 CHECK_EQ(33, r.Call(asi64(133), asi64(100)));
347 CHECK_EQ(0, r.Call(std::numeric_limits<int64_t>::min(), asi64(-1))); 347 CHECK_EQ(0, r.Call(std::numeric_limits<int64_t>::min(), asi64(-1)));
348 CHECK_TRAP64(r.Call(asi64(100), asi64(0))); 348 CHECK_TRAP64(r.Call(asi64(100), asi64(0)));
349 CHECK_TRAP64(r.Call(asi64(-1001), asi64(0))); 349 CHECK_TRAP64(r.Call(asi64(-1001), asi64(0)));
350 CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(0))); 350 CHECK_TRAP64(r.Call(std::numeric_limits<int64_t>::min(), asi64(0)));
351 } 351 }
352 352
353 WASM_EXEC_TEST(I64RemU) { 353 WASM_EXEC_TEST_WITH_TRAP(I64RemU) {
354 REQUIRE(I64RemU); 354 REQUIRE(I64RemU);
355 WasmRunner<uint64_t> r(execution_mode, MachineType::Uint64(), 355 WasmRunner<uint64_t> r(execution_mode, MachineType::Uint64(),
356 MachineType::Uint64()); 356 MachineType::Uint64());
357 BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 357 BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
358 FOR_UINT64_INPUTS(i) { 358 FOR_UINT64_INPUTS(i) {
359 FOR_UINT64_INPUTS(j) { 359 FOR_UINT64_INPUTS(j) {
360 if (*j == 0) { 360 if (*j == 0) {
361 CHECK_TRAP64(r.Call(*i, *j)); 361 CHECK_TRAP64(r.Call(*i, *j));
362 } else { 362 } else {
363 CHECK_EQ(*i % *j, r.Call(*i, *j)); 363 CHECK_EQ(*i % *j, r.Call(*i, *j));
364 } 364 }
365 } 365 }
366 } 366 }
367 } 367 }
368 368
369 WASM_EXEC_TEST(I64RemU_Trap) { 369 WASM_EXEC_TEST_WITH_TRAP(I64RemU_Trap) {
370 REQUIRE(I64RemU); 370 REQUIRE(I64RemU);
371 WasmRunner<uint64_t> r(execution_mode, MachineType::Uint64(), 371 WasmRunner<uint64_t> r(execution_mode, MachineType::Uint64(),
372 MachineType::Uint64()); 372 MachineType::Uint64());
373 BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 373 BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
374 CHECK_EQ(17u, r.Call(asu64(217), asu64(100))); 374 CHECK_EQ(17u, r.Call(asu64(217), asu64(100)));
375 CHECK_TRAP64(r.Call(asu64(100), asu64(0))); 375 CHECK_TRAP64(r.Call(asu64(100), asu64(0)));
376 CHECK_TRAP64(r.Call(asu64(1001), asu64(0))); 376 CHECK_TRAP64(r.Call(asu64(1001), asu64(0)));
377 CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0))); 377 CHECK_TRAP64(r.Call(std::numeric_limits<uint64_t>::max(), asu64(0)));
378 } 378 }
379 379
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 {0x8000008000000001, 0x43e0000010000000}, 837 {0x8000008000000001, 0x43e0000010000000},
838 {0x8000000000000400, 0x43e0000000000000}, 838 {0x8000000000000400, 0x43e0000000000000},
839 {0x8000000000000401, 0x43e0000000000001}}; 839 {0x8000000000000401, 0x43e0000000000001}};
840 WasmRunner<double> r(execution_mode, MachineType::Uint64()); 840 WasmRunner<double> r(execution_mode, MachineType::Uint64());
841 BUILD(r, WASM_F64_UCONVERT_I64(WASM_GET_LOCAL(0))); 841 BUILD(r, WASM_F64_UCONVERT_I64(WASM_GET_LOCAL(0)));
842 for (size_t i = 0; i < arraysize(values); i++) { 842 for (size_t i = 0; i < arraysize(values); i++) {
843 CHECK_EQ(bit_cast<double>(values[i].expected), r.Call(values[i].input)); 843 CHECK_EQ(bit_cast<double>(values[i].expected), r.Call(values[i].input));
844 } 844 }
845 } 845 }
846 846
847 WASM_EXEC_TEST(I64SConvertF32a) { 847 WASM_EXEC_TEST_WITH_TRAP(I64SConvertF32a) {
848 WasmRunner<int64_t> r(execution_mode, MachineType::Float32()); 848 WasmRunner<int64_t> r(execution_mode, MachineType::Float32());
849 BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0))); 849 BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0)));
850 850
851 FOR_FLOAT32_INPUTS(i) { 851 FOR_FLOAT32_INPUTS(i) {
852 if (*i < static_cast<float>(std::numeric_limits<int64_t>::max()) && 852 if (*i < static_cast<float>(std::numeric_limits<int64_t>::max()) &&
853 *i >= static_cast<float>(std::numeric_limits<int64_t>::min())) { 853 *i >= static_cast<float>(std::numeric_limits<int64_t>::min())) {
854 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); 854 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i));
855 } else { 855 } else {
856 CHECK_TRAP64(r.Call(*i)); 856 CHECK_TRAP64(r.Call(*i));
857 } 857 }
858 } 858 }
859 } 859 }
860 860
861 WASM_EXEC_TEST(I64SConvertF64a) { 861 WASM_EXEC_TEST_WITH_TRAP(I64SConvertF64a) {
862 WasmRunner<int64_t> r(execution_mode, MachineType::Float64()); 862 WasmRunner<int64_t> r(execution_mode, MachineType::Float64());
863 BUILD(r, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))); 863 BUILD(r, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0)));
864 864
865 FOR_FLOAT64_INPUTS(i) { 865 FOR_FLOAT64_INPUTS(i) {
866 if (*i < static_cast<double>(std::numeric_limits<int64_t>::max()) && 866 if (*i < static_cast<double>(std::numeric_limits<int64_t>::max()) &&
867 *i >= static_cast<double>(std::numeric_limits<int64_t>::min())) { 867 *i >= static_cast<double>(std::numeric_limits<int64_t>::min())) {
868 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); 868 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i));
869 } else { 869 } else {
870 CHECK_TRAP64(r.Call(*i)); 870 CHECK_TRAP64(r.Call(*i));
871 } 871 }
872 } 872 }
873 } 873 }
874 874
875 WASM_EXEC_TEST(I64UConvertF32a) { 875 WASM_EXEC_TEST_WITH_TRAP(I64UConvertF32a) {
876 WasmRunner<uint64_t> r(execution_mode, MachineType::Float32()); 876 WasmRunner<uint64_t> r(execution_mode, MachineType::Float32());
877 BUILD(r, WASM_I64_UCONVERT_F32(WASM_GET_LOCAL(0))); 877 BUILD(r, WASM_I64_UCONVERT_F32(WASM_GET_LOCAL(0)));
878 878
879 FOR_FLOAT32_INPUTS(i) { 879 FOR_FLOAT32_INPUTS(i) {
880 if (*i < static_cast<float>(std::numeric_limits<uint64_t>::max()) && 880 if (*i < static_cast<float>(std::numeric_limits<uint64_t>::max()) &&
881 *i > -1) { 881 *i > -1) {
882 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); 882 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i));
883 } else { 883 } else {
884 CHECK_TRAP64(r.Call(*i)); 884 CHECK_TRAP64(r.Call(*i));
885 } 885 }
886 } 886 }
887 } 887 }
888 888
889 WASM_EXEC_TEST(I64UConvertF64a) { 889 WASM_EXEC_TEST_WITH_TRAP(I64UConvertF64a) {
890 WasmRunner<uint64_t> r(execution_mode, MachineType::Float64()); 890 WasmRunner<uint64_t> r(execution_mode, MachineType::Float64());
891 BUILD(r, WASM_I64_UCONVERT_F64(WASM_GET_LOCAL(0))); 891 BUILD(r, WASM_I64_UCONVERT_F64(WASM_GET_LOCAL(0)));
892 892
893 FOR_FLOAT64_INPUTS(i) { 893 FOR_FLOAT64_INPUTS(i) {
894 if (*i < static_cast<float>(std::numeric_limits<uint64_t>::max()) && 894 if (*i < static_cast<float>(std::numeric_limits<uint64_t>::max()) &&
895 *i > -1) { 895 *i > -1) {
896 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); 896 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i));
897 } else { 897 } else {
898 CHECK_TRAP64(r.Call(*i)); 898 CHECK_TRAP64(r.Call(*i));
899 } 899 }
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 1259
1260 CHECK_EQ(expected, r.Call()); 1260 CHECK_EQ(expected, r.Call());
1261 CHECK_EQ(static_cast<byte>(i), memory[8 + size - 1]); 1261 CHECK_EQ(static_cast<byte>(i), memory[8 + size - 1]);
1262 for (int j = size; j < 8; j++) { 1262 for (int j = size; j < 8; j++) {
1263 CHECK_EQ(255, memory[8 + j]); 1263 CHECK_EQ(255, memory[8 + j]);
1264 } 1264 }
1265 } 1265 }
1266 } 1266 }
1267 } 1267 }
1268 1268
1269 WASM_EXEC_TEST(I64SConvertF32b) { 1269 WASM_EXEC_TEST_WITH_TRAP(I64SConvertF32b) {
1270 REQUIRE(I64SConvertF32); 1270 REQUIRE(I64SConvertF32);
1271 WasmRunner<int64_t> r(execution_mode, MachineType::Float32()); 1271 WasmRunner<int64_t> r(execution_mode, MachineType::Float32());
1272 BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0))); 1272 BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0)));
1273 1273
1274 FOR_FLOAT32_INPUTS(i) { 1274 FOR_FLOAT32_INPUTS(i) {
1275 if (*i < static_cast<float>(INT64_MAX) && 1275 if (*i < static_cast<float>(INT64_MAX) &&
1276 *i >= static_cast<float>(INT64_MIN)) { 1276 *i >= static_cast<float>(INT64_MIN)) {
1277 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); 1277 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i));
1278 } else { 1278 } else {
1279 CHECK_TRAP64(r.Call(*i)); 1279 CHECK_TRAP64(r.Call(*i));
1280 } 1280 }
1281 } 1281 }
1282 } 1282 }
1283 1283
1284 WASM_EXEC_TEST(I64SConvertF64b) { 1284 WASM_EXEC_TEST_WITH_TRAP(I64SConvertF64b) {
1285 REQUIRE(I64SConvertF64); 1285 REQUIRE(I64SConvertF64);
1286 WasmRunner<int64_t> r(execution_mode, MachineType::Float64()); 1286 WasmRunner<int64_t> r(execution_mode, MachineType::Float64());
1287 BUILD(r, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))); 1287 BUILD(r, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0)));
1288 1288
1289 FOR_FLOAT64_INPUTS(i) { 1289 FOR_FLOAT64_INPUTS(i) {
1290 if (*i < static_cast<double>(INT64_MAX) && 1290 if (*i < static_cast<double>(INT64_MAX) &&
1291 *i >= static_cast<double>(INT64_MIN)) { 1291 *i >= static_cast<double>(INT64_MIN)) {
1292 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); 1292 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i));
1293 } else { 1293 } else {
1294 CHECK_TRAP64(r.Call(*i)); 1294 CHECK_TRAP64(r.Call(*i));
1295 } 1295 }
1296 } 1296 }
1297 } 1297 }
1298 1298
1299 WASM_EXEC_TEST(I64UConvertF32b) { 1299 WASM_EXEC_TEST_WITH_TRAP(I64UConvertF32b) {
1300 REQUIRE(I64UConvertF32); 1300 REQUIRE(I64UConvertF32);
1301 WasmRunner<uint64_t> r(execution_mode, MachineType::Float32()); 1301 WasmRunner<uint64_t> r(execution_mode, MachineType::Float32());
1302 BUILD(r, WASM_I64_UCONVERT_F32(WASM_GET_LOCAL(0))); 1302 BUILD(r, WASM_I64_UCONVERT_F32(WASM_GET_LOCAL(0)));
1303 1303
1304 FOR_FLOAT32_INPUTS(i) { 1304 FOR_FLOAT32_INPUTS(i) {
1305 if (*i < static_cast<float>(UINT64_MAX) && *i > -1) { 1305 if (*i < static_cast<float>(UINT64_MAX) && *i > -1) {
1306 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); 1306 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i));
1307 } else { 1307 } else {
1308 CHECK_TRAP64(r.Call(*i)); 1308 CHECK_TRAP64(r.Call(*i));
1309 } 1309 }
1310 } 1310 }
1311 } 1311 }
1312 1312
1313 WASM_EXEC_TEST(I64UConvertF64b) { 1313 WASM_EXEC_TEST_WITH_TRAP(I64UConvertF64b) {
1314 REQUIRE(I64UConvertF64); 1314 REQUIRE(I64UConvertF64);
1315 WasmRunner<uint64_t> r(execution_mode, MachineType::Float64()); 1315 WasmRunner<uint64_t> r(execution_mode, MachineType::Float64());
1316 BUILD(r, WASM_I64_UCONVERT_F64(WASM_GET_LOCAL(0))); 1316 BUILD(r, WASM_I64_UCONVERT_F64(WASM_GET_LOCAL(0)));
1317 1317
1318 FOR_FLOAT64_INPUTS(i) { 1318 FOR_FLOAT64_INPUTS(i) {
1319 if (*i < static_cast<float>(UINT64_MAX) && *i > -1) { 1319 if (*i < static_cast<float>(UINT64_MAX) && *i > -1) {
1320 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i)); 1320 CHECK_EQ(static_cast<uint64_t>(*i), r.Call(*i));
1321 } else { 1321 } else {
1322 CHECK_TRAP64(r.Call(*i)); 1322 CHECK_TRAP64(r.Call(*i));
1323 } 1323 }
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 BUILD(r, WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 1506 BUILD(r, WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
1507 1507
1508 FOR_UINT64_INPUTS(i) { 1508 FOR_UINT64_INPUTS(i) {
1509 FOR_UINT64_INPUTS(j) { 1509 FOR_UINT64_INPUTS(j) {
1510 int64_t expected = bits::RotateLeft64(*i, *j & 0x3f); 1510 int64_t expected = bits::RotateLeft64(*i, *j & 0x3f);
1511 CHECK_EQ(expected, r.Call(*i, *j)); 1511 CHECK_EQ(expected, r.Call(*i, *j));
1512 } 1512 }
1513 } 1513 }
1514 } 1514 }
1515 1515
1516 WASM_EXEC_TEST(StoreMem_offset_oob_i64) { 1516 WASM_EXEC_TEST_WITH_TRAP(StoreMem_offset_oob_i64) {
1517 TestingModule module(execution_mode); 1517 TestingModule module(execution_mode);
1518 byte* memory = module.AddMemoryElems<byte>(32); 1518 byte* memory = module.AddMemoryElems<byte>(32);
1519 1519
1520 static const MachineType machineTypes[] = { 1520 static const MachineType machineTypes[] = {
1521 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(), 1521 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(),
1522 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(), 1522 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(),
1523 MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(), 1523 MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(),
1524 MachineType::Float64()}; 1524 MachineType::Float64()};
1525 1525
1526 for (size_t m = 0; m < arraysize(machineTypes); m++) { 1526 for (size_t m = 0; m < arraysize(machineTypes); m++) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 CHECK_EQ(expected, result); 1654 CHECK_EQ(expected, result);
1655 } 1655 }
1656 } 1656 }
1657 } 1657 }
1658 } 1658 }
1659 1659
1660 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); }
1661 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); }
1662 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); }
1663 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); }
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm.cc ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698