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 // TODO(jochen): Remove this after the setting is turned on globally. | 5 // TODO(jochen): Remove this after the setting is turned on globally. |
6 #define V8_IMMINENT_DEPRECATION_WARNINGS | 6 #define V8_IMMINENT_DEPRECATION_WARNINGS |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <functional> | 9 #include <functional> |
10 #include <limits> | 10 #include <limits> |
(...skipping 5372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5383 | 5383 |
5384 | 5384 |
5385 TEST(RunBitcastFloat64ToInt64) { | 5385 TEST(RunBitcastFloat64ToInt64) { |
5386 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64); | 5386 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64); |
5387 | 5387 |
5388 m.Return(m.BitcastFloat64ToInt64(m.Parameter(0))); | 5388 m.Return(m.BitcastFloat64ToInt64(m.Parameter(0))); |
5389 FOR_FLOAT64_INPUTS(i) { CHECK_EQ(bit_cast<int64_t>(*i), m.Call(*i)); } | 5389 FOR_FLOAT64_INPUTS(i) { CHECK_EQ(bit_cast<int64_t>(*i), m.Call(*i)); } |
5390 } | 5390 } |
5391 | 5391 |
5392 | 5392 |
5393 TEST(RunTruncateFloat32ToInt64) { | 5393 TEST(RunTryTruncateFloat32ToInt64WithoutCheck) { |
5394 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat32); | 5394 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat32); |
5395 m.Return(m.TruncateFloat32ToInt64(m.Parameter(0))); | 5395 m.Return(m.TryTruncateFloat32ToInt64(m.Parameter(0))); |
5396 | 5396 |
5397 FOR_INT64_INPUTS(i) { | 5397 FOR_INT64_INPUTS(i) { |
5398 float input = static_cast<float>(*i); | 5398 float input = static_cast<float>(*i); |
5399 if (input < 9223372036854775808.0 && input > -9223372036854775809.0) { | 5399 if (input < 9223372036854775808.0 && input > -9223372036854775809.0) { |
5400 CHECK_EQ(static_cast<int64_t>(input), m.Call(input)); | 5400 CHECK_EQ(static_cast<int64_t>(input), m.Call(input)); |
5401 } | 5401 } |
5402 } | 5402 } |
5403 FOR_FLOAT32_INPUTS(j) { | 5403 } |
5404 if (*j < 9223372036854775808.0 && *j > -9223372036854775809.0) { | 5404 |
5405 CHECK_EQ(static_cast<int64_t>(*j), m.Call(*j)); | 5405 |
| 5406 TEST(RunTryTruncateFloat32ToInt64WithCheck) { |
| 5407 int64_t success = 0; |
| 5408 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat32); |
| 5409 Node* trunc = m.TryTruncateFloat32ToInt64(m.Parameter(0)); |
| 5410 Node* val = m.Projection(0, trunc); |
| 5411 Node* check = m.Projection(1, trunc); |
| 5412 m.StoreToPointer(&success, kMachInt64, check); |
| 5413 m.Return(val); |
| 5414 |
| 5415 FOR_FLOAT32_INPUTS(i) { |
| 5416 if (*i < 9223372036854775808.0 && *i > -9223372036854775809.0) { |
| 5417 CHECK_EQ(static_cast<int64_t>(*i), m.Call(*i)); |
| 5418 CHECK_NE(0, success); |
| 5419 } else { |
| 5420 m.Call(*i); |
| 5421 CHECK_EQ(0, success); |
5406 } | 5422 } |
5407 } | 5423 } |
5408 } | 5424 } |
5409 | 5425 |
5410 | 5426 |
5411 TEST(RunTryTruncateFloat64ToInt64WithoutCheck) { | 5427 TEST(RunTryTruncateFloat64ToInt64WithoutCheck) { |
5412 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64); | 5428 BufferedRawMachineAssemblerTester<int64_t> m(kMachFloat64); |
5413 m.Return(m.TryTruncateFloat64ToInt64(m.Parameter(0))); | 5429 m.Return(m.TryTruncateFloat64ToInt64(m.Parameter(0))); |
5414 | 5430 |
5415 FOR_INT64_INPUTS(i) { | 5431 FOR_INT64_INPUTS(i) { |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5750 Node* call = r.AddNode(r.common()->Call(desc), phi); | 5766 Node* call = r.AddNode(r.common()->Call(desc), phi); |
5751 r.Return(call); | 5767 r.Return(call); |
5752 | 5768 |
5753 CHECK_EQ(33, r.Call(1)); | 5769 CHECK_EQ(33, r.Call(1)); |
5754 CHECK_EQ(44, r.Call(0)); | 5770 CHECK_EQ(44, r.Call(0)); |
5755 } | 5771 } |
5756 | 5772 |
5757 } // namespace compiler | 5773 } // namespace compiler |
5758 } // namespace internal | 5774 } // namespace internal |
5759 } // namespace v8 | 5775 } // namespace v8 |
OLD | NEW |