javaop.h (WORD_TO_INT): Mask lower 32 bits of a jword before sign extending.
authorAndrew Haley <aph@cygnus.com>
Tue, 29 Aug 2000 16:12:59 +0000 (16:12 +0000)
committerAlexandre Petit-Bianco <apbianco@gcc.gnu.org>
Tue, 29 Aug 2000 16:12:59 +0000 (09:12 -0700)
2000-08-22  Andrew Haley  <aph@cygnus.com>

* javaop.h (WORD_TO_INT): Mask lower 32 bits of a jword before
sign extending. Fixes gcj/321.
* jcf-parse.c (get_constant): Mask lower 32 bits of a jint before
combining to make a jlong. Fixes gcj/321.

(This fixes gcj/321:
 http://sources.redhat.com/ml/java-prs/2000-q3/msg00146.html
 http://gcc.gnu.org/ml/gcc-patches/2000-08/msg00897.html)

From-SVN: r36037

gcc/java/ChangeLog
gcc/java/javaop.h
gcc/java/jcf-parse.c

index fa146cd08ab0cb1084b9095740ea0c4729cdb29b..3e5d963ed42d17aef7ba4ffed0b35108fcb9f4d5 100644 (file)
@@ -7,6 +7,13 @@
        * lang.c (lang_decode_option): Use ARRAY_SIZE.
        * parse.y (BINOP_LOOKUP): Likewise.
 
+2000-08-22  Andrew Haley  <aph@cygnus.com>
+
+       * javaop.h (WORD_TO_INT): Mask lower 32 bits of a jword before
+       sign extending. Fixes gcj/321.
+       * jcf-parse.c (get_constant): Mask lower 32 bits of a jint before
+       combining to make a jlong. Fixes gcj/321.
+
 2000-08-21  Nix  <nix@esperi.demon.co.uk>
         
        * lang-specs.h: Do not process -o or run the assembler if
index d8418f71a2af67a6ed2e939ecf97935c056ba074..6ce33ff67a95c349841aed3e76aa5e57442772e3 100644 (file)
@@ -109,13 +109,16 @@ WORD_TO_FLOAT(jword w)
   return wu.f;
 } 
 
-/* Sign extend w. */
+/* Sign extend w.  If the host on which this cross-compiler runs uses
+   a 64-bit type for jword the appropriate sign extension is
+   performed; if it's a 32-bit type the arithmetic does nothing but is
+   harmless.  */
 static inline jint
 WORD_TO_INT(jword w)
 {
-  jint n = w;
+  jint n = w & 0xffffffff; /* Mask lower 32 bits.  */
   n ^= (jint)1 << 31;
-  n -= (jint)1 << 31;
+  n -= (jint)1 << 31; /* Sign extend lower 32 bits to upper.  */
   return n;
 } 
 
index 1962f80ecc2b62d9d5ccb4d7faeaa0a135567fc4..4b00c432f47b0dc7c9154df8f59b413b6e7010ff 100644 (file)
@@ -270,8 +270,8 @@ get_constant (jcf, index)
        jint num = JPOOL_INT (jcf, index);
        HOST_WIDE_INT lo, hi;
        lshift_double (num, 0, 32, 64, &lo, &hi, 0);
-       num = JPOOL_INT (jcf, index+1);
-       add_double (lo, hi, (uint32)num, 0, &lo, &hi);
+       num = JPOOL_INT (jcf, index+1) & 0xffffffff;
+       add_double (lo, hi, num, 0, &lo, &hi);
        value = build_int_2 (lo, hi);
        TREE_TYPE (value) = long_type_node;
        force_fit_type (value, 0);