use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class TruffleBoundaryInliningTest method runTest.
private void runTest() {
RootNode n1 = createRootNodeAllowInline();
RootCallTarget c1 = runtime.createCallTarget(n1);
StructuredGraph allowInline = partialEval((OptimizedCallTarget) c1, new Object[] {}, StructuredGraph.AllowAssumptions.YES, CompilationIdentifier.INVALID_COMPILATION_ID);
RootNode n2 = createRootNodeNoInline();
RootCallTarget c2 = runtime.createCallTarget(n2);
StructuredGraph noInline = partialEval((OptimizedCallTarget) c2, new Object[] {}, StructuredGraph.AllowAssumptions.YES, CompilationIdentifier.INVALID_COMPILATION_ID);
checkHasTestMethod(allowInline);
checkHasTestMethod(noInline);
}
use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class IndirectCallSiteTest method testIndirectCallNodeDoesNotDeopOnFirstCall.
@Test
public void testIndirectCallNodeDoesNotDeopOnFirstCall() {
final Object[] noArguments = new Object[0];
final OptimizedCallTarget innerTarget = (OptimizedCallTarget) runtime.createCallTarget(new RootNode(null) {
@Override
public Object execute(VirtualFrame frame) {
return null;
}
});
final OptimizedCallTarget uninitializedInnerTarget = (OptimizedCallTarget) runtime.createCallTarget(new RootNode(null) {
@Override
public Object execute(VirtualFrame frame) {
return null;
}
});
final OptimizedCallTarget outerTarget = (OptimizedCallTarget) runtime.createCallTarget(new RootNode(null) {
@Child
OptimizedIndirectCallNode indirectCallNode = (OptimizedIndirectCallNode) runtime.createIndirectCallNode();
@Override
public Object execute(VirtualFrame frame) {
if (frame.getArguments().length == 0) {
return indirectCallNode.call(innerTarget, noArguments);
} else {
return indirectCallNode.call(uninitializedInnerTarget, noArguments);
}
}
});
final int compilationThreshold = TruffleCompilerOptions.getValue(TruffleCompilationThreshold);
for (int i = 0; i < compilationThreshold; i++) {
outerTarget.call(noArguments);
}
assertCompiled(outerTarget);
outerTarget.call(new Object[] { null });
assertCompiled(outerTarget);
}
use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class SLGraalRuntimeBuiltin method findCallsTo.
/**
* Finds all {@link DirectCallNode} instances calling a certain original {@link CallTarget} in
* the caller function.
*/
@TruffleBoundary
protected static final Set<DirectCallNode> findCallsTo(OptimizedCallTarget originalCallTarget) {
FrameInstance frame = Truffle.getRuntime().getCallerFrame();
RootNode root = frame.getCallNode().getRootNode();
return findCallsTo(root, originalCallTarget);
}
use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class SLGraalRuntimeBuiltin method findCallsTo.
/**
* Finds all {@link DirectCallNode} instances calling a certain original {@link CallTarget} in a
* given {@link RootNode}.
*/
@TruffleBoundary
protected static final Set<DirectCallNode> findCallsTo(RootNode root, OptimizedCallTarget originalCallTarget) {
final Set<DirectCallNode> allCallNodes = new HashSet<>();
root.accept(new NodeVisitor() {
@Override
public boolean visit(Node node) {
if (node instanceof DirectCallNode) {
DirectCallNode callNode = (DirectCallNode) node;
if (callNode.getCallTarget() == originalCallTarget || callNode.getClonedCallTarget() == originalCallTarget) {
allCallNodes.add(callNode);
}
}
return true;
}
});
return allCallNodes;
}
use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class NFILanguageImpl method parse.
@Override
protected CallTarget parse(ParsingRequest request) throws Exception {
CharSequence library = request.getSource().getCharacters();
RootNode root;
NativeLibraryDescriptor descriptor = Parser.parseLibraryDescriptor(library);
NFIContext ctx = getContextReference().get();
if (descriptor.isDefaultLibrary()) {
root = new GetDefaultLibraryNode();
} else {
int flags = 0;
boolean lazyOrNow = false;
if (descriptor.getFlags() != null) {
for (String flag : descriptor.getFlags()) {
switch(flag) {
case "RTLD_GLOBAL":
flags |= ctx.RTLD_GLOBAL;
break;
case "RTLD_LOCAL":
flags |= ctx.RTLD_LOCAL;
break;
case "RTLD_LAZY":
flags |= ctx.RTLD_LAZY;
lazyOrNow = true;
break;
case "RTLD_NOW":
flags |= ctx.RTLD_NOW;
lazyOrNow = true;
break;
}
}
}
if (!lazyOrNow) {
// default to 'RTLD_NOW' if neither 'RTLD_LAZY' nor 'RTLD_NOW' was specified
flags |= ctx.RTLD_NOW;
}
root = new LoadLibraryNode(this, descriptor.getFilename(), flags);
}
return Truffle.getRuntime().createCallTarget(root);
}
Aggregations