8162477: [JVMCI] assert(wf.check_method_context(ctxk, m)) failed: proper context
Reviewed-by: kvn
--- a/hotspot/src/share/vm/code/dependencies.cpp Mon Aug 01 22:34:23 2016 -0700
+++ b/hotspot/src/share/vm/code/dependencies.cpp Tue Aug 02 17:12:16 2016 -0700
@@ -1082,12 +1082,11 @@
if (!(m->is_public() || m->is_protected()))
// The override story is complex when packages get involved.
return true; // Must punt the assertion to true.
- Klass* k = ctxk;
- Method* lm = k->lookup_method(m->name(), m->signature());
- if (lm == NULL && k->is_instance_klass()) {
+ Method* lm = ctxk->lookup_method(m->name(), m->signature());
+ if (lm == NULL && ctxk->is_instance_klass()) {
// It might be an interface method
- lm = InstanceKlass::cast(k)->lookup_method_in_ordered_interfaces(m->name(),
- m->signature());
+ lm = InstanceKlass::cast(ctxk)->lookup_method_in_ordered_interfaces(m->name(),
+ m->signature());
}
if (lm == m)
// Method m is inherited into ctxk.
@@ -1101,11 +1100,19 @@
// Static methods don't override non-static so punt
return true;
}
- if ( !Dependencies::is_concrete_method(lm, k)
- && !Dependencies::is_concrete_method(m, ctxk)
- && lm->method_holder()->is_subtype_of(m->method_holder()))
- // Method m is overridden by lm, but both are non-concrete.
- return true;
+ if (!Dependencies::is_concrete_method(lm, ctxk) &&
+ !Dependencies::is_concrete_method(m, ctxk)) {
+ // They are both non-concrete
+ if (lm->method_holder()->is_subtype_of(m->method_holder())) {
+ // Method m is overridden by lm, but both are non-concrete.
+ return true;
+ }
+ if (lm->method_holder()->is_interface() && m->method_holder()->is_interface() &&
+ ctxk->is_subtype_of(m->method_holder()) && ctxk->is_subtype_of(lm->method_holder())) {
+ // Interface method defined in multiple super interfaces
+ return true;
+ }
+ }
}
ResourceMark rm;
tty->print_cr("Dependency method not found in the associated context:");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/jvmci/common/testcases/DuplicateSimpleSingleImplementerInterface.java Tue Aug 02 17:12:16 2016 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package compiler.jvmci.common.testcases;
+
+public interface DuplicateSimpleSingleImplementerInterface {
+ void interfaceMethod();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/jvmci/common/testcases/MultipleSuperImplementers.java Tue Aug 02 17:12:16 2016 -0700
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package compiler.jvmci.common.testcases;
+
+public abstract class MultipleSuperImplementers implements DuplicateSimpleSingleImplementerInterface, SimpleSingleImplementerInterface {
+ public void finalize() {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/jvmci/common/testcases/SimpleSingleImplementerInterface.java Tue Aug 02 17:12:16 2016 -0700
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package compiler.jvmci.common.testcases;
+
+public interface SimpleSingleImplementerInterface {
+ void interfaceMethod();
+}
--- a/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java Mon Aug 01 22:34:23 2016 -0700
+++ b/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java Tue Aug 02 17:12:16 2016 -0700
@@ -32,6 +32,8 @@
* java.base/jdk.internal.org.objectweb.asm.tree
* jdk.vm.ci/jdk.vm.ci.hotspot
* jdk.vm.ci/jdk.vm.ci.code
+ * jdk.vm.ci/jdk.vm.ci.meta
+ * jdk.vm.ci/jdk.vm.ci.runtime
* @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
* @build compiler.jvmci.compilerToVM.FindUniqueConcreteMethodTest
* @run main/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
@@ -41,7 +43,10 @@
package compiler.jvmci.compilerToVM;
import compiler.jvmci.common.CTVMUtilities;
+import compiler.jvmci.common.testcases.DuplicateSimpleSingleImplementerInterface;
+import compiler.jvmci.common.testcases.SimpleSingleImplementerInterface;
import compiler.jvmci.common.testcases.MultipleImplementer1;
+import compiler.jvmci.common.testcases.MultipleSuperImplementers;
import compiler.jvmci.common.testcases.SingleImplementer;
import compiler.jvmci.common.testcases.SingleImplementerInterface;
import compiler.jvmci.common.testcases.SingleSubclass;
@@ -96,6 +101,11 @@
// static method
result.add(new TestCase(false, SingleSubclass.class,
SingleSubclass.class, "staticMethod"));
+ // interface method
+ result.add(new TestCase(false, MultipleSuperImplementers.class,
+ DuplicateSimpleSingleImplementerInterface.class, "interfaceMethod", false));
+ result.add(new TestCase(false, MultipleSuperImplementers.class,
+ SimpleSingleImplementerInterface.class, "interfaceMethod", false));
return result;
}
@@ -103,7 +113,7 @@
System.out.println(tcase);
Method method = tcase.holder.getDeclaredMethod(tcase.methodName);
HotSpotResolvedJavaMethod testMethod = CTVMUtilities
- .getResolvedMethod(tcase.receiver, method);
+ .getResolvedMethod(tcase.methodFromReceiver ? tcase.receiver : tcase.holder, method);
HotSpotResolvedObjectType resolvedType = CompilerToVMHelper
.lookupType(Utils.toJVMTypeSignature(tcase.receiver), getClass(),
/* resolve = */ true);
@@ -118,20 +128,25 @@
public final Class<?> holder;
public final String methodName;
public final boolean isPositive;
+ public final boolean methodFromReceiver;
public TestCase(boolean isPositive, Class<?> clazz, Class<?> holder,
- String methodName) {
+ String methodName, boolean methodFromReceiver) {
this.receiver = clazz;
this.methodName = methodName;
this.isPositive = isPositive;
this.holder = holder;
+ this.methodFromReceiver = methodFromReceiver;
+ }
+
+ public TestCase(boolean isPositive, Class<?> clazz, Class<?> holder, String methodName) {
+ this(isPositive, clazz, holder, methodName, true);
}
@Override
public String toString() {
- return String.format("CASE: receiver=%s, holder=%s, method=%s,"
- + " isPositive=%s", receiver.getName(),
- holder.getName(), methodName, isPositive);
+ return String.format("CASE: receiver=%s, holder=%s, method=%s, isPositive=%s, methodFromReceiver=%s",
+ receiver.getName(), holder.getName(), methodName, isPositive, methodFromReceiver);
}
}
}