All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jruby.truffle.interop.OutgoingForeignCallNodeGen Maven / Gradle / Ivy

The newest version!
// CheckStyle: start generated
package org.jruby.truffle.interop;

import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.dsl.internal.SpecializationNode;
import com.oracle.truffle.api.dsl.internal.SpecializedNode;
import com.oracle.truffle.api.dsl.internal.SuppressFBWarnings;
import com.oracle.truffle.api.frame.Frame;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import org.jruby.truffle.language.RubyNode;

@GeneratedBy(OutgoingForeignCallNode.class)
@SuppressFBWarnings("SA_LOCAL_SELF_COMPARISON")
public final class OutgoingForeignCallNodeGen extends OutgoingForeignCallNode implements SpecializedNode {

    @Child private RubyNode receiver_;
    @Child private RubyNode args_;
    @CompilationFinal private boolean excludeCallCached_;
    @Child private BaseNode_ specialization_;

    private OutgoingForeignCallNodeGen(String name, RubyNode receiver, RubyNode args) {
        super(name);
        this.receiver_ = receiver;
        this.args_ = args;
        this.specialization_ = UninitializedNode_.create(this);
    }

    @Override
    public NodeCost getCost() {
        return specialization_.getNodeCost();
    }

    @Override
    public Object executeCall(VirtualFrame frameValue, TruffleObject receiverValue, Object[] argsValue) {
        return specialization_.execute1(frameValue, receiverValue, argsValue);
    }

    @Override
    public Object execute(VirtualFrame frameValue) {
        return specialization_.execute0(frameValue);
    }

    @Override
    public void executeVoid(VirtualFrame frameValue) {
        specialization_.executeVoid(frameValue);
        return;
    }

    @Override
    public SpecializationNode getSpecializationNode() {
        return specialization_;
    }

    @Override
    public Node deepCopy() {
        return SpecializationNode.updateRoot(super.deepCopy());
    }

    public static OutgoingForeignCallNode create(String name, RubyNode receiver, RubyNode args) {
        return new OutgoingForeignCallNodeGen(name, receiver, args);
    }

    @GeneratedBy(OutgoingForeignCallNode.class)
    private abstract static class BaseNode_ extends SpecializationNode {

        @CompilationFinal protected OutgoingForeignCallNodeGen root;

        BaseNode_(OutgoingForeignCallNodeGen root, int index) {
            super(index);
            this.root = root;
        }

        @Override
        protected final void setRoot(Node root) {
            this.root = (OutgoingForeignCallNodeGen) root;
        }

        @Override
        protected final Node[] getSuppliedChildren() {
            return new Node[] {root.receiver_, root.args_};
        }

        @Override
        public final Object acceptAndExecute(Frame frameValue, Object receiverValue, Object argsValue) {
            return this.execute_((VirtualFrame) frameValue, receiverValue, argsValue);
        }

        public abstract Object execute_(VirtualFrame frameValue, Object receiverValue, Object argsValue);

        public Object execute1(VirtualFrame frameValue, TruffleObject receiverValue, Object[] argsValue) {
            return execute_(frameValue, receiverValue, argsValue);
        }

        public Object execute0(VirtualFrame frameValue) {
            Object receiverValue_ = root.receiver_.execute(frameValue);
            Object argsValue_ = root.args_.execute(frameValue);
            return execute_(frameValue, receiverValue_, argsValue_);
        }

        public void executeVoid(VirtualFrame frameValue) {
            execute0(frameValue);
            return;
        }

        @Override
        protected final SpecializationNode createNext(Frame frameValue, Object receiverValue, Object argsValue) {
            if (receiverValue instanceof TruffleObject && argsValue instanceof Object[]) {
                Object[] argsValue_ = (Object[]) argsValue;
                int cachedArgsLength1 = (argsValue_.length);
                if ((argsValue_.length == cachedArgsLength1)) {
                    if (!root.excludeCallCached_) {
                        OutgoingNode outgoingNode1 = (root.createHelperNode(cachedArgsLength1));
                        RubyToForeignNode[] toForeignNodes1 = (root.createToForeignNodes(cachedArgsLength1));
                        ForeignToRubyNode toRubyNode1 = (ForeignToRubyNode.create());
                        SpecializationNode s = CallCachedNode_.create(root, cachedArgsLength1, outgoingNode1, toForeignNodes1, toRubyNode1);
                        if (countSame(s) < (root.getCacheLimit())) {
                            return s;
                        }
                    }
                }
                ForeignToRubyNode toRubyNode2 = (ForeignToRubyNode.create());
                root.excludeCallCached_ = true;
                return CallUncachedNode_.create(root, toRubyNode2);
            }
            return null;
        }

        @Override
        protected final SpecializationNode createPolymorphic() {
            return PolymorphicNode_.create(root);
        }

        protected final BaseNode_ getNext() {
            return (BaseNode_) this.next;
        }

    }
    @GeneratedBy(OutgoingForeignCallNode.class)
    private static final class UninitializedNode_ extends BaseNode_ {

        UninitializedNode_(OutgoingForeignCallNodeGen root) {
            super(root, 2147483647);
        }

        @Override
        public Object execute_(VirtualFrame frameValue, Object receiverValue, Object argsValue) {
            return uninitialized(frameValue, receiverValue, argsValue);
        }

