The jdk.internal.jvmci.hotspot.CompilerToVM method "resolveInvokeDynamicInPool" does not work as expected.
Javadoc says: "Ensures that the type referenced by the specified JVM_CONSTANT_InvokeDynamic entry at index cpi in constantPool is loaded and initialized. The behavior of this method is undefined if cpi does not denote a JVM_CONSTANT_InvokeDynamic entry."
That means the method is expected to work if we pass index denoting a JVM_CONSTANT_InvokeDynamic entry.
But actual behavior is JVM crash.
We have constant pool containing:
#26 = InvokeDynamic #0:#91 // #0:run:(Lcompiler/jvmci/compilerToVM/test/MultipleImplementer2;)Ljava/lang/Runnable;
We use resolveInvokeDynamicInPool(constantPool, 26) and get crash:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fc7453e1c45, pid=26548, tid=26574
#
# JRE version: Java(TM) SE Runtime Environment (9.0) (build 1.9.0-internal-kshefov_2015_09_24_11_50-b00)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (1.9.0-internal-kshefov_2015_09_24_11_50-b00, mixed mode, tiered, jvmci, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# V [libjvm.so+0x4efc45] CompilationPolicy::must_be_compiled(methodHandle, int)+0x15
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %P" (or dumping to /home/kshefov/JTwork/scratch/core.26548)
#
# An error report file with more information is saved as:
# /home/kshefov/JTwork/scratch/hs_err_pid26548.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
Test cases attached, just apply "ResolveInvokeDynamicInPoolTest.patch" to the clone of http://hg.openjdk.java.net/graal/graal-jvmci-9/hotspot and run test with JTREG:
test/compiler/jvmci/CompilerToVM/ResolveInvokeDynamicInPoolTest.java