8216970: condy causes JVM crash
Fix issue with ConstantPool::constant_tag_at to correctly handle a condy whose return type is an array. Reviewed-by: acorn, hseigel, jrose
This commit is contained in:
parent
02924f478b
commit
4c63f4d399
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2019, 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
|
||||
@ -817,9 +817,9 @@ constantTag ConstantPool::constant_tag_at(int which) {
|
||||
constantTag tag = tag_at(which);
|
||||
if (tag.is_dynamic_constant() ||
|
||||
tag.is_dynamic_constant_in_error()) {
|
||||
// have to look at the signature for this one
|
||||
Symbol* constant_type = uncached_signature_ref_at(which);
|
||||
return constantTag::ofBasicType(FieldType::basic_type(constant_type));
|
||||
BasicType bt = basic_type_for_constant_at(which);
|
||||
// dynamic constant could return an array, treat as object
|
||||
return constantTag::ofBasicType(is_reference_type(bt) ? T_OBJECT : bt);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8216970
|
||||
* @summary Ensure escape analysis can handle an ldc of a dynamic
|
||||
* constant whose return type is an array of boolean.
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* @library /test/lib
|
||||
* @compile TestEscapeThroughInvokeWithCondy$A.jasm
|
||||
* @compile TestEscapeThroughInvokeWithCondy.jasm
|
||||
* @compile TestEscapeCondy.java
|
||||
* @run main/othervm TestEscapeCondy
|
||||
*/
|
||||
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.compiler.InMemoryJavaCompiler;
|
||||
|
||||
public class TestEscapeCondy {
|
||||
public static void main(String args[]) throws Throwable {
|
||||
// 1. Test escape analysis of a method that contains
|
||||
// a ldc instruction of a condy whose return type is an array of boolean
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
|
||||
"-XX:CompileCommand=dontinline,runtime.condy.TestEscapeThroughInvokeWithCondy::create",
|
||||
"runtime.condy.TestEscapeThroughInvokeWithCondy");
|
||||
OutputAnalyzer oa = new OutputAnalyzer(pb.start());
|
||||
oa.shouldContain("Test has successfully analyzed ldc bytecode within method create");
|
||||
oa.shouldHaveExitValue(0);
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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 runtime/condy;
|
||||
|
||||
super class TestEscapeThroughInvokeWithCondy$A
|
||||
version 55:0
|
||||
{
|
||||
|
||||
private Field saved:"Lruntime/condy/TestEscapeThroughInvokeWithCondy$A;";
|
||||
|
||||
public Method "<init>":"(Ljava/lang/Integer;)V"
|
||||
stack 1 locals 2
|
||||
{
|
||||
aload_0;
|
||||
invokespecial Method java/lang/Object."<init>":"()V";
|
||||
return;
|
||||
}
|
||||
|
||||
public Method saveInto:"(Lruntime/condy/TestEscapeThroughInvokeWithCondy$A;Ljava/lang/Integer;)V"
|
||||
stack 2 locals 3
|
||||
{
|
||||
aload_1;
|
||||
aload_0;
|
||||
putfield Field saved:"Lruntime/condy/TestEscapeThroughInvokeWithCondy$A;";
|
||||
return;
|
||||
}
|
||||
|
||||
public Method check:"(Lruntime/condy/TestEscapeThroughInvokeWithCondy$A;)V"
|
||||
stack 3 locals 2
|
||||
{
|
||||
aload_0;
|
||||
getfield Field saved:"Lruntime/condy/TestEscapeThroughInvokeWithCondy$A;";
|
||||
aload_1;
|
||||
if_acmpeq L18;
|
||||
new class java/lang/RuntimeException;
|
||||
dup;
|
||||
ldc String "TEST FAILED: Objects not equal.";
|
||||
invokespecial Method java/lang/RuntimeException."<init>":"(Ljava/lang/String;)V";
|
||||
athrow;
|
||||
L18: stack_frame_type same;
|
||||
return;
|
||||
}
|
||||
|
||||
NestHost TestEscapeThroughInvokeWithCondy;
|
||||
static InnerClass A=class TestEscapeThroughInvokeWithCondy$A of class TestEscapeThroughInvokeWithCondy;
|
||||
|
||||
} // end Class TestEscapeThroughInvokeWithCondy$A
|
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 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.
|
||||
*
|
||||
*/
|
||||
|
||||
// The below .jasm code implements the same java code as test
|
||||
// compiler/escapeAnalysis/TestEscapeThrowInvoke.java with the addition
|
||||
// of an ldc bytecode of a dynamic constant whose return type is an array of boolean.
|
||||
// The method bsmArray is the bootstrap method for the dynamic constant.
|
||||
// The ldc has been added to the method create.
|
||||
|
||||
package runtime/condy;
|
||||
|
||||
super public class TestEscapeThroughInvokeWithCondy
|
||||
version 55:0
|
||||
{
|
||||
|
||||
private Field a:"Lruntime/condy/TestEscapeThroughInvokeWithCondy$A;";
|
||||
|
||||
public Method "<init>":"()V"
|
||||
stack 1 locals 1
|
||||
{
|
||||
aload_0;
|
||||
invokespecial Method java/lang/Object."<init>":"()V";
|
||||
return;
|
||||
}
|
||||
|
||||
public static Method main:"([Ljava/lang/String;)V"
|
||||
stack 4 locals 3
|
||||
{
|
||||
new class TestEscapeThroughInvokeWithCondy;
|
||||
dup;
|
||||
invokespecial Method "<init>":"()V";
|
||||
astore_1;
|
||||
aload_1;
|
||||
new class TestEscapeThroughInvokeWithCondy$A;
|
||||
dup;
|
||||
bipush 42;
|
||||
invokestatic Method java/lang/Integer.valueOf:"(I)Ljava/lang/Integer;";
|
||||
invokespecial Method TestEscapeThroughInvokeWithCondy$A."<init>":"(Ljava/lang/Integer;)V";
|
||||
putfield Field a:"Lruntime/condy/TestEscapeThroughInvokeWithCondy$A;";
|
||||
iconst_0;
|
||||
istore_2;
|
||||
L26: stack_frame_type append;
|
||||
locals_map class TestEscapeThroughInvokeWithCondy, int;
|
||||
iload_2;
|
||||
ldc int 100000;
|
||||
if_icmpge L42;
|
||||
aload_1;
|
||||
invokevirtual Method run:"()V";
|
||||
iinc 2, 1;
|
||||
goto L26;
|
||||
L42: stack_frame_type chop1;
|
||||
getstatic Field java/lang/System.out:"Ljava/io/PrintStream;";
|
||||
ldc String "Test has successfully analyzed ldc bytecode within method create";
|
||||
invokevirtual Method java/io/PrintStream.println:"(Ljava/lang/String;)V";
|
||||
return;
|
||||
}
|
||||
public static Method bsmArray:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)[Z"
|
||||
stack 5 locals 6
|
||||
{
|
||||
iconst_2;
|
||||
newarray boolean;
|
||||
astore_3;
|
||||
aload_3;
|
||||
iconst_0;
|
||||
iconst_1;
|
||||
bastore;
|
||||
aload_3;
|
||||
iconst_1;
|
||||
iconst_1;
|
||||
bastore;
|
||||
aload_3;
|
||||
areturn;
|
||||
}
|
||||
|
||||
private Method run:"()V"
|
||||
stack 2 locals 2
|
||||
{
|
||||
new class java/lang/Object;
|
||||
dup;
|
||||
invokespecial Method java/lang/Object."<init>":"()V";
|
||||
pop;
|
||||
aload_0;
|
||||
bipush 42;
|
||||
invokestatic Method java/lang/Integer.valueOf:"(I)Ljava/lang/Integer;";
|
||||
invokevirtual Method create:"(Ljava/lang/Integer;)Lruntime/condy/TestEscapeThroughInvokeWithCondy$A;";
|
||||
astore_1;
|
||||
aload_0;
|
||||
getfield Field a:"Lruntime/condy/TestEscapeThroughInvokeWithCondy$A;";
|
||||
aload_1;
|
||||
invokevirtual Method TestEscapeThroughInvokeWithCondy$A.check:"(Lruntime/condy/TestEscapeThroughInvokeWithCondy$A;)V";
|
||||
return;
|
||||
}
|
||||
|
||||
private Method create:"(Ljava/lang/Integer;)Lruntime/condy/TestEscapeThroughInvokeWithCondy$A;"
|
||||
stack 5 locals 4
|
||||
{
|
||||
ldc Dynamic REF_invokeStatic:TestEscapeThroughInvokeWithCondy.bsmArray:"(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)[Z":name:"[Z";
|
||||
astore_2;
|
||||
aload_2;
|
||||
iconst_1;
|
||||
iconst_1;
|
||||
bastore;
|
||||
new class TestEscapeThroughInvokeWithCondy$A;
|
||||
dup;
|
||||
aload_1;
|
||||
invokespecial Method TestEscapeThroughInvokeWithCondy$A."<init>":"(Ljava/lang/Integer;)V";
|
||||
astore_3;
|
||||
aload_3;
|
||||
aload_0;
|
||||
getfield Field a:"Lruntime/condy/TestEscapeThroughInvokeWithCondy$A;";
|
||||
aload_1;
|
||||
invokevirtual Method TestEscapeThroughInvokeWithCondy$A.saveInto:"(Lruntime/condy/TestEscapeThroughInvokeWithCondy$A;Ljava/lang/Integer;)V";
|
||||
aload_3;
|
||||
areturn;
|
||||
}
|
||||
|
||||
NestMembers TestEscapeThroughInvokeWithCondy$A;
|
||||
static InnerClass A=class TestEscapeThroughInvokeWithCondy$A of class TestEscapeThroughInvokeWithCondy;
|
||||
|
||||
} // end Class TestEscapeThroughInvokeWithCondy
|
Loading…
x
Reference in New Issue
Block a user