| 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 "src/wasm/wasm-external-refs.h" | 5 #include "src/wasm/wasm-external-refs.h" |
| 6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
| 7 #include "test/cctest/compiler/codegen-tester.h" | 7 #include "test/cctest/compiler/codegen-tester.h" |
| 8 #include "test/cctest/compiler/value-helper.h" | 8 #include "test/cctest/compiler/value-helper.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 m->PointerConstant(¶m1), m->PointerConstant(¶m2)); | 41 m->PointerConstant(¶m1), m->PointerConstant(¶m2)); |
| 42 m->Return(m->Int32Constant(4356)); | 42 m->Return(m->Int32Constant(4356)); |
| 43 | 43 |
| 44 m->Call(); | 44 m->Call(); |
| 45 comparison(&comparison_param1, &comparison_param2); | 45 comparison(&comparison_param1, &comparison_param2); |
| 46 | 46 |
| 47 CHECK_EQ(comparison_param1, param1); | 47 CHECK_EQ(comparison_param1, param1); |
| 48 CHECK_EQ(comparison_param2, param2); | 48 CHECK_EQ(comparison_param2, param2); |
| 49 } | 49 } |
| 50 | 50 |
| 51 template <typename R, typename P> |
| 52 void TestExternalReference(BufferedRawMachineAssemblerTester<R>* m, |
| 53 ExternalReference ref, R (*comparison)(P*), |
| 54 P param) { |
| 55 P comparison_param = param; |
| 56 |
| 57 Node* function = m->ExternalConstant(ref); |
| 58 m->Return(m->CallCFunction1(MachineType::Pointer(), MachineType::Pointer(), |
| 59 function, m->PointerConstant(¶m))); |
| 60 |
| 61 CHECK_EQ(comparison(&comparison_param), m->Call()); |
| 62 |
| 63 CHECK_EQ(comparison_param, param); |
| 64 } |
| 65 |
| 51 template <typename R, typename P1, typename P2> | 66 template <typename R, typename P1, typename P2> |
| 52 void TestExternalReference(BufferedRawMachineAssemblerTester<R>* m, | 67 void TestExternalReference(BufferedRawMachineAssemblerTester<R>* m, |
| 53 ExternalReference ref, R (*comparison)(P1*, P2*), | 68 ExternalReference ref, R (*comparison)(P1*, P2*), |
| 54 P1 param1, P2 param2) { | 69 P1 param1, P2 param2) { |
| 55 P1 comparison_param1 = param1; | 70 P1 comparison_param1 = param1; |
| 56 P2 comparison_param2 = param2; | 71 P2 comparison_param2 = param2; |
| 57 | 72 |
| 58 Node* function = m->ExternalConstant(ref); | 73 Node* function = m->ExternalConstant(ref); |
| 59 m->Return(m->CallCFunction2( | 74 m->Return(m->CallCFunction2( |
| 60 MachineType::Pointer(), MachineType::Pointer(), MachineType::Pointer(), | 75 MachineType::Pointer(), MachineType::Pointer(), MachineType::Pointer(), |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 TestExternalReference(&m, ref, wasm::uint64_div_wrapper, uint64_t(1774), | 209 TestExternalReference(&m, ref, wasm::uint64_div_wrapper, uint64_t(1774), |
| 195 uint64_t(21)); | 210 uint64_t(21)); |
| 196 } | 211 } |
| 197 | 212 |
| 198 TEST(RunCallUint64Mod) { | 213 TEST(RunCallUint64Mod) { |
| 199 BufferedRawMachineAssemblerTester<int32_t> m; | 214 BufferedRawMachineAssemblerTester<int32_t> m; |
| 200 ExternalReference ref = ExternalReference::wasm_uint64_mod(m.isolate()); | 215 ExternalReference ref = ExternalReference::wasm_uint64_mod(m.isolate()); |
| 201 TestExternalReference(&m, ref, wasm::uint64_mod_wrapper, uint64_t(1774), | 216 TestExternalReference(&m, ref, wasm::uint64_mod_wrapper, uint64_t(1774), |
| 202 uint64_t(21)); | 217 uint64_t(21)); |
| 203 } | 218 } |
| 219 |
| 220 TEST(RunCallWord32Ctz) { |
| 221 BufferedRawMachineAssemblerTester<uint32_t> m; |
| 222 ExternalReference ref = ExternalReference::wasm_word32_ctz(m.isolate()); |
| 223 TestExternalReference(&m, ref, wasm::word32_ctz_wrapper, uint32_t(1774)); |
| 224 } |
| 225 |
| 226 TEST(RunCallWord64Ctz) { |
| 227 BufferedRawMachineAssemblerTester<uint32_t> m; |
| 228 ExternalReference ref = ExternalReference::wasm_word64_ctz(m.isolate()); |
| 229 TestExternalReference(&m, ref, wasm::word64_ctz_wrapper, uint64_t(1774)); |
| 230 } |
| 231 |
| 232 TEST(RunCallWord32Popcnt) { |
| 233 BufferedRawMachineAssemblerTester<uint32_t> m; |
| 234 ExternalReference ref = ExternalReference::wasm_word32_popcnt(m.isolate()); |
| 235 TestExternalReference(&m, ref, wasm::word32_popcnt_wrapper, uint32_t(1774)); |
| 236 } |
| 237 |
| 238 TEST(RunCallWord64Popcnt) { |
| 239 BufferedRawMachineAssemblerTester<uint32_t> m; |
| 240 ExternalReference ref = ExternalReference::wasm_word64_popcnt(m.isolate()); |
| 241 TestExternalReference(&m, ref, wasm::word64_popcnt_wrapper, uint64_t(1774)); |
| 242 } |
| 204 } // namespace compiler | 243 } // namespace compiler |
| 205 } // namespace internal | 244 } // namespace internal |
| 206 } // namespace v8 | 245 } // namespace v8 |
| OLD | NEW |