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


Java CallTarget类代码示例

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

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

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

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

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

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

示例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);
}
 
开发者ID:fehrenbach,项目名称:tuber-basic,代码行数:17,代码来源:Main.java

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

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

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

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

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

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

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

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


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