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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 m.PointerConstant(&output)); | 324 m.PointerConstant(&output)); |
325 m.Return(m.Int32Constant(4356)); | 325 m.Return(m.Int32Constant(4356)); |
326 | 326 |
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 TEST(RunCallFloat32ToInt64) { |
| 335 BufferedRawMachineAssemblerTester<int32_t> m; |
| 336 ExternalReference ref = ExternalReference::wasm_float32_to_int64(m.isolate()); |
| 337 |
| 338 float input; |
| 339 int64_t output; |
| 340 |
| 341 Node* function = m.ExternalConstant(ref); |
| 342 m.Return(m.CallCFunction2( |
| 343 MachineType::Int32(), MachineType::Pointer(), MachineType::Pointer(), |
| 344 function, m.PointerConstant(&input), m.PointerConstant(&output))); |
| 345 FOR_FLOAT32_INPUTS(i) { |
| 346 input = *i; |
| 347 if (*i >= static_cast<float>(std::numeric_limits<int64_t>::min()) && |
| 348 *i < static_cast<float>(std::numeric_limits<int64_t>::max())) { |
| 349 CHECK_EQ(1, m.Call()); |
| 350 CHECK_EQ(static_cast<int64_t>(*i), output); |
| 351 } else { |
| 352 CHECK_EQ(0, m.Call()); |
| 353 } |
| 354 } |
| 355 } |
| 356 |
| 357 TEST(RunCallFloat32ToUint64) { |
| 358 BufferedRawMachineAssemblerTester<int32_t> m; |
| 359 ExternalReference ref = |
| 360 ExternalReference::wasm_float32_to_uint64(m.isolate()); |
| 361 |
| 362 float input; |
| 363 uint64_t output; |
| 364 |
| 365 Node* function = m.ExternalConstant(ref); |
| 366 m.Return(m.CallCFunction2( |
| 367 MachineType::Int32(), MachineType::Pointer(), MachineType::Pointer(), |
| 368 function, m.PointerConstant(&input), m.PointerConstant(&output))); |
| 369 FOR_FLOAT32_INPUTS(i) { |
| 370 input = *i; |
| 371 if (*i > -1.0 && |
| 372 *i < static_cast<float>(std::numeric_limits<uint64_t>::max())) { |
| 373 CHECK_EQ(1, m.Call()); |
| 374 CHECK_EQ(static_cast<uint64_t>(*i), output); |
| 375 } else { |
| 376 CHECK_EQ(0, m.Call()); |
| 377 } |
| 378 } |
| 379 } |
| 380 |
| 381 TEST(RunCallFloat64ToInt64) { |
| 382 BufferedRawMachineAssemblerTester<int32_t> m; |
| 383 ExternalReference ref = ExternalReference::wasm_float64_to_int64(m.isolate()); |
| 384 |
| 385 double input; |
| 386 int64_t output; |
| 387 |
| 388 Node* function = m.ExternalConstant(ref); |
| 389 m.Return(m.CallCFunction2( |
| 390 MachineType::Int32(), MachineType::Pointer(), MachineType::Pointer(), |
| 391 function, m.PointerConstant(&input), m.PointerConstant(&output))); |
| 392 FOR_FLOAT64_INPUTS(i) { |
| 393 input = *i; |
| 394 if (*i >= static_cast<double>(std::numeric_limits<int64_t>::min()) && |
| 395 *i < static_cast<double>(std::numeric_limits<int64_t>::max())) { |
| 396 CHECK_EQ(1, m.Call()); |
| 397 CHECK_EQ(static_cast<int64_t>(*i), output); |
| 398 } else { |
| 399 CHECK_EQ(0, m.Call()); |
| 400 } |
| 401 } |
| 402 } |
| 403 |
| 404 TEST(RunCallFloat64ToUint64) { |
| 405 BufferedRawMachineAssemblerTester<int32_t> m; |
| 406 ExternalReference ref = |
| 407 ExternalReference::wasm_float64_to_uint64(m.isolate()); |
| 408 |
| 409 double input; |
| 410 uint64_t output; |
| 411 |
| 412 Node* function = m.ExternalConstant(ref); |
| 413 m.Return(m.CallCFunction2( |
| 414 MachineType::Int32(), MachineType::Pointer(), MachineType::Pointer(), |
| 415 function, m.PointerConstant(&input), m.PointerConstant(&output))); |
| 416 FOR_FLOAT64_INPUTS(i) { |
| 417 input = *i; |
| 418 if (*i > -1.0 && |
| 419 *i < static_cast<double>(std::numeric_limits<uint64_t>::max())) { |
| 420 CHECK_EQ(1, m.Call()); |
| 421 CHECK_EQ(static_cast<uint64_t>(*i), output); |
| 422 } else { |
| 423 CHECK_EQ(0, m.Call()); |
| 424 } |
| 425 } |
| 426 } |
334 } // namespace compiler | 427 } // namespace compiler |
335 } // namespace internal | 428 } // namespace internal |
336 } // namespace v8 | 429 } // namespace v8 |
OLD | NEW |