提交 1aec8f2a 编写于 作者: T thartmann

8040121: Load variable through a pointer of an incompatible type in...

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
上级 77405b0e
......@@ -783,9 +783,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;
}
......@@ -802,9 +802,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;
}
......
......@@ -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); }
......
......@@ -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)
......
......@@ -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)
......
......@@ -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:
......
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册