PATCH: Mauve powerpc test failures
Andrew Haley
aph@cambridge.redhat.com
Fri Apr 19 10:16:00 GMT 2002
The logic that handles longs in Java .class files is broken -- it
assumes that a HOST_WIDE_INT is 32 bits and doesn't handle sign
extension properly.
This patch fixes 57 test failures, no regressions.
OK for branch and trunk?
Andrew.
2002-04-19 Andrew Haley <aph@redhat.com>
* jcf-write.c (push_long_const): lo, hi: New variables.
Use rshift_double to extract the high part of a 64-bit long.
Use WORD_TO_INT to extract the low part.
* jcf-parse.c (get_constant): CONSTANT_Integer: Use an unsigned
HOST_WIDE_INT for num. Use JPOOL_UINT to get it.
CONSTANT_Double: Use JPOOL_UINT to get both halve of a double.
Index: jcf-parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-parse.c,v
retrieving revision 1.104.2.5
diff -c -2 -p -r1.104.2.5 jcf-parse.c
*** jcf-parse.c 29 Mar 2002 00:14:00 -0000 1.104.2.5
--- jcf-parse.c 19 Apr 2002 16:35:30 -0000
*************** get_constant (jcf, index)
*** 293,300 ****
case CONSTANT_Long:
{
! 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) & 0xffffffff;
add_double (lo, hi, num, 0, &lo, &hi);
value = build_int_2 (lo, hi);
--- 293,300 ----
case CONSTANT_Long:
{
! unsigned HOST_WIDE_INT num = JPOOL_UINT (jcf, index);
HOST_WIDE_INT lo, hi;
lshift_double (num, 0, 32, 64, &lo, &hi, 0);
! num = JPOOL_UINT (jcf, index+1);
add_double (lo, hi, num, 0, &lo, &hi);
value = build_int_2 (lo, hi);
*************** get_constant (jcf, index)
*** 323,329 ****
REAL_VALUE_TYPE d;
HOST_WIDE_INT lo, hi;
! num[0] = JPOOL_INT (jcf, index);
lshift_double (num[0], 0, 32, 64, &lo, &hi, 0);
! num[0] = JPOOL_INT (jcf, index+1);
add_double (lo, hi, num[0], 0, &lo, &hi);
--- 323,329 ----
REAL_VALUE_TYPE d;
HOST_WIDE_INT lo, hi;
! num[0] = JPOOL_UINT (jcf, index);
lshift_double (num[0], 0, 32, 64, &lo, &hi, 0);
! num[0] = JPOOL_UINT (jcf, index+1);
add_double (lo, hi, num[0], 0, &lo, &hi);
Index: jcf-write.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.99.2.1
diff -c -2 -p -r1.99.2.1 jcf-write.c
*** jcf-write.c 12 Mar 2002 10:33:57 -0000 1.99.2.1
--- jcf-write.c 19 Apr 2002 16:35:30 -0000
*************** push_long_const (lo, hi, state)
*** 853,865 ****
struct jcf_partial *state;
{
! if (hi == 0 && lo >= 0 && lo <= 1)
{
RESERVE(1);
! OP1(OPCODE_lconst_0 + lo);
}
! else if ((hi == 0 && (jword)(lo & 0xFFFFFFFF) < 32768)
! || (hi == -1 && (lo & 0xFFFFFFFF) >= (jword)-32768))
{
! push_int_const (lo, state);
RESERVE (1);
OP1 (OPCODE_i2l);
--- 853,870 ----
struct jcf_partial *state;
{
! HOST_WIDE_INT highpart, dummy;
! jint lowpart = WORD_TO_INT (lo);
!
! rshift_double (lo, hi, 32, 64, &highpart, &dummy, 1);
!
! if (highpart == 0 && (lowpart == 0 || lowpart == 1))
{
RESERVE(1);
! OP1(OPCODE_lconst_0 + lowpart);
}
! else if ((highpart == 0 && lowpart > 0 && lowpart < 32768)
! || (highpart == -1 && lowpart < 0 && lowpart >= -32768))
{
! push_int_const (lowpart, state);
RESERVE (1);
OP1 (OPCODE_i2l);
More information about the Gcc-patches
mailing list