        static BaseNode_ create(OutgoingForeignCallNodeGen root) {
            return new UninitializedNode_(root);
        }

    }
    @GeneratedBy(OutgoingForeignCallNode.class)
    private static final class PolymorphicNode_ extends BaseNode_ {

        PolymorphicNode_(OutgoingForeignCallNodeGen root) {
            super(root, 0);
        }

        @Override
        public SpecializationNode merge(SpecializationNode newNode, Frame frameValue, Object receiverValue, Object argsValue) {
            return polymorphicMerge(newNode, super.merge(newNode, frameValue, receiverValue, argsValue));
        }

        @Override
        public Object execute_(VirtualFrame frameValue, Object receiverValue, Object argsValue) {
            return getNext().execute_(frameValue, receiverValue, argsValue);
        }

        static BaseNode_ create(OutgoingForeignCallNodeGen root) {
            return new PolymorphicNode_(root);
        }

    }
    @GeneratedBy(methodName = "callCached(VirtualFrame, TruffleObject, Object[], int, OutgoingNode, RubyToForeignNode[], ForeignToRubyNode)", value = OutgoingForeignCallNode.class)
    private static final class CallCachedNode_ extends BaseNode_ {

        private final int cachedArgsLength;
        @Child private OutgoingNode outgoingNode;
        @Children private final RubyToForeignNode[] toForeignNodes;
        @Child private ForeignToRubyNode toRubyNode;

        CallCachedNode_(OutgoingForeignCallNodeGen root, int cachedArgsLength, OutgoingNode outgoingNode, RubyToForeignNode[] toForeignNodes, ForeignToRubyNode toRubyNode) {
            super(root, 1);
            this.cachedArgsLength = cachedArgsLength;
            this.outgoingNode = outgoingNode;
            this.toForeignNodes = toForeignNodes;
            this.toRubyNode = toRubyNode;
        }

        @Override
        public SpecializationNode merge(SpecializationNode newNode, Frame frameValue, Object receiverValue, Object argsValue) {
            if (newNode.getClass() == CallUncachedNode_.class) {
                removeSame("Contained by callUncached(VirtualFrame, TruffleObject, Object[], ForeignToRubyNode)");
            }
            return super.merge(newNode, frameValue, receiverValue, argsValue);
        }

        @Override
        public boolean isIdentical(SpecializationNode other, Frame frameValue, Object receiverValue, Object argsValue) {
            if (receiverValue instanceof TruffleObject && argsValue instanceof Object[]) {
                Object[] argsValue_ = (Object[]) argsValue;
                if ((argsValue_.length == this.cachedArgsLength)) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public Object execute1(VirtualFrame frameValue, TruffleObject receiverValue, Object[] argsValue) {
            if ((argsValue.length == this.cachedArgsLength)) {
                return root.callCached(frameValue, receiverValue, argsValue, this.cachedArgsLength, this.outgoingNode, this.toForeignNodes, this.toRubyNode);
            }
            return getNext().execute1(frameValue, receiverValue, argsValue);
        }

        @Override
        public Object execute_(VirtualFrame frameValue, Object receiverValue, Object argsValue) {
            if (receiverValue instanceof TruffleObject && argsValue instanceof Object[]) {
                TruffleObject receiverValue_ = (TruffleObject) receiverValue;
                Object[] argsValue_ = (Object[]) argsValue;
                if ((argsValue_.length == this.cachedArgsLength)) {
                    return root.callCached(frameValue, receiverValue_, argsValue_, this.cachedArgsLength, this.outgoingNode, this.toForeignNodes, this.toRubyNode);
                }
            }
            return getNext().execute_(frameValue, receiverValue, argsValue);
        }

        static BaseNode_ create(OutgoingForeignCallNodeGen root, int cachedArgsLength, OutgoingNode outgoingNode, RubyToForeignNode[] toForeignNodes, ForeignToRubyNode toRubyNode) {
            return new CallCachedNode_(root, cachedArgsLength, outgoingNode, toForeignNodes, toRubyNode);
        }

    }
    @GeneratedBy(methodName = "callUncached(VirtualFrame, TruffleObject, Object[], ForeignToRubyNode)", value = OutgoingForeignCallNode.class)
    private static final class CallUncachedNode_ extends BaseNode_ {

        @Child private ForeignToRubyNode toRubyNode;

        CallUncachedNode_(OutgoingForeignCallNodeGen root, ForeignToRubyNode toRubyNode) {
            super(root, 2);
            this.toRubyNode = toRubyNode;
        }

        @Override
        public Object execute1(VirtualFrame frameValue, TruffleObject receiverValue, Object[] argsValue) {
            return root.callUncached(frameValue, receiverValue, argsValue, this.toRubyNode);
        }

        @Override
        public Object execute_(VirtualFrame frameValue, Object receiverValue, Object argsValue) {
            if (receiverValue instanceof TruffleObject && argsValue instanceof Object[]) {
                TruffleObject receiverValue_ = (TruffleObject) receiverValue;
                Object[] argsValue_ = (Object[]) argsValue;
                return root.callUncached(frameValue, receiverValue_, argsValue_, this.toRubyNode);
            }
            return getNext().execute_(frameValue, receiverValue, argsValue);
        }

        static BaseNode_ create(OutgoingForeignCallNodeGen root, ForeignToRubyNode toRubyNode) {
            return new CallUncachedNode_(root, toRubyNode);
        }

    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy