• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Specialization类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.oracle.truffle.api.dsl.Specialization的典型用法代码示例。如果您正苦于以下问题:Java Specialization类的具体用法?Java Specialization怎么用?Java Specialization使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Specialization类属于com.oracle.truffle.api.dsl包,在下文中一共展示了Specialization类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doOver

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization(guards = {"function.getArity() < arguments.length"})
public Object doOver(VirtualFrame frame, Function function, Object[] arguments,
                     @Cached("createDispatchNode()") DispatchNode dispatchNode) {
    int argIndex = 0;

    while (function.getArity() < arguments.length-argIndex) {
        Object[] argumentValues = Arrays.copyOfRange(arguments, argIndex, argIndex+function.getArity());

        argIndex += function.getArity();
        function = (Function) call(dispatchNode, frame, function, function.packArguments(argumentValues), false);
    }

    Object[] remainingArguments = Arrays.copyOfRange(arguments, argIndex, arguments.length);

    if (function.getArity() > remainingArguments.length) {
        return function.curry(remainingArguments);
    } else {
        return call(dispatchNode, frame, function, function.packArguments(remainingArguments));
    }
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:21,代码来源:InvokeNode.java


示例2: createBindings

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization(guards = {"needsBindings()"})
public Bindings createBindings(
  VirtualFrame frame,
  @Cached("createGetBindingsNode()") GetBindingsNode getBindingsNode,
  @Cached(value = "createFetchers()", dimensions = 1) Fetcher[] fetchers
) {
  Bindings ownBindings = getBindingsNode.executeGetBindings(frame);
  Bindings bindings = new Bindings();
  if (fetchers.length > 0) {
    MaterializedFrame materializedFrame = frame.materialize();
    for (Fetcher fetcher : fetchers) {
      String name = fetcher.getName();
      Binding binding = fetcher.fetch(materializedFrame, ownBindings);
      bindings.add(name, binding);
    }
  }
  return bindings;
}
 
开发者ID:dirk,项目名称:hummingbird2,代码行数:19,代码来源:CreateBindingsNode.java


示例3: callUntilCompiled

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization
public SLFunction callUntilCompiled(SLFunction function, boolean checkTarget) {
    OptimizedCallTarget target = ((OptimizedCallTarget) function.getCallTarget());
    for (int i = 0; i < MAX_CALLS; i++) {
        if (isCompiling(target)) {
            break;
        } else {
            indirectCall.call(target, EMPTY_ARGS);
        }
    }

    // call one more in compiled
    indirectCall.call(target, EMPTY_ARGS);

    if (checkTarget) {
        checkTarget(target);
    }

    return function;
}
 
开发者ID:graalvm,项目名称:graal-core,代码行数:21,代码来源:SLCallUntilOptimizedBuiltin.java


示例4: doDoubleArray

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization(guards = "arr.isDoubleType()")
public final SArray doDoubleArray(final SArray arr, final SBlock block) {
  double[] storage = arr.getDoubleStorage(storageType);
  int length = storage.length;
  try {
    if (SArray.FIRST_IDX < length) {
      execBlock(block, storage[SArray.FIRST_IDX]);
    }
    for (long i = SArray.FIRST_IDX + 1; i < length; i++) {
      execBlock(block, storage[(int) i]);
    }
  } finally {
    if (CompilerDirectives.inInterpreter()) {
      SomLoop.reportLoopCount(length, this);
    }
  }
  return arr;
}
 
开发者ID:smarr,项目名称:SOMns,代码行数:19,代码来源:DoPrim.java


示例5: toNearRefWithResultPromise

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization(guards = {"isResultUsed()", "!isFarRefRcvr(args)", "!isPromiseRcvr(args)"})
public final SPromise toNearRefWithResultPromise(final Object[] args) {
  Actor current = EventualMessage.getActorCurrentMessageIsExecutionOn();

  SPromise result = SPromise.createPromise(current,
      false, promiseResolutionBreakpoint.executeShouldHalt(), source);
  SResolver resolver = SPromise.createResolver(result);

  DirectMessage msg = new DirectMessage(current, selector, args, current,
      resolver, onReceive,
      messageReceiverBreakpoint.executeShouldHalt(),
      promiseResolverBreakpoint.executeShouldHalt());

  if (VmSettings.ACTOR_TRACING) {
    ActorExecutionTrace.sendOperation(SendOp.ACTOR_MSG, msg.getMessageId(),
        current.getId());
  }
  current.send(msg, actorPool);

  return result;
}
 
开发者ID:smarr,项目名称:SOMns,代码行数:22,代码来源:EventualSendNode.java


示例6: doUncached

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization(replaces = "doCachedWithoutArgArr", guards = "argsArr == null")
@TruffleBoundary
public Object doUncached(final Object receiver, final SSymbol selector,
    final Object argsArr,
    @Cached("create()") final IndirectCallNode call) {
  SClass rcvrClass = Types.getClassOf(receiver);
  Dispatchable invokable = rcvrClass.lookupMessage(selector, AccessModifier.PUBLIC);

  Object[] arguments = {receiver};
  if (invokable != null) {
    return invokable.invoke(call, arguments);
  } else {
    return GenericDispatchNode.performDnu(arguments, receiver,
        rcvrClass, selector, call);
  }
}
 
开发者ID:smarr,项目名称:SOMns,代码行数:17,代码来源:AbstractSymbolDispatch.java


示例7: readObject

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization(contains = {"readLong", "readBoolean"})
protected Object readObject(VirtualFrame frame) {
    if (!frame.isObject(getSlot())) {
        CompilerDirectives.transferToInterpreter();
        Object result = frame.getValue(getSlot());
        frame.setObject(getSlot(), result);
        return result;
    }

    return FrameUtil.getObjectSafe(frame, getSlot());
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:12,代码来源:ReadLocalVariableNode.java


示例8: writeLong

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization(guards = "isLongOrIllegal(frame)")
protected long writeLong(VirtualFrame frame, long value) {
    getSlot().setKind(FrameSlotKind.Long);

    frame.setLong(getSlot(), value);
    return value;
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:8,代码来源:WriteLocalVariableNode.java


示例9: writeBoolean

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization(guards = "isBooleanOrIllegal(frame)")
protected boolean writeBoolean(VirtualFrame frame, boolean value) {
    getSlot().setKind(FrameSlotKind.Boolean);

    frame.setBoolean(getSlot(), value);
    return value;
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:8,代码来源:WriteLocalVariableNode.java


示例10: write

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization(contains = {"writeLong", "writeBoolean"})
protected Object write(VirtualFrame frame, Object value) {
    getSlot().setKind(FrameSlotKind.Object);

    frame.setObject(getSlot(), value);
    return value;
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:8,代码来源:WriteLocalVariableNode.java


示例11: read

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization(contains = { "readLong", "readDouble", "readObject" })
protected Object read(VirtualFrame virtualFrame) {
    try {
        return this.readUpStack(Frame::getValue, virtualFrame);
    } catch (FrameSlotTypeException e) {
        // FrameSlotTypeException not thrown
    }
    return null;
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:10,代码来源:ReadLexicalClosureVariableNode.java


示例12: doDirect

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的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


示例13: open

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization(rewriteOn = FrameSlotTypeException.class)
@CompilerDirectives.TruffleBoundary
public Closeable open(String path, Symbol direction) throws FrameSlotTypeException {
    File file = new File(path);
    if (!file.isAbsolute()) {
        MaterializedFrame globals = this.getContext().getGlobalFrame();
        FrameSlot homeDirectorySlot = globals.getFrameDescriptor().findFrameSlot("*home-directory*");
        String homeDirectory = (String) globals.getObject(homeDirectorySlot);
        file = new File(homeDirectory, path);
        //throw new RuntimeException("not implemented");
    }

    //System.out.println(file.getAbsoluteFile());

    try {
        switch (direction.getName()) {
            case "in":
                return new BufferedInputStream(new FileInputStream(file));
            case "out":
                return new BufferedOutputStream(new FileOutputStream(file));
        }
    } catch (FileNotFoundException e) {
        throw new RuntimeException("file not found:" + e);
    }

    throw new IllegalArgumentException("invalid direction");
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:28,代码来源:Open.java


示例14: close

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization
public Object close(Closeable stream) {
    try {
        stream.close();
    } catch (IOException e) {
        throw new RuntimeException("error closing stream:" + e);
    }
    // TODO: empty list?
    return null;
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:11,代码来源:Close.java


示例15: writeByte

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization
public long writeByte(long value, OutputStream stream) {
    try {
        stream.write((int) value);
        stream.flush();
        return value;
    } catch (IOException e) {
        throw new RuntimeException("write-byte: " + e);
    }
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:11,代码来源:WriteByte.java


示例16: readByte

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization
public long readByte(InputStream stream) {
    try {
        return (long)stream.read();
    } catch (IOException e) {
        throw new RuntimeException("read-byte: " + e);
    }
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:9,代码来源:ReadByte.java


示例17: stringToNumber

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization
public long stringToNumber(String s) {
    if (s.length() != 1) {
        throw new RuntimeException("string->n: not a unit string: " + s);
    }
    return s.charAt(0);
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:8,代码来源:StringToNumber.java


示例18: tail

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization
public String tail(String s) {
    if (s.length() < 1) {
        throw new RuntimeException("tlstr: too short: " + s);
    }
    return s.substring(1);
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:8,代码来源:Tail.java


示例19: setFast

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization(guards = "symbol == cachedSymbol", limit = "2")
public Object setFast(Symbol symbol, Object value,
                    @Cached("symbol") Symbol cachedSymbol,
                    @Cached("lookupFrameSlot(cachedSymbol)") FrameSlot cachedFrameSlot,
                    @Cached("getGlobalFrame()") MaterializedFrame cachedGlobalFrame) {
    cachedGlobalFrame.setObject(cachedFrameSlot, value);
    return value;
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:9,代码来源:Set.java


示例20: setSlow

import com.oracle.truffle.api.dsl.Specialization; //导入依赖的package包/类
@Specialization(replaces = "setFast")
public Object setSlow(Symbol symbol, Object value) {
    CompilerDirectives.transferToInterpreterAndInvalidate();

    FrameSlot frameSlot = lookupFrameSlot(symbol);
    this.getGlobalFrame().setObject(frameSlot, value);
    return value;
}
 
开发者ID:ragnard,项目名称:shen-truffle,代码行数:9,代码来源:Set.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EntitySnowman类代码示例发布时间:2022-05-23
下一篇:
Java RetryNoRetry类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap