Search in sources :

Example 31 with ResolvedJavaMethod

use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.

the class HistogramInlineInvokePlugin method accept.

private void accept(MethodStatistic current) {
    ResolvedJavaMethod method = current.getMethod();
    HistogramInlineInvokePlugin.MethodStatistics statistics = histogram.get(method);
    if (statistics == null) {
        statistics = new MethodStatistics(method);
        histogram.put(method, statistics);
    }
    statistics.accept(current);
}
Also used : ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 32 with ResolvedJavaMethod

use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.

the class UnsafeDeopt method testByteBuffer.

@Test
public void testByteBuffer() {
    int m = 42;
    try {
        ResolvedJavaMethod method = getResolvedJavaMethod("readWriteReadByteBuffer");
        Object receiver = method.isStatic() ? null : this;
        Result expect = executeExpected(method, receiver, ByteBuffer.allocateDirect(32), m);
        if (getCodeCache() == null) {
            return;
        }
        ByteBuffer warmupBuffer = ByteBuffer.allocateDirect(32);
        for (int i = 0; i < 10000; ++i) {
            readWriteReadByteBuffer(warmupBuffer, (i % 50) + 1);
            warmupBuffer.putInt(0, 0);
        }
        testAgainstExpected(method, expect, receiver, ByteBuffer.allocateDirect(32), m);
    } catch (AssumptionViolatedException e) {
    // Suppress so that subsequent calls to this method within the
    // same Junit @Test annotated method can proceed.
    }
}
Also used : AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) ByteBuffer(java.nio.ByteBuffer) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) JTTTest(org.graalvm.compiler.jtt.JTTTest) Test(org.junit.Test)

Example 33 with ResolvedJavaMethod

use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.

the class ControlFlowAnchorDirectiveTest method getNodeCountAnnotations.

private static List<NodeCount> getNodeCountAnnotations(StructuredGraph graph) {
    ResolvedJavaMethod method = graph.method();
    AnchorSnippet snippet = method.getAnnotation(AnchorSnippet.class);
    if (snippet != null) {
        return Arrays.asList(snippet.value());
    }
    NodeCount single = method.getAnnotation(NodeCount.class);
    if (single != null) {
        return Collections.singletonList(single);
    }
    return Collections.emptyList();
}
Also used : ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 34 with ResolvedJavaMethod

use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.

the class PartialEscapeAnalysisTreesTest method testGraph.

/**
 * Prepare a graph that includes some blackholes and then remove the blackholes and compile
 * normally to create an unusual situation for PEA.
 */
@SuppressWarnings("try")
public void testGraph(String name) {
    ResolvedJavaMethod method = getResolvedJavaMethod(name);
    prepareGraph(name, true);
    try (DebugContext.Scope s = graph.getDebug().scope(getClass(), method, getCodeCache(), graph)) {
        for (BlackholeNode node : graph.getNodes().filter(BlackholeNode.class)) {
            graph.removeFixed(node);
        }
        new DeadCodeEliminationPhase().apply(graph);
        new CanonicalizerPhase().apply(graph, context);
        InstalledCode code = getCode(method, graph, true);
        GraalCompilerTest.Result r = executeExpected(method, null, true);
        int expectedInstances = ((TreeNode) r.returnValue).countInstances();
        TreeNode r2 = (TreeNode) code.executeVarargs(true);
        Assert.assertEquals("Wrong number of nodes in tree", expectedInstances, r2.countInstances());
        r = executeExpected(method, null, false);
        expectedInstances = ((TreeNode) r.returnValue).countInstances();
        r2 = (TreeNode) code.executeVarargs(false);
        Assert.assertEquals("Wrong number of nodes in tree", expectedInstances, r2.countInstances());
    } catch (Throwable e) {
        throw graph.getDebug().handle(e);
    }
}
Also used : BlackholeNode(org.graalvm.compiler.nodes.debug.BlackholeNode) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest) InstalledCode(jdk.vm.ci.code.InstalledCode) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 35 with ResolvedJavaMethod

use of jdk.vm.ci.meta.ResolvedJavaMethod in project graal by oracle.

the class UnsafeEATest method testEscapeAnalysis.

@Override
protected void testEscapeAnalysis(String snippet, JavaConstant expectedConstantResult, boolean iterativeEscapeAnalysis) {
    // Exercise both a graph containing UnsafeAccessNodes and one which has been possibly been
    // canonicalized into AccessFieldNodes.
    testingUnsafe = true;
    super.testEscapeAnalysis(snippet, expectedConstantResult, iterativeEscapeAnalysis);
    testingUnsafe = false;
    super.testEscapeAnalysis(snippet, expectedConstantResult, iterativeEscapeAnalysis);
    if (expectedConstantResult != null) {
        // Check that a compiled version of this method returns the same value if we expect a
        // constant result.
        ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
        JavaKind[] javaKinds = method.getSignature().toParameterKinds(false);
        Object[] args = new Object[javaKinds.length];
        int i = 0;
        for (JavaKind k : javaKinds) {
            args[i++] = JavaConstant.defaultForKind(k).asBoxedPrimitive();
        }
        Result result = executeExpected(method, null, args);
        assertTrue(result.returnValue.equals(expectedConstantResult.asBoxedPrimitive()));
    }
}
Also used : ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) JavaKind(jdk.vm.ci.meta.JavaKind)

Aggregations

ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)331 ValueNode (org.graalvm.compiler.nodes.ValueNode)104 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)92 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)89 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)67 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)66 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)66 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)57 Test (org.junit.Test)54 DebugContext (org.graalvm.compiler.debug.DebugContext)35 OptionValues (org.graalvm.compiler.options.OptionValues)32 InstalledCode (jdk.vm.ci.code.InstalledCode)24 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)23 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)22 JavaKind (jdk.vm.ci.meta.JavaKind)21 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)20 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)19 JavaConstant (jdk.vm.ci.meta.JavaConstant)17 LogicNode (org.graalvm.compiler.nodes.LogicNode)17 ArrayList (java.util.ArrayList)16