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 5359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5370 | 5370 |
5371 | 5371 |
5372 TEST(RunRoundInt64ToFloat64) { | 5372 TEST(RunRoundInt64ToFloat64) { |
5373 BufferedRawMachineAssemblerTester<double> m(kMachInt64); | 5373 BufferedRawMachineAssemblerTester<double> m(kMachInt64); |
5374 m.Return(m.RoundInt64ToFloat64(m.Parameter(0))); | 5374 m.Return(m.RoundInt64ToFloat64(m.Parameter(0))); |
5375 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<double>(*i), m.Call(*i)); } | 5375 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<double>(*i), m.Call(*i)); } |
5376 } | 5376 } |
5377 | 5377 |
5378 | 5378 |
5379 TEST(RunRoundUint64ToFloat64) { | 5379 TEST(RunRoundUint64ToFloat64) { |
| 5380 struct { |
| 5381 uint64_t input; |
| 5382 uint64_t expected; |
| 5383 } values[] = {{0x0, 0x0}, |
| 5384 {0x1, 0x3ff0000000000000}, |
| 5385 {0xffffffff, 0x41efffffffe00000}, |
| 5386 {0x1b09788b, 0x41bb09788b000000}, |
| 5387 {0x4c5fce8, 0x419317f3a0000000}, |
| 5388 {0xcc0de5bf, 0x41e981bcb7e00000}, |
| 5389 {0x2, 0x4000000000000000}, |
| 5390 {0x3, 0x4008000000000000}, |
| 5391 {0x4, 0x4010000000000000}, |
| 5392 {0x5, 0x4014000000000000}, |
| 5393 {0x8, 0x4020000000000000}, |
| 5394 {0x9, 0x4022000000000000}, |
| 5395 {0xffffffffffffffff, 0x43f0000000000000}, |
| 5396 {0xfffffffffffffffe, 0x43f0000000000000}, |
| 5397 {0xfffffffffffffffd, 0x43f0000000000000}, |
| 5398 {0x100000000, 0x41f0000000000000}, |
| 5399 {0xffffffff00000000, 0x43efffffffe00000}, |
| 5400 {0x1b09788b00000000, 0x43bb09788b000000}, |
| 5401 {0x4c5fce800000000, 0x439317f3a0000000}, |
| 5402 {0xcc0de5bf00000000, 0x43e981bcb7e00000}, |
| 5403 {0x200000000, 0x4200000000000000}, |
| 5404 {0x300000000, 0x4208000000000000}, |
| 5405 {0x400000000, 0x4210000000000000}, |
| 5406 {0x500000000, 0x4214000000000000}, |
| 5407 {0x800000000, 0x4220000000000000}, |
| 5408 {0x900000000, 0x4222000000000000}, |
| 5409 {0x273a798e187937a3, 0x43c39d3cc70c3c9c}, |
| 5410 {0xece3af835495a16b, 0x43ed9c75f06a92b4}, |
| 5411 {0xb668ecc11223344, 0x43a6cd1d98224467}, |
| 5412 {0x9e, 0x4063c00000000000}, |
| 5413 {0x43, 0x4050c00000000000}, |
| 5414 {0xaf73, 0x40e5ee6000000000}, |
| 5415 {0x116b, 0x40b16b0000000000}, |
| 5416 {0x658ecc, 0x415963b300000000}, |
| 5417 {0x2b3b4c, 0x41459da600000000}, |
| 5418 {0x88776655, 0x41e10eeccaa00000}, |
| 5419 {0x70000000, 0x41dc000000000000}, |
| 5420 {0x7200000, 0x419c800000000000}, |
| 5421 {0x7fffffff, 0x41dfffffffc00000}, |
| 5422 {0x56123761, 0x41d5848dd8400000}, |
| 5423 {0x7fffff00, 0x41dfffffc0000000}, |
| 5424 {0x761c4761eeeeeeee, 0x43dd8711d87bbbbc}, |
| 5425 {0x80000000eeeeeeee, 0x43e00000001dddde}, |
| 5426 {0x88888888dddddddd, 0x43e11111111bbbbc}, |
| 5427 {0xa0000000dddddddd, 0x43e40000001bbbbc}, |
| 5428 {0xddddddddaaaaaaaa, 0x43ebbbbbbbb55555}, |
| 5429 {0xe0000000aaaaaaaa, 0x43ec000000155555}, |
| 5430 {0xeeeeeeeeeeeeeeee, 0x43edddddddddddde}, |
| 5431 {0xfffffffdeeeeeeee, 0x43efffffffbdddde}, |
| 5432 {0xf0000000dddddddd, 0x43ee0000001bbbbc}, |
| 5433 {0x7fffffdddddddd, 0x435ffffff7777777}, |
| 5434 {0x3fffffaaaaaaaa, 0x434fffffd5555555}, |
| 5435 {0x1fffffaaaaaaaa, 0x433fffffaaaaaaaa}, |
| 5436 {0xfffff, 0x412ffffe00000000}, |
| 5437 {0x7ffff, 0x411ffffc00000000}, |
| 5438 {0x3ffff, 0x410ffff800000000}, |
| 5439 {0x1ffff, 0x40fffff000000000}, |
| 5440 {0xffff, 0x40efffe000000000}, |
| 5441 {0x7fff, 0x40dfffc000000000}, |
| 5442 {0x3fff, 0x40cfff8000000000}, |
| 5443 {0x1fff, 0x40bfff0000000000}, |
| 5444 {0xfff, 0x40affe0000000000}, |
| 5445 {0x7ff, 0x409ffc0000000000}, |
| 5446 {0x3ff, 0x408ff80000000000}, |
| 5447 {0x1ff, 0x407ff00000000000}, |
| 5448 {0x3fffffffffff, 0x42cfffffffffff80}, |
| 5449 {0x1fffffffffff, 0x42bfffffffffff00}, |
| 5450 {0xfffffffffff, 0x42affffffffffe00}, |
| 5451 {0x7ffffffffff, 0x429ffffffffffc00}, |
| 5452 {0x3ffffffffff, 0x428ffffffffff800}, |
| 5453 {0x1ffffffffff, 0x427ffffffffff000}, |
| 5454 {0x8000008000000000, 0x43e0000010000000}, |
| 5455 {0x8000008000000001, 0x43e0000010000000}, |
| 5456 {0x8000000000000400, 0x43e0000000000000}, |
| 5457 {0x8000000000000401, 0x43e0000000000001}}; |
| 5458 |
5380 BufferedRawMachineAssemblerTester<double> m(kMachUint64); | 5459 BufferedRawMachineAssemblerTester<double> m(kMachUint64); |
5381 m.Return(m.RoundUint64ToFloat64(m.Parameter(0))); | 5460 m.Return(m.RoundUint64ToFloat64(m.Parameter(0))); |
5382 | 5461 |
5383 CHECK_EQ(bit_cast<double>(uint64_t(0x0000000000000000)), | 5462 for (int i = 0; i < arraysize(values); i++) { |
5384 m.Call(uint64_t(0x0000000000000000))); | 5463 CHECK_EQ(bit_cast<double>(values[i].expected), m.Call(values[i].input)); |
5385 CHECK_EQ(bit_cast<double>(uint64_t(0x3ff0000000000000)), | 5464 } |
5386 m.Call(uint64_t(0x0000000000000001))); | |
5387 CHECK_EQ(bit_cast<double>(uint64_t(0x41efffffffe00000)), | |
5388 m.Call(uint64_t(0x00000000ffffffff))); | |
5389 CHECK_EQ(bit_cast<double>(uint64_t(0x41bb09788b000000)), | |
5390 m.Call(uint64_t(0x000000001b09788b))); | |
5391 CHECK_EQ(bit_cast<double>(uint64_t(0x419317f3a0000000)), | |
5392 m.Call(uint64_t(0x0000000004c5fce8))); | |
5393 CHECK_EQ(bit_cast<double>(uint64_t(0x41e981bcb7e00000)), | |
5394 m.Call(uint64_t(0x00000000cc0de5bf))); | |
5395 CHECK_EQ(bit_cast<double>(uint64_t(0x4000000000000000)), | |
5396 m.Call(uint64_t(0x0000000000000002))); | |
5397 CHECK_EQ(bit_cast<double>(uint64_t(0x4008000000000000)), | |
5398 m.Call(uint64_t(0x0000000000000003))); | |
5399 CHECK_EQ(bit_cast<double>(uint64_t(0x4010000000000000)), | |
5400 m.Call(uint64_t(0x0000000000000004))); | |
5401 CHECK_EQ(bit_cast<double>(uint64_t(0x4014000000000000)), | |
5402 m.Call(uint64_t(0x0000000000000005))); | |
5403 CHECK_EQ(bit_cast<double>(uint64_t(0x4020000000000000)), | |
5404 m.Call(uint64_t(0x0000000000000008))); | |
5405 CHECK_EQ(bit_cast<double>(uint64_t(0x4022000000000000)), | |
5406 m.Call(uint64_t(0x0000000000000009))); | |
5407 CHECK_EQ(bit_cast<double>(uint64_t(0x43f0000000000000)), | |
5408 m.Call(uint64_t(0xffffffffffffffff))); | |
5409 CHECK_EQ(bit_cast<double>(uint64_t(0x43f0000000000000)), | |
5410 m.Call(uint64_t(0xfffffffffffffffe))); | |
5411 CHECK_EQ(bit_cast<double>(uint64_t(0x43f0000000000000)), | |
5412 m.Call(uint64_t(0xfffffffffffffffd))); | |
5413 CHECK_EQ(bit_cast<double>(uint64_t(0x0000000000000000)), | |
5414 m.Call(uint64_t(0x0000000000000000))); | |
5415 CHECK_EQ(bit_cast<double>(uint64_t(0x41f0000000000000)), | |
5416 m.Call(uint64_t(0x0000000100000000))); | |
5417 CHECK_EQ(bit_cast<double>(uint64_t(0x43efffffffe00000)), | |
5418 m.Call(uint64_t(0xffffffff00000000))); | |
5419 CHECK_EQ(bit_cast<double>(uint64_t(0x43bb09788b000000)), | |
5420 m.Call(uint64_t(0x1b09788b00000000))); | |
5421 CHECK_EQ(bit_cast<double>(uint64_t(0x439317f3a0000000)), | |
5422 m.Call(uint64_t(0x04c5fce800000000))); | |
5423 CHECK_EQ(bit_cast<double>(uint64_t(0x43e981bcb7e00000)), | |
5424 m.Call(uint64_t(0xcc0de5bf00000000))); | |
5425 CHECK_EQ(bit_cast<double>(uint64_t(0x4200000000000000)), | |
5426 m.Call(uint64_t(0x0000000200000000))); | |
5427 CHECK_EQ(bit_cast<double>(uint64_t(0x4208000000000000)), | |
5428 m.Call(uint64_t(0x0000000300000000))); | |
5429 CHECK_EQ(bit_cast<double>(uint64_t(0x4210000000000000)), | |
5430 m.Call(uint64_t(0x0000000400000000))); | |
5431 CHECK_EQ(bit_cast<double>(uint64_t(0x4214000000000000)), | |
5432 m.Call(uint64_t(0x0000000500000000))); | |
5433 CHECK_EQ(bit_cast<double>(uint64_t(0x4220000000000000)), | |
5434 m.Call(uint64_t(0x0000000800000000))); | |
5435 CHECK_EQ(bit_cast<double>(uint64_t(0x4222000000000000)), | |
5436 m.Call(uint64_t(0x0000000900000000))); | |
5437 CHECK_EQ(bit_cast<double>(uint64_t(0x43c39d3cc70c3c9c)), | |
5438 m.Call(uint64_t(0x273a798e187937a3))); | |
5439 CHECK_EQ(bit_cast<double>(uint64_t(0x43ed9c75f06a92b4)), | |
5440 m.Call(uint64_t(0xece3af835495a16b))); | |
5441 CHECK_EQ(bit_cast<double>(uint64_t(0x43a6cd1d98224467)), | |
5442 m.Call(uint64_t(0x0b668ecc11223344))); | |
5443 CHECK_EQ(bit_cast<double>(uint64_t(0x4063c00000000000)), | |
5444 m.Call(uint64_t(0x000000000000009e))); | |
5445 CHECK_EQ(bit_cast<double>(uint64_t(0x4050c00000000000)), | |
5446 m.Call(uint64_t(0x0000000000000043))); | |
5447 CHECK_EQ(bit_cast<double>(uint64_t(0x40e5ee6000000000)), | |
5448 m.Call(uint64_t(0x000000000000af73))); | |
5449 CHECK_EQ(bit_cast<double>(uint64_t(0x40b16b0000000000)), | |
5450 m.Call(uint64_t(0x000000000000116b))); | |
5451 CHECK_EQ(bit_cast<double>(uint64_t(0x415963b300000000)), | |
5452 m.Call(uint64_t(0x0000000000658ecc))); | |
5453 CHECK_EQ(bit_cast<double>(uint64_t(0x41459da600000000)), | |
5454 m.Call(uint64_t(0x00000000002b3b4c))); | |
5455 CHECK_EQ(bit_cast<double>(uint64_t(0x41e10eeccaa00000)), | |
5456 m.Call(uint64_t(0x0000000088776655))); | |
5457 CHECK_EQ(bit_cast<double>(uint64_t(0x41dc000000000000)), | |
5458 m.Call(uint64_t(0x0000000070000000))); | |
5459 CHECK_EQ(bit_cast<double>(uint64_t(0x419c800000000000)), | |
5460 m.Call(uint64_t(0x0000000007200000))); | |
5461 CHECK_EQ(bit_cast<double>(uint64_t(0x41dfffffffc00000)), | |
5462 m.Call(uint64_t(0x000000007fffffff))); | |
5463 CHECK_EQ(bit_cast<double>(uint64_t(0x41d5848dd8400000)), | |
5464 m.Call(uint64_t(0x0000000056123761))); | |
5465 CHECK_EQ(bit_cast<double>(uint64_t(0x41dfffffc0000000)), | |
5466 m.Call(uint64_t(0x000000007fffff00))); | |
5467 CHECK_EQ(bit_cast<double>(uint64_t(0x43dd8711d87bbbbc)), | |
5468 m.Call(uint64_t(0x761c4761eeeeeeee))); | |
5469 CHECK_EQ(bit_cast<double>(uint64_t(0x43e00000001dddde)), | |
5470 m.Call(uint64_t(0x80000000eeeeeeee))); | |
5471 CHECK_EQ(bit_cast<double>(uint64_t(0x43e11111111bbbbc)), | |
5472 m.Call(uint64_t(0x88888888dddddddd))); | |
5473 CHECK_EQ(bit_cast<double>(uint64_t(0x43e40000001bbbbc)), | |
5474 m.Call(uint64_t(0xa0000000dddddddd))); | |
5475 CHECK_EQ(bit_cast<double>(uint64_t(0x43ebbbbbbbb55555)), | |
5476 m.Call(uint64_t(0xddddddddaaaaaaaa))); | |
5477 CHECK_EQ(bit_cast<double>(uint64_t(0x43ec000000155555)), | |
5478 m.Call(uint64_t(0xe0000000aaaaaaaa))); | |
5479 CHECK_EQ(bit_cast<double>(uint64_t(0x43edddddddddddde)), | |
5480 m.Call(uint64_t(0xeeeeeeeeeeeeeeee))); | |
5481 CHECK_EQ(bit_cast<double>(uint64_t(0x43efffffffbdddde)), | |
5482 m.Call(uint64_t(0xfffffffdeeeeeeee))); | |
5483 CHECK_EQ(bit_cast<double>(uint64_t(0x43ee0000001bbbbc)), | |
5484 m.Call(uint64_t(0xf0000000dddddddd))); | |
5485 CHECK_EQ(bit_cast<double>(uint64_t(0x435ffffff7777777)), | |
5486 m.Call(uint64_t(0x007fffffdddddddd))); | |
5487 CHECK_EQ(bit_cast<double>(uint64_t(0x434fffffd5555555)), | |
5488 m.Call(uint64_t(0x003fffffaaaaaaaa))); | |
5489 CHECK_EQ(bit_cast<double>(uint64_t(0x433fffffaaaaaaaa)), | |
5490 m.Call(uint64_t(0x001fffffaaaaaaaa))); | |
5491 CHECK_EQ(bit_cast<double>(uint64_t(0x412ffffe00000000)), | |
5492 m.Call(uint64_t(0x00000000000fffff))); | |
5493 CHECK_EQ(bit_cast<double>(uint64_t(0x411ffffc00000000)), | |
5494 m.Call(uint64_t(0x000000000007ffff))); | |
5495 CHECK_EQ(bit_cast<double>(uint64_t(0x410ffff800000000)), | |
5496 m.Call(uint64_t(0x000000000003ffff))); | |
5497 CHECK_EQ(bit_cast<double>(uint64_t(0x40fffff000000000)), | |
5498 m.Call(uint64_t(0x000000000001ffff))); | |
5499 CHECK_EQ(bit_cast<double>(uint64_t(0x40efffe000000000)), | |
5500 m.Call(uint64_t(0x000000000000ffff))); | |
5501 CHECK_EQ(bit_cast<double>(uint64_t(0x40dfffc000000000)), | |
5502 m.Call(uint64_t(0x0000000000007fff))); | |
5503 CHECK_EQ(bit_cast<double>(uint64_t(0x40cfff8000000000)), | |
5504 m.Call(uint64_t(0x0000000000003fff))); | |
5505 CHECK_EQ(bit_cast<double>(uint64_t(0x40bfff0000000000)), | |
5506 m.Call(uint64_t(0x0000000000001fff))); | |
5507 CHECK_EQ(bit_cast<double>(uint64_t(0x40affe0000000000)), | |
5508 m.Call(uint64_t(0x0000000000000fff))); | |
5509 CHECK_EQ(bit_cast<double>(uint64_t(0x409ffc0000000000)), | |
5510 m.Call(uint64_t(0x00000000000007ff))); | |
5511 CHECK_EQ(bit_cast<double>(uint64_t(0x408ff80000000000)), | |
5512 m.Call(uint64_t(0x00000000000003ff))); | |
5513 CHECK_EQ(bit_cast<double>(uint64_t(0x407ff00000000000)), | |
5514 m.Call(uint64_t(0x00000000000001ff))); | |
5515 CHECK_EQ(bit_cast<double>(uint64_t(0x42cfffffffffff80)), | |
5516 m.Call(uint64_t(0x00003fffffffffff))); | |
5517 CHECK_EQ(bit_cast<double>(uint64_t(0x42bfffffffffff00)), | |
5518 m.Call(uint64_t(0x00001fffffffffff))); | |
5519 CHECK_EQ(bit_cast<double>(uint64_t(0x42affffffffffe00)), | |
5520 m.Call(uint64_t(0x00000fffffffffff))); | |
5521 CHECK_EQ(bit_cast<double>(uint64_t(0x429ffffffffffc00)), | |
5522 m.Call(uint64_t(0x000007ffffffffff))); | |
5523 CHECK_EQ(bit_cast<double>(uint64_t(0x428ffffffffff800)), | |
5524 m.Call(uint64_t(0x000003ffffffffff))); | |
5525 CHECK_EQ(bit_cast<double>(uint64_t(0x427ffffffffff000)), | |
5526 m.Call(uint64_t(0x000001ffffffffff))); | |
5527 CHECK_EQ(bit_cast<double>(uint64_t(0x43e0000010000000)), | |
5528 m.Call(uint64_t(0x8000008000000000))); | |
5529 CHECK_EQ(bit_cast<double>(uint64_t(0x43e0000010000000)), | |
5530 m.Call(uint64_t(0x8000008000000001))); | |
5531 CHECK_EQ(bit_cast<double>(uint64_t(0x43e0000000000000)), | |
5532 m.Call(uint64_t(0x8000000000000400))); | |
5533 CHECK_EQ(bit_cast<double>(uint64_t(0x43e0000000000001)), | |
5534 m.Call(uint64_t(0x8000000000000401))); | |
5535 } | 5465 } |
5536 | 5466 |
5537 | 5467 |
5538 TEST(RunRoundUint64ToFloat32) { | 5468 TEST(RunRoundUint64ToFloat32) { |
5539 struct { | 5469 struct { |
5540 uint64_t input; | 5470 uint64_t input; |
5541 uint32_t expected; | 5471 uint32_t expected; |
5542 } values[] = {{0x0, 0x0}, | 5472 } values[] = {{0x0, 0x0}, |
5543 {0x1, 0x3f800000}, | 5473 {0x1, 0x3f800000}, |
5544 {0xffffffff, 0x4f800000}, | 5474 {0xffffffff, 0x4f800000}, |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5703 Node* call = r.AddNode(r.common()->Call(desc), phi); | 5633 Node* call = r.AddNode(r.common()->Call(desc), phi); |
5704 r.Return(call); | 5634 r.Return(call); |
5705 | 5635 |
5706 CHECK_EQ(33, r.Call(1)); | 5636 CHECK_EQ(33, r.Call(1)); |
5707 CHECK_EQ(44, r.Call(0)); | 5637 CHECK_EQ(44, r.Call(0)); |
5708 } | 5638 } |
5709 | 5639 |
5710 } // namespace compiler | 5640 } // namespace compiler |
5711 } // namespace internal | 5641 } // namespace internal |
5712 } // namespace v8 | 5642 } // namespace v8 |
OLD | NEW |