JDK-6795362 : 32bit server compiler leads to wrong results on solaris-x86
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: hs13
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris
  • CPU: x86
  • Submitted: 2009-01-19
  • Updated: 2011-03-08
  • Resolved: 2011-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u14Fixed 7Fixed hs14Fixed
Description
The following test case produces wrong results (var_bad) when
running jvm with 32bit server compiler on solaris-x86.

> JDK7b43/bin/java -server -Xcomp -XX:CompileOnly=TesterSmall_Class_0 TesterSmall
var_bad = -602947331
var_ok  = 0

============ TesterSmall.java ==============
class TesterSmall_Class_0 {
    static long var_bad = -1L;

    public TesterSmall_Class_0()
    {
      var_bad >>= 65;
      var_bad /= 65;
    }
}

public class TesterSmall {
    public static void main(String[] args)
    {
        TesterSmall_Class_0 t =  new TesterSmall_Class_0();

        long var_ok = -1L;
        var_ok >>= 65;
        var_ok /= 65;

        System.out.println("var_bad = " + TesterSmall_Class_0.var_bad);
        System.out.println("var_ok  = " + var_ok);
    }
}

=======================================

The test works fine on other platforms with bot 32bit and 64bit jvms.

Comments
EVALUATION The fix has been verified as part of hs15-b02 pit.
24-02-2009

EVALUATION http://hg.openjdk.java.net/jdk7/hotspot-comp/hotspot/rev/7628781568e1
03-02-2009

SUGGESTED FIX diff -Nupr 6795362.3b5ac9e7e6ea/src/share/vm/opto/mulnode.cpp 6795362/src/share/vm/opto/mulnode.cpp --- 6795362.3b5ac9e7e6ea/src/share/vm/opto/mulnode.cpp 2009-01-30 11:24:39.694445872 +0100 +++ 6795362/src/share/vm/opto/mulnode.cpp 2009-01-30 11:24:39.695265016 +0100 @@ -581,6 +581,7 @@ Node *AndLNode::Identity( PhaseTransform const TypeInt *t12 = phase->type( usr->in(2) )->isa_int(); if( t12 && t12->is_con() ) { int shift_con = t12->get_con(); + shift_con &= (BitsPerJavaInteger * 2) - 1; // semantics of Java shifts jlong mask = max_julong >> shift_con; if( (mask&con) == mask ) // If AND is useless, skip it return usr;
30-01-2009

EVALUATION As Tom suspected the bug is in the Op_URShiftL special case in AndLNode::Identity. The constant shift value gets not masked before calculations are done. Adding the line: shift &= (BitsPerJavaInteger * 2) - 1; // semantics of Java shifts fixes the bug. It seems the same bug is in AndINode::Identity, but I couldn't create a testcase yet. If I find one I will open a new CR.
30-01-2009

EVALUATION When the: // Masking off sign bits? Dont make them! if( rop == Op_RShiftL ) { special case in AndLNode::Ideal is commented, the generated code is correct.
29-01-2009

EVALUATION Obviously, because 6732154 fixes a similar but different problem. Still investigating.
29-01-2009

EVALUATION 6732154 has been fixed in hs14-b04, but the test still fails with latest hs14-b10 as well as hs14-b04: /java/re/jdk/7/promoted/all/b44/binaries/solaris-i586/bin/java -server -Xcomp -XX:CompileOnly=TesterSmall_Class_0 -showversion TesterSmall java version "1.7.0-ea" Java(TM) SE Runtime Environment (build 1.7.0-ea-b44) Java HotSpot(TM) Server VM (build 14.0-b10, compiled mode) var_bad = -602947331 var_ok = 0 /java/re/jdk/7/promoted/all/b35/binaries/solaris-i586/bin/java -server -Xcomp -XX:CompileOnly=TesterSmall_Class_0 -showversion TesterSmall java version "1.7.0-ea" Java(TM) SE Runtime Environment (build 1.7.0-ea-b35) Java HotSpot(TM) Server VM (build 14.0-b04, compiled mode) var_bad = -602947331 var_ok = 0
29-01-2009

EVALUATION The bug was introduced with 6603011 and 6732154 already fixed a problem in the new code. I suspect this bug is similar to 6732154.
29-01-2009