[kaffe] CVS kaffe (robilad): cache Float.NaN for conversions

Kaffe CVS cvs-commits at kaffe.org
Thu Feb 14 16:02:47 PST 2008


PatchSet 7747 
Date: 2008/02/15 00:01:16
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
cache Float.NaN for conversions

2008-02-15  Dalibor Topic  <robilad at kaffe.org>

* kaffe/kaffevm/fp.c (floatAdd, floatSubtract, floatMultiply)
(floatDivide):  Use KAFFE_JFLOAT_NAN.

* kaffe/kaffevm/soft.c (soft_cvtdf):  Use KAFFE_JFLOAT_NAN. Documented.

* kaffe/kaffevm/baseClasses.c (initBaseClasses): Initialize KAFFE_JFLOAT_NAN.

* kaffe/kaffevm/baseClasses.h (KAFFE_JFLOAT_NAN): New field caching
java.lang.Float.NaN.

Members: 
	ChangeLog:1.5247->1.5248 
	kaffe/kaffevm/baseClasses.c:1.81->1.82 
	kaffe/kaffevm/baseClasses.h:1.26->1.27 
	kaffe/kaffevm/fp.c:1.10->1.11 
	kaffe/kaffevm/soft.c:1.89->1.90 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.5247 kaffe/ChangeLog:1.5248
--- kaffe/ChangeLog:1.5247	Thu Feb 14 23:42:20 2008
+++ kaffe/ChangeLog	Fri Feb 15 00:01:16 2008
@@ -1,5 +1,17 @@
 2008-02-15  Dalibor Topic  <robilad at kaffe.org>
 
+	* kaffe/kaffevm/fp.c (floatAdd, floatSubtract, floatMultiply)
+	(floatDivide):  Use KAFFE_JFLOAT_NAN.
+
+	* kaffe/kaffevm/soft.c (soft_cvtdf):  Use KAFFE_JFLOAT_NAN. Documented.
+
+	* kaffe/kaffevm/baseClasses.c (initBaseClasses): Initialize KAFFE_JFLOAT_NAN.
+
+	* kaffe/kaffevm/baseClasses.h (KAFFE_JFLOAT_NAN): New field caching
+	java.lang.Float.NaN.
+
+2008-02-15  Dalibor Topic  <robilad at kaffe.org>
+
 	* kaffe/kaffevm/fp.h (DNANBITS, longToDouble): Removed.
 
 	* kaffe/kaffevm/fp.c (longToDouble): Simplified collapsing of NaNs.
Index: kaffe/kaffe/kaffevm/baseClasses.c
diff -u kaffe/kaffe/kaffevm/baseClasses.c:1.81 kaffe/kaffe/kaffevm/baseClasses.c:1.82
--- kaffe/kaffe/kaffevm/baseClasses.c:1.81	Thu Feb 14 23:31:41 2008
+++ kaffe/kaffe/kaffevm/baseClasses.c	Fri Feb 15 00:01:18 2008
@@ -91,6 +91,7 @@
 Hjava_lang_Class* javaLangFloatClass;
 Hjava_lang_Class* javaLangDoubleClass;
 
+jfloat KAFFE_JFLOAT_NAN;
 jdouble KAFFE_JDOUBLE_NAN;
 
 Hjava_lang_Class *javaNioBufferClass;
@@ -425,6 +426,9 @@
 	    KAFFEVM_EXIT(-1);
 	  }
 
+	KAFFE_JFLOAT_NAN = KaffeJNI_GetStaticFloatField(NULL, javaLangFloatClass, 
+							  KNI_lookupFieldC(javaLangFloatClass,
+									   "NaN", true, &einfo));
 	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.26 kaffe/kaffe/kaffevm/baseClasses.h:1.27
--- kaffe/kaffe/kaffevm/baseClasses.h:1.26	Thu Feb 14 23:31:41 2008
+++ kaffe/kaffe/kaffevm/baseClasses.h	Fri Feb 15 00:01:19 2008
@@ -50,6 +50,7 @@
 extern struct Hjava_lang_Class*	javaLangLongClass;
 extern struct Hjava_lang_Class*	javaLangFloatClass;
 extern struct Hjava_lang_Class*	javaLangDoubleClass;
+extern jfloat KAFFE_JFLOAT_NAN;
 extern jdouble KAFFE_JDOUBLE_NAN;
 
 extern struct Hjava_lang_Class *javaNioDirectByteBufferImplClass;
Index: kaffe/kaffe/kaffevm/fp.c
diff -u kaffe/kaffe/kaffevm/fp.c:1.10 kaffe/kaffe/kaffevm/fp.c:1.11
--- kaffe/kaffe/kaffevm/fp.c:1.10	Thu Feb 14 23:42:22 2008
+++ kaffe/kaffe/kaffevm/fp.c	Fri Feb 15 00:01:19 2008
@@ -121,7 +121,7 @@
 floatAdd(jfloat v1, jfloat v2)
 {
 	if (isnan(v1) || isnan(v2)) {
-		return intToFloat(FNANBITS);
+		return KAFFE_JFLOAT_NAN;
 	}
 	return (v1 + v2);
 }
@@ -145,7 +145,7 @@
 floatSubtract(jfloat v1, jfloat v2)
 {
 	if (isnan(v1) || isnan(v2)) {
-		return intToFloat(FNANBITS);
+		return KAFFE_JFLOAT_NAN;
 	}
 	return (v1 - v2);
 }
@@ -169,7 +169,7 @@
 floatMultiply(jfloat v1, jfloat v2)
 {
 	if (isnan(v1) || isnan(v2)) {
-		return intToFloat(FNANBITS);
+		return KAFFE_JFLOAT_NAN;
 	}
 	return (v1 * v2);
 }
@@ -209,13 +209,13 @@
 	v2bits = floatToInt(v2);
 
 	if (isnan(v1) || isnan(v2)) {
-		return intToFloat(FNANBITS);
+		return KAFFE_JFLOAT_NAN;
 	}
 	if (v2 != 0.0) {
 		return (v1 / v2);
 	}
 	if (v1 == 0.0) {
-		return intToFloat(FNANBITS);
+		return KAFFE_JFLOAT_NAN;
 	}
 	return intToFloat((jint)(FINFBITS | ((v1bits ^ v2bits) & FSIGNBIT)));
 }
Index: kaffe/kaffe/kaffevm/soft.c
diff -u kaffe/kaffe/kaffevm/soft.c:1.89 kaffe/kaffe/kaffevm/soft.c:1.90
--- kaffe/kaffe/kaffevm/soft.c:1.89	Thu Feb 14 23:31:41 2008
+++ kaffe/kaffe/kaffevm/soft.c	Fri Feb 15 00:01:19 2008
@@ -861,15 +861,20 @@
 		return (jdouble)v;
 }
 
+/**
+ * convert a double to float
+ *
+ * @param v a double
+ * 
+ * @return the float corresponding to the double, or Float.NaN if the double is a NaN.
+ */
 jfloat
 soft_cvtdf(jdouble v)
 {
-        if (isnan(v)) {
-		return (intToFloat(FNANBITS));
-	}
-	else {
-		return ((jfloat)v);
-	}
+        if (isnan(v))
+		return KAFFE_JFLOAT_NAN;
+	else
+		return (jfloat)v;
 }
 
 /*




More information about the kaffe mailing list