* ===========================================================================
*/
+typedef union {
+ u4 arg;
+ float ff;
+} Convert32;
+
+typedef union {
+ u4 arg[2];
+ s8 ll;
+ double dd;
+} Convert64;
+
/*
* public static int abs(int)
*/
static bool javaLangMath_abs_long(u4 arg0, u4 arg1, u4 arg2, u4 arg3,
JValue* pResult)
{
- union {
- u4 arg[2];
- s8 ll;
- } convert;
-
+ Convert64 convert;
convert.arg[0] = arg0;
convert.arg[1] = arg1;
s8 val = convert.ll;
static bool javaLangMath_abs_float(u4 arg0, u4 arg1, u4 arg2, u4 arg3,
JValue* pResult)
{
- union {
- u4 arg;
- float ff;
- } convert;
-
+ Convert32 convert;
/* clear the sign bit; assumes a fairly common fp representation */
convert.arg = arg0 & 0x7fffffff;
pResult->f = convert.ff;
static bool javaLangMath_abs_double(u4 arg0, u4 arg1, u4 arg2, u4 arg3,
JValue* pResult)
{
- union {
- u4 arg[2];
- s8 ll;
- double dd;
- } convert;
-
- /* clear the sign bit in the (endian-dependent) high word */
+ Convert64 convert;
convert.arg[0] = arg0;
convert.arg[1] = arg1;
+ /* clear the sign bit in the (endian-dependent) high word */
convert.ll &= 0x7fffffffffffffffULL;
pResult->d = convert.dd;
return true;
static bool javaLangMath_sqrt(u4 arg0, u4 arg1, u4 arg2, u4 arg3,
JValue* pResult)
{
- union {
- u4 arg[2];
- double dd;
- } convert;
-
+ Convert64 convert;
convert.arg[0] = arg0;
convert.arg[1] = arg1;
pResult->d = sqrt(convert.dd);
static bool javaLangMath_cos(u4 arg0, u4 arg1, u4 arg2, u4 arg3,
JValue* pResult)
{
- union {
- u4 arg[2];
- double dd;
- } convert;
-
+ Convert64 convert;
convert.arg[0] = arg0;
convert.arg[1] = arg1;
pResult->d = cos(convert.dd);
static bool javaLangMath_sin(u4 arg0, u4 arg1, u4 arg2, u4 arg3,
JValue* pResult)
{
- union {
- u4 arg[2];
- double dd;
- } convert;
-
+ Convert64 convert;
convert.arg[0] = arg0;
convert.arg[1] = arg1;
pResult->d = sin(convert.dd);
return true;
}
+/*
+ * ===========================================================================
+ * java.lang.Float
+ * ===========================================================================
+ */
+
+static bool javaLangFloat_floatToIntBits(u4 arg0, u4 arg1, u4 arg2, u4 arg,
+ JValue* pResult)
+{
+ Convert32 convert;
+ convert.arg = arg0;
+ pResult->i = isnanf(convert.ff) ? 0x7fc00000 : arg0;
+ return true;
+}
+
+static bool javaLangFloat_floatToRawIntBits(u4 arg0, u4 arg1, u4 arg2, u4 arg,
+ JValue* pResult)
+{
+ pResult->i = arg0;
+ return true;
+}
+
+static bool javaLangFloat_intBitsToFloat(u4 arg0, u4 arg1, u4 arg2, u4 arg,
+ JValue* pResult)
+{
+ Convert32 convert;
+ convert.arg = arg0;
+ pResult->f = convert.ff;
+ return true;
+}
+
+/*
+ * ===========================================================================
+ * java.lang.Double
+ * ===========================================================================
+ */
+
+static bool javaLangDouble_doubleToLongBits(u4 arg0, u4 arg1, u4 arg2, u4 arg,
+ JValue* pResult)
+{
+ Convert64 convert;
+ convert.arg[0] = arg0;
+ convert.arg[1] = arg1;
+ pResult->j = isnan(convert.dd) ? 0x7ff8000000000000LL : convert.ll;
+ return true;
+}
+
+static bool javaLangDouble_doubleToRawLongBits(u4 arg0, u4 arg1, u4 arg2,
+ u4 arg, JValue* pResult)
+{
+ Convert64 convert;
+ convert.arg[0] = arg0;
+ convert.arg[1] = arg1;
+ pResult->j = convert.ll;
+ return true;
+}
+
+static bool javaLangDouble_longBitsToDouble(u4 arg0, u4 arg1, u4 arg2, u4 arg,
+ JValue* pResult)
+{
+ Convert64 convert;
+ convert.arg[0] = arg0;
+ convert.arg[1] = arg1;
+ pResult->d = convert.dd;
+ return true;
+}
/*
* ===========================================================================
"Ljava/lang/Math;", "cos", "(D)D" },
{ javaLangMath_sin,
"Ljava/lang/Math;", "sin", "(D)D" },
+
+ { javaLangFloat_floatToIntBits,
+ "Ljava/lang/Float;", "floatToIntBits", "(F)I" },
+ { javaLangFloat_floatToRawIntBits,
+ "Ljava/lang/Float;", "floatToRawIntBits", "(F)I" },
+ { javaLangFloat_intBitsToFloat,
+ "Ljava/lang/Float;", "intBitsToFloat", "(I)F" },
+
+ { javaLangDouble_doubleToLongBits,
+ "Ljava/lang/Double;", "doubleToLongBits", "(D)J" },
+ { javaLangDouble_doubleToRawLongBits,
+ "Ljava/lang/Double;", "doubleToRawLongBits", "(D)J" },
+ { javaLangDouble_longBitsToDouble,
+ "Ljava/lang/Double;", "longBitsToDouble", "(J)D" },
};
/*
{
RegLocation rlSrc = dvmCompilerGetSrc(cUnit, mir, 0);
rlSrc = loadValue(cUnit, rlSrc, kCoreReg);
- RegLocation rlDest = inlinedTarget(cUnit, mir, false);;
+ RegLocation rlDest = inlinedTarget(cUnit, mir, false);
RegLocation rlResult = dvmCompilerEvalLoc(cUnit, rlDest, kCoreReg, true);
int signReg = dvmCompilerAllocTemp(cUnit);
/*
return false;
}
+static bool genInlinedIntFloatConversion(CompilationUnit *cUnit, MIR *mir)
+{
+ // Just move from source to destination...
+ RegLocation rlSrc = dvmCompilerGetSrc(cUnit, mir, 0);
+ RegLocation rlDest = inlinedTarget(cUnit, mir, false);
+ storeValue(cUnit, rlDest, rlSrc);
+ return false;
+}
+
+static bool genInlinedLongDoubleConversion(CompilationUnit *cUnit, MIR *mir)
+{
+ // Just move from source to destination...
+ RegLocation rlSrc = dvmCompilerGetSrcWide(cUnit, mir, 0, 1);
+ RegLocation rlDest = inlinedTargetWide(cUnit, mir, false);
+ storeValueWide(cUnit, rlDest, rlSrc);
+ return false;
+}
+
/*
* NOTE: Handles both range and non-range versions (arguments
* have already been normalized by this point).
return false;
else
break;
+ case INLINE_FLOAT_TO_RAW_INT_BITS:
+ case INLINE_INT_BITS_TO_FLOAT:
+ return genInlinedIntFloatConversion(cUnit, mir);
+ case INLINE_DOUBLE_TO_RAW_LONG_BITS:
+ case INLINE_LONG_BITS_TO_DOUBLE:
+ return genInlinedLongDoubleConversion(cUnit, mir);
case INLINE_STRING_EQUALS:
case INLINE_MATH_COS:
case INLINE_MATH_SIN:
+ case INLINE_FLOAT_TO_INT_BITS:
+ case INLINE_DOUBLE_TO_LONG_BITS:
break; /* Handle with C routine */
default:
dvmCompilerAbort(cUnit);