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

Side by Side Diff: test/cctest/compiler/test-run-machops.cc

Issue 1738623003: [wasm] Int64Lowering of FXXXConvertI64 instructions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make code dependent on V8_CC_MSC and not V8_OS_WIN Created 4 years, 9 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
OLDNEW
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 <cmath> 5 #include <cmath>
6 #include <functional> 6 #include <functional>
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
(...skipping 5636 matching lines...) Expand 10 before | Expand all | Expand 10 after
5647 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(), 5647 MachineType::Int32(), MachineType::Int32(), MachineType::Int32(),
5648 function, param, param, param, param, param, param, param, param)); 5648 function, param, param, param, param, param, param, param, param));
5649 FOR_INT32_INPUTS(i) { 5649 FOR_INT32_INPUTS(i) {
5650 int32_t const x = *i; 5650 int32_t const x = *i;
5651 CHECK_EQ(x * 8, m.Call(x)); 5651 CHECK_EQ(x * 8, m.Call(x));
5652 } 5652 }
5653 } 5653 }
5654 #endif // USE_SIMULATOR 5654 #endif // USE_SIMULATOR
5655 5655
5656 template <typename T> 5656 template <typename T>
5657 void TestExternalReferenceFunction( 5657 void TestExternalReferenceRoundingFunction(
titzer 2016/02/25 17:04:33 Can we split all these external references tests i
ahaas 2016/02/25 18:29:18 Done.
5658 BufferedRawMachineAssemblerTester<int32_t>* m, ExternalReference ref, 5658 BufferedRawMachineAssemblerTester<int32_t>* m, ExternalReference ref,
5659 T (*comparison)(T)) { 5659 T (*comparison)(T)) {
5660 T parameter; 5660 T parameter;
5661 5661
5662 Node* function = m->ExternalConstant(ref); 5662 Node* function = m->ExternalConstant(ref);
5663 m->CallCFunction1(MachineType::Pointer(), MachineType::Pointer(), function, 5663 m->CallCFunction1(MachineType::Pointer(), MachineType::Pointer(), function,
5664 m->PointerConstant(&parameter)); 5664 m->PointerConstant(&parameter));
5665 m->Return(m->Int32Constant(4356)); 5665 m->Return(m->Int32Constant(4356));
5666 FOR_FLOAT64_INPUTS(i) { 5666 FOR_FLOAT64_INPUTS(i) {
5667 parameter = *i; 5667 parameter = *i;
5668 m->Call(); 5668 m->Call();
5669 CheckDoubleEq(comparison(*i), parameter); 5669 CheckDoubleEq(comparison(*i), parameter);
5670 } 5670 }
5671 } 5671 }
5672 5672
5673 TEST(RunCallExternalReferenceF32Trunc) { 5673 TEST(RunCallExternalReferenceF32Trunc) {
5674 BufferedRawMachineAssemblerTester<int32_t> m; 5674 BufferedRawMachineAssemblerTester<int32_t> m;
5675 ExternalReference ref = 5675 ExternalReference ref = ExternalReference::wasm_f32_trunc(m.isolate());
5676 ExternalReference::f32_trunc_wrapper_function(m.isolate()); 5676 TestExternalReferenceRoundingFunction<float>(&m, ref, truncf);
5677 TestExternalReferenceFunction<float>(&m, ref, truncf);
5678 } 5677 }
5679 5678
5680 TEST(RunCallExternalReferenceF32Floor) { 5679 TEST(RunCallExternalReferenceF32Floor) {
5681 BufferedRawMachineAssemblerTester<int32_t> m; 5680 BufferedRawMachineAssemblerTester<int32_t> m;
5682 ExternalReference ref = 5681 ExternalReference ref = ExternalReference::wasm_f32_floor(m.isolate());
5683 ExternalReference::f32_floor_wrapper_function(m.isolate()); 5682 TestExternalReferenceRoundingFunction<float>(&m, ref, floorf);
5684 TestExternalReferenceFunction<float>(&m, ref, floorf);
5685 } 5683 }
5686 5684
5687 TEST(RunCallExternalReferenceF32Ceil) { 5685 TEST(RunCallExternalReferenceF32Ceil) {
5688 BufferedRawMachineAssemblerTester<int32_t> m; 5686 BufferedRawMachineAssemblerTester<int32_t> m;
5689 ExternalReference ref = 5687 ExternalReference ref = ExternalReference::wasm_f32_ceil(m.isolate());
5690 ExternalReference::f32_ceil_wrapper_function(m.isolate()); 5688 TestExternalReferenceRoundingFunction<float>(&m, ref, ceilf);
5691 TestExternalReferenceFunction<float>(&m, ref, ceilf);
5692 } 5689 }
5693 5690
5694 TEST(RunCallExternalReferenceF32RoundTiesEven) { 5691 TEST(RunCallExternalReferenceF32RoundTiesEven) {
5695 BufferedRawMachineAssemblerTester<int32_t> m; 5692 BufferedRawMachineAssemblerTester<int32_t> m;
5696 ExternalReference ref = 5693 ExternalReference ref = ExternalReference::wasm_f32_nearest_int(m.isolate());
5697 ExternalReference::f32_nearest_int_wrapper_function(m.isolate()); 5694 TestExternalReferenceRoundingFunction<float>(&m, ref, nearbyintf);
5698 TestExternalReferenceFunction<float>(&m, ref, nearbyintf);
5699 } 5695 }
5700 5696
5701 TEST(RunCallExternalReferenceF64Trunc) { 5697 TEST(RunCallExternalReferenceF64Trunc) {
5702 BufferedRawMachineAssemblerTester<int32_t> m; 5698 BufferedRawMachineAssemblerTester<int32_t> m;
5703 ExternalReference ref = 5699 ExternalReference ref = ExternalReference::wasm_f64_trunc(m.isolate());
5704 ExternalReference::f64_trunc_wrapper_function(m.isolate()); 5700 TestExternalReferenceRoundingFunction<double>(&m, ref, trunc);
5705 TestExternalReferenceFunction<double>(&m, ref, trunc);
5706 } 5701 }
5707 5702
5708 TEST(RunCallExternalReferenceF64Floor) { 5703 TEST(RunCallExternalReferenceF64Floor) {
5709 BufferedRawMachineAssemblerTester<int32_t> m; 5704 BufferedRawMachineAssemblerTester<int32_t> m;
5710 ExternalReference ref = 5705 ExternalReference ref = ExternalReference::wasm_f64_floor(m.isolate());
5711 ExternalReference::f64_floor_wrapper_function(m.isolate()); 5706 TestExternalReferenceRoundingFunction<double>(&m, ref, floor);
5712 TestExternalReferenceFunction<double>(&m, ref, floor);
5713 } 5707 }
5714 5708
5715 TEST(RunCallExternalReferenceF64Ceil) { 5709 TEST(RunCallExternalReferenceF64Ceil) {
5716 BufferedRawMachineAssemblerTester<int32_t> m; 5710 BufferedRawMachineAssemblerTester<int32_t> m;
5717 ExternalReference ref = 5711 ExternalReference ref = ExternalReference::wasm_f64_ceil(m.isolate());
5718 ExternalReference::f64_ceil_wrapper_function(m.isolate()); 5712 TestExternalReferenceRoundingFunction<double>(&m, ref, ceil);
5719 TestExternalReferenceFunction<double>(&m, ref, ceil);
5720 } 5713 }
5721 5714
5722 TEST(RunCallExternalReferenceF64RoundTiesEven) { 5715 TEST(RunCallExternalReferenceF64RoundTiesEven) {
5723 BufferedRawMachineAssemblerTester<int32_t> m; 5716 BufferedRawMachineAssemblerTester<int32_t> m;
5717 ExternalReference ref = ExternalReference::wasm_f64_nearest_int(m.isolate());
5718 TestExternalReferenceRoundingFunction<double>(&m, ref, nearbyint);
5719 }
5720
5721 TEST(RunCallExternalReferenceConvertInt64ToFloat32) {
5722 BufferedRawMachineAssemblerTester<int32_t> m;
5723 ExternalReference ref = ExternalReference::wasm_int64_to_float32(m.isolate());
5724
5725 int64_t input;
5726 float output;
5727
5728 Node* function = m.ExternalConstant(ref);
5729 m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(),
5730 MachineType::Pointer(), function, m.PointerConstant(&input),
5731 m.PointerConstant(&output));
5732 m.Return(m.Int32Constant(4356));
5733 FOR_INT64_INPUTS(i) {
5734 input = *i;
5735 m.Call();
5736 CheckFloatEq(static_cast<float>(*i), output);
5737 }
5738 }
5739
5740 TEST(RunCallExternalReferenceConvertUint64ToFloat32) {
5741 BufferedRawMachineAssemblerTester<int32_t> m;
5724 ExternalReference ref = 5742 ExternalReference ref =
5725 ExternalReference::f64_nearest_int_wrapper_function(m.isolate()); 5743 ExternalReference::wasm_uint64_to_float32(m.isolate());
5726 TestExternalReferenceFunction<double>(&m, ref, nearbyint); 5744
5745 uint64_t input;
5746 float output;
5747
5748 Node* function = m.ExternalConstant(ref);
5749 m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(),
5750 MachineType::Pointer(), function, m.PointerConstant(&input),
5751 m.PointerConstant(&output));
5752 m.Return(m.Int32Constant(4356));
5753 FOR_UINT64_INPUTS(i) {
5754 input = *i;
5755 m.Call();
5756 CheckFloatEq(static_cast<float>(*i), output);
5757 }
5758 }
5759
5760 TEST(RunCallExternalReferenceConvertInt64ToFloat64) {
5761 BufferedRawMachineAssemblerTester<int32_t> m;
5762 ExternalReference ref = ExternalReference::wasm_int64_to_float64(m.isolate());
5763
5764 int64_t input;
5765 double output;
5766
5767 Node* function = m.ExternalConstant(ref);
5768 m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(),
5769 MachineType::Pointer(), function, m.PointerConstant(&input),
5770 m.PointerConstant(&output));
5771 m.Return(m.Int32Constant(4356));
5772 FOR_INT64_INPUTS(i) {
5773 input = *i;
5774 m.Call();
5775 CheckDoubleEq(static_cast<double>(*i), output);
5776 }
5777 }
5778
5779 TEST(RunCallExternalReferenceConvertUint64ToFloat64) {
5780 BufferedRawMachineAssemblerTester<int32_t> m;
5781 ExternalReference ref =
5782 ExternalReference::wasm_uint64_to_float64(m.isolate());
5783
5784 uint64_t input;
5785 double output;
5786
5787 Node* function = m.ExternalConstant(ref);
5788 m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(),
5789 MachineType::Pointer(), function, m.PointerConstant(&input),
5790 m.PointerConstant(&output));
5791 m.Return(m.Int32Constant(4356));
5792 FOR_UINT64_INPUTS(i) {
5793 input = *i;
5794 m.Call();
5795 CheckDoubleEq(static_cast<double>(*i), output);
5796 }
5727 } 5797 }
5728 5798
5729 #if V8_TARGET_ARCH_64_BIT 5799 #if V8_TARGET_ARCH_64_BIT
5730 // TODO(titzer): run int64 tests on all platforms when supported. 5800 // TODO(titzer): run int64 tests on all platforms when supported.
5731 TEST(RunCheckedLoadInt64) { 5801 TEST(RunCheckedLoadInt64) {
5732 int64_t buffer[] = {0x66bbccddeeff0011LL, 0x1122334455667788LL}; 5802 int64_t buffer[] = {0x66bbccddeeff0011LL, 0x1122334455667788LL};
5733 RawMachineAssemblerTester<int64_t> m(MachineType::Int32()); 5803 RawMachineAssemblerTester<int64_t> m(MachineType::Int32());
5734 Node* base = m.PointerConstant(buffer); 5804 Node* base = m.PointerConstant(buffer);
5735 Node* index = m.Parameter(0); 5805 Node* index = m.Parameter(0);
5736 Node* length = m.Int32Constant(16); 5806 Node* length = m.Int32Constant(16);
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
6254 r.Goto(&merge); 6324 r.Goto(&merge);
6255 r.Bind(&merge); 6325 r.Bind(&merge);
6256 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb); 6326 Node* phi = r.Phi(MachineRepresentation::kWord32, fa, fb);
6257 r.Return(phi); 6327 r.Return(phi);
6258 CHECK_EQ(1, r.Call(1)); 6328 CHECK_EQ(1, r.Call(1));
6259 } 6329 }
6260 6330
6261 } // namespace compiler 6331 } // namespace compiler
6262 } // namespace internal 6332 } // namespace internal
6263 } // namespace v8 6333 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698