提交 45ace52a 编写于 作者: T thartmann

8050079: crash while compiling java.lang.ref.Finalizer::runFinalizer

Summary: Ignore non-instance Klasses in the subclass hierarchy.
Reviewed-by: kvn, iignatyev, jrose
上级 4bf19cf4
...@@ -879,6 +879,8 @@ class ClassHierarchyWalker { ...@@ -879,6 +879,8 @@ class ClassHierarchyWalker {
bool is_witness(Klass* k) { bool is_witness(Klass* k) {
if (doing_subtype_search()) { if (doing_subtype_search()) {
return Dependencies::is_concrete_klass(k); return Dependencies::is_concrete_klass(k);
} else if (!k->oop_is_instance()) {
return false; // no methods to find in an array type
} else { } else {
Method* m = InstanceKlass::cast(k)->find_method(_name, _signature); Method* m = InstanceKlass::cast(k)->find_method(_name, _signature);
if (m == NULL || !Dependencies::is_concrete_method(m)) return false; if (m == NULL || !Dependencies::is_concrete_method(m)) return false;
...@@ -1085,7 +1087,7 @@ Klass* ClassHierarchyWalker::find_witness_anywhere(Klass* context_type, ...@@ -1085,7 +1087,7 @@ Klass* ClassHierarchyWalker::find_witness_anywhere(Klass* context_type,
Klass* chain; // scratch variable Klass* chain; // scratch variable
#define ADD_SUBCLASS_CHAIN(k) { \ #define ADD_SUBCLASS_CHAIN(k) { \
assert(chaini < CHAINMAX, "oob"); \ assert(chaini < CHAINMAX, "oob"); \
chain = InstanceKlass::cast(k)->subklass(); \ chain = k->subklass(); \
if (chain != NULL) chains[chaini++] = chain; } if (chain != NULL) chains[chaini++] = chain; }
// Look for non-abstract subclasses. // Look for non-abstract subclasses.
...@@ -1096,6 +1098,7 @@ Klass* ClassHierarchyWalker::find_witness_anywhere(Klass* context_type, ...@@ -1096,6 +1098,7 @@ Klass* ClassHierarchyWalker::find_witness_anywhere(Klass* context_type,
// (Their subclasses are additional indirect implementors. // (Their subclasses are additional indirect implementors.
// See InstanceKlass::add_implementor.) // See InstanceKlass::add_implementor.)
// (Note: nof_implementors is always zero for non-interfaces.) // (Note: nof_implementors is always zero for non-interfaces.)
if (top_level_call) {
int nof_impls = InstanceKlass::cast(context_type)->nof_implementors(); int nof_impls = InstanceKlass::cast(context_type)->nof_implementors();
if (nof_impls > 1) { if (nof_impls > 1) {
// Avoid this case: *I.m > { A.m, C }; B.m > C // Avoid this case: *I.m > { A.m, C }; B.m > C
...@@ -1127,6 +1130,7 @@ Klass* ClassHierarchyWalker::find_witness_anywhere(Klass* context_type, ...@@ -1127,6 +1130,7 @@ Klass* ClassHierarchyWalker::find_witness_anywhere(Klass* context_type,
ADD_SUBCLASS_CHAIN(impl); ADD_SUBCLASS_CHAIN(impl);
} }
} }
}
// Recursively process each non-trivial sibling chain. // Recursively process each non-trivial sibling chain.
while (chaini > 0) { while (chaini > 0) {
......
/*
* Copyright (c) 2014, 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.
*/
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import com.oracle.java.testlibrary.*;
/*
* @test
* @bug 8050079
* @summary Compiles a monomorphic call to finalizeObject() on a modified java.lang.Object to test C1 CHA.
* @library /testlibrary
* @compile -XDignore.symbol.file java/lang/Object.java TestMonomorphicObjectCall.java
* @run main TestMonomorphicObjectCall
*/
public class TestMonomorphicObjectCall {
final static String testClasses = System.getProperty("test.classes") + File.separator;
private static void callFinalize(Object object) throws Throwable {
// Call modified version of java.lang.Object::finalize() that is
// not overridden by any subclass. C1 CHA should mark the call site
// as monomorphic and inline the method.
object.finalizeObject();
}
public static void main(String[] args) throws Throwable {
if (args.length == 0) {
// Execute new instance with modified java.lang.Object
executeTestJvm();
} else {
// Trigger compilation of 'callFinalize'
callFinalize(new Object());
}
}
public static void executeTestJvm() throws Throwable {
// Execute test with modified version of java.lang.Object
// in -Xbootclasspath.
String[] vmOpts = new String[] {
"-Xbootclasspath/p:" + testClasses,
"-Xcomp",
"-XX:-VerifyDependencies",
"-XX:CompileOnly=TestMonomorphicObjectCall::callFinalize",
"-XX:CompileOnly=Object::finalizeObject",
"-XX:TieredStopAtLevel=1",
TestMonomorphicObjectCall.class.getName(),
"true"};
OutputAnalyzer output = ProcessTools.executeTestJvm(vmOpts);
output.shouldHaveExitValue(0);
}
}
/*
* Copyright (c) 1994, 2014, 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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 java.lang;
/**
* Slightly modified version of java.lang.Object that replaces
* finalize() by finalizeObject() to avoid overriding in subclasses.
*/
public class Object {
private static native void registerNatives();
static {
registerNatives();
}
public final native Class<?> getClass();
public native int hashCode();
public boolean equals(Object obj) {
return (this == obj);
}
protected native Object clone() throws CloneNotSupportedException;
public String toString() {
return getClass().getName() + "@" + Integer.toHexString(hashCode());
}
public final native void notify();
public final native void notifyAll();
public final native void wait(long timeout) throws InterruptedException;
public final void wait(long timeout, int nanos) throws InterruptedException {
if (timeout < 0) {
throw new IllegalArgumentException("timeout value is negative");
}
if (nanos < 0 || nanos > 999999) {
throw new IllegalArgumentException(
"nanosecond timeout value out of range");
}
if (nanos >= 500000 || (nanos != 0 && timeout == 0)) {
timeout++;
}
wait(timeout);
}
public final void wait() throws InterruptedException {
wait(0);
}
/**
* Replaces original finalize() method and is therefore not
* overridden by any subclasses of Object.
* @throws Throwable
*/
// protected void finalize() throws Throwable { }
public void finalizeObject() throws Throwable { }
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册