OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
672 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); | 672 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); |
673 USE(dummy); | 673 USE(dummy); |
674 CHECK_EQ(1.5e14, t.a); | 674 CHECK_EQ(1.5e14, t.a); |
675 CHECK_EQ(2.75e11, t.b); | 675 CHECK_EQ(2.75e11, t.b); |
676 CHECK_EQ(1, t.result); | 676 CHECK_EQ(1, t.result); |
677 } | 677 } |
678 | 678 |
679 | 679 |
680 TEST(MIPS8) { | 680 TEST(MIPS8) { |
681 // Test ROTR and ROTRV instructions. | 681 // Test ROTR and ROTRV instructions. |
682 CcTest::InitializeVM(); | 682 if (IsMipsArchVariant(kMips32r2)) { |
683 Isolate* isolate = CcTest::i_isolate(); | 683 CcTest::InitializeVM(); |
684 HandleScope scope(isolate); | 684 Isolate* isolate = CcTest::i_isolate(); |
685 HandleScope scope(isolate); | |
685 | 686 |
686 typedef struct { | 687 typedef struct { |
687 int32_t input; | 688 int32_t input; |
688 int32_t result_rotr_4; | 689 int32_t result_rotr_4; |
689 int32_t result_rotr_8; | 690 int32_t result_rotr_8; |
690 int32_t result_rotr_12; | 691 int32_t result_rotr_12; |
691 int32_t result_rotr_16; | 692 int32_t result_rotr_16; |
692 int32_t result_rotr_20; | 693 int32_t result_rotr_20; |
693 int32_t result_rotr_24; | 694 int32_t result_rotr_24; |
694 int32_t result_rotr_28; | 695 int32_t result_rotr_28; |
695 int32_t result_rotrv_4; | 696 int32_t result_rotrv_4; |
696 int32_t result_rotrv_8; | 697 int32_t result_rotrv_8; |
697 int32_t result_rotrv_12; | 698 int32_t result_rotrv_12; |
698 int32_t result_rotrv_16; | 699 int32_t result_rotrv_16; |
699 int32_t result_rotrv_20; | 700 int32_t result_rotrv_20; |
700 int32_t result_rotrv_24; | 701 int32_t result_rotrv_24; |
701 int32_t result_rotrv_28; | 702 int32_t result_rotrv_28; |
702 } T; | 703 } T; |
703 T t; | 704 T t; |
704 | 705 |
705 MacroAssembler assm(isolate, NULL, 0); | 706 MacroAssembler assm(isolate, NULL, 0); |
706 | 707 |
707 // Basic word load. | 708 // Basic word load. |
708 __ lw(t0, MemOperand(a0, OFFSET_OF(T, input)) ); | 709 __ lw(t0, MemOperand(a0, OFFSET_OF(T, input)) ); |
709 | 710 |
710 // ROTR instruction (called through the Ror macro). | 711 // ROTR instruction (called through the Ror macro). |
711 __ Ror(t1, t0, 0x0004); | 712 __ Ror(t1, t0, 0x0004); |
712 __ Ror(t2, t0, 0x0008); | 713 __ Ror(t2, t0, 0x0008); |
713 __ Ror(t3, t0, 0x000c); | 714 __ Ror(t3, t0, 0x000c); |
714 __ Ror(t4, t0, 0x0010); | 715 __ Ror(t4, t0, 0x0010); |
715 __ Ror(t5, t0, 0x0014); | 716 __ Ror(t5, t0, 0x0014); |
716 __ Ror(t6, t0, 0x0018); | 717 __ Ror(t6, t0, 0x0018); |
717 __ Ror(t7, t0, 0x001c); | 718 __ Ror(t7, t0, 0x001c); |
718 | 719 |
719 // Basic word store. | 720 // Basic word store. |
720 __ sw(t1, MemOperand(a0, OFFSET_OF(T, result_rotr_4)) ); | 721 __ sw(t1, MemOperand(a0, OFFSET_OF(T, result_rotr_4)) ); |
721 __ sw(t2, MemOperand(a0, OFFSET_OF(T, result_rotr_8)) ); | 722 __ sw(t2, MemOperand(a0, OFFSET_OF(T, result_rotr_8)) ); |
722 __ sw(t3, MemOperand(a0, OFFSET_OF(T, result_rotr_12)) ); | 723 __ sw(t3, MemOperand(a0, OFFSET_OF(T, result_rotr_12)) ); |
723 __ sw(t4, MemOperand(a0, OFFSET_OF(T, result_rotr_16)) ); | 724 __ sw(t4, MemOperand(a0, OFFSET_OF(T, result_rotr_16)) ); |
724 __ sw(t5, MemOperand(a0, OFFSET_OF(T, result_rotr_20)) ); | 725 __ sw(t5, MemOperand(a0, OFFSET_OF(T, result_rotr_20)) ); |
725 __ sw(t6, MemOperand(a0, OFFSET_OF(T, result_rotr_24)) ); | 726 __ sw(t6, MemOperand(a0, OFFSET_OF(T, result_rotr_24)) ); |
726 __ sw(t7, MemOperand(a0, OFFSET_OF(T, result_rotr_28)) ); | 727 __ sw(t7, MemOperand(a0, OFFSET_OF(T, result_rotr_28)) ); |
727 | 728 |
728 // ROTRV instruction (called through the Ror macro). | 729 // ROTRV instruction (called through the Ror macro). |
729 __ li(t7, 0x0004); | 730 __ li(t7, 0x0004); |
730 __ Ror(t1, t0, t7); | 731 __ Ror(t1, t0, t7); |
731 __ li(t7, 0x0008); | 732 __ li(t7, 0x0008); |
732 __ Ror(t2, t0, t7); | 733 __ Ror(t2, t0, t7); |
733 __ li(t7, 0x000C); | 734 __ li(t7, 0x000C); |
734 __ Ror(t3, t0, t7); | 735 __ Ror(t3, t0, t7); |
735 __ li(t7, 0x0010); | 736 __ li(t7, 0x0010); |
736 __ Ror(t4, t0, t7); | 737 __ Ror(t4, t0, t7); |
737 __ li(t7, 0x0014); | 738 __ li(t7, 0x0014); |
738 __ Ror(t5, t0, t7); | 739 __ Ror(t5, t0, t7); |
739 __ li(t7, 0x0018); | 740 __ li(t7, 0x0018); |
740 __ Ror(t6, t0, t7); | 741 __ Ror(t6, t0, t7); |
741 __ li(t7, 0x001C); | 742 __ li(t7, 0x001C); |
742 __ Ror(t7, t0, t7); | 743 __ Ror(t7, t0, t7); |
743 | 744 |
744 // Basic word store. | 745 // Basic word store. |
745 __ sw(t1, MemOperand(a0, OFFSET_OF(T, result_rotrv_4)) ); | 746 __ sw(t1, MemOperand(a0, OFFSET_OF(T, result_rotrv_4)) ); |
746 __ sw(t2, MemOperand(a0, OFFSET_OF(T, result_rotrv_8)) ); | 747 __ sw(t2, MemOperand(a0, OFFSET_OF(T, result_rotrv_8)) ); |
747 __ sw(t3, MemOperand(a0, OFFSET_OF(T, result_rotrv_12)) ); | 748 __ sw(t3, MemOperand(a0, OFFSET_OF(T, result_rotrv_12)) ); |
748 __ sw(t4, MemOperand(a0, OFFSET_OF(T, result_rotrv_16)) ); | 749 __ sw(t4, MemOperand(a0, OFFSET_OF(T, result_rotrv_16)) ); |
749 __ sw(t5, MemOperand(a0, OFFSET_OF(T, result_rotrv_20)) ); | 750 __ sw(t5, MemOperand(a0, OFFSET_OF(T, result_rotrv_20)) ); |
750 __ sw(t6, MemOperand(a0, OFFSET_OF(T, result_rotrv_24)) ); | 751 __ sw(t6, MemOperand(a0, OFFSET_OF(T, result_rotrv_24)) ); |
751 __ sw(t7, MemOperand(a0, OFFSET_OF(T, result_rotrv_28)) ); | 752 __ sw(t7, MemOperand(a0, OFFSET_OF(T, result_rotrv_28)) ); |
752 | 753 |
753 __ jr(ra); | 754 __ jr(ra); |
754 __ nop(); | 755 __ nop(); |
755 | 756 |
756 CodeDesc desc; | 757 CodeDesc desc; |
757 assm.GetCode(&desc); | 758 assm.GetCode(&desc); |
758 Handle<Code> code = isolate->factory()->NewCode( | 759 Handle<Code> code = isolate->factory()->NewCode( |
759 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 760 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
760 F3 f = FUNCTION_CAST<F3>(code->entry()); | 761 F3 f = FUNCTION_CAST<F3>(code->entry()); |
761 t.input = 0x12345678; | 762 t.input = 0x12345678; |
762 Object* dummy = CALL_GENERATED_CODE(f, &t, 0x0, 0, 0, 0); | 763 Object* dummy = CALL_GENERATED_CODE(f, &t, 0x0, 0, 0, 0); |
763 USE(dummy); | 764 USE(dummy); |
764 CHECK_EQ(static_cast<int32_t>(0x81234567), t.result_rotr_4); | 765 CHECK_EQ(static_cast<int32_t>(0x81234567), t.result_rotr_4); |
765 CHECK_EQ(static_cast<int32_t>(0x78123456), t.result_rotr_8); | 766 CHECK_EQ(static_cast<int32_t>(0x78123456), t.result_rotr_8); |
766 CHECK_EQ(static_cast<int32_t>(0x67812345), t.result_rotr_12); | 767 CHECK_EQ(static_cast<int32_t>(0x67812345), t.result_rotr_12); |
767 CHECK_EQ(static_cast<int32_t>(0x56781234), t.result_rotr_16); | 768 CHECK_EQ(static_cast<int32_t>(0x56781234), t.result_rotr_16); |
768 CHECK_EQ(static_cast<int32_t>(0x45678123), t.result_rotr_20); | 769 CHECK_EQ(static_cast<int32_t>(0x45678123), t.result_rotr_20); |
769 CHECK_EQ(static_cast<int32_t>(0x34567812), t.result_rotr_24); | 770 CHECK_EQ(static_cast<int32_t>(0x34567812), t.result_rotr_24); |
770 CHECK_EQ(static_cast<int32_t>(0x23456781), t.result_rotr_28); | 771 CHECK_EQ(static_cast<int32_t>(0x23456781), t.result_rotr_28); |
771 | 772 |
772 CHECK_EQ(static_cast<int32_t>(0x81234567), t.result_rotrv_4); | 773 CHECK_EQ(static_cast<int32_t>(0x81234567), t.result_rotrv_4); |
773 CHECK_EQ(static_cast<int32_t>(0x78123456), t.result_rotrv_8); | 774 CHECK_EQ(static_cast<int32_t>(0x78123456), t.result_rotrv_8); |
774 CHECK_EQ(static_cast<int32_t>(0x67812345), t.result_rotrv_12); | 775 CHECK_EQ(static_cast<int32_t>(0x67812345), t.result_rotrv_12); |
775 CHECK_EQ(static_cast<int32_t>(0x56781234), t.result_rotrv_16); | 776 CHECK_EQ(static_cast<int32_t>(0x56781234), t.result_rotrv_16); |
776 CHECK_EQ(static_cast<int32_t>(0x45678123), t.result_rotrv_20); | 777 CHECK_EQ(static_cast<int32_t>(0x45678123), t.result_rotrv_20); |
777 CHECK_EQ(static_cast<int32_t>(0x34567812), t.result_rotrv_24); | 778 CHECK_EQ(static_cast<int32_t>(0x34567812), t.result_rotrv_24); |
778 CHECK_EQ(static_cast<int32_t>(0x23456781), t.result_rotrv_28); | 779 CHECK_EQ(static_cast<int32_t>(0x23456781), t.result_rotrv_28); |
780 } | |
779 } | 781 } |
780 | 782 |
781 | 783 |
782 TEST(MIPS9) { | 784 TEST(MIPS9) { |
783 // Test BRANCH improvements. | 785 // Test BRANCH improvements. |
784 CcTest::InitializeVM(); | 786 CcTest::InitializeVM(); |
785 Isolate* isolate = CcTest::i_isolate(); | 787 Isolate* isolate = CcTest::i_isolate(); |
786 HandleScope scope(isolate); | 788 HandleScope scope(isolate); |
787 | 789 |
788 MacroAssembler assm(isolate, NULL, 0); | 790 MacroAssembler assm(isolate, NULL, 0); |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1416 double a; | 1418 double a; |
1417 double b; | 1419 double b; |
1418 double c; | 1420 double c; |
1419 double d; | 1421 double d; |
1420 } TestFloat; | 1422 } TestFloat; |
1421 | 1423 |
1422 TestFloat test; | 1424 TestFloat test; |
1423 | 1425 |
1424 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a))); | 1426 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a))); |
1425 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b))); | 1427 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b))); |
1426 __ min(D, f10, f8, f4); | 1428 __ min(D, f10, f4, f8); |
1427 __ max(D, f12, f8, f4); | 1429 __ max(D, f12, f4, f8); |
1428 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, c))); | 1430 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, c))); |
1429 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, d))); | 1431 __ sdc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, d))); |
1430 __ jr(ra); | 1432 __ jr(ra); |
1431 __ nop(); | 1433 __ nop(); |
1432 | 1434 |
1433 CodeDesc desc; | 1435 CodeDesc desc; |
1434 assm.GetCode(&desc); | 1436 assm.GetCode(&desc); |
1435 Handle<Code> code = isolate->factory()->NewCode( | 1437 Handle<Code> code = isolate->factory()->NewCode( |
1436 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 1438 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
1437 F3 f = FUNCTION_CAST<F3>(code->entry()); | 1439 F3 f = FUNCTION_CAST<F3>(code->entry()); |
(...skipping 23 matching lines...) Expand all Loading... | |
1461 | 1463 |
1462 test.a = std::numeric_limits<double>::quiet_NaN(); | 1464 test.a = std::numeric_limits<double>::quiet_NaN(); |
1463 test.b = std::numeric_limits<double>::quiet_NaN(); | 1465 test.b = std::numeric_limits<double>::quiet_NaN(); |
1464 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | 1466 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); |
1465 DCHECK(std::isnan(test.c)); | 1467 DCHECK(std::isnan(test.c)); |
1466 DCHECK(std::isnan(test.d)); | 1468 DCHECK(std::isnan(test.d)); |
1467 } | 1469 } |
1468 } | 1470 } |
1469 | 1471 |
1470 | 1472 |
1473 TEST(MIPS18) { | |
1474 if (IsMipsArchVariant(kMips32r6)) { | |
1475 const int tableLength = 30; | |
1476 CcTest::InitializeVM(); | |
1477 Isolate* isolate = CcTest::i_isolate(); | |
1478 HandleScope scope(isolate); | |
1479 MacroAssembler assm(isolate, NULL, 0); | |
1480 | |
1481 typedef struct test_float { | |
1482 double a; | |
1483 double b; | |
1484 int fcsr; | |
1485 }TestFloat; | |
1486 | |
1487 TestFloat test; | |
1488 double inputs[tableLength] = {18446744073709551617.0, | |
1489 4503599627370496.0, -4503599627370496.0, | |
1490 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, | |
1491 1.7976931348623157E+308, 6.27463370218383111104242366943E-307, | |
1492 309485009821345068724781056.89, | |
1493 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
1494 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
1495 37778931862957161709568.0, 37778931862957161709569.0, | |
1496 37778931862957161709580.0, 37778931862957161709581.0, | |
1497 37778931862957161709582.0, 37778931862957161709583.0, | |
1498 37778931862957161709584.0, 37778931862957161709585.0, | |
1499 37778931862957161709586.0, 37778931862957161709587.0}; | |
1500 double outputs_RN[tableLength] = {18446744073709551617.0, | |
1501 4503599627370496.0, -4503599627370496.0, | |
1502 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, | |
1503 1.7976931348623157E308, 0, | |
1504 309485009821345068724781057.0, | |
1505 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | |
1506 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | |
1507 37778931862957161709568.0, 37778931862957161709569.0, | |
1508 37778931862957161709580.0, 37778931862957161709581.0, | |
1509 37778931862957161709582.0, 37778931862957161709583.0, | |
1510 37778931862957161709584.0, 37778931862957161709585.0, | |
1511 37778931862957161709586.0, 37778931862957161709587.0}; | |
1512 double outputs_RZ[tableLength] = {18446744073709551617.0, | |
1513 4503599627370496.0, -4503599627370496.0, | |
1514 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, | |
1515 1.7976931348623157E308, 0, | |
1516 309485009821345068724781057.0, | |
1517 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
1518 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
1519 37778931862957161709568.0, 37778931862957161709569.0, | |
1520 37778931862957161709580.0, 37778931862957161709581.0, | |
1521 37778931862957161709582.0, 37778931862957161709583.0, | |
1522 37778931862957161709584.0, 37778931862957161709585.0, | |
1523 37778931862957161709586.0, 37778931862957161709587.0}; | |
1524 double outputs_RP[tableLength] = {18446744073709551617.0, | |
1525 4503599627370496.0, -4503599627370496.0, | |
1526 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, | |
1527 1.7976931348623157E308, 1, | |
1528 309485009821345068724781057.0, | |
1529 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | |
1530 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
1531 37778931862957161709568.0, 37778931862957161709569.0, | |
1532 37778931862957161709580.0, 37778931862957161709581.0, | |
1533 37778931862957161709582.0, 37778931862957161709583.0, | |
1534 37778931862957161709584.0, 37778931862957161709585.0, | |
1535 37778931862957161709586.0, 37778931862957161709587.0}; | |
1536 double outputs_RM[tableLength] = {18446744073709551617.0, | |
1537 4503599627370496.0, -4503599627370496.0, | |
1538 1.26782468584154733584017312973E30, 1.44860108245951772690707170478E147, | |
1539 1.7976931348623157E308, 0, | |
1540 309485009821345068724781057.0, | |
1541 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
1542 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | |
1543 37778931862957161709568.0, 37778931862957161709569.0, | |
1544 37778931862957161709580.0, 37778931862957161709581.0, | |
1545 37778931862957161709582.0, 37778931862957161709583.0, | |
1546 37778931862957161709584.0, 37778931862957161709585.0, | |
1547 37778931862957161709586.0, 37778931862957161709587.0}; | |
1548 int fcsr_inputs[4] = | |
1549 {kRoundToNearest, kRoundToZero, kRoundToPlusInf, kRoundToMinusInf}; | |
1550 double* outputs[4] = {outputs_RN, outputs_RZ, outputs_RP, outputs_RM}; | |
1551 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a)) ); | |
1552 __ lw(t0, MemOperand(a0, OFFSET_OF(TestFloat, fcsr)) ); | |
1553 __ cfc1(t1, FCSR); | |
1554 __ ctc1(t0, FCSR); | |
1555 __ rint(D, f8, f4); | |
1556 __ sdc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b)) ); | |
1557 __ ctc1(t1, FCSR); | |
1558 __ jr(ra); | |
1559 __ nop(); | |
1560 | |
1561 CodeDesc desc; | |
1562 assm.GetCode(&desc); | |
1563 Handle<Code> code = isolate->factory()->NewCode( | |
1564 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
1565 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
1566 | |
1567 for (int j = 0;j < 4;j++) { | |
paul.l...
2015/04/27 05:12:50
Style nit: space after ';' in these 4 loops.
Djordje.Pesic
2015/04/27 12:46:59
Done.
| |
1568 test.fcsr = fcsr_inputs[j]; | |
1569 for (int i = 0;i < tableLength;i++) { | |
1570 test.a = inputs[i]; | |
1571 std::cout << j << " " << i << "\n"; | |
1572 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
1573 CHECK_EQ(test.b, outputs[j][i]); | |
1574 } | |
1575 } | |
1576 } | |
1577 } | |
1578 | |
1579 | |
1580 TEST(MIPS19) { | |
1581 CcTest::InitializeVM(); | |
1582 Isolate* isolate = CcTest::i_isolate(); | |
1583 HandleScope scope(isolate); | |
1584 MacroAssembler assm(isolate, NULL, 0); | |
1585 | |
1586 typedef struct test_float { | |
1587 double a; | |
1588 int32_t b; | |
1589 int32_t fcsr; | |
1590 }Test; | |
1591 const int tableLength = 24; | |
1592 double inputs[tableLength] = { | |
1593 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, | |
1594 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, | |
1595 2147483637.0, 2147483638.0, 2147483639.0, | |
1596 2147483640.0, 2147483641.0, 2147483642.0, | |
1597 2147483643.0, 2147483644.0, 2147483645.0, | |
1598 2147483646.0, 2147483647.0, 2147483653.0 | |
1599 }; | |
1600 double outputs_RN[tableLength] = { | |
1601 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, | |
1602 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, | |
1603 2147483637.0, 2147483638.0, 2147483639.0, | |
1604 2147483640.0, 2147483641.0, 2147483642.0, | |
1605 2147483643.0, 2147483644.0, 2147483645.0, | |
1606 2147483646.0, 2147483647.0, kFPUInvalidResult}; | |
1607 double outputs_RZ[tableLength] = { | |
1608 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
1609 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
1610 2147483637.0, 2147483638.0, 2147483639.0, | |
1611 2147483640.0, 2147483641.0, 2147483642.0, | |
1612 2147483643.0, 2147483644.0, 2147483645.0, | |
1613 2147483646.0, 2147483647.0, kFPUInvalidResult}; | |
1614 double outputs_RP[tableLength] = { | |
1615 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, | |
1616 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, | |
1617 2147483637.0, 2147483638.0, 2147483639.0, | |
1618 2147483640.0, 2147483641.0, 2147483642.0, | |
1619 2147483643.0, 2147483644.0, 2147483645.0, | |
1620 2147483646.0, 2147483647.0, kFPUInvalidResult}; | |
1621 double outputs_RM[tableLength] = { | |
1622 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, | |
1623 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, | |
1624 2147483637.0, 2147483638.0, 2147483639.0, | |
1625 2147483640.0, 2147483641.0, 2147483642.0, | |
1626 2147483643.0, 2147483644.0, 2147483645.0, | |
1627 2147483646.0, 2147483647.0, kFPUInvalidResult}; | |
1628 int fcsr_inputs[4] = | |
1629 {kRoundToNearest, kRoundToZero, kRoundToPlusInf, kRoundToMinusInf}; | |
1630 double* outputs[4] = {outputs_RN, outputs_RZ, outputs_RP, outputs_RM}; | |
1631 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); | |
1632 __ lw(t0, MemOperand(a0, OFFSET_OF(Test, fcsr)) ); | |
1633 __ cfc1(t1, FCSR); | |
1634 __ ctc1(t0, FCSR); | |
1635 __ cvt_w_d(f8, f4); | |
1636 __ swc1(f8, MemOperand(a0, OFFSET_OF(Test, b)) ); | |
1637 __ ctc1(t1, FCSR); | |
1638 __ jr(ra); | |
1639 __ nop(); | |
1640 Test test; | |
1641 CodeDesc desc; | |
1642 assm.GetCode(&desc); | |
1643 Handle<Code> code = isolate->factory()->NewCode( | |
1644 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
1645 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
1646 for (int j = 0;j < 4;j++) { | |
1647 test.fcsr = fcsr_inputs[j]; | |
1648 for (int i = 0;i < tableLength;i++) { | |
1649 test.a = inputs[i]; | |
1650 std::cout << i << " " << j << "\n"; | |
1651 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0)); | |
1652 CHECK_EQ(test.b, outputs[j][i]); | |
1653 } | |
1654 } | |
1655 } | |
1656 | |
1657 | |
1471 TEST(jump_tables1) { | 1658 TEST(jump_tables1) { |
1472 // Test jump tables with forward jumps. | 1659 // Test jump tables with forward jumps. |
1473 CcTest::InitializeVM(); | 1660 CcTest::InitializeVM(); |
1474 Isolate* isolate = CcTest::i_isolate(); | 1661 Isolate* isolate = CcTest::i_isolate(); |
1475 HandleScope scope(isolate); | 1662 HandleScope scope(isolate); |
1476 Assembler assm(isolate, nullptr, 0); | 1663 Assembler assm(isolate, nullptr, 0); |
1477 | 1664 |
1478 const int kNumCases = 512; | 1665 const int kNumCases = 512; |
1479 int values[kNumCases]; | 1666 int values[kNumCases]; |
1480 isolate->random_number_generator()->NextBytes(values, sizeof(values)); | 1667 isolate->random_number_generator()->NextBytes(values, sizeof(values)); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1673 ::printf("f(%d) = ", i); | 1860 ::printf("f(%d) = ", i); |
1674 result->Print(std::cout); | 1861 result->Print(std::cout); |
1675 ::printf("\n"); | 1862 ::printf("\n"); |
1676 #endif | 1863 #endif |
1677 CHECK(values[i].is_identical_to(result)); | 1864 CHECK(values[i].is_identical_to(result)); |
1678 } | 1865 } |
1679 } | 1866 } |
1680 | 1867 |
1681 | 1868 |
1682 #undef __ | 1869 #undef __ |
OLD | NEW |