8043301: Duplicate definitions in vm/runtime/sharedRuntimeTrans.cpp versus math.h in VS2013

Thu, 22 May 2014 11:36:23 -0400

author
lfoltan
date
Thu, 22 May 2014 11:36:23 -0400
changeset 7000
631c3a4ea10c
parent 6999
cabe05c85665
child 7001
b6a8cc1e0d92

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

src/share/vm/runtime/sharedRuntimeMath.hpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/sharedRuntimeTrans.cpp file | annotate | diff | comparison | revisions
src/share/vm/runtime/sharedRuntimeTrig.cpp file | annotate | diff | comparison | revisions
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/runtime/sharedRuntimeMath.hpp	Thu May 22 11:36:23 2014 -0400
     1.3 @@ -0,0 +1,97 @@
     1.4 +/*
     1.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_RUNTIME_SHAREDRUNTIMEMATH_HPP
    1.29 +#define SHARE_VM_RUNTIME_SHAREDRUNTIMEMATH_HPP
    1.30 +
    1.31 +#include <math.h>
    1.32 +
    1.33 +// VM_LITTLE_ENDIAN is #defined appropriately in the Makefiles
    1.34 +// [jk] this is not 100% correct because the float word order may different
    1.35 +// from the byte order (e.g. on ARM FPA)
    1.36 +#ifdef VM_LITTLE_ENDIAN
    1.37 +# define __HI(x) *(1+(int*)&x)
    1.38 +# define __LO(x) *(int*)&x
    1.39 +#else
    1.40 +# define __HI(x) *(int*)&x
    1.41 +# define __LO(x) *(1+(int*)&x)
    1.42 +#endif
    1.43 +
    1.44 +static double copysignA(double x, double y) {
    1.45 +  __HI(x) = (__HI(x)&0x7fffffff)|(__HI(y)&0x80000000);
    1.46 +  return x;
    1.47 +}
    1.48 +
    1.49 +/*
    1.50 + * ====================================================
    1.51 + * Copyright (c) 1998 Oracle and/or its affiliates. All rights reserved.
    1.52 + *
    1.53 + * Developed at SunSoft, a Sun Microsystems, Inc. business.
    1.54 + * Permission to use, copy, modify, and distribute this
    1.55 + * software is freely granted, provided that this notice
    1.56 + * is preserved.
    1.57 + * ====================================================
    1.58 + */
    1.59 +
    1.60 +/*
    1.61 + * scalbn (double x, int n)
    1.62 + * scalbn(x,n) returns x* 2**n  computed by  exponent
    1.63 + * manipulation rather than by actually performing an
    1.64 + * exponentiation or a multiplication.
    1.65 + */
    1.66 +
    1.67 +static const double
    1.68 +two54   =  1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
    1.69 +twom54  =  5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
    1.70 +hugeX  = 1.0e+300,
    1.71 +tiny   = 1.0e-300;
    1.72 +
    1.73 +static double scalbnA (double x, int n) {
    1.74 +  int  k,hx,lx;
    1.75 +  hx = __HI(x);
    1.76 +  lx = __LO(x);
    1.77 +  k = (hx&0x7ff00000)>>20;              /* extract exponent */
    1.78 +  if (k==0) {                           /* 0 or subnormal x */
    1.79 +    if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */
    1.80 +    x *= two54;
    1.81 +    hx = __HI(x);
    1.82 +    k = ((hx&0x7ff00000)>>20) - 54;
    1.83 +    if (n< -50000) return tiny*x;       /*underflow*/
    1.84 +  }
    1.85 +  if (k==0x7ff) return x+x;             /* NaN or Inf */
    1.86 +  k = k+n;
    1.87 +  if (k >  0x7fe) return hugeX*copysignA(hugeX,x); /* overflow  */
    1.88 +  if (k > 0)                            /* normal result */
    1.89 +    {__HI(x) = (hx&0x800fffff)|(k<<20); return x;}
    1.90 +  if (k <= -54) {
    1.91 +    if (n > 50000)      /* in case integer overflow in n+k */
    1.92 +      return hugeX*copysignA(hugeX,x);  /*overflow*/
    1.93 +    else return tiny*copysignA(tiny,x); /*underflow*/
    1.94 +  }
    1.95 +  k += 54;                              /* subnormal result */
    1.96 +  __HI(x) = (hx&0x800fffff)|(k<<20);
    1.97 +  return x*twom54;
    1.98 +}
    1.99 +
   1.100 +#endif // SHARE_VM_RUNTIME_SHAREDRUNTIMEMATH_HPP
     2.1 --- a/src/share/vm/runtime/sharedRuntimeTrans.cpp	Mon Aug 11 19:19:47 2014 +0400
     2.2 +++ b/src/share/vm/runtime/sharedRuntimeTrans.cpp	Thu May 22 11:36:23 2014 -0400
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -43,78 +43,7 @@
    2.11  # pragma optimize ( "", off )
    2.12  #endif
    2.13  
    2.14 -#include <math.h>
    2.15 -
    2.16 -// VM_LITTLE_ENDIAN is #defined appropriately in the Makefiles
    2.17 -// [jk] this is not 100% correct because the float word order may different
    2.18 -// from the byte order (e.g. on ARM)
    2.19 -#ifdef VM_LITTLE_ENDIAN
    2.20 -# define __HI(x) *(1+(int*)&x)
    2.21 -# define __LO(x) *(int*)&x
    2.22 -#else
    2.23 -# define __HI(x) *(int*)&x
    2.24 -# define __LO(x) *(1+(int*)&x)
    2.25 -#endif
    2.26 -
    2.27 -#if !defined(AIX)
    2.28 -double copysign(double x, double y) {
    2.29 -  __HI(x) = (__HI(x)&0x7fffffff)|(__HI(y)&0x80000000);
    2.30 -  return x;
    2.31 -}
    2.32 -#endif
    2.33 -
    2.34 -/*
    2.35 - * ====================================================
    2.36 - * Copyright (c) 1998 Oracle and/or its affiliates. All rights reserved.
    2.37 - *
    2.38 - * Developed at SunSoft, a Sun Microsystems, Inc. business.
    2.39 - * Permission to use, copy, modify, and distribute this
    2.40 - * software is freely granted, provided that this notice
    2.41 - * is preserved.
    2.42 - * ====================================================
    2.43 - */
    2.44 -
    2.45 -/*
    2.46 - * scalbn (double x, int n)
    2.47 - * scalbn(x,n) returns x* 2**n  computed by  exponent
    2.48 - * manipulation rather than by actually performing an
    2.49 - * exponentiation or a multiplication.
    2.50 - */
    2.51 -
    2.52 -static const double
    2.53 -two54   =  1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
    2.54 -  twom54  =  5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
    2.55 -  hugeX   = 1.0e+300,
    2.56 -  tiny   = 1.0e-300;
    2.57 -
    2.58 -#if !defined(AIX)
    2.59 -double scalbn (double x, int n) {
    2.60 -  int  k,hx,lx;
    2.61 -  hx = __HI(x);
    2.62 -  lx = __LO(x);
    2.63 -  k = (hx&0x7ff00000)>>20;              /* extract exponent */
    2.64 -  if (k==0) {                           /* 0 or subnormal x */
    2.65 -    if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */
    2.66 -    x *= two54;
    2.67 -    hx = __HI(x);
    2.68 -    k = ((hx&0x7ff00000)>>20) - 54;
    2.69 -    if (n< -50000) return tiny*x;       /*underflow*/
    2.70 -  }
    2.71 -  if (k==0x7ff) return x+x;             /* NaN or Inf */
    2.72 -  k = k+n;
    2.73 -  if (k >  0x7fe) return hugeX*copysign(hugeX,x); /* overflow  */
    2.74 -  if (k > 0)                            /* normal result */
    2.75 -    {__HI(x) = (hx&0x800fffff)|(k<<20); return x;}
    2.76 -  if (k <= -54) {
    2.77 -    if (n > 50000)      /* in case integer overflow in n+k */
    2.78 -      return hugeX*copysign(hugeX,x);   /*overflow*/
    2.79 -    else return tiny*copysign(tiny,x);  /*underflow*/
    2.80 -  }
    2.81 -  k += 54;                              /* subnormal result */
    2.82 -  __HI(x) = (hx&0x800fffff)|(k<<20);
    2.83 -  return x*twom54;
    2.84 -}
    2.85 -#endif
    2.86 +#include "runtime/sharedRuntimeMath.hpp"
    2.87  
    2.88  /* __ieee754_log(x)
    2.89   * Return the logrithm of x
    2.90 @@ -719,7 +648,7 @@
    2.91    z  = one-(r-z);
    2.92    j  = __HI(z);
    2.93    j += (n<<20);
    2.94 -  if((j>>20)<=0) z = scalbn(z,n);       /* subnormal output */
    2.95 +  if((j>>20)<=0) z = scalbnA(z,n);       /* subnormal output */
    2.96    else __HI(z) += (n<<20);
    2.97    return s*z;
    2.98  }
     3.1 --- a/src/share/vm/runtime/sharedRuntimeTrig.cpp	Mon Aug 11 19:19:47 2014 +0400
     3.2 +++ b/src/share/vm/runtime/sharedRuntimeTrig.cpp	Thu May 22 11:36:23 2014 -0400
     3.3 @@ -1,5 +1,5 @@
     3.4  /*
     3.5 - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
     3.6 + * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
     3.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.8   *
     3.9   * This code is free software; you can redistribute it and/or modify it
    3.10 @@ -63,63 +63,7 @@
    3.11  #define SAFEBUF
    3.12  #endif
    3.13  
    3.14 -#include <math.h>
    3.15 -
    3.16 -// VM_LITTLE_ENDIAN is #defined appropriately in the Makefiles
    3.17 -// [jk] this is not 100% correct because the float word order may different
    3.18 -// from the byte order (e.g. on ARM)
    3.19 -#ifdef VM_LITTLE_ENDIAN
    3.20 -# define __HI(x) *(1+(int*)&x)
    3.21 -# define __LO(x) *(int*)&x
    3.22 -#else
    3.23 -# define __HI(x) *(int*)&x
    3.24 -# define __LO(x) *(1+(int*)&x)
    3.25 -#endif
    3.26 -
    3.27 -static double copysignA(double x, double y) {
    3.28 -  __HI(x) = (__HI(x)&0x7fffffff)|(__HI(y)&0x80000000);
    3.29 -  return x;
    3.30 -}
    3.31 -
    3.32 -/*
    3.33 - * scalbn (double x, int n)
    3.34 - * scalbn(x,n) returns x* 2**n  computed by  exponent
    3.35 - * manipulation rather than by actually performing an
    3.36 - * exponentiation or a multiplication.
    3.37 - */
    3.38 -
    3.39 -static const double
    3.40 -two54   =  1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
    3.41 -twom54  =  5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
    3.42 -hugeX  = 1.0e+300,
    3.43 -tiny   = 1.0e-300;
    3.44 -
    3.45 -static double scalbnA (double x, int n) {
    3.46 -  int  k,hx,lx;
    3.47 -  hx = __HI(x);
    3.48 -  lx = __LO(x);
    3.49 -  k = (hx&0x7ff00000)>>20;              /* extract exponent */
    3.50 -  if (k==0) {                           /* 0 or subnormal x */
    3.51 -    if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */
    3.52 -    x *= two54;
    3.53 -    hx = __HI(x);
    3.54 -    k = ((hx&0x7ff00000)>>20) - 54;
    3.55 -    if (n< -50000) return tiny*x;       /*underflow*/
    3.56 -  }
    3.57 -  if (k==0x7ff) return x+x;             /* NaN or Inf */
    3.58 -  k = k+n;
    3.59 -  if (k >  0x7fe) return hugeX*copysignA(hugeX,x); /* overflow  */
    3.60 -  if (k > 0)                            /* normal result */
    3.61 -    {__HI(x) = (hx&0x800fffff)|(k<<20); return x;}
    3.62 -  if (k <= -54) {
    3.63 -    if (n > 50000)      /* in case integer overflow in n+k */
    3.64 -      return hugeX*copysignA(hugeX,x);  /*overflow*/
    3.65 -    else return tiny*copysignA(tiny,x); /*underflow*/
    3.66 -  }
    3.67 -  k += 54;                              /* subnormal result */
    3.68 -  __HI(x) = (hx&0x800fffff)|(k<<20);
    3.69 -  return x*twom54;
    3.70 -}
    3.71 +#include "runtime/sharedRuntimeMath.hpp"
    3.72  
    3.73  /*
    3.74   * __kernel_rem_pio2(x,y,e0,nx,prec,ipio2)

mercurial