OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <functional> | 5 #include <functional> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "test/cctest/cctest.h" | 9 #include "test/cctest/cctest.h" |
10 #include "test/cctest/compiler/codegen-tester.h" | 10 #include "test/cctest/compiler/codegen-tester.h" |
(...skipping 4227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4238 RawMachineAssemblerTester<int32_t> m; | 4238 RawMachineAssemblerTester<int32_t> m; |
4239 m.Return(m.TruncateInt64ToInt32(m.LoadFromPointer(&expected, kMachInt64))); | 4239 m.Return(m.TruncateInt64ToInt32(m.LoadFromPointer(&expected, kMachInt64))); |
4240 FOR_UINT32_INPUTS(i) { | 4240 FOR_UINT32_INPUTS(i) { |
4241 FOR_UINT32_INPUTS(j) { | 4241 FOR_UINT32_INPUTS(j) { |
4242 expected = (static_cast<uint64_t>(*j) << 32) | *i; | 4242 expected = (static_cast<uint64_t>(*j) << 32) | *i; |
4243 CHECK_UINT32_EQ(expected, m.Call()); | 4243 CHECK_UINT32_EQ(expected, m.Call()); |
4244 } | 4244 } |
4245 } | 4245 } |
4246 } | 4246 } |
4247 | 4247 |
| 4248 |
| 4249 TEST(RunTruncateFloat64ToInt32P) { |
| 4250 struct { |
| 4251 double from; |
| 4252 double raw; |
| 4253 } kValues[] = {{0, 0}, |
| 4254 {0.5, 0}, |
| 4255 {-0.5, 0}, |
| 4256 {1.5, 1}, |
| 4257 {-1.5, -1}, |
| 4258 {5.5, 5}, |
| 4259 {-5.0, -5}, |
| 4260 {v8::base::OS::nan_value(), 0}, |
| 4261 {std::numeric_limits<double>::infinity(), 0}, |
| 4262 {-v8::base::OS::nan_value(), 0}, |
| 4263 {-std::numeric_limits<double>::infinity(), 0}, |
| 4264 {4.94065645841e-324, 0}, |
| 4265 {-4.94065645841e-324, 0}, |
| 4266 {0.9999999999999999, 0}, |
| 4267 {-0.9999999999999999, 0}, |
| 4268 {4294967296.0, 0}, |
| 4269 {-4294967296.0, 0}, |
| 4270 {9223372036854775000.0, 4294966272.0}, |
| 4271 {-9223372036854775000.0, -4294966272.0}, |
| 4272 {4.5036e+15, 372629504}, |
| 4273 {-4.5036e+15, -372629504}, |
| 4274 {287524199.5377777, 0x11234567}, |
| 4275 {-287524199.5377777, -0x11234567}, |
| 4276 {2300193596.302222, 2300193596.0}, |
| 4277 {-2300193596.302222, -2300193596.0}, |
| 4278 {4600387192.604444, 305419896}, |
| 4279 {-4600387192.604444, -305419896}, |
| 4280 {4823855600872397.0, 1737075661}, |
| 4281 {-4823855600872397.0, -1737075661}, |
| 4282 {4503603922337791.0, -1}, |
| 4283 {-4503603922337791.0, 1}, |
| 4284 {4503601774854143.0, 2147483647}, |
| 4285 {-4503601774854143.0, -2147483647}, |
| 4286 {9007207844675582.0, -2}, |
| 4287 {-9007207844675582.0, 2}, |
| 4288 {2.4178527921507624e+24, -536870912}, |
| 4289 {-2.4178527921507624e+24, 536870912}, |
| 4290 {2.417853945072267e+24, -536870912}, |
| 4291 {-2.417853945072267e+24, 536870912}, |
| 4292 {4.8357055843015248e+24, -1073741824}, |
| 4293 {-4.8357055843015248e+24, 1073741824}, |
| 4294 {4.8357078901445341e+24, -1073741824}, |
| 4295 {-4.8357078901445341e+24, 1073741824}, |
| 4296 {2147483647.0, 2147483647.0}, |
| 4297 {-2147483648.0, -2147483648.0}, |
| 4298 {9.6714111686030497e+24, -2147483648.0}, |
| 4299 {-9.6714111686030497e+24, -2147483648.0}, |
| 4300 {9.6714157802890681e+24, -2147483648.0}, |
| 4301 {-9.6714157802890681e+24, -2147483648.0}, |
| 4302 {1.9342813113834065e+25, 2147483648.0}, |
| 4303 {-1.9342813113834065e+25, 2147483648.0}, |
| 4304 {3.868562622766813e+25, 0}, |
| 4305 {-3.868562622766813e+25, 0}, |
| 4306 {1.7976931348623157e+308, 0}, |
| 4307 {-1.7976931348623157e+308, 0}}; |
| 4308 double input = -1.0; |
| 4309 RawMachineAssemblerTester<int32_t> m; |
| 4310 m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64))); |
| 4311 for (size_t i = 0; i < ARRAY_SIZE(kValues); ++i) { |
| 4312 input = kValues[i].from; |
| 4313 uint64_t expected = static_cast<int64_t>(kValues[i].raw); |
| 4314 CHECK_EQ(static_cast<int>(expected), m.Call()); |
| 4315 } |
| 4316 } |
| 4317 |
4248 #endif // V8_TURBOFAN_TARGET | 4318 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |