本文整理汇总了Java中com.oracle.truffle.api.CallTarget.call方法的典型用法代码示例。如果您正苦于以下问题:Java CallTarget.call方法的具体用法?Java CallTarget.call怎么用?Java CallTarget.call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.oracle.truffle.api.CallTarget
的用法示例。
在下文中一共展示了CallTarget.call方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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));
}
示例3: 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();
}
}
示例4: 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]);
}
示例5: executeGeneric
import com.oracle.truffle.api.CallTarget; //导入方法依赖的package包/类
@Override
public Object executeGeneric(VirtualFrame frame) {
Object target = this.targetNode.executeGeneric(frame);
CallTarget callTarget;
Layout layout = new Layout(target, null);
for (HBNode argumentNode : this.argumentNodes) {
Object argumentValue = argumentNode.executeGeneric(frame);
layout.addArgument(argumentValue);
}
if (target instanceof Method) {
Method method = (Method)target;
callTarget = method.getCallTarget();
layout.setReceiver(method.getReceiver());
} else if (target instanceof Function) {
Function function = (Function)target;
callTarget = function.getCallTarget();
} else {
throw new Error("Cannot call to: " + target.toString());
}
Object[] arguments = layout.getCallArguments();
return callTarget.call(arguments);
}
示例6: doBefore
import com.oracle.truffle.api.CallTarget; //导入方法依赖的package包/类
@BeforeClass
public static void doBefore() {
// ensure that all classes are properly loaded
TestRootNode rootNode = new TestRootNode(DEFAULT, new TestRepeatingNode());
CallTarget target = runtime.createCallTarget(rootNode);
target.call(1);
rootNode = new TestRootNode(CONFIGURED, new TestRepeatingNode());
target = runtime.createCallTarget(rootNode);
target.call(1);
}
示例7: testOSRSingleInvocation
import com.oracle.truffle.api.CallTarget; //导入方法依赖的package包/类
@Theory
public void testOSRSingleInvocation(OSRLoopFactory factory) {
TestRootNode rootNode = new TestRootNode(factory, new TestRepeatingNode());
CallTarget target = runtime.createCallTarget(rootNode);
target.call(OSR_THRESHOLD + 1);
assertCompiled(rootNode.getOSRTarget());
target.call(2);
assertCompiled(rootNode.getOSRTarget());
Assert.assertTrue(rootNode.wasRepeatingCalledCompiled());
}
示例8: testInternalInvalidations
import com.oracle.truffle.api.CallTarget; //导入方法依赖的package包/类
@Theory
public void testInternalInvalidations(OSRLoopFactory factory) {
TestRepeatingNode repeating = new TestRepeatingNode();
TestRootNode rootNode = new TestRootNode(factory, repeating);
CallTarget target = runtime.createCallTarget(rootNode);
target.call(OSR_THRESHOLD + 1);
assertCompiled(rootNode.getOSRTarget());
repeating.invalidationCounter = 5;
target.call(4);
assertCompiled(rootNode.getOSRTarget());
target.call(2); // should trigger invalidation
assertNotCompiled(rootNode.getOSRTarget());
}
示例9: testTwoLoopsSilblings
import com.oracle.truffle.api.CallTarget; //导入方法依赖的package包/类
@Theory
public void testTwoLoopsSilblings(OSRLoopFactory factory) {
TwoSilblingLoopNodesTest rootNode = new TwoSilblingLoopNodesTest(factory, new TestRepeatingNode(), new TestRepeatingNode());
CallTarget target = runtime.createCallTarget(rootNode);
target.call(OSR_THRESHOLD + 1, 1);
assertCompiled(rootNode.getOSRTarget());
assertNotCompiled(rootNode.getOSRTarget2());
target.call(1, OSR_THRESHOLD + 1);
assertCompiled(rootNode.getOSRTarget());
assertCompiled(rootNode.getOSRTarget2());
Assert.assertTrue(rootNode.getOSRTarget() != rootNode.getOSRTarget2());
}
示例10: testTwoLoopsParentChild1
import com.oracle.truffle.api.CallTarget; //导入方法依赖的package包/类
@Theory
public void testTwoLoopsParentChild1(OSRLoopFactory factory) {
ChildLoopRepeatingNode childLoop = new ChildLoopRepeatingNode(factory, new TestRepeatingNode(), loop -> {
assertNotCompiled(loop.getOSRTarget());
return null;
});
TestRootNode rootNode = new TestRootNode(factory, childLoop);
CallTarget target = runtime.createCallTarget(rootNode);
target.call(1, OSR_THRESHOLD);
assertCompiled(rootNode.getOSRTarget());
assertNotCompiled(childLoop.getOSRTarget());
}
示例11: testTwoLoopsParentChild2
import com.oracle.truffle.api.CallTarget; //导入方法依赖的package包/类
@Theory
public void testTwoLoopsParentChild2(OSRLoopFactory factory) {
ChildLoopRepeatingNode childLoop = new ChildLoopRepeatingNode(factory, new TestRepeatingNode(), loop -> {
assertCompiled(loop.getOSRTarget());
return null;
});
TestRootNode rootNode = new TestRootNode(factory, childLoop);
CallTarget target = runtime.createCallTarget(rootNode);
target.call(1, OSR_THRESHOLD + 1);
assertCompiled(rootNode.getOSRTarget());
assertCompiled(childLoop.getOSRTarget());
}
示例12: testStackTraceDoesNotShowOSR
import com.oracle.truffle.api.CallTarget; //导入方法依赖的package包/类
@Theory
public void testStackTraceDoesNotShowOSR(OSRLoopFactory factory) {
TestRootNode rootNode = new TestRootNode(factory, new TestOSRStackTrace());
CallTarget target = runtime.createCallTarget(rootNode);
target.call(1);
rootNode.forceOSR();
assertCompiled(rootNode.getOSRTarget());
target.call(1);
assertCompiled(rootNode.getOSRTarget());
}
示例13: instantiateModuleClass
import com.oracle.truffle.api.CallTarget; //导入方法依赖的package包/类
public SClass instantiateModuleClass() {
VM.callerNeedsToBeOptimized(
"only meant for code loading, which is supposed to be on the slowpath");
CallTarget callTarget = superclassMixinResolution.createCallTarget();
SClass superClass = (SClass) callTarget.call(Nil.nilObject);
SClass classObject = instantiateClass(Nil.nilObject, superClass);
return classObject;
}