Search in sources :

Example 1 with InvalidInstalledCodeException

use of jdk.vm.ci.code.InvalidInstalledCodeException in project graal by oracle.

the class AssemblerTest method runTest.

protected Object runTest(String methodName, CodeGenTest test, Object... args) {
    Method method = getMethod(methodName);
    InstalledCode code = assembleMethod(method, test);
    try {
        return code.executeVarargs(args);
    } catch (InvalidInstalledCodeException e) {
        throw new RuntimeException(e);
    }
}
Also used : InvalidInstalledCodeException(jdk.vm.ci.code.InvalidInstalledCodeException) InstalledCode(jdk.vm.ci.code.InstalledCode) Method(java.lang.reflect.Method) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 2 with InvalidInstalledCodeException

use of jdk.vm.ci.code.InvalidInstalledCodeException in project graal by oracle.

the class CompiledMethodTest method test3.

@Test
public void test3() {
    final ResolvedJavaMethod javaMethod = getResolvedJavaMethod("testMethod");
    InstalledCode compiledMethod = getCode(javaMethod);
    try {
        Object result = compiledMethod.executeVarargs("1", "2", "3");
        Assert.assertEquals("1 2 3", result);
    } catch (InvalidInstalledCodeException t) {
        Assert.fail("method invalidated");
    }
}
Also used : InvalidInstalledCodeException(jdk.vm.ci.code.InvalidInstalledCodeException) InstalledCode(jdk.vm.ci.code.InstalledCode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 3 with InvalidInstalledCodeException

use of jdk.vm.ci.code.InvalidInstalledCodeException in project graal by oracle.

the class MarkUnsafeAccessTest method testCompiled.

@Test
public void testCompiled() throws IOException {
    ResolvedJavaMethod getMethod = asResolvedJavaMethod(getMethod(ByteBuffer.class, "get", new Class<?>[] {}));
    ResolvedJavaType mbbClass = getMetaAccess().lookupJavaType(MappedByteBuffer.class);
    ResolvedJavaMethod getMethodImpl = mbbClass.findUniqueConcreteMethod(getMethod).getResult();
    Assert.assertNotNull(getMethodImpl);
    StructuredGraph graph = parseForCompile(getMethodImpl);
    HighTierContext highContext = getDefaultHighTierContext();
    new CanonicalizerPhase().apply(graph, highContext);
    new InliningPhase(new InlineEverythingPolicy(), new CanonicalizerPhase()).apply(graph, highContext);
    InstalledCode compiledCode = getCode(getMethodImpl, graph);
    testMappedByteBuffer(mbb -> {
        try {
            return (byte) compiledCode.executeVarargs(mbb);
        } catch (InvalidInstalledCodeException e) {
            Assert.fail();
            return 0;
        }
    });
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) InlineEverythingPolicy(org.graalvm.compiler.phases.common.inlining.policy.InlineEverythingPolicy) InvalidInstalledCodeException(jdk.vm.ci.code.InvalidInstalledCodeException) InstalledCode(jdk.vm.ci.code.InstalledCode) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) ByteBuffer(java.nio.ByteBuffer) MappedByteBuffer(java.nio.MappedByteBuffer) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) Test(org.junit.Test)

Example 4 with InvalidInstalledCodeException

use of jdk.vm.ci.code.InvalidInstalledCodeException in project graal by oracle.

the class HotSpotNmethodTest method testInstallCodeInvalidation.

@Test
public void testInstallCodeInvalidation() {
    final ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod("foo");
    final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, parseEager("otherFoo", AllowAssumptions.YES));
    Assert.assertTrue(nmethod.isValid());
    Object result;
    try {
        result = nmethod.executeVarargs(null, "b", "c");
        assertDeepEquals(43, result);
    } catch (InvalidInstalledCodeException e) {
        Assert.fail("Code was invalidated");
    }
    Assert.assertTrue(nmethod.isValid());
    nmethod.invalidate();
    Assert.assertFalse(nmethod.isValid());
    try {
        result = nmethod.executeVarargs(null, null, null);
        Assert.fail("Code was not invalidated");
    } catch (InvalidInstalledCodeException e) {
    }
    Assert.assertFalse(nmethod.isValid());
}
Also used : HotSpotNmethod(jdk.vm.ci.hotspot.HotSpotNmethod) InvalidInstalledCodeException(jdk.vm.ci.code.InvalidInstalledCodeException) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 5 with InvalidInstalledCodeException

use of jdk.vm.ci.code.InvalidInstalledCodeException in project graal by oracle.

the class HotSpotNmethodTest method testInstalledCodeCalledFromCompiledCode.

@Test
public void testInstalledCodeCalledFromCompiledCode() {
    final ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod("foo");
    final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, parseEager("otherFoo", AllowAssumptions.YES));
    Assert.assertTrue(nmethod.isValid());
    try {
        for (int i = 0; i < ITERATION_COUNT; ++i) {
            nmethod.executeVarargs(null, "b", "c");
        }
    } catch (InvalidInstalledCodeException e) {
        Assert.fail("Code was invalidated");
    }
}
Also used : HotSpotNmethod(jdk.vm.ci.hotspot.HotSpotNmethod) InvalidInstalledCodeException(jdk.vm.ci.code.InvalidInstalledCodeException) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Aggregations

InvalidInstalledCodeException (jdk.vm.ci.code.InvalidInstalledCodeException)9 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)9 Test (org.junit.Test)8 InstalledCode (jdk.vm.ci.code.InstalledCode)6 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)6 HotSpotNmethod (jdk.vm.ci.hotspot.HotSpotNmethod)3 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)2 Method (java.lang.reflect.Method)1 ByteBuffer (java.nio.ByteBuffer)1 MappedByteBuffer (java.nio.MappedByteBuffer)1 Function (java.util.function.Function)1 InspectedFrame (jdk.vm.ci.code.stack.InspectedFrame)1 StackIntrospection (jdk.vm.ci.code.stack.StackIntrospection)1 HotSpotJVMCIRuntime (jdk.vm.ci.hotspot.HotSpotJVMCIRuntime)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)1 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)1 InlineEverythingPolicy (org.graalvm.compiler.phases.common.inlining.policy.InlineEverythingPolicy)1