[kaffe] CVS kaffe (robilad): cache Double.NaN for conversions
Kaffe CVS
cvs-commits at kaffe.org
Thu Feb 14 15:33:16 PST 2008
PatchSet 7745
Date: 2008/02/14 23:31:38
Author: robilad
Branch: HEAD
Tag: (none)
Log:
cache Double.NaN for conversions
2008-02-15 Dalibor Topic <robilad at kaffe.org>
* kaffe/kaffevm/fp.c (doubleAdd, doubleSubtract, doubleMultiply)
(doubleDivide): Use KAFFE_JDOUBLE_NAN.
* kaffe/kaffevm/soft.c (soft_cvtfd): Use KAFFE_JDOUBLE_NAN. Documented.
* kaffe/kaffevm/baseClasses.c (initBaseClasses): Initialize KAFFE_JDOUBLE_NAN.
* kaffe/kaffevm/baseClasses.h (KAFFE_JDOUBLE_NAN): New field caching
java.lang.Double.NaN.
Members:
ChangeLog:1.5245->1.5246
kaffe/kaffevm/baseClasses.c:1.80->1.81
kaffe/kaffevm/baseClasses.h:1.25->1.26
kaffe/kaffevm/fp.c:1.8->1.9
kaffe/kaffevm/soft.c:1.88->1.89
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.5245 kaffe/ChangeLog:1.5246
--- kaffe/ChangeLog:1.5245 Thu Feb 14 22:24:40 2008
+++ kaffe/ChangeLog Thu Feb 14 23:31:38 2008
@@ -1,3 +1,15 @@
+2008-02-15 Dalibor Topic <robilad at kaffe.org>
+
+ * kaffe/kaffevm/fp.c (doubleAdd, doubleSubtract, doubleMultiply)
+ (doubleDivide): Use KAFFE_JDOUBLE_NAN.
+
+ * kaffe/kaffevm/soft.c (soft_cvtfd): Use KAFFE_JDOUBLE_NAN. Documented.
+
+ * kaffe/kaffevm/baseClasses.c (initBaseClasses): Initialize KAFFE_JDOUBLE_NAN.
+
+ * kaffe/kaffevm/baseClasses.h (KAFFE_JDOUBLE_NAN): New field caching
+ java.lang.Double.NaN.
+
2008-02-14 Dalibor Topic <robilad at kaffe.org>
* kaffe/kaffevm/fp.h (DISNAN): Removed.
Index: kaffe/kaffe/kaffevm/baseClasses.c
diff -u kaffe/kaffe/kaffevm/baseClasses.c:1.80 kaffe/kaffe/kaffevm/baseClasses.c:1.81
--- kaffe/kaffe/kaffevm/baseClasses.c:1.80 Mon Jan 21 01:04:36 2008
+++ kaffe/kaffe/kaffevm/baseClasses.c Thu Feb 14 23:31:41 2008
@@ -44,6 +44,7 @@
#include "fileSections.h"
#include "verify-type.h"
#include "jar.h"
+#include "jni_funcs.h"
Utf8Const* init_name;
Utf8Const* final_name;
@@ -90,6 +91,8 @@
Hjava_lang_Class* javaLangFloatClass;
Hjava_lang_Class* javaLangDoubleClass;
+jdouble KAFFE_JDOUBLE_NAN;
+
Hjava_lang_Class *javaNioBufferClass;
Hjava_lang_Class *javaNioDirectByteBufferImplClass;
Hjava_lang_Class *javaNioDirectByteBufferImplReadWriteClass;
@@ -421,5 +424,9 @@
DBG(INIT, dprintf("Cannot resolve fields necessary for NIO operations\n"); );
KAFFEVM_EXIT(-1);
}
+
+ KAFFE_JDOUBLE_NAN = KaffeJNI_GetStaticDoubleField(NULL, javaLangDoubleClass,
+ KNI_lookupFieldC(javaLangDoubleClass,
+ "NaN", true, &einfo));
}
Index: kaffe/kaffe/kaffevm/baseClasses.h
diff -u kaffe/kaffe/kaffevm/baseClasses.h:1.25 kaffe/kaffe/kaffevm/baseClasses.h:1.26
--- kaffe/kaffe/kaffevm/baseClasses.h:1.25 Fri Dec 16 20:35:47 2005
+++ kaffe/kaffe/kaffevm/baseClasses.h Thu Feb 14 23:31:41 2008
@@ -50,6 +50,7 @@
extern struct Hjava_lang_Class* javaLangLongClass;
extern struct Hjava_lang_Class* javaLangFloatClass;
extern struct Hjava_lang_Class* javaLangDoubleClass;
+extern jdouble KAFFE_JDOUBLE_NAN;
extern struct Hjava_lang_Class *javaNioDirectByteBufferImplClass;
extern struct Hjava_lang_Class *javaNioDirectByteBufferImplReadWriteClass;
Index: kaffe/kaffe/kaffevm/fp.c
diff -u kaffe/kaffe/kaffevm/fp.c:1.8 kaffe/kaffe/kaffevm/fp.c:1.9
--- kaffe/kaffe/kaffevm/fp.c:1.8 Thu Feb 14 22:24:41 2008
+++ kaffe/kaffe/kaffevm/fp.c Thu Feb 14 23:31:41 2008
@@ -15,6 +15,7 @@
#include "config-mem.h"
#include "config-hacks.h"
#include <math.h>
+#include "baseClasses.h"
#include "gtypes.h"
#include "defs.h"
#include "files.h"
@@ -106,7 +107,7 @@
doubleAdd(jdouble v1, jdouble v2)
{
if (isnan(v1) || isnan(v2)) {
- return longToDouble(DNANBITS);
+ return KAFFE_JDOUBLE_NAN;
}
return (v1 + v2);
}
@@ -130,7 +131,7 @@
doubleSubtract(jdouble v1, jdouble v2)
{
if (isnan(v1) || isnan(v2)) {
- return longToDouble(DNANBITS);
+ return KAFFE_JDOUBLE_NAN;
}
return (v1 - v2);
}
@@ -154,7 +155,7 @@
doubleMultiply(jdouble v1, jdouble v2)
{
if (isnan(v1) || isnan(v2)) {
- return longToDouble(DNANBITS);
+ return KAFFE_JDOUBLE_NAN;
}
return (v1 * v2);
}
@@ -183,13 +184,13 @@
v2bits = doubleToLong(v2);
if (isnan(v1) || isnan(v2)) {
- return longToDouble(DNANBITS);
+ return KAFFE_JDOUBLE_NAN;
}
if (v2 != 0.0) {
return (v1 / v2);
}
if (v1 == 0.0) {
- return longToDouble(DNANBITS);
+ return KAFFE_JDOUBLE_NAN;
}
return longToDouble((jlong)(DINFBITS | ((v1bits ^ v2bits) & DSIGNBIT)));
}
Index: kaffe/kaffe/kaffevm/soft.c
diff -u kaffe/kaffe/kaffevm/soft.c:1.88 kaffe/kaffe/kaffevm/soft.c:1.89
--- kaffe/kaffe/kaffevm/soft.c:1.88 Thu Feb 14 22:24:41 2008
+++ kaffe/kaffe/kaffevm/soft.c Thu Feb 14 23:31:41 2008
@@ -845,15 +845,20 @@
return ((jdouble)v);
}
+/**
+ * convert a float to a double
+ *
+ * @param v a float
+ *
+ * @return the double corresponding to the float, or Double.NaN if the float is a NaN.
+ */
jdouble
soft_cvtfd(jfloat v)
{
- if (isnan(v)) {
- return (longToDouble(DNANBITS));
- }
- else {
- return ((jdouble)v);
- }
+ if (isnan(v))
+ return KAFFE_JDOUBLE_NAN;
+ else
+ return (jdouble)v;
}
jfloat
More information about the kaffe
mailing list