8040121: Load variable through a pointer of an incompatible type in src/hotspot/src/share/vm: opto/output.cpp, runtime/sharedRuntimeTrans.cpp, utilities/globalDefinitions_visCPP.hpp

Tue, 29 Jul 2014 13:54:16 +0200

author
thartmann
date
Tue, 29 Jul 2014 13:54:16 +0200
changeset 7001
b6a8cc1e0d92
parent 7000
631c3a4ea10c
child 7002
a073be2ce5c2

8040121: Load variable through a pointer of an incompatible type in src/hotspot/src/share/vm: opto/output.cpp, runtime/sharedRuntimeTrans.cpp, utilities/globalDefinitions_visCPP.hpp
Summary: Fixed parfait warnings in globalDefinitions files by using a union for casts.
Reviewed-by: kvn

src/share/vm/opto/output.cpp file | annotate | diff | comparison | revisions
src/share/vm/utilities/globalDefinitions.hpp file | annotate | diff | comparison | revisions
src/share/vm/utilities/globalDefinitions_gcc.hpp file | annotate | diff | comparison | revisions
src/share/vm/utilities/globalDefinitions_sparcWorks.hpp file | annotate | diff | comparison | revisions
src/share/vm/utilities/globalDefinitions_visCPP.hpp file | annotate | diff | comparison | revisions
src/share/vm/utilities/globalDefinitions_xlc.hpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/opto/output.cpp	Thu May 22 11:36:23 2014 -0400
     1.2 +++ b/src/share/vm/opto/output.cpp	Tue Jul 29 13:54:16 2014 +0200
     1.3 @@ -783,9 +783,9 @@
     1.4      // grow downwards in all implementations.
     1.5      // (If, on some machine, the interpreter's Java locals or stack
     1.6      // were to grow upwards, the embedded doubles would be word-swapped.)
     1.7 -    jint   *dp = (jint*)&d;
     1.8 -    array->append(new ConstantIntValue(dp[1]));
     1.9 -    array->append(new ConstantIntValue(dp[0]));
    1.10 +    jlong_accessor acc = { jlong_cast(d) };
    1.11 +    array->append(new ConstantIntValue(acc.words[1]));
    1.12 +    array->append(new ConstantIntValue(acc.words[0]));
    1.13  #endif
    1.14      break;
    1.15    }
    1.16 @@ -802,9 +802,9 @@
    1.17      // grow downwards in all implementations.
    1.18      // (If, on some machine, the interpreter's Java locals or stack
    1.19      // were to grow upwards, the embedded doubles would be word-swapped.)
    1.20 -    jint *dp = (jint*)&d;
    1.21 -    array->append(new ConstantIntValue(dp[1]));
    1.22 -    array->append(new ConstantIntValue(dp[0]));
    1.23 +    jlong_accessor acc = { d };
    1.24 +    array->append(new ConstantIntValue(acc.words[1]));
    1.25 +    array->append(new ConstantIntValue(acc.words[0]));
    1.26  #endif
    1.27      break;
    1.28    }
     2.1 --- a/src/share/vm/utilities/globalDefinitions.hpp	Thu May 22 11:36:23 2014 -0400
     2.2 +++ b/src/share/vm/utilities/globalDefinitions.hpp	Tue Jul 29 13:54:16 2014 +0200
     2.3 @@ -558,6 +558,27 @@
     2.4    return fabs(value);
     2.5  }
     2.6  
     2.7 +//----------------------------------------------------------------------------------------------------
     2.8 +// Special casts
     2.9 +// Cast floats into same-size integers and vice-versa w/o changing bit-pattern
    2.10 +typedef union {
    2.11 +  jfloat f;
    2.12 +  jint i;
    2.13 +} FloatIntConv;
    2.14 +
    2.15 +typedef union {
    2.16 +  jdouble d;
    2.17 +  jlong l;
    2.18 +  julong ul;
    2.19 +} DoubleLongConv;
    2.20 +
    2.21 +inline jint    jint_cast    (jfloat  x)  { return ((FloatIntConv*)&x)->i; }
    2.22 +inline jfloat  jfloat_cast  (jint    x)  { return ((FloatIntConv*)&x)->f; }
    2.23 +
    2.24 +inline jlong   jlong_cast   (jdouble x)  { return ((DoubleLongConv*)&x)->l;  }
    2.25 +inline julong  julong_cast  (jdouble x)  { return ((DoubleLongConv*)&x)->ul; }
    2.26 +inline jdouble jdouble_cast (jlong   x)  { return ((DoubleLongConv*)&x)->d;  }
    2.27 +
    2.28  inline jint low (jlong value)                    { return jint(value); }
    2.29  inline jint high(jlong value)                    { return jint(value >> 32); }
    2.30  
     3.1 --- a/src/share/vm/utilities/globalDefinitions_gcc.hpp	Thu May 22 11:36:23 2014 -0400
     3.2 +++ b/src/share/vm/utilities/globalDefinitions_gcc.hpp	Tue Jul 29 13:54:16 2014 +0200
     3.3 @@ -167,17 +167,6 @@
     3.4  typedef uint32_t juint;
     3.5  typedef uint64_t julong;
     3.6  
     3.7 -//----------------------------------------------------------------------------------------------------
     3.8 -// Special (possibly not-portable) casts
     3.9 -// Cast floats into same-size integers and vice-versa w/o changing bit-pattern
    3.10 -// %%%%%% These seem like standard C++ to me--how about factoring them out? - Ungar
    3.11 -
    3.12 -inline jint    jint_cast   (jfloat  x)           { return *(jint*   )&x; }
    3.13 -inline jlong   jlong_cast  (jdouble x)           { return *(jlong*  )&x; }
    3.14 -inline julong  julong_cast (jdouble x)           { return *(julong* )&x; }
    3.15 -
    3.16 -inline jfloat  jfloat_cast (jint    x)           { return *(jfloat* )&x; }
    3.17 -inline jdouble jdouble_cast(jlong   x)           { return *(jdouble*)&x; }
    3.18  
    3.19  //----------------------------------------------------------------------------------------------------
    3.20  // Constant for jlong (specifying an long long canstant is C++ compiler specific)
     4.1 --- a/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp	Thu May 22 11:36:23 2014 -0400
     4.2 +++ b/src/share/vm/utilities/globalDefinitions_sparcWorks.hpp	Tue Jul 29 13:54:16 2014 +0200
     4.3 @@ -183,15 +183,6 @@
     4.4  typedef unsigned int       juint;
     4.5  typedef unsigned long long julong;
     4.6  
     4.7 -//----------------------------------------------------------------------------------------------------
     4.8 -// Special (possibly not-portable) casts
     4.9 -// Cast floats into same-size integers and vice-versa w/o changing bit-pattern
    4.10 -
    4.11 -inline jint    jint_cast   (jfloat  x)           { return *(jint*   )&x; }
    4.12 -inline jlong   jlong_cast  (jdouble x)           { return *(jlong*  )&x; }
    4.13 -
    4.14 -inline jfloat  jfloat_cast (jint    x)           { return *(jfloat* )&x; }
    4.15 -inline jdouble jdouble_cast(jlong   x)           { return *(jdouble*)&x; }
    4.16  
    4.17  //----------------------------------------------------------------------------------------------------
    4.18  // Constant for jlong (specifying an long long constant is C++ compiler specific)
     5.1 --- a/src/share/vm/utilities/globalDefinitions_visCPP.hpp	Thu May 22 11:36:23 2014 -0400
     5.2 +++ b/src/share/vm/utilities/globalDefinitions_visCPP.hpp	Tue Jul 29 13:54:16 2014 +0200
     5.3 @@ -116,16 +116,6 @@
     5.4  typedef unsigned int     juint;
     5.5  typedef unsigned __int64 julong;
     5.6  
     5.7 -//----------------------------------------------------------------------------------------------------
     5.8 -// Special (possibly not-portable) casts
     5.9 -// Cast floats into same-size integers and vice-versa w/o changing bit-pattern
    5.10 -
    5.11 -inline jint    jint_cast   (jfloat  x)           { return *(jint*   )&x; }
    5.12 -inline jlong   jlong_cast  (jdouble x)           { return *(jlong*  )&x; }
    5.13 -
    5.14 -inline jfloat  jfloat_cast (jint    x)           { return *(jfloat* )&x; }
    5.15 -inline jdouble jdouble_cast(jlong   x)           { return *(jdouble*)&x; }
    5.16 -
    5.17  
    5.18  //----------------------------------------------------------------------------------------------------
    5.19  // Non-standard stdlib-like stuff:
     6.1 --- a/src/share/vm/utilities/globalDefinitions_xlc.hpp	Thu May 22 11:36:23 2014 -0400
     6.2 +++ b/src/share/vm/utilities/globalDefinitions_xlc.hpp	Tue Jul 29 13:54:16 2014 +0200
     6.3 @@ -114,16 +114,6 @@
     6.4  typedef uint32_t juint;
     6.5  typedef uint64_t julong;
     6.6  
     6.7 -//----------------------------------------------------------------------------------------------------
     6.8 -// Special (possibly not-portable) casts
     6.9 -// Cast floats into same-size integers and vice-versa w/o changing bit-pattern
    6.10 -// %%%%%% These seem like standard C++ to me--how about factoring them out? - Ungar
    6.11 -
    6.12 -inline jint    jint_cast   (jfloat  x)           { return *(jint*   )&x; }
    6.13 -inline jlong   jlong_cast  (jdouble x)           { return *(jlong*  )&x; }
    6.14 -
    6.15 -inline jfloat  jfloat_cast (jint    x)           { return *(jfloat* )&x; }
    6.16 -inline jdouble jdouble_cast(jlong   x)           { return *(jdouble*)&x; }
    6.17  
    6.18  //----------------------------------------------------------------------------------------------------
    6.19  // Constant for jlong (specifying an long long canstant is C++ compiler specific)

mercurial