OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this | 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "test/cctest/cctest.h" | 5 #include "test/cctest/cctest.h" |
6 #include "test/cctest/compiler/codegen-tester.h" | 6 #include "test/cctest/compiler/codegen-tester.h" |
7 #include "test/cctest/compiler/value-helper.h" | 7 #include "test/cctest/compiler/value-helper.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 input = *i; | 417 input = *i; |
418 if (*i > -1.0 && | 418 if (*i > -1.0 && |
419 *i < static_cast<double>(std::numeric_limits<uint64_t>::max())) { | 419 *i < static_cast<double>(std::numeric_limits<uint64_t>::max())) { |
420 CHECK_EQ(1, m.Call()); | 420 CHECK_EQ(1, m.Call()); |
421 CHECK_EQ(static_cast<uint64_t>(*i), output); | 421 CHECK_EQ(static_cast<uint64_t>(*i), output); |
422 } else { | 422 } else { |
423 CHECK_EQ(0, m.Call()); | 423 CHECK_EQ(0, m.Call()); |
424 } | 424 } |
425 } | 425 } |
426 } | 426 } |
| 427 |
| 428 TEST(RunCallInt64Div) { |
| 429 BufferedRawMachineAssemblerTester<int32_t> m; |
| 430 ExternalReference ref = ExternalReference::wasm_int64_div(m.isolate()); |
| 431 |
| 432 int64_t dst; |
| 433 int64_t src; |
| 434 |
| 435 Node* function = m.ExternalConstant(ref); |
| 436 m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Pointer(), |
| 437 MachineType::Pointer(), function, |
| 438 m.PointerConstant(&dst), m.PointerConstant(&src))); |
| 439 FOR_INT64_INPUTS(i) { |
| 440 FOR_INT64_INPUTS(j) { |
| 441 dst = *i; |
| 442 src = *j; |
| 443 if (src == 0) { |
| 444 CHECK_EQ(0, m.Call()); |
| 445 } else if (src == -1 && dst == std::numeric_limits<int64_t>::min()) { |
| 446 CHECK_EQ(-1, m.Call()); |
| 447 } else { |
| 448 CHECK_EQ(1, m.Call()); |
| 449 CHECK_EQ(*i / *j, dst); |
| 450 } |
| 451 } |
| 452 } |
| 453 } |
| 454 |
| 455 TEST(RunCallInt64Mod) { |
| 456 BufferedRawMachineAssemblerTester<int32_t> m; |
| 457 ExternalReference ref = ExternalReference::wasm_int64_mod(m.isolate()); |
| 458 |
| 459 int64_t dst; |
| 460 int64_t src; |
| 461 |
| 462 Node* function = m.ExternalConstant(ref); |
| 463 m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Pointer(), |
| 464 MachineType::Pointer(), function, |
| 465 m.PointerConstant(&dst), m.PointerConstant(&src))); |
| 466 FOR_INT64_INPUTS(i) { |
| 467 FOR_INT64_INPUTS(j) { |
| 468 dst = *i; |
| 469 src = *j; |
| 470 if (src == 0) { |
| 471 CHECK_EQ(0, m.Call()); |
| 472 } else { |
| 473 CHECK_EQ(1, m.Call()); |
| 474 CHECK_EQ(*i % *j, dst); |
| 475 } |
| 476 } |
| 477 } |
| 478 } |
| 479 |
| 480 TEST(RunCallUint64Div) { |
| 481 BufferedRawMachineAssemblerTester<int32_t> m; |
| 482 ExternalReference ref = ExternalReference::wasm_uint64_div(m.isolate()); |
| 483 |
| 484 uint64_t dst; |
| 485 uint64_t src; |
| 486 |
| 487 Node* function = m.ExternalConstant(ref); |
| 488 m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Pointer(), |
| 489 MachineType::Pointer(), function, |
| 490 m.PointerConstant(&dst), m.PointerConstant(&src))); |
| 491 FOR_UINT64_INPUTS(i) { |
| 492 FOR_UINT64_INPUTS(j) { |
| 493 dst = *i; |
| 494 src = *j; |
| 495 if (src == 0) { |
| 496 CHECK_EQ(0, m.Call()); |
| 497 } else { |
| 498 CHECK_EQ(1, m.Call()); |
| 499 CHECK_EQ(*i / *j, dst); |
| 500 } |
| 501 } |
| 502 } |
| 503 } |
| 504 |
| 505 TEST(RunCallUint64Mod) { |
| 506 BufferedRawMachineAssemblerTester<int32_t> m; |
| 507 ExternalReference ref = ExternalReference::wasm_uint64_mod(m.isolate()); |
| 508 |
| 509 uint64_t dst; |
| 510 uint64_t src; |
| 511 |
| 512 Node* function = m.ExternalConstant(ref); |
| 513 m.Return(m.CallCFunction2(MachineType::Int32(), MachineType::Pointer(), |
| 514 MachineType::Pointer(), function, |
| 515 m.PointerConstant(&dst), m.PointerConstant(&src))); |
| 516 FOR_UINT64_INPUTS(i) { |
| 517 FOR_UINT64_INPUTS(j) { |
| 518 dst = *i; |
| 519 src = *j; |
| 520 if (src == 0) { |
| 521 CHECK_EQ(0, m.Call()); |
| 522 } else { |
| 523 CHECK_EQ(1, m.Call()); |
| 524 CHECK_EQ(*i % *j, dst); |
| 525 } |
| 526 } |
| 527 } |
| 528 } |
427 } // namespace compiler | 529 } // namespace compiler |
428 } // namespace internal | 530 } // namespace internal |
429 } // namespace v8 | 531 } // namespace v8 |
OLD | NEW |