comparison src/share/vm/runtime/sharedRuntimeTrig.cpp @ 20288:a073be2ce5c2

8049043: Load variable through a pointer of an incompatible type in hotspot/src/share/vm/runtime/sharedRuntimeMath.hpp Summary: Fixed parfait warnings caused by __HI and __LO macros in sharedRuntimeMath.hpp by using a union. Reviewed-by: kvn
author thartmann
date Tue, 29 Jul 2014 13:56:29 +0200
parents 631c3a4ea10c
children 7848fc12602b
comparison
equal deleted inserted replaced
20287:b6a8cc1e0d92 20288:a073be2ce5c2
545 545
546 static double __kernel_sin(double x, double y, int iy) 546 static double __kernel_sin(double x, double y, int iy)
547 { 547 {
548 double z,r,v; 548 double z,r,v;
549 int ix; 549 int ix;
550 ix = __HI(x)&0x7fffffff; /* high word of x */ 550 ix = high(x)&0x7fffffff; /* high word of x */
551 if(ix<0x3e400000) /* |x| < 2**-27 */ 551 if(ix<0x3e400000) /* |x| < 2**-27 */
552 {if((int)x==0) return x;} /* generate inexact */ 552 {if((int)x==0) return x;} /* generate inexact */
553 z = x*x; 553 z = x*x;
554 v = z*x; 554 v = z*x;
555 r = S2+z*(S3+z*(S4+z*(S5+z*S6))); 555 r = S2+z*(S3+z*(S4+z*(S5+z*S6)));
600 C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */ 600 C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */
601 C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */ 601 C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */
602 602
603 static double __kernel_cos(double x, double y) 603 static double __kernel_cos(double x, double y)
604 { 604 {
605 double a,h,z,r,qx; 605 double a,h,z,r,qx=0;
606 int ix; 606 int ix;
607 ix = __HI(x)&0x7fffffff; /* ix = |x|'s high word*/ 607 ix = high(x)&0x7fffffff; /* ix = |x|'s high word*/
608 if(ix<0x3e400000) { /* if x < 2**27 */ 608 if(ix<0x3e400000) { /* if x < 2**27 */
609 if(((int)x)==0) return one; /* generate inexact */ 609 if(((int)x)==0) return one; /* generate inexact */
610 } 610 }
611 z = x*x; 611 z = x*x;
612 r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6))))); 612 r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6)))));
614 return one - (0.5*z - (z*r - x*y)); 614 return one - (0.5*z - (z*r - x*y));
615 else { 615 else {
616 if(ix > 0x3fe90000) { /* x > 0.78125 */ 616 if(ix > 0x3fe90000) { /* x > 0.78125 */
617 qx = 0.28125; 617 qx = 0.28125;
618 } else { 618 } else {
619 __HI(qx) = ix-0x00200000; /* x/4 */ 619 set_high(&qx, ix-0x00200000); /* x/4 */
620 __LO(qx) = 0; 620 set_low(&qx, 0);
621 } 621 }
622 h = 0.5*z-qx; 622 h = 0.5*z-qx;
623 a = one-qx; 623 a = one-qx;
624 return a - (h - (z*r-x*y)); 624 return a - (h - (z*r-x*y));
625 } 625 }
680 680
681 static double __kernel_tan(double x, double y, int iy) 681 static double __kernel_tan(double x, double y, int iy)
682 { 682 {
683 double z,r,v,w,s; 683 double z,r,v,w,s;
684 int ix,hx; 684 int ix,hx;
685 hx = __HI(x); /* high word of x */ 685 hx = high(x); /* high word of x */
686 ix = hx&0x7fffffff; /* high word of |x| */ 686 ix = hx&0x7fffffff; /* high word of |x| */
687 if(ix<0x3e300000) { /* x < 2**-28 */ 687 if(ix<0x3e300000) { /* x < 2**-28 */
688 if((int)x==0) { /* generate inexact */ 688 if((int)x==0) { /* generate inexact */
689 if (((ix | __LO(x)) | (iy + 1)) == 0) 689 if (((ix | low(x)) | (iy + 1)) == 0)
690 return one / fabsd(x); 690 return one / fabsd(x);
691 else { 691 else {
692 if (iy == 1) 692 if (iy == 1)
693 return x; 693 return x;
694 else { /* compute -1 / (x+y) carefully */ 694 else { /* compute -1 / (x+y) carefully */
695 double a, t; 695 double a, t;
696 696
697 z = w = x + y; 697 z = w = x + y;
698 __LO(z) = 0; 698 set_low(&z, 0);
699 v = y - (z - x); 699 v = y - (z - x);
700 t = a = -one / w; 700 t = a = -one / w;
701 __LO(t) = 0; 701 set_low(&t, 0);
702 s = one + t * z; 702 s = one + t * z;
703 return t + a * (s + t * v); 703 return t + a * (s + t * v);
704 } 704 }
705 } 705 }
706 } 706 }
731 else { /* if allow error up to 2 ulp, 731 else { /* if allow error up to 2 ulp,
732 simply return -1.0/(x+r) here */ 732 simply return -1.0/(x+r) here */
733 /* compute -1.0/(x+r) accurately */ 733 /* compute -1.0/(x+r) accurately */
734 double a,t; 734 double a,t;
735 z = w; 735 z = w;
736 __LO(z) = 0; 736 set_low(&z, 0);
737 v = r-(z - x); /* z+v = r+x */ 737 v = r-(z - x); /* z+v = r+x */
738 t = a = -1.0/w; /* a = -1.0/w */ 738 t = a = -1.0/w; /* a = -1.0/w */
739 __LO(t) = 0; 739 set_low(&t, 0);
740 s = 1.0+t*z; 740 s = 1.0+t*z;
741 return t+a*(s+t*v); 741 return t+a*(s+t*v);
742 } 742 }
743 } 743 }
744 744
783 JRT_LEAF(jdouble, SharedRuntime::dsin(jdouble x)) 783 JRT_LEAF(jdouble, SharedRuntime::dsin(jdouble x))
784 double y[2],z=0.0; 784 double y[2],z=0.0;
785 int n, ix; 785 int n, ix;
786 786
787 /* High word of x. */ 787 /* High word of x. */
788 ix = __HI(x); 788 ix = high(x);
789 789
790 /* |x| ~< pi/4 */ 790 /* |x| ~< pi/4 */
791 ix &= 0x7fffffff; 791 ix &= 0x7fffffff;
792 if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0); 792 if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0);
793 793
841 JRT_LEAF(jdouble, SharedRuntime::dcos(jdouble x)) 841 JRT_LEAF(jdouble, SharedRuntime::dcos(jdouble x))
842 double y[2],z=0.0; 842 double y[2],z=0.0;
843 int n, ix; 843 int n, ix;
844 844
845 /* High word of x. */ 845 /* High word of x. */
846 ix = __HI(x); 846 ix = high(x);
847 847
848 /* |x| ~< pi/4 */ 848 /* |x| ~< pi/4 */
849 ix &= 0x7fffffff; 849 ix &= 0x7fffffff;
850 if(ix <= 0x3fe921fb) return __kernel_cos(x,z); 850 if(ix <= 0x3fe921fb) return __kernel_cos(x,z);
851 851
898 JRT_LEAF(jdouble, SharedRuntime::dtan(jdouble x)) 898 JRT_LEAF(jdouble, SharedRuntime::dtan(jdouble x))
899 double y[2],z=0.0; 899 double y[2],z=0.0;
900 int n, ix; 900 int n, ix;
901 901
902 /* High word of x. */ 902 /* High word of x. */
903 ix = __HI(x); 903 ix = high(x);
904 904
905 /* |x| ~< pi/4 */ 905 /* |x| ~< pi/4 */
906 ix &= 0x7fffffff; 906 ix &= 0x7fffffff;
907 if(ix <= 0x3fe921fb) return __kernel_tan(x,z,1); 907 if(ix <= 0x3fe921fb) return __kernel_tan(x,z,1);
908 908