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

com.oracle.truffle.nfi.CallSignatureNodeFactory Maven / Gradle / Ivy

// CheckStyle: start generated
package com.oracle.truffle.nfi;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.TruffleLanguage;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.GenerateAOT;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.dsl.UnsupportedSpecializationException;
import com.oracle.truffle.api.interop.ArityException;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.interop.UnsupportedTypeException;
import com.oracle.truffle.api.library.LibraryFactory;
import com.oracle.truffle.api.nodes.DenyReplace;
import com.oracle.truffle.api.nodes.EncapsulatingNodeReference;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.IndirectCallNode;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.NodeUtil;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.nfi.CallSignatureNode.BackendSymbolUnwrapNode;
import com.oracle.truffle.nfi.CallSignatureNode.CachedCallSignatureNode;
import com.oracle.truffle.nfi.CallSignatureNode.OptimizedCallClosureNode;
import com.oracle.truffle.nfi.CallSignatureNode.OptimizedCallSignatureNode;
import com.oracle.truffle.nfi.ConvertTypeNode.ConvertFromNativeNode;
import com.oracle.truffle.nfi.ConvertTypeNode.ConvertToNativeNode;
import com.oracle.truffle.nfi.ConvertTypeNodeFactory.ConvertFromNativeNodeGen;
import com.oracle.truffle.nfi.ConvertTypeNodeFactory.ConvertToNativeNodeGen;
import com.oracle.truffle.nfi.NFISignature.ArgsCachedState;
import com.oracle.truffle.nfi.NFISignature.SignatureCachedState;
import com.oracle.truffle.nfi.NFIType.TypeCachedState;
import com.oracle.truffle.nfi.backend.spi.NFIBackendSignatureLibrary;
import java.lang.invoke.VarHandle;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

@GeneratedBy(CallSignatureNode.class)
@SuppressWarnings("unused")
final class CallSignatureNodeFactory {

