Mercurial > hg > graal-compiler
changeset 22864:4fb65c8712dd
Adjust method handle test to reproduce JDK9 handle invoke problem
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 21 Oct 2015 20:34:36 -0700 |
parents | f6e1108b9a94 |
children | 016ec4502b75 |
files | graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InterfaceMethodHandleTest.java |
diffstat | 1 files changed, 35 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InterfaceMethodHandleTest.java Wed Oct 21 23:56:19 2015 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InterfaceMethodHandleTest.java Wed Oct 21 20:34:36 2015 -0700 @@ -30,6 +30,9 @@ import jdk.internal.org.objectweb.asm.Label; import jdk.internal.org.objectweb.asm.MethodVisitor; import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.vm.ci.code.CompilationResult; +import jdk.vm.ci.code.InstalledCode; +import jdk.vm.ci.meta.ResolvedJavaMethod; import org.junit.Test; @@ -54,6 +57,17 @@ } + static class M2Thrower implements I { + public int m() { + return 0; + } + + public int m2(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j) { + throw new InternalError(); + } + + } + static { try { MethodType type = MethodType.fromMethodDescriptorString("()I", I.class.getClassLoader()); @@ -84,20 +98,29 @@ return (int) INTERFACE_HANDLE_M2.invokeExact(o, a, b, c, d, e, f, g, h, i, j); } - @Test - public void testInvokeInterface03() throws InstantiationException, IllegalAccessException, ClassNotFoundException { - A goodInstance = new A(); - try { - invokeInterfaceHandle2(goodInstance, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - } catch (Throwable t) { + @Override + protected InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult) { + if (method.getDeclaringClass().equals(getMetaAccess().lookupJavaType(M2Thrower.class))) { + // Make sure M2Thrower.m2 is invoked from normal code + return getCodeCache().setDefaultCode(method, compResult); + } + return super.addMethod(method, compResult); + } - } - System.err.println(getCode(getMetaAccess().lookupJavaMethod(getMethod("invokeInterfaceHandle2")))); - I badInstance = (I) loader.findClass(NAME).newInstance(); - for (int i = 0; i < 100001; i++) { + /** + * Try to exercise a mixed calling sequence with regular JIT code calling a method handle that + * can't be inlined with an implementation compiled by Graal that throws an exception. + */ + @Test + public void testInvokeInterface03() throws Throwable { + A goodInstance = new A(); + I badInstance = new M2Thrower(); + getCode(getMetaAccess().lookupJavaMethod(getMethod(M2Thrower.class, "m2"))); + final int limit = 20000; + for (int i = 0; i <= limit; i++) { try { - invokeInterfaceHandle2(i < 100000 ? goodInstance : badInstance, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); - } catch (Throwable e) { + invokeInterfaceHandle2(i < limit - 1 ? goodInstance : badInstance, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); + } catch (InternalError e) { } }