--- a/hotspot/src/share/vm/adlc/formssel.cpp Tue Jul 21 16:56:06 2009 -0700
+++ b/hotspot/src/share/vm/adlc/formssel.cpp Tue Jul 21 21:33:44 2009 -0700
@@ -420,6 +420,13 @@
return _matrule->is_ideal_load();
}
+// Return 'true' if this instruction matches an ideal 'LoadKlass' node
+bool InstructForm::skip_antidep_check() const {
+ if( _matrule == NULL ) return false;
+
+ return _matrule->skip_antidep_check();
+}
+
// Return 'true' if this instruction matches an ideal 'Load?' node
Form::DataType InstructForm::is_ideal_store() const {
if( _matrule == NULL ) return Form::none;
@@ -567,6 +574,8 @@
// loads from memory, so must check for anti-dependence
bool InstructForm::needs_anti_dependence_check(FormDict &globals) const {
+ if ( skip_antidep_check() ) return false;
+
// Machine independent loads must be checked for anti-dependences
if( is_ideal_load() != Form::none ) return true;
@@ -3957,6 +3966,28 @@
}
+bool MatchRule::skip_antidep_check() const {
+ // Some loads operate on what is effectively immutable memory so we
+ // should skip the anti dep computations. For some of these nodes
+ // the rewritable field keeps the anti dep logic from triggering but
+ // for certain kinds of LoadKlass it does not since they are
+ // actually reading memory which could be rewritten by the runtime,
+ // though never by generated code. This disables it uniformly for
+ // the nodes that behave like this: LoadKlass, LoadNKlass and
+ // LoadRange.
+ if ( _opType && (strcmp(_opType,"Set") == 0) && _rChild ) {
+ const char *opType = _rChild->_opType;
+ if (strcmp("LoadKlass", opType) == 0 ||
+ strcmp("LoadNKlass", opType) == 0 ||
+ strcmp("LoadRange", opType) == 0) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
Form::DataType MatchRule::is_ideal_store() const {
Form::DataType ideal_store = Form::none;
--- a/hotspot/src/share/vm/adlc/formssel.hpp Tue Jul 21 16:56:06 2009 -0700
+++ b/hotspot/src/share/vm/adlc/formssel.hpp Tue Jul 21 21:33:44 2009 -0700
@@ -158,6 +158,9 @@
virtual Form::CallType is_ideal_call() const; // matches ideal 'Call'
virtual Form::DataType is_ideal_load() const; // node matches ideal 'LoadXNode'
+ // Should antidep checks be disabled for this Instruct
+ // See definition of MatchRule::skip_antidep_check
+ bool skip_antidep_check() const;
virtual Form::DataType is_ideal_store() const;// node matches ideal 'StoreXNode'
bool is_ideal_mem() const { return is_ideal_load() != Form::none || is_ideal_store() != Form::none; }
virtual uint two_address(FormDict &globals); // output reg must match input reg
@@ -1003,6 +1006,9 @@
bool is_ideal_loopEnd() const; // node matches ideal 'LoopEnd'
bool is_ideal_bool() const; // node matches ideal 'Bool'
Form::DataType is_ideal_load() const;// node matches ideal 'LoadXNode'
+ // Should antidep checks be disabled for this rule
+ // See definition of MatchRule::skip_antidep_check
+ bool skip_antidep_check() const;
Form::DataType is_ideal_store() const;// node matches ideal 'StoreXNode'
// Check if 'mRule2' is a cisc-spill variant of this MatchRule
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6857159/Test6857159.java Tue Jul 21 21:33:44 2009 -0700
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 6857159
+ * @summary local schedule failed with checkcast of Thread.currentThread()
+ *
+ * @run shell Test6857159.sh
+ */
+
+public class Test6857159 extends Thread {
+ static class ct0 extends Test6857159 {
+ public void message() {
+ // System.out.println("message");
+ }
+
+ public void run() {
+ message();
+ ct0 ct = (ct0) Thread.currentThread();
+ ct.message();
+ }
+ }
+ static class ct1 extends ct0 {
+ public void message() {
+ // System.out.println("message");
+ }
+ }
+ static class ct2 extends ct0 {
+ public void message() {
+ // System.out.println("message");
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ for (int i = 0; i < 100000; i++) {
+ Thread t = null;
+ switch (i % 3) {
+ case 0: t = new ct0(); break;
+ case 1: t = new ct1(); break;
+ case 2: t = new ct2(); break;
+ }
+ t.start();
+ t.join();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6857159/Test6857159.sh Tue Jul 21 21:33:44 2009 -0700
@@ -0,0 +1,65 @@
+#!/bin/sh
+#
+# Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+#
+
+if [ "${TESTSRC}" = "" ]
+then
+ echo "TESTSRC not set. Test cannot execute. Failed."
+ exit 1
+fi
+echo "TESTSRC=${TESTSRC}"
+if [ "${TESTJAVA}" = "" ]
+then
+ echo "TESTJAVA not set. Test cannot execute. Failed."
+ exit 1
+fi
+echo "TESTJAVA=${TESTJAVA}"
+if [ "${TESTCLASSES}" = "" ]
+then
+ echo "TESTCLASSES not set. Test cannot execute. Failed."
+ exit 1
+fi
+echo "TESTCLASSES=${TESTCLASSES}"
+echo "CLASSPATH=${CLASSPATH}"
+
+set -x
+
+cp ${TESTSRC}/Test6857159.java .
+cp ${TESTSRC}/Test6857159.sh .
+
+${TESTJAVA}/bin/javac -d . Test6857159.java
+
+${TESTJAVA}/bin/java ${TESTVMOPTS} -Xbatch -XX:+PrintCompilation -XX:CompileOnly=Test6857159\$ct.run Test6857159 > test.out 2>&1
+
+grep "COMPILE SKIPPED" test.out
+
+result=$?
+if [ $result -eq 1 ]
+then
+ echo "Passed"
+ exit 0
+else
+ echo "Failed"
+ exit 1
+fi