This is the mail archive of the
java-prs@sourceware.cygnus.com
mailing list for the Java project.
gcj/82: code generation for jvm IRETURN fails on boolean/byte/short methods if INT_TYPE_SIZE < 32
- To: java-gnats at sourceware dot cygnus dot com
- Subject: gcj/82: code generation for jvm IRETURN fails on boolean/byte/short methods if INT_TYPE_SIZE < 32
- From: Pekka dot Nikander at hut dot fi
- Date: 3 Nov 1999 10:11:18 -0000
- Reply-To: Pekka dot Nikander at hut dot fi
- Resent-Cc: java-prs at sourceware dot cygnus dot com, green at cygnus dot com
- Resent-Reply-To: java-gnats@sourceware.cygnus.com, Pekka.Nikander@hut.fi
>Number: 82
>Category: gcj
>Synopsis: code generation for jvm IRETURN fails on boolean/byte/short methods if INT_TYPE_SIZE < 32
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: apbianco
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Nov 03 02:16:00 PST 1999
>Closed-Date:
>Last-Modified:
>Originator: Pekka Nikander
>Release: gcc-2.95.1
>Organization:
>Environment:
FreeBSD 3.2-STABLE cross compiling for Hitachi/H3 h8300
>Description:
If the target machine native integer size,
INT_TYPE_SIZE, is smaller than Java integer size (32 bits),
when compiling class files generated by Sun javac,
code generation fails for methods that return an
boolean, byte or short value (maybe also char?).
The reason for this is that the compiler declares
the return type of the method to be node_integer_type,
which has INT_TYPE_SIZE bits, and the jvm return instruction,
IRETURN, returns an 32 bit integer. expand_java_return
does not handle this situation.
>How-To-Repeat:
Create a cross compiler for a suitable target (e.g. h8300)
and compile the following source into a class, and then
try to compile from the class file.
class Foo {
public boolean equals(Object x) { return x == this; }
}
% javac Foo.java
% gcj Foo.class
>Fix:
Apply the following patch:
$ diff -u gcc*orig/gcc/java/expr.c gcc*1/gcc/java/expr.c
--- gcc-2.95.1.orig/gcc/java/expr.c Sat Jun 5 11:18:19 1999
+++ gcc-2.95.1/gcc/java/expr.c Wed Nov 3 12:01:14 1999
@@ -982,6 +982,11 @@
tree retval = pop_value (type);
tree res = DECL_RESULT (current_function_decl);
retval = build (MODIFY_EXPR, TREE_TYPE (res), res, retval);
+#if INT_TYPE_SIZE < 32
+ if (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (res)))
+ < GET_MODE_SIZE (TYPE_MODE (type)))
+ retval = build1(NOP_EXPR, TREE_TYPE(res), retval);
+#endif
TREE_SIDE_EFFECTS (retval) = 1;
expand_return (retval);
}
>Release-Note:
>Audit-Trail:
>Unformatted: