This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
PATCH: Canonicalize NaNs in bytecode files
- From: Andrew Haley <aph at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Mon, 16 Aug 2004 12:54:02 +0100
- Subject: PATCH: Canonicalize NaNs in bytecode files
We've been writing target NaNs into bytecode files...
Committed.
Andrew.
2004-08-16 Andrew Haley <aph@redhat.com>
* jcf-write.c (find_constant_index): Canonicalize NaNs when
generating bytecode.
Index: jcf-write.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.154
diff -c -2 -p -r1.154 jcf-write.c
*** jcf-write.c 24 Jul 2004 00:03:28 -0000 1.154
--- jcf-write.c 16 Aug 2004 11:51:53 -0000
*************** find_constant_index (tree value, struct
*** 799,802 ****
--- 799,815 ----
long words[2];
+ /* IEEE NaN can have many values, but the Java VM spec defines a
+ canonical NaN. */
+ if (flag_emit_class_files
+ && REAL_VALUE_ISNAN (TREE_REAL_CST (value)))
+ {
+ if (TYPE_PRECISION (TREE_TYPE (value)) == 32)
+ return find_constant1 (&state->cpool, CONSTANT_Float,
+ 0x7fc00000);
+ else
+ return find_constant2 (&state->cpool, CONSTANT_Double,
+ 0x7ff80000, 0x00000000);
+ }
+
real_to_target (words, &TREE_REAL_CST (value),
TYPE_MODE (TREE_TYPE (value)));