Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/sharedRuntimeTrans.cpp @ 20286:631c3a4ea10c
8043301: Duplicate definitions in vm/runtime/sharedRuntimeTrans.cpp versus math.h in VS2013
Summary: Factor out definitions of copysignA and scalbnA into new file sharedRuntimeMath.hpp
Reviewed-by: kvn
author | lfoltan |
---|---|
date | Thu, 22 May 2014 11:36:23 -0400 |
parents | bdd155477289 |
children | a073be2ce5c2 |
comparison
equal
deleted
inserted
replaced
20285:cabe05c85665 | 20286:631c3a4ea10c |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
41 // file in the IDE on Windows | 41 // file in the IDE on Windows |
42 #ifdef WIN32 | 42 #ifdef WIN32 |
43 # pragma optimize ( "", off ) | 43 # pragma optimize ( "", off ) |
44 #endif | 44 #endif |
45 | 45 |
46 #include <math.h> | 46 #include "runtime/sharedRuntimeMath.hpp" |
47 | |
48 // VM_LITTLE_ENDIAN is #defined appropriately in the Makefiles | |
49 // [jk] this is not 100% correct because the float word order may different | |
50 // from the byte order (e.g. on ARM) | |
51 #ifdef VM_LITTLE_ENDIAN | |
52 # define __HI(x) *(1+(int*)&x) | |
53 # define __LO(x) *(int*)&x | |
54 #else | |
55 # define __HI(x) *(int*)&x | |
56 # define __LO(x) *(1+(int*)&x) | |
57 #endif | |
58 | |
59 #if !defined(AIX) | |
60 double copysign(double x, double y) { | |
61 __HI(x) = (__HI(x)&0x7fffffff)|(__HI(y)&0x80000000); | |
62 return x; | |
63 } | |
64 #endif | |
65 | |
66 /* | |
67 * ==================================================== | |
68 * Copyright (c) 1998 Oracle and/or its affiliates. All rights reserved. | |
69 * | |
70 * Developed at SunSoft, a Sun Microsystems, Inc. business. | |
71 * Permission to use, copy, modify, and distribute this | |
72 * software is freely granted, provided that this notice | |
73 * is preserved. | |
74 * ==================================================== | |
75 */ | |
76 | |
77 /* | |
78 * scalbn (double x, int n) | |
79 * scalbn(x,n) returns x* 2**n computed by exponent | |
80 * manipulation rather than by actually performing an | |
81 * exponentiation or a multiplication. | |
82 */ | |
83 | |
84 static const double | |
85 two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ | |
86 twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ | |
87 hugeX = 1.0e+300, | |
88 tiny = 1.0e-300; | |
89 | |
90 #if !defined(AIX) | |
91 double scalbn (double x, int n) { | |
92 int k,hx,lx; | |
93 hx = __HI(x); | |
94 lx = __LO(x); | |
95 k = (hx&0x7ff00000)>>20; /* extract exponent */ | |
96 if (k==0) { /* 0 or subnormal x */ | |
97 if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ | |
98 x *= two54; | |
99 hx = __HI(x); | |
100 k = ((hx&0x7ff00000)>>20) - 54; | |
101 if (n< -50000) return tiny*x; /*underflow*/ | |
102 } | |
103 if (k==0x7ff) return x+x; /* NaN or Inf */ | |
104 k = k+n; | |
105 if (k > 0x7fe) return hugeX*copysign(hugeX,x); /* overflow */ | |
106 if (k > 0) /* normal result */ | |
107 {__HI(x) = (hx&0x800fffff)|(k<<20); return x;} | |
108 if (k <= -54) { | |
109 if (n > 50000) /* in case integer overflow in n+k */ | |
110 return hugeX*copysign(hugeX,x); /*overflow*/ | |
111 else return tiny*copysign(tiny,x); /*underflow*/ | |
112 } | |
113 k += 54; /* subnormal result */ | |
114 __HI(x) = (hx&0x800fffff)|(k<<20); | |
115 return x*twom54; | |
116 } | |
117 #endif | |
118 | 47 |
119 /* __ieee754_log(x) | 48 /* __ieee754_log(x) |
120 * Return the logrithm of x | 49 * Return the logrithm of x |
121 * | 50 * |
122 * Method : | 51 * Method : |
717 t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); | 646 t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5)))); |
718 r = (z*t1)/(t1-two)-(w+z*w); | 647 r = (z*t1)/(t1-two)-(w+z*w); |
719 z = one-(r-z); | 648 z = one-(r-z); |
720 j = __HI(z); | 649 j = __HI(z); |
721 j += (n<<20); | 650 j += (n<<20); |
722 if((j>>20)<=0) z = scalbn(z,n); /* subnormal output */ | 651 if((j>>20)<=0) z = scalbnA(z,n); /* subnormal output */ |
723 else __HI(z) += (n<<20); | 652 else __HI(z) += (n<<20); |
724 return s*z; | 653 return s*z; |
725 } | 654 } |
726 | 655 |
727 | 656 |