| 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 { |
| 11 namespace compiler { | 11 namespace compiler { |
| 12 | 12 |
| 13 template <typename T> | 13 template <typename T> |
| 14 void TestExternalReferenceRoundingFunction( | 14 void TestExternalReferenceRoundingFunction( |
| 15 BufferedRawMachineAssemblerTester<int32_t>* m, ExternalReference ref, | 15 BufferedRawMachineAssemblerTester<int32_t>* m, ExternalReference ref, |
| 16 T (*comparison)(T)) { | 16 T (*comparison)(T)) { |
| 17 T parameter; | 17 T parameter; |
| 18 | 18 |
| 19 Node* function = m->ExternalConstant(ref); | 19 Node* function = m->ExternalConstant(ref); |
| 20 m->CallCFunction1(MachineType::Pointer(), MachineType::Pointer(), function, | 20 m->CallCFunction1(MachineType::Pointer(), MachineType::Pointer(), function, |
| 21 m->PointerConstant(¶meter)); | 21 m->PointerConstant(¶meter)); |
| 22 m->Return(m->Int32Constant(4356)); | 22 m->Return(m->Int32Constant(4356)); |
| 23 FOR_FLOAT64_INPUTS(i) { | 23 FOR_FLOAT64_INPUTS(i) { |
| 24 parameter = *i; | 24 parameter = *i; |
| 25 m->Call(); | 25 m->Call(); |
| 26 CheckDoubleEq(comparison(*i), parameter); | 26 CHECK_DOUBLE_EQ(comparison(*i), parameter); |
| 27 } | 27 } |
| 28 } | 28 } |
| 29 | 29 |
| 30 TEST(RunCallF32Trunc) { | 30 TEST(RunCallF32Trunc) { |
| 31 BufferedRawMachineAssemblerTester<int32_t> m; | 31 BufferedRawMachineAssemblerTester<int32_t> m; |
| 32 ExternalReference ref = ExternalReference::wasm_f32_trunc(m.isolate()); | 32 ExternalReference ref = ExternalReference::wasm_f32_trunc(m.isolate()); |
| 33 TestExternalReferenceRoundingFunction<float>(&m, ref, truncf); | 33 TestExternalReferenceRoundingFunction<float>(&m, ref, truncf); |
| 34 } | 34 } |
| 35 | 35 |
| 36 TEST(RunCallF32Floor) { | 36 TEST(RunCallF32Floor) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 float output; | 83 float output; |
| 84 | 84 |
| 85 Node* function = m.ExternalConstant(ref); | 85 Node* function = m.ExternalConstant(ref); |
| 86 m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(), | 86 m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(), |
| 87 MachineType::Pointer(), function, m.PointerConstant(&input), | 87 MachineType::Pointer(), function, m.PointerConstant(&input), |
| 88 m.PointerConstant(&output)); | 88 m.PointerConstant(&output)); |
| 89 m.Return(m.Int32Constant(4356)); | 89 m.Return(m.Int32Constant(4356)); |
| 90 FOR_INT64_INPUTS(i) { | 90 FOR_INT64_INPUTS(i) { |
| 91 input = *i; | 91 input = *i; |
| 92 m.Call(); | 92 m.Call(); |
| 93 CheckFloatEq(static_cast<float>(*i), output); | 93 CHECK_FLOAT_EQ(static_cast<float>(*i), output); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 TEST(RunCallUint64ToFloat32) { | 97 TEST(RunCallUint64ToFloat32) { |
| 98 struct { | 98 struct { |
| 99 uint64_t input; | 99 uint64_t input; |
| 100 uint32_t expected; | 100 uint32_t expected; |
| 101 } values[] = {{0x0, 0x0}, | 101 } values[] = {{0x0, 0x0}, |
| 102 {0x1, 0x3f800000}, | 102 {0x1, 0x3f800000}, |
| 103 {0xffffffff, 0x4f800000}, | 103 {0xffffffff, 0x4f800000}, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 double output; | 211 double output; |
| 212 | 212 |
| 213 Node* function = m.ExternalConstant(ref); | 213 Node* function = m.ExternalConstant(ref); |
| 214 m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(), | 214 m.CallCFunction2(MachineType::Pointer(), MachineType::Pointer(), |
| 215 MachineType::Pointer(), function, m.PointerConstant(&input), | 215 MachineType::Pointer(), function, m.PointerConstant(&input), |
| 216 m.PointerConstant(&output)); | 216 m.PointerConstant(&output)); |
| 217 m.Return(m.Int32Constant(4356)); | 217 m.Return(m.Int32Constant(4356)); |
| 218 FOR_INT64_INPUTS(i) { | 218 FOR_INT64_INPUTS(i) { |
| 219 input = *i; | 219 input = *i; |
| 220 m.Call(); | 220 m.Call(); |
| 221 CheckDoubleEq(static_cast<double>(*i), output); | 221 CHECK_DOUBLE_EQ(static_cast<double>(*i), output); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 | 224 |
| 225 TEST(RunCallUint64ToFloat64) { | 225 TEST(RunCallUint64ToFloat64) { |
| 226 struct { | 226 struct { |
| 227 uint64_t input; | 227 uint64_t input; |
| 228 uint64_t expected; | 228 uint64_t expected; |
| 229 } values[] = {{0x0, 0x0}, | 229 } values[] = {{0x0, 0x0}, |
| 230 {0x1, 0x3ff0000000000000}, | 230 {0x1, 0x3ff0000000000000}, |
| 231 {0xffffffff, 0x41efffffffe00000}, | 231 {0xffffffff, 0x41efffffffe00000}, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 for (size_t i = 0; i < arraysize(values); i++) { | 327 for (size_t i = 0; i < arraysize(values); i++) { |
| 328 input = values[i].input; | 328 input = values[i].input; |
| 329 m.Call(); | 329 m.Call(); |
| 330 CHECK_EQ(values[i].expected, bit_cast<uint64_t>(output)); | 330 CHECK_EQ(values[i].expected, bit_cast<uint64_t>(output)); |
| 331 } | 331 } |
| 332 } | 332 } |
| 333 | 333 |
| 334 } // namespace compiler | 334 } // namespace compiler |
| 335 } // namespace internal | 335 } // namespace internal |
| 336 } // namespace v8 | 336 } // namespace v8 |
| OLD | NEW |