Search in sources :

Example 6 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class GraalTVMCI method onLoopCount.

@Override
public void onLoopCount(Node source, int count) {
    Node node = source;
    Node parentNode = source != null ? source.getParent() : null;
    while (node != null) {
        if (node instanceof OptimizedOSRLoopNode) {
            ((OptimizedOSRLoopNode) node).reportChildLoopCount(count);
        }
        parentNode = node;
        node = node.getParent();
    }
    if (parentNode != null && parentNode instanceof RootNode) {
        CallTarget target = ((RootNode) parentNode).getCallTarget();
        if (target instanceof OptimizedCallTarget) {
            ((OptimizedCallTarget) target).onLoopCount(count);
        }
    }
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) RootCallTarget(com.oracle.truffle.api.RootCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Node(com.oracle.truffle.api.nodes.Node) RootNode(com.oracle.truffle.api.nodes.RootNode)

Example 7 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class CachedReachableFallbackTest method countGuardNodes.

private static int countGuardNodes(Node searchNode) {
    AtomicInteger count = new AtomicInteger(0);
    searchNode.accept(new NodeVisitor() {

        public boolean visit(Node node) {
            if (node instanceof GuardNode) {
                count.incrementAndGet();
                return false;
            }
            return true;
        }
    });
    return count.get();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Node(com.oracle.truffle.api.nodes.Node) NodeVisitor(com.oracle.truffle.api.nodes.NodeVisitor)

Example 8 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class CachedTest method testChildrenAdoption7.

@Test
public void testChildrenAdoption7() {
    ChildrenAdoption7 root = createNode(ChildrenAdoption7Factory.getInstance(), false);
    Node child = new ValueNode();
    root.execute(child);
    Assert.assertTrue(hasParent(root, child));
}
Also used : ValueNode(com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode) Node(com.oracle.truffle.api.nodes.Node) TestHelper.createNode(com.oracle.truffle.api.dsl.test.TestHelper.createNode) ValueNode(com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode) Test(org.junit.Test)

Example 9 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class CachedTest method testChildrenAdoption4.

@Test
public void testChildrenAdoption4() {
    ChildrenAdoption4 root = createNode(ChildrenAdoption4Factory.getInstance(), false);
    Node child = new ValueNode();
    root.execute(child);
    Assert.assertTrue(hasParent(root, child));
}
Also used : ValueNode(com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode) Node(com.oracle.truffle.api.nodes.Node) TestHelper.createNode(com.oracle.truffle.api.dsl.test.TestHelper.createNode) ValueNode(com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode) Test(org.junit.Test)

Example 10 with Node

use of com.oracle.truffle.api.nodes.Node in project graal by oracle.

the class DebugStackFrame method findCurrentRoot.

RootNode findCurrentRoot() {
    SuspendedContext context = getContext();
    if (currentFrame == null) {
        return context.getInstrumentedNode().getRootNode();
    } else {
        Node callNode = currentFrame.getCallNode();
        if (callNode != null) {
            return callNode.getRootNode();
        }
        CallTarget target = currentFrame.getCallTarget();
        if (target instanceof RootCallTarget) {
            return ((RootCallTarget) target).getRootNode();
        }
        return null;
    }
}
Also used : RootCallTarget(com.oracle.truffle.api.RootCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Node(com.oracle.truffle.api.nodes.Node) RootNode(com.oracle.truffle.api.nodes.RootNode) RootCallTarget(com.oracle.truffle.api.RootCallTarget)

Aggregations

Node (com.oracle.truffle.api.nodes.Node)101 RootNode (com.oracle.truffle.api.nodes.RootNode)65 Test (org.junit.Test)46 InstrumentableNode (com.oracle.truffle.api.instrumentation.InstrumentableNode)21 ProbeNode (com.oracle.truffle.api.instrumentation.ProbeNode)21 Source (com.oracle.truffle.api.source.Source)16 NodeVisitor (com.oracle.truffle.api.nodes.NodeVisitor)11 CallTarget (com.oracle.truffle.api.CallTarget)9 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)9 DirectCallNode (com.oracle.truffle.api.nodes.DirectCallNode)8 WrapperNode (com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode)7 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)6 SourceSection (com.oracle.truffle.api.source.SourceSection)6 TestHelper.createNode (com.oracle.truffle.api.dsl.test.TestHelper.createNode)5 ValueNode (com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode)5 SLEvalRootNode (com.oracle.truffle.sl.nodes.SLEvalRootNode)5 SLStatementNode (com.oracle.truffle.sl.nodes.SLStatementNode)5 SLBlockNode (com.oracle.truffle.sl.nodes.controlflow.SLBlockNode)5 LinkedHashMap (java.util.LinkedHashMap)5 TruffleInstrument (com.oracle.truffle.api.instrumentation.TruffleInstrument)4