@SuppressWarnings("try") @Override protected Object compute() { return messageCallNode.call(arguments); } };
/** * Calls the inner {@link CallTarget} returned by {@link #getCurrentCallTarget()}. * * @param arguments the arguments that should be passed to the callee * @return the return result of the call * @since 0.23 */ public Object call(Object[] arguments) { // TODO change to varargs as soon as #call(VirtualFrame, Object[] will removed. return call(LEGACY_FRAME, arguments); }
/** * Calls the inner {@link CallTarget} returned by {@link #getCurrentCallTarget()}. * * @param arguments the arguments that should be passed to the callee * @return the return result of the call * @since 0.23 */ public Object call(Object[] arguments) { // TODO change to varargs as soon as #call(VirtualFrame, Object[] will removed. return call(LEGACY_FRAME, arguments); }
/** * Calls the inner {@link CallTarget} returned by {@link #getCurrentCallTarget()}. * * @param arguments the arguments that should be passed to the callee * @return the return result of the call * @since 0.8 or earlier * @deprecated use call without frame instead */ @Deprecated public Object call(@SuppressWarnings("unused") VirtualFrame frame, Object[] arguments) { return call(arguments); }
/** * Calls the inner {@link CallTarget} returned by {@link #getCurrentCallTarget()}. * * @param arguments the arguments that should be passed to the callee * @return the return result of the call * @since 0.8 or earlier * @deprecated use call without frame instead */ @Deprecated public Object call(@SuppressWarnings("unused") VirtualFrame frame, Object[] arguments) { return call(arguments); }
protected static boolean acceptCached(TruffleObject receiver, ForeignAccess foreignAccess, DirectCallNode canHandleCall) { if (canHandleCall != null) { return (boolean) canHandleCall.call(new Object[]{receiver}); } else if (foreignAccess != null) { return foreignAccess.canHandle(receiver); } else { return false; } }
@Override protected Object executeDispatch(VirtualFrame frame, CallTarget callTarget, Object[] arguments) { if (this.cachedCallTarget == callTarget) { return this.callCachedTargetNode.call(frame, arguments); } return this.nextNode.executeDispatch(frame, callTarget, arguments); } }
protected static boolean acceptCached(TruffleObject receiver, ForeignAccess foreignAccess, DirectCallNode canHandleCall) { if (canHandleCall != null) { return (boolean) canHandleCall.call(new Object[]{receiver}); } else if (foreignAccess != null) { return foreignAccess.canHandle(receiver); } else { return false; } }
private Object doAccess(VirtualFrame frame, TruffleObject receiver, Object[] arguments) { if (languageCheck.test(receiver)) { return callTarget.call(frame, ForeignAccessArguments.create(receiver, arguments)); } else { return doNext(frame, receiver, arguments); } }
@Specialization(guards = {"target == cachedTarget"}) Object executeDirect(@SuppressWarnings("unused") CallTarget target, Object[] args, @Cached("target") @SuppressWarnings("unused") CallTarget cachedTarget, @Cached("create(cachedTarget)") DirectCallNode callNode) { return callNode.call(args); }
@Override protected Object executeDispatch(VirtualFrame frame, LuaFunction function, Object[] arguments) { if (this.cachedMethod == function) { try { cachedTargetStable.check(); return callCachedTargetNode.call(frame, arguments); } catch (InvalidAssumptionException ex) { replace(nextNode); } } return nextNode.executeDispatch(frame, function, arguments); } }
@SuppressWarnings("unused") @Specialization(guards = "acceptCached(receiver, foreignAccess, canHandleCall)", limit = "CACHE_SIZE") protected static Object doCached(TruffleObject receiver, Object[] arguments, @Cached("receiver.getForeignAccess()") ForeignAccess foreignAccess, @Cached("createInlinedCallNode(createMessageTarget(foreignAccess))") DirectCallNode sendMessageCall, @Cached("createCanHandleInlinedCallNode(foreignAccess, receiver)") DirectCallNode canHandleCall) { return sendMessageCall.call(arguments); }
@SuppressWarnings("unused") @Specialization(guards = "acceptCached(receiver, foreignAccess, canHandleCall)", limit = "CACHE_SIZE") protected static Object doCached(TruffleObject receiver, Object[] arguments, @Cached("receiver.getForeignAccess()") ForeignAccess foreignAccess, @Cached("createInlinedCallNode(createMessageTarget(foreignAccess))") DirectCallNode sendMessageCall, @Cached("createInlinedCallNode(createCanHandleTarget(foreignAccess))") DirectCallNode canHandleCall) { return sendMessageCall.call(arguments); }
@Override protected Object executeImpl(VirtualFrame frame) { if (call == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); initialize(); } Object result = call.call(EMPTY_ARRAY); // TODO null is not valid value, wrap it using java interop // we should make this a strong check. if (result == null) { result = NULL_VALUE; } if (source.isInteractive()) { printResult(result); } return result; }
@Override public Object execute(VirtualFrame frame) { EngineTruffleObject engineTruffleObject = (EngineTruffleObject) ForeignAccess.getReceiver(frame); Object[] oldArguments = frame.getArguments(); final Object[] arguments = new Object[oldArguments.length]; TruffleObject delegate = engineTruffleObject.getDelegate(); arguments[0] = delegate; System.arraycopy(oldArguments, 1, arguments, 1, oldArguments.length - 1); Object res; if (engine.executor() == null) { res = messageCallNode.call(arguments); } else { res = invokeOnExecutor(arguments); } return wrap(engine, res); }
@Specialization(guards = "receiver == cachedReceiver", limit = "4") public RegexResult doCached(@SuppressWarnings("unused") CompiledRegex receiver, RegexObject regexObject, Object input, Object fromIndex, @Cached("create()") ExpectStringOrTruffleObjectNode expectStringOrTruffleObjectNode, @Cached("create()") RegexParamToLongNode expectNumberNode, @SuppressWarnings("unused") @Cached("receiver") CompiledRegex cachedReceiver, @Cached("create(cachedReceiver.getRegexCallTarget())") DirectCallNode directCallNode) { final Object unboxedInput = expectStringOrTruffleObjectNode.execute(input); final long fromIndexLong = expectNumberNode.execute(fromIndex); if (fromIndexLong > Integer.MAX_VALUE) { return RegexResult.NO_MATCH; } return (RegexResult) directCallNode.call(new Object[]{regexObject, unboxedInput, (int) fromIndexLong}); }
boolean executeBreakCondition(VirtualFrame frame, DebuggerSession[] sessions) { if ((conditionSnippet == null && conditionCallNode == null) || !conditionUnchanged.isValid()) { CompilerDirectives.transferToInterpreterAndInvalidate(); initializeConditional(frame.materialize()); } Object result; try { suspensionEnabledNode.execute(false, sessions); if (conditionSnippet != null) { result = conditionSnippet.execute(frame); } else { result = conditionCallNode.call(EMPTY_ARRAY); } } finally { suspensionEnabledNode.execute(true, sessions); } if (!(result instanceof Boolean)) { CompilerDirectives.transferToInterpreter(); throw new IllegalArgumentException("Unsupported return type " + result + " in condition."); } return (Boolean) result; }
boolean executeBreakCondition(VirtualFrame frame, DebuggerSession[] sessions) { if ((conditionSnippet == null && conditionCallNode == null) || !conditionUnchanged.isValid()) { CompilerDirectives.transferToInterpreterAndInvalidate(); initializeConditional(frame.materialize()); } Object result; try { suspensionEnabledNode.execute(false, sessions); if (conditionSnippet != null) { result = conditionSnippet.execute(frame); } else { result = conditionCallNode.call(EMPTY_ARRAY); } } finally { suspensionEnabledNode.execute(true, sessions); } if (!(result instanceof Boolean)) { CompilerDirectives.transferToInterpreter(); throw new IllegalArgumentException("Unsupported return type " + result + " in condition."); } return (Boolean) result; }