    private static final LibraryFactory N_F_I_BACKEND_SIGNATURE_LIBRARY_ = LibraryFactory.resolve(NFIBackendSignatureLibrary.class);
    private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class);

    @GeneratedBy(CachedCallSignatureNode.class)
    static final class CachedCallSignatureNodeGen extends CachedCallSignatureNode implements GenerateAOT.Provider {

        private static final Uncached UNCACHED = new Uncached();

        @CompilationFinal private volatile int state_0_;
        @CompilationFinal private volatile int exclude_;
        @Child private OptimizedDirectData optimizedDirect_cache;
        @Child private IndirectCallNode optimizedIndirect_call_;
        @Child private SlowPathData slowPath_cache;

        private CachedCallSignatureNodeGen() {
        }

        @ExplodeLoop
        @Override
        Object execute(NFISignature arg0Value, Object arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
            int state_0 = this.state_0_;
            if (CompilerDirectives.inInterpreter() && (state_0 & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
            }
            if ((state_0 & 0b1110) != 0 /* is-state_0 doOptimizedDirect(NFISignature, Object, Object[], SignatureCachedState, CallSignatureNode) || doOptimizedIndirect(NFISignature, Object, Object[], IndirectCallNode) || doSlowPath(NFISignature, Object, Object[], BranchProfile, ConvertToNativeNode, ConvertFromNativeNode, NFIBackendSignatureLibrary, BackendSymbolUnwrapNode) */) {
                if ((state_0 & 0b10) != 0 /* is-state_0 doOptimizedDirect(NFISignature, Object, Object[], SignatureCachedState, CallSignatureNode) */) {
                    OptimizedDirectData s0_ = this.optimizedDirect_cache;
                    while (s0_ != null) {
                        assert (s0_.cachedState_ != null);
                        if ((arg0Value.cachedState == s0_.cachedState_)) {
                            return doOptimizedDirect(arg0Value, arg1Value, arg2Value, s0_.cachedState_, s0_.call_);
                        }
                        s0_ = s0_.next_;
                    }
                }
                if ((state_0 & 0b100) != 0 /* is-state_0 doOptimizedIndirect(NFISignature, Object, Object[], IndirectCallNode) */) {
                    if ((arg0Value.cachedState != null)) {
                        return doOptimizedIndirect(arg0Value, arg1Value, arg2Value, this.optimizedIndirect_call_);
                    }
                }
                if ((state_0 & 0b1000) != 0 /* is-state_0 doSlowPath(NFISignature, Object, Object[], BranchProfile, ConvertToNativeNode, ConvertFromNativeNode, NFIBackendSignatureLibrary, BackendSymbolUnwrapNode) */) {
                    SlowPathData s2_ = this.slowPath_cache;
                    if (s2_ != null) {
                        if ((arg0Value.cachedState == null)) {
                            return doSlowPath(arg0Value, arg1Value, arg2Value, s2_.exception_, s2_.convertArg_, s2_.convertRet_, s2_.nativeLibrary_, s2_.backendSymbolUnwrapNode_);
                        }
                    }
                }
            }
            CompilerDirectives.transferToInterpreterAndInvalidate();
            return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
        }

        private Object executeAndSpecialize(NFISignature arg0Value, Object arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
            Lock lock = getLock();
            boolean hasLock = true;
            lock.lock();
            try {
                if ((this.state_0_ & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                    this.resetAOT_();
                }
                int state_0 = this.state_0_;
                int exclude = this.exclude_;
                if ((exclude) == 0 /* is-not-exclude doOptimizedDirect(NFISignature, Object, Object[], SignatureCachedState, CallSignatureNode) */) {
                    int count0_ = 0;
                    OptimizedDirectData s0_ = this.optimizedDirect_cache;
                    if ((state_0 & 0b10) != 0 /* is-state_0 doOptimizedDirect(NFISignature, Object, Object[], SignatureCachedState, CallSignatureNode) */) {
                        while (s0_ != null) {
                            assert (s0_.cachedState_ != null);
                            if ((arg0Value.cachedState == s0_.cachedState_)) {
                                break;
                            }
                            s0_ = s0_.next_;
                            count0_++;
                        }
                    }
                    if (s0_ == null) {
                        {
                            SignatureCachedState cachedState__ = (arg0Value.cachedState);
                            if ((cachedState__ != null)) {
                                // assert (arg0Value.cachedState == cachedState__);
                                if (count0_ < (3)) {
                                    s0_ = super.insert(new OptimizedDirectData(optimizedDirect_cache));
                                    s0_.cachedState_ = cachedState__;
                                    s0_.call_ = s0_.insertAccessor((cachedState__.createOptimizedSignatureCall()));
                                    VarHandle.storeStoreFence();
                                    this.optimizedDirect_cache = s0_;
                                    this.state_0_ = state_0 = state_0 | 0b10 /* add-state_0 doOptimizedDirect(NFISignature, Object, Object[], SignatureCachedState, CallSignatureNode) */;
                                }
                            }
                        }
                    }
                    if (s0_ != null) {
                        lock.unlock();
                        hasLock = false;
                        return doOptimizedDirect(arg0Value, arg1Value, arg2Value, s0_.cachedState_, s0_.call_);
                    }
                }
                if ((arg0Value.cachedState != null)) {
                    this.optimizedIndirect_call_ = super.insert((IndirectCallNode.create()));
                    this.exclude_ = exclude = exclude | 0b1 /* add-exclude doOptimizedDirect(NFISignature, Object, Object[], SignatureCachedState, CallSignatureNode) */;
                    this.optimizedDirect_cache = null;
                    state_0 = state_0 & 0xfffffffd /* remove-state_0 doOptimizedDirect(NFISignature, Object, Object[], SignatureCachedState, CallSignatureNode) */;
                    this.state_0_ = state_0 = state_0 | 0b100 /* add-state_0 doOptimizedIndirect(NFISignature, Object, Object[], IndirectCallNode) */;
                    lock.unlock();
                    hasLock = false;
                    return doOptimizedIndirect(arg0Value, arg1Value, arg2Value, this.optimizedIndirect_call_);
                }
                if ((arg0Value.cachedState == null)) {
                    SlowPathData s2_ = super.insert(new SlowPathData());
                    s2_.exception_ = (BranchProfile.create());
                    s2_.convertArg_ = s2_.insertAccessor((ConvertToNativeNodeGen.create()));
                    s2_.convertRet_ = s2_.insertAccessor((ConvertFromNativeNodeGen.create()));
                    s2_.nativeLibrary_ = s2_.insertAccessor((N_F_I_BACKEND_SIGNATURE_LIBRARY_.createDispatched(3)));
                    s2_.backendSymbolUnwrapNode_ = s2_.insertAccessor((BackendSymbolUnwrapNodeGen.create()));
                    VarHandle.storeStoreFence();
                    this.slowPath_cache = s2_;
                    this.state_0_ = state_0 = state_0 | 0b1000 /* add-state_0 doSlowPath(NFISignature, Object, Object[], BranchProfile, ConvertToNativeNode, ConvertFromNativeNode, NFIBackendSignatureLibrary, BackendSymbolUnwrapNode) */;
                    lock.unlock();
                    hasLock = false;
                    return doSlowPath(arg0Value, arg1Value, arg2Value, s2_.exception_, s2_.convertArg_, s2_.convertRet_, s2_.nativeLibrary_, s2_.backendSymbolUnwrapNode_);
                }
                throw new UnsupportedSpecializationException(this, new Node[] {null, null, null}, arg0Value, arg1Value, arg2Value);
            } finally {
                if (hasLock) {
                    lock.unlock();
                }
            }
        }

        @Override
        public NodeCost getCost() {
            int state_0 = this.state_0_;
            if ((state_0 & 0b1110) == 0) {
                return NodeCost.UNINITIALIZED;
            } else {
                if (((state_0 & 0b1110) & ((state_0 & 0b1110) - 1)) == 0 /* is-single-state_0  */) {
                    OptimizedDirectData s0_ = this.optimizedDirect_cache;
                    if ((s0_ == null || s0_.next_ == null)) {
                        return NodeCost.MONOMORPHIC;
                    }
                }
            }
            return NodeCost.POLYMORPHIC;
        }

        @Override
        public void prepareForAOT(TruffleLanguage language, RootNode root) {
            assert !isAdoptable() || ((ReentrantLock) getLock()).isHeldByCurrentThread() : "During prepare AST lock must be held.";
            int state_0 = this.state_0_;
            if ((state_0 & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                return;
            }
            this.optimizedIndirect_call_ = super.insert((IndirectCallNode.create()));
            this.exclude_ = this.exclude_ | 0b1 /* add-exclude doOptimizedDirect(NFISignature, Object, Object[], SignatureCachedState, CallSignatureNode) */;
            this.optimizedDirect_cache = null;
            state_0 = state_0 & 0xfffffffd /* remove-state_0 doOptimizedDirect(NFISignature, Object, Object[], SignatureCachedState, CallSignatureNode) */;
            SlowPathData s2_ = super.insert(new SlowPathData());
            s2_.exception_ = (BranchProfile.create());
            s2_.convertArg_ = s2_.insertAccessor((ConvertToNativeNodeGen.create()));
            s2_.convertRet_ = s2_.insertAccessor((ConvertFromNativeNodeGen.create()));
            s2_.nativeLibrary_ = s2_.insertAccessor((N_F_I_BACKEND_SIGNATURE_LIBRARY_.createDispatched(3)));
            s2_.backendSymbolUnwrapNode_ = s2_.insertAccessor((BackendSymbolUnwrapNodeGen.create()));
            s2_.exception_.disable();
            VarHandle.storeStoreFence();
            this.slowPath_cache = s2_;
            assert NodeUtil.assertRecursion(s2_.convertArg_, 1);
            ((GenerateAOT.Provider) s2_.convertArg_).prepareForAOT(language, root);
            assert NodeUtil.assertRecursion(s2_.convertRet_, 1);
            ((GenerateAOT.Provider) s2_.convertRet_).prepareForAOT(language, root);
            if (s2_.nativeLibrary_ instanceof GenerateAOT.Provider) {
                assert NodeUtil.assertRecursion(s2_.nativeLibrary_, 1);
                ((GenerateAOT.Provider) s2_.nativeLibrary_).prepareForAOT(language, root);
            }
            assert NodeUtil.assertRecursion(s2_.backendSymbolUnwrapNode_, 1);
            ((GenerateAOT.Provider) s2_.backendSymbolUnwrapNode_).prepareForAOT(language, root);
            this.state_0_ = state_0 = state_0 | 0b1101 /* add-state_0 AOT-prepared, doOptimizedIndirect(NFISignature, Object, Object[], IndirectCallNode), doSlowPath(NFISignature, Object, Object[], BranchProfile, ConvertToNativeNode, ConvertFromNativeNode, NFIBackendSignatureLibrary, BackendSymbolUnwrapNode) */;
        }

        private void resetAOT_() {
            int state_0 = this.state_0_;
            if (((state_0 & 0b1)) == 0 /* is-not-state_0 AOT-prepared */) {
                return;
            }
            if ((state_0 & 0b1000) != 0 /* is-state_0 doSlowPath(NFISignature, Object, Object[], BranchProfile, ConvertToNativeNode, ConvertFromNativeNode, NFIBackendSignatureLibrary, BackendSymbolUnwrapNode) */) {
                this.slowPath_cache.exception_.reset();
            }
            this.state_0_ = 0;
            this.exclude_ = 0;
            this.slowPath_cache = null;
        }

        public static CachedCallSignatureNode create() {
            return new CachedCallSignatureNodeGen();
        }

        public static CachedCallSignatureNode getUncached() {
            return CachedCallSignatureNodeGen.UNCACHED;
        }

        @GeneratedBy(CachedCallSignatureNode.class)
        private static final class OptimizedDirectData extends Node {

            @Child OptimizedDirectData next_;
            @CompilationFinal SignatureCachedState cachedState_;
            @Child CallSignatureNode call_;

            OptimizedDirectData(OptimizedDirectData next_) {
                this.next_ = next_;
            }

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

             T insertAccessor(T node) {
                return super.insert(node);
            }

        }
        @GeneratedBy(CachedCallSignatureNode.class)
        private static final class SlowPathData extends Node {

            @CompilationFinal BranchProfile exception_;
            @Child ConvertToNativeNode convertArg_;
            @Child ConvertFromNativeNode convertRet_;
            @Child NFIBackendSignatureLibrary nativeLibrary_;
            @Child BackendSymbolUnwrapNode backendSymbolUnwrapNode_;

            SlowPathData() {
            }

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

             T insertAccessor(T node) {
                return super.insert(node);
            }

        }
        @GeneratedBy(CachedCallSignatureNode.class)
        @DenyReplace
        private static final class Uncached extends CachedCallSignatureNode {

            @TruffleBoundary
            @Override
            Object execute(NFISignature arg0Value, Object arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
                if ((arg0Value.cachedState != null)) {
                    return doOptimizedIndirect(arg0Value, arg1Value, arg2Value, (IndirectCallNode.getUncached()));
                }
                if ((arg0Value.cachedState == null)) {
                    return doSlowPath(arg0Value, arg1Value, arg2Value, (BranchProfile.getUncached()), (ConvertToNativeNodeGen.getUncached()), (ConvertFromNativeNodeGen.getUncached()), (N_F_I_BACKEND_SIGNATURE_LIBRARY_.getUncached()), (BackendSymbolUnwrapNodeGen.getUncached()));
                }
                throw new UnsupportedSpecializationException(this, new Node[] {null, null, null}, arg0Value, arg1Value, arg2Value);
            }

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

            @Override
            public boolean isAdoptable() {
                return false;
            }

        }
    }
    @GeneratedBy(OptimizedCallSignatureNode.class)
    static final class OptimizedCallSignatureNodeGen extends OptimizedCallSignatureNode implements GenerateAOT.Provider {

        @CompilationFinal private volatile int state_0_;
        @Child private CallData call_cache;

        private OptimizedCallSignatureNodeGen(TypeCachedState retType, ArgsCachedState argsState) {
            super(retType, argsState);
        }

        @Override
        Object execute(NFISignature arg0Value, Object arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
            int state_0 = this.state_0_;
            if (CompilerDirectives.inInterpreter() && (state_0 & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
            }
            if ((state_0 & 0b10) != 0 /* is-state_0 doCall(NFISignature, Object, Object[], BranchProfile, NFIBackendSignatureLibrary, BackendSymbolUnwrapNode) */) {
                CallData s0_ = this.call_cache;
                if (s0_ != null) {
                    return doCall(arg0Value, arg1Value, arg2Value, s0_.exception_, s0_.backendLibrary_, s0_.backendSymbolUnwrapNode_);
                }
            }
            CompilerDirectives.transferToInterpreterAndInvalidate();
            return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
        }

        private Object executeAndSpecialize(NFISignature arg0Value, Object arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
            Lock lock = getLock();
            boolean hasLock = true;
            lock.lock();
            try {
                if ((this.state_0_ & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                    this.resetAOT_();
                }
                int state_0 = this.state_0_;
                CallData s0_ = super.insert(new CallData());
                s0_.exception_ = (BranchProfile.create());
                s0_.backendLibrary_ = s0_.insertAccessor((N_F_I_BACKEND_SIGNATURE_LIBRARY_.createDispatched(1)));
                s0_.backendSymbolUnwrapNode_ = s0_.insertAccessor((BackendSymbolUnwrapNodeGen.create()));
                VarHandle.storeStoreFence();
                this.call_cache = s0_;
                this.state_0_ = state_0 = state_0 | 0b10 /* add-state_0 doCall(NFISignature, Object, Object[], BranchProfile, NFIBackendSignatureLibrary, BackendSymbolUnwrapNode) */;
                lock.unlock();
                hasLock = false;
                return doCall(arg0Value, arg1Value, arg2Value, s0_.exception_, s0_.backendLibrary_, s0_.backendSymbolUnwrapNode_);
            } finally {
                if (hasLock) {
                    lock.unlock();
                }
            }
        }

        @Override
        public NodeCost getCost() {
            int state_0 = this.state_0_;
            if ((state_0 & 0b10) == 0) {
                return NodeCost.UNINITIALIZED;
            } else {
                return NodeCost.MONOMORPHIC;
            }
        }

        @Override
        public void prepareForAOT(TruffleLanguage language, RootNode root) {
            assert !isAdoptable() || ((ReentrantLock) getLock()).isHeldByCurrentThread() : "During prepare AST lock must be held.";
            int state_0 = this.state_0_;
            if ((state_0 & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                return;
            }
            CallData s0_ = super.insert(new CallData());
            s0_.exception_ = (BranchProfile.create());
            s0_.backendLibrary_ = s0_.insertAccessor((N_F_I_BACKEND_SIGNATURE_LIBRARY_.createDispatched(1)));
            s0_.backendSymbolUnwrapNode_ = s0_.insertAccessor((BackendSymbolUnwrapNodeGen.create()));
            s0_.exception_.disable();
            VarHandle.storeStoreFence();
            this.call_cache = s0_;
            if (s0_.backendLibrary_ instanceof GenerateAOT.Provider) {
                assert NodeUtil.assertRecursion(s0_.backendLibrary_, 1);
                ((GenerateAOT.Provider) s0_.backendLibrary_).prepareForAOT(language, root);
            }
            assert NodeUtil.assertRecursion(s0_.backendSymbolUnwrapNode_, 1);
            ((GenerateAOT.Provider) s0_.backendSymbolUnwrapNode_).prepareForAOT(language, root);
            this.state_0_ = state_0 = state_0 | 0b11 /* add-state_0 AOT-prepared, doCall(NFISignature, Object, Object[], BranchProfile, NFIBackendSignatureLibrary, BackendSymbolUnwrapNode) */;
        }

        private void resetAOT_() {
            int state_0 = this.state_0_;
            if (((state_0 & 0b1)) == 0 /* is-not-state_0 AOT-prepared */) {
                return;
            }
            if ((state_0 & 0b10) != 0 /* is-state_0 doCall(NFISignature, Object, Object[], BranchProfile, NFIBackendSignatureLibrary, BackendSymbolUnwrapNode) */) {
                this.call_cache.exception_.reset();
            }
            this.state_0_ = 0;
            this.call_cache = null;
        }

        public static OptimizedCallSignatureNode create(TypeCachedState retType, ArgsCachedState argsState) {
            return new OptimizedCallSignatureNodeGen(retType, argsState);
        }

        @GeneratedBy(OptimizedCallSignatureNode.class)
        private static final class CallData extends Node {

            @CompilationFinal BranchProfile exception_;
            @Child NFIBackendSignatureLibrary backendLibrary_;
            @Child BackendSymbolUnwrapNode backendSymbolUnwrapNode_;

            CallData() {
            }

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

             T insertAccessor(T node) {
                return super.insert(node);
            }

        }
    }
    @GeneratedBy(OptimizedCallClosureNode.class)
    static final class OptimizedCallClosureNodeGen extends OptimizedCallClosureNode implements GenerateAOT.Provider {

        @CompilationFinal private volatile int state_0_;
        @CompilationFinal private volatile int exclude_;
        @CompilationFinal private BranchProfile call0_exception_;
        @Child private InteropLibrary call0_interop_;
        @CompilationFinal private BranchProfile call1_exception_;

        private OptimizedCallClosureNodeGen(TypeCachedState retType, ArgsCachedState argsState) {
            super(retType, argsState);
        }

        @Override
        Object execute(NFISignature arg0Value, Object arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
            int state_0 = this.state_0_;
            if (CompilerDirectives.inInterpreter() && (state_0 & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
            }
            if ((state_0 & 0b110) != 0 /* is-state_0 doCall(NFISignature, Object, Object[], BranchProfile, InteropLibrary) || doCall(NFISignature, Object, Object[], BranchProfile, InteropLibrary) */) {
                if ((state_0 & 0b10) != 0 /* is-state_0 doCall(NFISignature, Object, Object[], BranchProfile, InteropLibrary) */) {
                    if ((this.call0_interop_.accepts(arg1Value))) {
                        return doCall(arg0Value, arg1Value, arg2Value, this.call0_exception_, this.call0_interop_);
                    }
                }
                if ((state_0 & 0b100) != 0 /* is-state_0 doCall(NFISignature, Object, Object[], BranchProfile, InteropLibrary) */) {
                    return this.call1Boundary(state_0, arg0Value, arg1Value, arg2Value);
                }
            }
            CompilerDirectives.transferToInterpreterAndInvalidate();
            return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
        }

        @SuppressWarnings("static-method")
        @TruffleBoundary
        private Object call1Boundary(int state_0, NFISignature arg0Value, Object arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
            EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
            Node prev_ = encapsulating_.set(this);
            try {
                {
                    InteropLibrary call1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                    return doCall(arg0Value, arg1Value, arg2Value, this.call1_exception_, call1_interop__);
                }
            } finally {
                encapsulating_.set(prev_);
            }
        }

        private Object executeAndSpecialize(NFISignature arg0Value, Object arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
            Lock lock = getLock();
            boolean hasLock = true;
            lock.lock();
            try {
                if ((this.state_0_ & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                    this.resetAOT_();
                }
                int state_0 = this.state_0_;
                int exclude = this.exclude_;
                if ((exclude) == 0 /* is-not-exclude doCall(NFISignature, Object, Object[], BranchProfile, InteropLibrary) */) {
                    boolean Call0_duplicateFound_ = false;
                    if ((state_0 & 0b10) != 0 /* is-state_0 doCall(NFISignature, Object, Object[], BranchProfile, InteropLibrary) */) {
                        if ((this.call0_interop_.accepts(arg1Value))) {
                            Call0_duplicateFound_ = true;
                        }
                    }
                    if (!Call0_duplicateFound_) {
                        // assert (this.call0_interop_.accepts(arg1Value));
                        if (((state_0 & 0b10)) == 0 /* is-not-state_0 doCall(NFISignature, Object, Object[], BranchProfile, InteropLibrary) */) {
                            this.call0_exception_ = (BranchProfile.create());
                            this.call0_interop_ = super.insert((INTEROP_LIBRARY_.create(arg1Value)));
                            this.state_0_ = state_0 = state_0 | 0b10 /* add-state_0 doCall(NFISignature, Object, Object[], BranchProfile, InteropLibrary) */;
                            Call0_duplicateFound_ = true;
                        }
                    }
                    if (Call0_duplicateFound_) {
                        lock.unlock();
                        hasLock = false;
                        return doCall(arg0Value, arg1Value, arg2Value, this.call0_exception_, this.call0_interop_);
                    }
                }
                {
                    InteropLibrary call1_interop__ = null;
                    {
                        EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                        Node prev_ = encapsulating_.set(this);
                        try {
                            this.call1_exception_ = (BranchProfile.create());
                            call1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                            this.exclude_ = exclude = exclude | 0b1 /* add-exclude doCall(NFISignature, Object, Object[], BranchProfile, InteropLibrary) */;
                            state_0 = state_0 & 0xfffffffd /* remove-state_0 doCall(NFISignature, Object, Object[], BranchProfile, InteropLibrary) */;
                            this.state_0_ = state_0 = state_0 | 0b100 /* add-state_0 doCall(NFISignature, Object, Object[], BranchProfile, InteropLibrary) */;
                            lock.unlock();
                            hasLock = false;
                            return doCall(arg0Value, arg1Value, arg2Value, this.call1_exception_, call1_interop__);
                        } finally {
                            encapsulating_.set(prev_);
                        }
                    }
                }
            } finally {
                if (hasLock) {
                    lock.unlock();
                }
            }
        }

        @Override
        public NodeCost getCost() {
            int state_0 = this.state_0_;
            if ((state_0 & 0b110) == 0) {
                return NodeCost.UNINITIALIZED;
            } else {
                if (((state_0 & 0b110) & ((state_0 & 0b110) - 1)) == 0 /* is-single-state_0  */) {
                    return NodeCost.MONOMORPHIC;
                }
            }
            return NodeCost.POLYMORPHIC;
        }

        @Override
        public void prepareForAOT(TruffleLanguage language, RootNode root) {
            assert !isAdoptable() || ((ReentrantLock) getLock()).isHeldByCurrentThread() : "During prepare AST lock must be held.";
            int state_0 = this.state_0_;
            if ((state_0 & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                return;
            }
            this.state_0_ = state_0 = state_0 | 0b1 /* add-state_0 AOT-prepared */;
        }

        private void resetAOT_() {
            int state_0 = this.state_0_;
            if (((state_0 & 0b1)) == 0 /* is-not-state_0 AOT-prepared */) {
                return;
            }
            this.state_0_ = 0;
            this.exclude_ = 0;
        }

        public static OptimizedCallClosureNode create(TypeCachedState retType, ArgsCachedState argsState) {
            return new OptimizedCallClosureNodeGen(retType, argsState);
        }

    }
    @GeneratedBy(BackendSymbolUnwrapNode.class)
    static final class BackendSymbolUnwrapNodeGen extends BackendSymbolUnwrapNode implements GenerateAOT.Provider {

        private static final Uncached UNCACHED = new Uncached();

        @CompilationFinal private int state_0_;

        private BackendSymbolUnwrapNodeGen() {
        }

        @Override
        Object execute(Object arg0Value) {
            int state_0 = this.state_0_;
            if (CompilerDirectives.inInterpreter() && (state_0 & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                return executeAndSpecialize(arg0Value);
            }
            if ((state_0 & 0b10) != 0 /* is-state_0 unwrapNFISymbol(NFISymbol) */ && arg0Value instanceof NFISymbol) {
                NFISymbol arg0Value_ = (NFISymbol) arg0Value;
                return unwrapNFISymbol(arg0Value_);
            }
            if ((state_0 & 0b100) != 0 /* is-state_0 noUnwrap(Object) */) {
                if (fallbackGuard_(state_0, arg0Value)) {
                    return noUnwrap(arg0Value);
                }
            }
            CompilerDirectives.transferToInterpreterAndInvalidate();
            return executeAndSpecialize(arg0Value);
        }

        private Object executeAndSpecialize(Object arg0Value) {
            if ((this.state_0_ & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                this.resetAOT_();
            }
            int state_0 = this.state_0_;
            if (arg0Value instanceof NFISymbol) {
                NFISymbol arg0Value_ = (NFISymbol) arg0Value;
                this.state_0_ = state_0 = state_0 | 0b10 /* add-state_0 unwrapNFISymbol(NFISymbol) */;
                return unwrapNFISymbol(arg0Value_);
            }
            this.state_0_ = state_0 = state_0 | 0b100 /* add-state_0 noUnwrap(Object) */;
            return noUnwrap(arg0Value);
        }

        @Override
        public NodeCost getCost() {
            int state_0 = this.state_0_;
            if ((state_0 & 0b110) == 0) {
                return NodeCost.UNINITIALIZED;
            } else {
                if (((state_0 & 0b110) & ((state_0 & 0b110) - 1)) == 0 /* is-single-state_0  */) {
                    return NodeCost.MONOMORPHIC;
                }
            }
            return NodeCost.POLYMORPHIC;
        }

        @Override
        public void prepareForAOT(TruffleLanguage language, RootNode root) {
            assert !isAdoptable() || ((ReentrantLock) getLock()).isHeldByCurrentThread() : "During prepare AST lock must be held.";
            int state_0 = this.state_0_;
            if ((state_0 & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                return;
            }
            this.state_0_ = state_0 = state_0 | 0b111 /* add-state_0 AOT-prepared, unwrapNFISymbol(NFISymbol), noUnwrap(Object) */;
        }

        private void resetAOT_() {
            int state_0 = this.state_0_;
            if (((state_0 & 0b1)) == 0 /* is-not-state_0 AOT-prepared */) {
                return;
            }
            this.state_0_ = 0;
        }

        private static boolean fallbackGuard_(int state_0, Object arg0Value) {
            if (((state_0 & 0b10)) == 0 /* is-not-state_0 unwrapNFISymbol(NFISymbol) */ && arg0Value instanceof NFISymbol) {
                return false;
            }
            return true;
        }

        public static BackendSymbolUnwrapNode create() {
            return new BackendSymbolUnwrapNodeGen();
        }

        public static BackendSymbolUnwrapNode getUncached() {
            return BackendSymbolUnwrapNodeGen.UNCACHED;
        }

        @GeneratedBy(BackendSymbolUnwrapNode.class)
        @DenyReplace
        private static final class Uncached extends BackendSymbolUnwrapNode {

            @TruffleBoundary
            @Override
            Object execute(Object arg0Value) {
                if (arg0Value instanceof NFISymbol) {
                    NFISymbol arg0Value_ = (NFISymbol) arg0Value;
                    return unwrapNFISymbol(arg0Value_);
                }
                return noUnwrap(arg0Value);
            }

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

            @Override
            public boolean isAdoptable() {
                return false;
            }

        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy