[kaffe] CVS kaffe (robilad): cleanup interpreter double division
Kaffe CVS
cvs-commits at kaffe.org
Sun Feb 17 05:19:51 PST 2008
PatchSet 7761
Date: 2008/02/17 13:17:59
Author: robilad
Branch: HEAD
Tag: (none)
Log:
cleanup interpreter double division
2008-02-17 Dalibor Topic <robilad at kaffe.org>
* kaffe/kaffevm/fp.c (doubleDivide): Follow the spec more closely.
* kaffe/kaffevm/soft.c, kaffe/kaffevm/soft.h (soft_fdivl):
Make the function available to the interpreter.
* kaffe/kaffevm/intrp/icode.h (div_double): Use soft_fdivl.
Members:
ChangeLog:1.5261->1.5262
kaffe/kaffevm/fp.c:1.14->1.15
kaffe/kaffevm/soft.c:1.90->1.91
kaffe/kaffevm/soft.h:1.20->1.21
kaffe/kaffevm/intrp/icode.h:1.28->1.29
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.5261 kaffe/ChangeLog:1.5262
--- kaffe/ChangeLog:1.5261 Sat Feb 16 17:40:10 2008
+++ kaffe/ChangeLog Sun Feb 17 13:17:59 2008
@@ -1,3 +1,12 @@
+2008-02-17 Dalibor Topic <robilad at kaffe.org>
+
+ * kaffe/kaffevm/fp.c (doubleDivide): Follow the spec more closely.
+
+ * kaffe/kaffevm/soft.c, kaffe/kaffevm/soft.h (soft_fdivl):
+ Make the function available to the interpreter.
+
+ * kaffe/kaffevm/intrp/icode.h (div_double): Use soft_fdivl.
+
2008-02-16 Dalibor Topic <robilad at kaffe.org>
* TODO: Updated.
Index: kaffe/kaffe/kaffevm/fp.c
diff -u kaffe/kaffe/kaffevm/fp.c:1.14 kaffe/kaffe/kaffevm/fp.c:1.15
--- kaffe/kaffe/kaffevm/fp.c:1.14 Fri Feb 15 01:32:36 2008
+++ kaffe/kaffe/kaffevm/fp.c Sun Feb 17 13:18:01 2008
@@ -131,19 +131,48 @@
jdouble
doubleDivide(jdouble v1, jdouble v2)
{
- if (isnan(v1) || isnan(v2)) {
+ jboolean negative_result;
+
+ if (isnan(v1) || isnan(v2))
return KAFFE_JDOUBLE_NAN;
+
+ negative_result = ((signbit(v1) == 0) && (signbit(v2) != 0))
+ || ((signbit(v1) != 0) && (signbit(v2) == 0));
+
+ if (isinf(v1) && isinf(v2))
+ return KAFFE_JDOUBLE_NAN;
+
+ if (isinf(v1) && isfinite(v2)) {
+ if (negative_result)
+ return KAFFE_JDOUBLE_NEG_INF;
+ else
+ return KAFFE_JDOUBLE_POS_INF;
}
- if (v2 != 0.0) {
- return (v1 / v2);
+
+ if (isfinite(v1) && isinf(v2)) {
+ if (negative_result)
+ return -0.0;
+ else
+ return 0.0;
}
+
if (v1 == 0.0) {
- return KAFFE_JDOUBLE_NAN;
+ if (v2 == 0.0)
+ return KAFFE_JDOUBLE_NAN;
+ else if (negative_result)
+ return -0.0;
+ else
+ return 0.0;
+ }
+
+ if (v1 != 0.0 && v2 == 0.0) {
+ if (negative_result)
+ return KAFFE_JDOUBLE_NEG_INF;
+ else
+ return KAFFE_JDOUBLE_POS_INF;
}
- if (signbit(v1) ^ signbit(v2))
- return KAFFE_JDOUBLE_NEG_INF;
- else
- return KAFFE_JDOUBLE_POS_INF;
+
+ return (v1 / v2);
}
/*
Index: kaffe/kaffe/kaffevm/soft.c
diff -u kaffe/kaffe/kaffevm/soft.c:1.90 kaffe/kaffe/kaffevm/soft.c:1.91
--- kaffe/kaffe/kaffevm/soft.c:1.90 Fri Feb 15 00:01:19 2008
+++ kaffe/kaffe/kaffevm/soft.c Sun Feb 17 13:18:02 2008
@@ -686,6 +686,12 @@
return soft_dcmpl(v1, v2);
}
+jdouble
+soft_fdivl(jdouble v1, jdouble v2)
+{
+ return doubleDivide(v1, v2);
+}
+
#if defined(TRANSLATOR)
jlong
soft_lmul(jlong v1, jlong v2)
@@ -746,12 +752,6 @@
soft_fdiv(jfloat v1, jfloat v2)
{
return floatDivide(v1, v2);
-}
-
-jdouble
-soft_fdivl(jdouble v1, jdouble v2)
-{
- return doubleDivide(v1, v2);
}
jfloat
Index: kaffe/kaffe/kaffevm/soft.h
diff -u kaffe/kaffe/kaffevm/soft.h:1.20 kaffe/kaffe/kaffevm/soft.h:1.21
--- kaffe/kaffe/kaffevm/soft.h:1.20 Sun Mar 5 14:35:26 2006
+++ kaffe/kaffe/kaffevm/soft.h Sun Feb 17 13:18:02 2008
@@ -59,6 +59,8 @@
void* soft_multianewarray(struct Hjava_lang_Class*, jint, struct _slots*);
#endif
+jdouble soft_fdivl(jdouble, jdouble);
+
#if defined(TRANSLATOR)
jlong soft_lmul(jlong, jlong);
jlong soft_ldiv(jlong, jlong);
@@ -70,7 +72,6 @@
jfloat soft_fmul(jfloat, jfloat);
jdouble soft_fmull(jdouble, jdouble);
jfloat soft_fdiv(jfloat, jfloat);
-jdouble soft_fdivl(jdouble, jdouble);
jfloat soft_frem(jfloat, jfloat);
jdouble soft_freml(jdouble, jdouble);
jlong soft_lshll(jlong, jint);
Index: kaffe/kaffe/kaffevm/intrp/icode.h
diff -u kaffe/kaffe/kaffevm/intrp/icode.h:1.28 kaffe/kaffe/kaffevm/intrp/icode.h:1.29
--- kaffe/kaffe/kaffevm/intrp/icode.h:1.28 Mon Feb 11 23:26:09 2008
+++ kaffe/kaffe/kaffevm/intrp/icode.h Sun Feb 17 13:18:03 2008
@@ -266,7 +266,7 @@
#define mul_float(t, f1, f2) (t)[0].v.tfloat = (f1)[0].v.tfloat * (f2)[0].v.tfloat
#define mul_double(t, f1, f2) (t)[0].v.tdouble = (f1)[0].v.tdouble * (f2)[0].v.tdouble
#define div_float(t, f1, f2) (t)[0].v.tfloat = (f1)[0].v.tfloat / (f2)[0].v.tfloat
-#define div_double(t, f1, f2) (t)[0].v.tdouble = (f1)[0].v.tdouble / (f2)[0].v.tdouble
+#define div_double(t, f1, f2) (t)[0].v.tdouble = soft_fdivl((f1)[0].v.tdouble , (f2)[0].v.tdouble)
#define rem_float(t, f1, f2) (t)[0].v.tfloat = javaRemainderf((f1)[0].v.tfloat, (f2)[0].v.tfloat)
#define rem_double(t, f1, f2) (t)[0].v.tdouble = javaRemainder((f1)[0].v.tdouble, (f2)[0].v.tdouble)
#define neg_float(t, f) (t)[0].v.tfloat = -(f)[0].v.tfloat
More information about the kaffe
mailing list