Search in sources :

Example 6 with InvalidInstalledCodeException

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

the class HotSpotNmethodTest method testInstallCodeInvalidationWhileRunning.

@Test
public void testInstallCodeInvalidationWhileRunning() {
    final ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod("foo");
    final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, parseEager("otherFoo", AllowAssumptions.YES));
    Object result;
    try {
        result = nmethod.executeVarargs(nmethod, null, null);
        assertDeepEquals(43, result);
    } catch (InvalidInstalledCodeException e) {
        Assert.fail("Code was invalidated");
    }
    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 7 with InvalidInstalledCodeException

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

the class HotSpotStackIntrospectionTest method test.

private void test(String name) throws InvalidInstalledCodeException {
    ResolvedJavaMethod method = getMetaAccess().lookupJavaMethod(getMethod(name));
    Function<Void, Void> f = o -> {
        stackIntrospection.iterateFrames(null, null, 0, frame -> {
            if (frame.getMethod().equals(method)) {
                frame.materializeVirtualObjects(true);
            }
            return null;
        });
        return null;
    };
    InstalledCode code = getCode(method);
    code.executeVarargs(f);
}
Also used : InstalledCode(jdk.vm.ci.code.InstalledCode) InvalidInstalledCodeException(jdk.vm.ci.code.InvalidInstalledCodeException) GraalTest(org.graalvm.compiler.test.GraalTest) InspectedFrame(jdk.vm.ci.code.stack.InspectedFrame) Assume(org.junit.Assume) Test(org.junit.Test) StackIntrospection(jdk.vm.ci.code.stack.StackIntrospection) HotSpotJVMCIRuntime(jdk.vm.ci.hotspot.HotSpotJVMCIRuntime) Function(java.util.function.Function) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) InstalledCode(jdk.vm.ci.code.InstalledCode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 8 with InvalidInstalledCodeException

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

the class CompiledMethodTest method test4.

@Test
public void test4() {
    final ResolvedJavaMethod javaMethod = getResolvedJavaMethod("testMethodVirtual");
    InstalledCode compiledMethod = getCode(javaMethod);
    try {
        f1 = "0";
        Object result = compiledMethod.executeVarargs(this, "1", "2", "3");
        Assert.assertEquals("0 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 9 with InvalidInstalledCodeException

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

the class CompiledMethodTest method test1.

/**
 * Usages of the constant {@code " "} are replaced with the constant {@code "-"} and it is
 * verified that executing the compiled code produces a result that the preserves the node
 * replacement unless deoptimization occurs (e.g., due to -Xcomp causing profiles to be
 * missing).
 */
@Test
public void test1() {
    final ResolvedJavaMethod javaMethod = getResolvedJavaMethod("testMethod");
    final StructuredGraph graph = parseEager(javaMethod, AllowAssumptions.NO);
    new CanonicalizerPhase().apply(graph, new PhaseContext(getProviders()));
    new DeadCodeEliminationPhase().apply(graph);
    for (ConstantNode node : ConstantNode.getConstantNodes(graph)) {
        if (node.getStackKind() == JavaKind.Object && " ".equals(getSnippetReflection().asObject(String.class, node.asJavaConstant()))) {
            node.replace(graph, ConstantNode.forConstant(getSnippetReflection().forObject("-"), getMetaAccess(), graph));
        }
    }
    InstalledCode compiledMethod = getCode(javaMethod, graph);
    try {
        Object result = compiledMethod.executeVarargs("1", "2", "3");
        if (!"1-2-3".equals(result)) {
            // Deoptimization probably occurred
            Assert.assertEquals("interpreter", result);
        }
    } catch (InvalidInstalledCodeException t) {
        Assert.fail("method invalidated");
    }
}
Also used : PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) InvalidInstalledCodeException(jdk.vm.ci.code.InvalidInstalledCodeException) InstalledCode(jdk.vm.ci.code.InstalledCode) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) 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