[PATCH] Fix err10.java test case failure on 64-bit hosts

Ulrich Weigand Ulrich.Weigand@de.ibm.com
Tue Oct 8 09:45:00 GMT 2002


Hello,

the Java interpreter implements unsigned 32-bit right shifts incorrectly
on 64-bit hosts, causing the err10.java test case to fail.

The reason is that it assigns a jint variable to an unsigned long,
and then shifts that unsigned long temporary.  However, on platforms
where unsigned long is 64-bit, this doesn't work as a signed jint
will be sign-extended to 64-bit during this assigment, and thus the
shift will shift in sign bits instead of zero bits.

The following patch fixes the err10 case on s390x-ibm-linux and
introduces no further regressions.  (Now the set of failures on
s390x-ibm-linux is identical to that on s390-ibm-linux.)

OK to apply?

ChangeLog:

      * interpret.cc (_Jv_InterpMethod::run): Use UINT32 instead of
      unsigned long temporary to implement insn_iushr shifts.

Index: libjava/interpret.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/interpret.cc,v
retrieving revision 1.34
diff -c -p -r1.34 interpret.cc
*** libjava/interpret.cc      29 Aug 2002 17:53:27 -0000    1.34
--- libjava/interpret.cc      8 Oct 2002 14:43:41 -0000
*************** _Jv_InterpMethod::run (void *retp, ffi_r
*** 1883,1889 ****
      insn_iushr:
        {
      jint shift = (POPI() & 0x1f);
!     unsigned long value = POPI();
      PUSHI ((jint) (value >> shift));
        }
        NEXT_INSN;
--- 1883,1889 ----
      insn_iushr:
        {
      jint shift = (POPI() & 0x1f);
!     UINT32 value = (UINT32) POPI();
      PUSHI ((jint) (value >> shift));
        }
        NEXT_INSN;


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com



More information about the Java-patches mailing list