use of com.oracle.truffle.api.nodes.DirectCallNode in project graal by oracle.
the class NFILanguage method parse.
@Override
protected CallTarget parse(ParsingRequest request) throws Exception {
CharSequence nfiSource = request.getSource().getCharacters();
NativeSource source = Parser.parseNFISource(nfiSource);
String backendId;
if (source.isDefaultBackend()) {
backendId = "native";
} else {
backendId = source.getNFIBackendId();
}
Source backendSource = Source.newBuilder(source.getLibraryDescriptor()).mimeType("trufflenfi/" + backendId).name("<nfi-impl>").build();
CallTarget backendTarget = getContextReference().get().env.parse(backendSource);
DirectCallNode loadLibrary = DirectCallNode.create(backendTarget);
return Truffle.getRuntime().createCallTarget(new NFIRootNode(this, loadLibrary, source));
}
use of com.oracle.truffle.api.nodes.DirectCallNode in project graal by oracle.
the class TruffleTreeDumpHandler method dumpInlinedTrees.
private static void dumpInlinedTrees(GraphOutput<AST, ?> output, final RootCallTarget callTarget, TruffleInlining inlining, List<RootCallTarget> dumped) throws IOException {
for (DirectCallNode callNode : NodeUtil.findAllNodeInstances(callTarget.getRootNode(), DirectCallNode.class)) {
CallTarget inlinedCallTarget = callNode.getCurrentCallTarget();
if (inlinedCallTarget instanceof RootCallTarget && callNode instanceof OptimizedDirectCallNode) {
TruffleInliningDecision decision = inlining.findByCall((OptimizedDirectCallNode) callNode);
if (decision != null && decision.shouldInline()) {
final RootCallTarget rootCallTarget = (RootCallTarget) inlinedCallTarget;
if (!dumped.contains(rootCallTarget)) {
AST ast = new AST(rootCallTarget);
output.beginGroup(ast, inlinedCallTarget.toString(), rootCallTarget.getRootNode().getName(), null, 0, DebugContext.addVersionProperties(null));
output.print(ast, Collections.emptyMap(), 0, AFTER_PROFILING);
output.endGroup();
dumped.add(rootCallTarget);
dumpInlinedTrees(output, (OptimizedCallTarget) inlinedCallTarget, decision, dumped);
}
}
}
}
}
use of com.oracle.truffle.api.nodes.DirectCallNode 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;
}
use of com.oracle.truffle.api.nodes.DirectCallNode in project sulong by graalvm.
the class LLVMDispatchNode method getIntrinsificationCallNode.
/*
* Function is not defined in the user program (not available as LLVM IR). This would normally
* result in a native call BUT there is an intrinsification available
*/
protected DirectCallNode getIntrinsificationCallNode(Intrinsic intrinsic) {
RootCallTarget target = intrinsic.forceSplit() ? intrinsic.generateCallTarget(type) : intrinsic.cachedCallTarget(type);
DirectCallNode directCallNode = DirectCallNode.create(target);
if (intrinsic.forceInline()) {
directCallNode.forceInlining();
}
return directCallNode;
}
Aggregations