Merge
authorrasbold
Tue, 29 Apr 2008 06:52:16 -0700
changeset 377 ec822f294fbc
parent 375 6969999e4e7b (current diff)
parent 376 7209afaaef5d (diff)
child 378 39fb2dc78042
Merge
--- a/hotspot/src/share/vm/opto/parse2.cpp	Mon Apr 28 08:08:12 2008 -0700
+++ b/hotspot/src/share/vm/opto/parse2.cpp	Tue Apr 29 06:52:16 2008 -0700
@@ -105,10 +105,19 @@
   if (GenerateRangeChecks && need_range_check) {
     // Range is constant in array-oop, so we can use the original state of mem
     Node* len = load_array_length(ary);
-    // Test length vs index (standard trick using unsigned compare)
-    Node* chk = _gvn.transform( new (C, 3) CmpUNode(idx, len) );
-    BoolTest::mask btest = BoolTest::lt;
-    Node* tst = _gvn.transform( new (C, 2) BoolNode(chk, btest) );
+    Node* tst;
+    if (sizetype->_hi <= 0) {
+      // If the greatest array bound is negative, we can conclude that we're
+      // compiling unreachable code, but the unsigned compare trick used below
+      // only works with non-negative lengths.  Instead, hack "tst" to be zero so
+      // the uncommon_trap path will always be taken.
+      tst = _gvn.intcon(0);
+    } else {
+      // Test length vs index (standard trick using unsigned compare)
+      Node* chk = _gvn.transform( new (C, 3) CmpUNode(idx, len) );
+      BoolTest::mask btest = BoolTest::lt;
+      tst = _gvn.transform( new (C, 2) BoolNode(chk, btest) );
+    }
     // Branch to failure if out of bounds
     { BuildCutout unless(this, tst, PROB_MAX);
       if (C->allow_range_check_smearing()) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6646019/Test.java	Tue Apr 29 06:52:16 2008 -0700
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
+ * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+/*
+ * @test
+ * @bug 6646019
+ * @summary array subscript expressions become top() with -d64
+ * @run main/othervm -Xcomp -XX:CompileOnly=Test.test Test
+*/
+
+
+public class Test  {
+  final static int i = 2076285318;
+  long l = 2;
+  short s;
+
+  public static void main(String[] args) {
+    Test t = new Test();
+    try { t.test(); }
+    catch (Throwable e) {
+      if (t.l != 5) {
+        System.out.println("Fails: " + t.l + " != 5");
+      }
+    }
+  }
+
+  private void test() {
+    l = 5;
+    l = (new short[(byte)-2])[(byte)(l = i)];
+  }
+}