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

Fixed parfait warnings in globalDefinitions files by using a union for casts.

Reviewed-by: kvn
This commit is contained in:
Tobias Hartmann 2014-07-29 13:54:16 +02:00
parent e8d1955b5e
commit d2a5b70cdf
6 changed files with 27 additions and 46 deletions

View File

@ -785,9 +785,9 @@ void Compile::FillLocArray( int idx, MachSafePointNode* sfpt, Node *local,
// grow downwards in all implementations.
// (If, on some machine, the interpreter's Java locals or stack
// were to grow upwards, the embedded doubles would be word-swapped.)
jint *dp = (jint*)&d;
array->append(new ConstantIntValue(dp[1]));
array->append(new ConstantIntValue(dp[0]));
jlong_accessor acc = { jlong_cast(d) };
array->append(new ConstantIntValue(acc.words[1]));
array->append(new ConstantIntValue(acc.words[0]));
#endif
break;
}
@ -804,9 +804,9 @@ void Compile::FillLocArray( int idx, MachSafePointNode* sfpt, Node *local,
// grow downwards in all implementations.
// (If, on some machine, the interpreter's Java locals or stack
// were to grow upwards, the embedded doubles would be word-swapped.)
jint *dp = (jint*)&d;
array->append(new ConstantIntValue(dp[1]));
array->append(new ConstantIntValue(dp[0]));
jlong_accessor acc = { d };
array->append(new ConstantIntValue(acc.words[1]));
array->append(new ConstantIntValue(acc.words[0]));
#endif
break;
}

View File

@ -558,6 +558,27 @@ inline double fabsd(double value) {
return fabs(value);
}
//----------------------------------------------------------------------------------------------------
// Special casts
// Cast floats into same-size integers and vice-versa w/o changing bit-pattern
typedef union {
jfloat f;
jint i;
} FloatIntConv;
typedef union {
jdouble d;
jlong l;
julong ul;
} DoubleLongConv;
inline jint jint_cast (jfloat x) { return ((FloatIntConv*)&x)->i; }
inline jfloat jfloat_cast (jint x) { return ((FloatIntConv*)&x)->f; }
inline jlong jlong_cast (jdouble x) { return ((DoubleLongConv*)&x)->l; }
inline julong julong_cast (jdouble x) { return ((DoubleLongConv*)&x)->ul; }
inline jdouble jdouble_cast (jlong x) { return ((DoubleLongConv*)&x)->d; }
inline jint low (jlong value) { return jint(value); }
inline jint high(jlong value) { return jint(value >> 32); }

View File

@ -167,17 +167,6 @@ typedef uint16_t jushort;
typedef uint32_t juint;
typedef uint64_t julong;
//----------------------------------------------------------------------------------------------------
// Special (possibly not-portable) casts
// Cast floats into same-size integers and vice-versa w/o changing bit-pattern
// %%%%%% These seem like standard C++ to me--how about factoring them out? - Ungar
inline jint jint_cast (jfloat x) { return *(jint* )&x; }
inline jlong jlong_cast (jdouble x) { return *(jlong* )&x; }
inline julong julong_cast (jdouble x) { return *(julong* )&x; }
inline jfloat jfloat_cast (jint x) { return *(jfloat* )&x; }
inline jdouble jdouble_cast(jlong x) { return *(jdouble*)&x; }
//----------------------------------------------------------------------------------------------------
// Constant for jlong (specifying an long long canstant is C++ compiler specific)

View File

@ -183,15 +183,6 @@ typedef unsigned short jushort;
typedef unsigned int juint;
typedef unsigned long long julong;
//----------------------------------------------------------------------------------------------------
// Special (possibly not-portable) casts
// Cast floats into same-size integers and vice-versa w/o changing bit-pattern
inline jint jint_cast (jfloat x) { return *(jint* )&x; }
inline jlong jlong_cast (jdouble x) { return *(jlong* )&x; }
inline jfloat jfloat_cast (jint x) { return *(jfloat* )&x; }
inline jdouble jdouble_cast(jlong x) { return *(jdouble*)&x; }
//----------------------------------------------------------------------------------------------------
// Constant for jlong (specifying an long long constant is C++ compiler specific)

View File

@ -116,16 +116,6 @@ typedef unsigned short jushort;
typedef unsigned int juint;
typedef unsigned __int64 julong;
//----------------------------------------------------------------------------------------------------
// Special (possibly not-portable) casts
// Cast floats into same-size integers and vice-versa w/o changing bit-pattern
inline jint jint_cast (jfloat x) { return *(jint* )&x; }
inline jlong jlong_cast (jdouble x) { return *(jlong* )&x; }
inline jfloat jfloat_cast (jint x) { return *(jfloat* )&x; }
inline jdouble jdouble_cast(jlong x) { return *(jdouble*)&x; }
//----------------------------------------------------------------------------------------------------
// Non-standard stdlib-like stuff:

View File

@ -114,16 +114,6 @@ typedef uint16_t jushort;
typedef uint32_t juint;
typedef uint64_t julong;
//----------------------------------------------------------------------------------------------------
// Special (possibly not-portable) casts
// Cast floats into same-size integers and vice-versa w/o changing bit-pattern
// %%%%%% These seem like standard C++ to me--how about factoring them out? - Ungar
inline jint jint_cast (jfloat x) { return *(jint* )&x; }
inline jlong jlong_cast (jdouble x) { return *(jlong* )&x; }
inline jfloat jfloat_cast (jint x) { return *(jfloat* )&x; }
inline jdouble jdouble_cast(jlong x) { return *(jdouble*)&x; }
//----------------------------------------------------------------------------------------------------
// Constant for jlong (specifying an long long canstant is C++ compiler specific)