Search in sources :

Example 76 with Node

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

the class OptimizedCallTarget method pullOutParentChain.

private static void pullOutParentChain(Node node, List<Node> toDump) {
    Node rootNode = node;
    while (rootNode.getParent() != null) {
        toDump.add(rootNode);
        rootNode = rootNode.getParent();
    }
    toDump.add(rootNode);
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) Node(com.oracle.truffle.api.nodes.Node)

Example 77 with Node

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

the class TruffleInlining method getCallNodes.

private static List<OptimizedDirectCallNode> getCallNodes(OptimizedCallTarget target) {
    final List<OptimizedDirectCallNode> callNodes = new ArrayList<>();
    target.getRootNode().accept(new NodeVisitor() {

        @Override
        public boolean visit(Node node) {
            if (node instanceof OptimizedDirectCallNode) {
                callNodes.add((OptimizedDirectCallNode) node);
            }
            return true;
        }
    });
    return callNodes;
}
Also used : DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode) Node(com.oracle.truffle.api.nodes.Node) ArrayList(java.util.ArrayList) NodeVisitor(com.oracle.truffle.api.nodes.NodeVisitor)

Example 78 with Node

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

the class TruffleInlining method getPosition.

@Override
public SourceLanguagePosition getPosition(JavaConstant node) {
    SnippetReflectionProvider snippetReflection = runtime().getGraalRuntime().getRequiredCapability(SnippetReflectionProvider.class);
    Node truffleNode = snippetReflection.asObject(Node.class, node);
    if (truffleNode == null) {
        return null;
    }
    SourceSection section = null;
    if (truffleNode instanceof DirectCallNode) {
        section = ((DirectCallNode) truffleNode).getCurrentRootNode().getSourceSection();
    }
    if (section == null) {
        section = truffleNode.getSourceSection();
    }
    if (section == null) {
        Node cur = truffleNode.getParent();
        while (cur != null) {
            section = cur.getSourceSection();
            if (section != null) {
                break;
            }
            cur = cur.getParent();
        }
    }
    if (section != null) {
        return new TruffleSourceLanguagePosition(section);
    }
    return null;
}
Also used : SnippetReflectionProvider(org.graalvm.compiler.api.replacements.SnippetReflectionProvider) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode) Node(com.oracle.truffle.api.nodes.Node) SourceSection(com.oracle.truffle.api.source.SourceSection) DirectCallNode(com.oracle.truffle.api.nodes.DirectCallNode)

Example 79 with Node

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

the class NodeAdoptionBenchmark method shallowBigBlocks.

@Benchmark
public Object shallowBigBlocks() {
    Node block = createBlock(0, 30);
    block.adoptChildren();
    return block;
}
Also used : Node(com.oracle.truffle.api.nodes.Node) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 80 with Node

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

the class DebuggerSessionSnippets method evalInContext.

/**
 * Evaluates a snippet of code in a halted execution context. Assumes frame is part of the
 * current execution stack, behavior is undefined if not.
 *
 * @param ev event notification where execution is halted
 * @param code text of the code to be executed
 * @param frameInstance frame where execution is halted
 * @return
 * @throws IOException
 */
static Object evalInContext(SuspendedEvent ev, String code, FrameInstance frameInstance) throws IOException {
    try {
        Node node;
        MaterializedFrame frame;
        if (frameInstance == null) {
            node = ev.getContext().getInstrumentedNode();
            frame = ev.getMaterializedFrame();
        } else {
            node = frameInstance.getCallNode();
            frame = frameInstance.getFrame(FrameAccess.MATERIALIZE).materialize();
        }
        return Debugger.ACCESSOR.evalInContext(node, frame, code);
    } catch (KillException kex) {
        throw new IOException("Evaluation was killed.", kex);
    }
}
Also used : ProbeNode(com.oracle.truffle.api.instrumentation.ProbeNode) Node(com.oracle.truffle.api.nodes.Node) ExecutionEventNode(com.oracle.truffle.api.instrumentation.ExecutionEventNode) MaterializedFrame(com.oracle.truffle.api.frame.MaterializedFrame) IOException(java.io.IOException)

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