本文整理汇总了Java中com.oracle.truffle.api.CallTarget类的典型用法代码示例。如果您正苦于以下问题:Java CallTarget类的具体用法?Java CallTarget怎么用?Java CallTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CallTarget类属于com.oracle.truffle.api包,在下文中一共展示了CallTarget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addNodeFactories
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
private void addNodeFactories(List<? extends NodeFactory<? extends HBNode>> factories) {
for (NodeFactory<? extends HBNode> factory : factories) {
Class<?> nodeClass = factory.getClass().getAnnotation(GeneratedBy.class).value();
BuiltinMethod methodAnnotation = this.getMethodAnnotation(nodeClass);
BuiltinClass classAnnotation = this.getClassAnnotation(nodeClass);
String methodName = methodAnnotation.value();
String className = classAnnotation.value();
MethodTargets methodTargets = this.getOrCreateMethodTargets(className);
HBNode bodyNode = this.createNode(factory, methodAnnotation);
HBBuiltinRootNode rootNode = new HBBuiltinRootNode(
this.language,
new FrameDescriptor(),
bodyNode
);
CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
methodTargets.put(methodName, callTarget);
}
}
示例2: parse
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
@Override
protected CallTarget parse(ParsingRequest request) throws Exception {
Source source = request.getSource();
HBSourceRootNode program = ParserWrapper.parse(this, source);
System.out.println(program.toString());
// Bootstrap the builtin node targets and the builtin types in the
// type-system.
BuiltinNodes builtinNodes = BuiltinNodes.bootstrap(this);
Index index = Index.bootstrap(builtinNodes);
InferenceVisitor visitor = new InferenceVisitor(index);
program.accept(visitor);
return Truffle.getRuntime().createCallTarget(program);
}
示例3: testCanBeClonedWithoutParent
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
@Test
public void testCanBeClonedWithoutParent() {
final RootNode rootNode = new RootNode(null) {
@Override
public Object execute(VirtualFrame frame) {
return 42;
}
@Override
public boolean isCloningAllowed() {
return true;
}
};
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);
final DirectCallNode callNode = Truffle.getRuntime().createDirectCallNode(callTarget);
assertTrue(callNode.isCallTargetCloningAllowed());
assertTrue(callNode.cloneCallTarget());
}
示例4: onLoopCount
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
@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);
}
}
}
示例5: AbstractWhileNode
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
public AbstractWhileNode(final SBlock rcvr, final SBlock arg,
final boolean predicateBool, final SourceSection source) {
super(false, source);
CallTarget callTargetCondition = rcvr.getMethod().getCallTarget();
conditionValueSend = Truffle.getRuntime().createDirectCallNode(
callTargetCondition);
CallTarget callTargetBody = arg.getMethod().getCallTarget();
bodyValueSend = Truffle.getRuntime().createDirectCallNode(
callTargetBody);
this.predicateBool = predicateBool;
}
示例6: performDnu
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
public static Object performDnu(final Object[] arguments, final Object rcvr,
final SClass rcvrClass, final SSymbol selector,
final IndirectCallNode call) {
if (VmSettings.DNU_PRINT_STACK_TRACE) {
PrintStackTracePrim.printStackTrace(0, null);
VM.errorPrintln("Lookup of " + selector + " failed in "
+ Types.getClassOf(rcvr).getName().getString());
}
// Won't use DNU caching here, because it is already a megamorphic node
SArray argumentsArray = SArguments.getArgumentsWithoutReceiver(arguments);
Object[] args = new Object[] {arguments[0], selector, argumentsArray};
CallTarget target = CachedDnuNode.getDnu(rcvrClass, selector,
SomLanguage.getVM(call.getRootNode()));
return call.call(target, args);
}
示例7: main
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
CharStream in = new ANTLRInputStream(new FileInputStream(args[0]));
TuberBasicLexer lexer = new TuberBasicLexer(in);
TokenStream tokens = new CommonTokenStream(lexer);
TuberBasicParser parser = new TuberBasicParser(tokens);
ParserRuleContext tree = parser.statements();
Visitor visitor = new Visitor();
TuberNode ast = visitor.visit(tree);
TruffleRuntime runtime = Truffle.getRuntime();
TuberRootNode rootNode = new TuberRootNode(ast);
CallTarget target = runtime.createCallTarget(rootNode);
Object result = target.call();
System.out.println(result);
}
示例8: stackDepth
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
public static int stackDepth() {
final StringBuilder str = new StringBuilder();
Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<Integer>() {
@Override
public Integer visitFrame(FrameInstance frameInstance) {
CallTarget callTarget = frameInstance.getCallTarget();
RootNode rn = ((RootCallTarget) callTarget).getRootNode();
if (rn.getClass().getName().contains("DynSemRuleForeignAccess")) {
return 1;
}
str.append(" ");
return null;
}
});
return str.length();
}
示例9: evalObject
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
@Override
@ExplodeLoop
Object evalObject(VirtualFrame frame) {
Object[] arguments = new Object[argumentNodes.length];
for(int i=0; i<argumentNodes.length; i++) {
arguments[i] = argumentNodes[i].eval(frame);
}
//FIXME stupid ahead of time compilation
CallTarget callTarget = this.callTarget;
if (callTarget != null) {
return callTarget.call(frame.pack(), new ArrayArguments(arguments));
}
callTarget = callTargetMap.get(name);
this.callTarget = callTarget;
return callTarget.call(frame.pack(), new ArrayArguments(arguments));
}
示例10: interpret
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
public void interpret(Path path) throws IOException {
byte[] data = Files.readAllBytes(path);
TruffleRuntime runtime = Truffle.getRuntime();
System.out.println("using " + runtime.getName());
Parser parser = new Parser(data);
while(!parser.end()) {
List list = parser.parseList();
FrameDescriptor frameDescriptor = new FrameDescriptor();
Node node = createAST(list, frameDescriptor);
EvalNode evalNode = new EvalNode(node);
CallTarget callTarget = runtime.createCallTarget(evalNode, frameDescriptor);
callTarget.call();
}
}
示例11: executeDispatch
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
@Override
public Object executeDispatch(
final VirtualFrame frame, final Object[] arguments) {
Object rcvr = arguments[0];
SClass rcvrClass = Types.getClassOf(rcvr, universe);
SInvokable method = rcvrClass.lookupInvokable(selector);
CallTarget target;
Object[] args;
if (method != null) {
target = method.getCallTarget();
args = arguments;
} else {
// Won't use DNU caching here, because it is already a megamorphic node
SArray argumentsArray = SArguments.getArgumentsWithoutReceiver(arguments);
args = new Object[] {arguments[0], selector, argumentsArray};
target = CachedDnuNode.getDnuCallTarget(rcvrClass, universe);
}
return call.call(target, args);
}
示例12: parse
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
@Override
protected CallTarget parse(ParsingRequest request) throws Exception {
Source source = request.getSource();
try(IndexedPushbackReader r = new IndexedPushbackReader(source.getReader())) {
List<CallTarget> callTargets = new ArrayList<>();
while(true) {
int startIndex = r.getPosition();
Object form = Reader.read(r);
if (form == null) {
break;
}
RootNode expr = Analyzer.analyzeRoot(this, form, source.createSection(startIndex, r.getPosition()-startIndex-1));
callTargets.add(Truffle.getRuntime().createCallTarget(expr));
}
SequenceNode node = new SequenceNode(callTargets.toArray(new CallTarget[0]));
RootNode root = new RootNode(this, null, node);
//NodeUtil.printCompactTree(System.out, root);
return Truffle.getRuntime().createCallTarget(root);
//return Truffle.getRuntime().createCallTarget(new RootNode(null, null, doNode));
}
}
示例13: doDirect
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
@Specialization(limit = "INLINE_CACHE_SIZE",
guards = "callTarget == cachedCallTarget")
public static Object doDirect(VirtualFrame frame, CallTarget callTarget, Object[] arguments,
@Cached("callTarget") CallTarget cachedCallTarget,
@Cached("create(cachedCallTarget)") DirectCallNode callNode) {
return callNode.call(arguments);
}
示例14: call
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
protected Object call(VirtualFrame frame, CallTarget callTarget, Object[] arguments) {
if (this.isTail()) {
throw new TailCallException(callTarget, arguments);
}
while (true) {
try {
return dispatchNode.executeDispatch(frame, callTarget, arguments);
//return callTarget.call(arguments);
} catch (TailCallException e) {
callTarget = e.callTarget;
arguments = e.arguments;
}
}
}
示例15: eval
import com.oracle.truffle.api.CallTarget; //导入依赖的package包/类
@Specialization
//@CompilerDirectives.TruffleBoundary
public Object eval(VirtualFrame frame, Object expr) {
CompilerDirectives.transferToInterpreterAndInvalidate();
//System.out.println("eval: " + expr);
RootNode root = Analyzer.analyzeRoot(getContext().getLanguage(), expr, Builtins.BUILTIN_SOURCE.createUnavailableSection());
/*if(this.isTail()) {
root.setIsTail();
}*/
CallTarget callTarget = Truffle.getRuntime().createCallTarget(root);
return callTarget.call(frame.getArguments()[0]);
}