当前位置: 首页>>代码示例>>Java>>正文


Java CallTarget.call方法代码示例

本文整理汇总了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);
}
 
开发者ID:fehrenbach,项目名称:tuber-basic,代码行数:17,代码来源:Main.java

示例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));
}
 
开发者ID:forax,项目名称:ninal,代码行数:19,代码来源:Interpreter.java

示例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();
  }
}
 
开发者ID:forax,项目名称:ninal,代码行数:18,代码来源:Interpreter.java

示例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]);
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:16,代码来源:Eval.java

示例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);
}
 
开发者ID:dirk,项目名称:hummingbird2,代码行数:29,代码来源:HBCallNode.java

示例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);
}
 
开发者ID:graalvm,项目名称:graal-core,代码行数:11,代码来源:OptimizedOSRLoopNodeTest.java

示例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());
}
 
开发者ID:graalvm,项目名称:graal-core,代码行数:11,代码来源:OptimizedOSRLoopNodeTest.java

示例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());
}
 
开发者ID:graalvm,项目名称:graal-core,代码行数:15,代码来源:OptimizedOSRLoopNodeTest.java

示例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());
}
 
开发者ID:graalvm,项目名称:graal-core,代码行数:13,代码来源:OptimizedOSRLoopNodeTest.java

示例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());
}
 
开发者ID:graalvm,项目名称:graal-core,代码行数:14,代码来源:OptimizedOSRLoopNodeTest.java

示例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());
}
 
开发者ID:graalvm,项目名称:graal-core,代码行数:14,代码来源:OptimizedOSRLoopNodeTest.java

示例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());
}
 
开发者ID:graalvm,项目名称:graal-core,代码行数:11,代码来源:OptimizedOSRLoopNodeTest.java

示例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;
}
 
开发者ID:smarr,项目名称:SOMns,代码行数:9,代码来源:MixinDefinition.java


注:本文中的com.oracle.truffle.api.CallTarget.call方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。