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

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

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

import com.oracle.truffle.api.Assumption;
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.interop.ArityException;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.UnknownIdentifierException;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
import com.oracle.truffle.api.interop.UnsupportedTypeException;
import com.oracle.truffle.api.library.DynamicDispatchLibrary;
import com.oracle.truffle.api.library.EagerExportProvider;
import com.oracle.truffle.api.library.LibraryExport;
import com.oracle.truffle.api.library.LibraryFactory;
import com.oracle.truffle.api.nodes.DenyReplace;
import com.oracle.truffle.api.nodes.ExplodeLoop;
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.CachedCallSignatureNode;
import com.oracle.truffle.nfi.CallSignatureNodeFactory.CachedCallSignatureNodeGen;
import com.oracle.truffle.nfi.NFISignature.Bind;
import com.oracle.truffle.nfi.NFISignature.CreateClosure;
import com.oracle.truffle.nfi.NFISignature.InvokeMember;
import com.oracle.truffle.nfi.api.SignatureLibrary;
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(NFISignature.class)
@SuppressWarnings("unused")
public final class NFISignatureGen {

    private static final LibraryFactory DYNAMIC_DISPATCH_LIBRARY_ = LibraryFactory.resolve(DynamicDispatchLibrary.class);
    private static final LibraryFactory SIGNATURE_LIBRARY_ = LibraryFactory.resolve(SignatureLibrary.class);
    private static final LibraryFactory N_F_I_BACKEND_SIGNATURE_LIBRARY_ = LibraryFactory.resolve(NFIBackendSignatureLibrary.class);

    static  {
        LibraryExport.register(NFISignature.class, new InteropLibraryExports(), new SignatureLibraryExports());
    }

    private NFISignatureGen() {
    }

    private static void init() {
        // This method is intended to ensure class initialization.
    }

    @GeneratedBy(NFISignature.class)
    private static final class InteropLibraryExports extends LibraryExport {

        private InteropLibraryExports() {
            super(InteropLibrary.class, NFISignature.class, false, false, 0);
        }

        @Override
        protected InteropLibrary createUncached(Object receiver) {
            assert receiver instanceof NFISignature;
            InteropLibrary uncached = new Uncached();
            return uncached;
        }

        @Override
        protected InteropLibrary createCached(Object receiver) {
            assert receiver instanceof NFISignature;
            return new Cached(receiver);
        }

        @GeneratedBy(NFISignature.class)
        private static final class Cached extends InteropLibrary {

            @Child private SignatureLibrary receiverSignatureLibrary_;
            @CompilationFinal private volatile int state_0_;
            @CompilationFinal private BranchProfile invokeException;

            protected Cached(Object receiver) {
                NFISignature castReceiver = ((NFISignature) receiver) ;
                this.receiverSignatureLibrary_ = super.insert(SIGNATURE_LIBRARY_.create((castReceiver)));
            }

            @Override
            public boolean accepts(Object receiver) {
                assert !(receiver instanceof NFISignature) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
                if (!(receiver instanceof NFISignature)) {
                    return false;
                } else if (!this.receiverSignatureLibrary_.accepts((receiver))) {
                    return false;
                } else {
                    return true;
                }
            }

            @Override
            public Object invokeMember(Object arg0Value_, String arg1Value, Object... arg2Value) throws UnsupportedMessageException, ArityException, UnknownIdentifierException, UnsupportedTypeException {
                assert arg0Value_ instanceof NFISignature : "Invalid library usage. Library does not accept given receiver.";
                assert assertAdopted();
                NFISignature arg0Value = ((NFISignature) arg0Value_);
                int state_0 = this.state_0_;
                if (state_0 != 0 /* is-state_0 doBind(NFISignature, String, Object[], SignatureLibrary, BranchProfile) || doCreateClosure(NFISignature, String, Object[], SignatureLibrary, BranchProfile) || doUnknown(NFISignature, String, Object[]) */) {
                    if ((state_0 & 0b1) != 0 /* is-state_0 doBind(NFISignature, String, Object[], SignatureLibrary, BranchProfile) */) {
                        if ((NFISignature.isBind(arg1Value))) {
                            SignatureLibrary bind_signatureLibrary__ = this.receiverSignatureLibrary_;
                            return InvokeMember.doBind(arg0Value, arg1Value, arg2Value, bind_signatureLibrary__, this.invokeException);
                        }
                    }
                    if ((state_0 & 0b10) != 0 /* is-state_0 doCreateClosure(NFISignature, String, Object[], SignatureLibrary, BranchProfile) */) {
                        if ((NFISignature.isCreateClosure(arg1Value))) {
                            SignatureLibrary createClosure_signatureLibrary__ = this.receiverSignatureLibrary_;
                            return InvokeMember.doCreateClosure(arg0Value, arg1Value, arg2Value, createClosure_signatureLibrary__, this.invokeException);
                        }
                    }
                    if ((state_0 & 0b100) != 0 /* is-state_0 doUnknown(NFISignature, String, Object[]) */) {
                        if (fallbackGuard_(state_0, arg0Value, arg1Value, arg2Value)) {
                            return InvokeMember.doUnknown(arg0Value, arg1Value, arg2Value);
                        }
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
            }

            private Object executeAndSpecialize(NFISignature arg0Value, String arg1Value, Object[] arg2Value) throws ArityException, UnknownIdentifierException {
                Lock lock = getLock();
                boolean hasLock = true;
                lock.lock();
                try {
                    int state_0 = this.state_0_;
                    {
                        SignatureLibrary bind_signatureLibrary__ = null;
                        if ((NFISignature.isBind(arg1Value))) {
                            bind_signatureLibrary__ = this.receiverSignatureLibrary_;
                            this.invokeException = this.invokeException == null ? ((BranchProfile.create())) : this.invokeException;
                            this.state_0_ = state_0 = state_0 | 0b1 /* add-state_0 doBind(NFISignature, String, Object[], SignatureLibrary, BranchProfile) */;
                            lock.unlock();
                            hasLock = false;
                            return InvokeMember.doBind(arg0Value, arg1Value, arg2Value, bind_signatureLibrary__, this.invokeException);
                        }
                    }
                    {
                        SignatureLibrary createClosure_signatureLibrary__ = null;
                        if ((NFISignature.isCreateClosure(arg1Value))) {
                            createClosure_signatureLibrary__ = this.receiverSignatureLibrary_;
                            this.invokeException = this.invokeException == null ? ((BranchProfile.create())) : this.invokeException;
                            this.state_0_ = state_0 = state_0 | 0b10 /* add-state_0 doCreateClosure(NFISignature, String, Object[], SignatureLibrary, BranchProfile) */;
                            lock.unlock();
                            hasLock = false;
                            return InvokeMember.doCreateClosure(arg0Value, arg1Value, arg2Value, createClosure_signatureLibrary__, this.invokeException);
                        }
                    }
                    this.state_0_ = state_0 = state_0 | 0b100 /* add-state_0 doUnknown(NFISignature, String, Object[]) */;
                    lock.unlock();
                    hasLock = false;
                    return InvokeMember.doUnknown(arg0Value, arg1Value, arg2Value);
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

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

            @Override
            public boolean hasMembers(Object receiver) {
                assert receiver instanceof NFISignature : "Invalid library usage. Library does not accept given receiver.";
                assert assertAdopted();
                return (((NFISignature) receiver)).hasMembers();
            }

            @Override
            public Object getMembers(Object receiver, boolean includeInternal) throws UnsupportedMessageException {
                assert receiver instanceof NFISignature : "Invalid library usage. Library does not accept given receiver.";
                assert assertAdopted();
                return (((NFISignature) receiver)).getMembers(includeInternal);
            }

            @Override
            public boolean isMemberInvocable(Object receiver, String member) {
                assert receiver instanceof NFISignature : "Invalid library usage. Library does not accept given receiver.";
                assert assertAdopted();
                return (((NFISignature) receiver)).isMemberInvocable(member);
            }

            private static boolean fallbackGuard_(int state_0, NFISignature arg0Value, String arg1Value, Object[] arg2Value) {
                if (((state_0 & 0b1)) == 0 /* is-not-state_0 doBind(NFISignature, String, Object[], SignatureLibrary, BranchProfile) */ && (NFISignature.isBind(arg1Value))) {
                    return false;
                }
                if (((state_0 & 0b10)) == 0 /* is-not-state_0 doCreateClosure(NFISignature, String, Object[], SignatureLibrary, BranchProfile) */ && (NFISignature.isCreateClosure(arg1Value))) {
                    return false;
                }
                return true;
            }

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

            protected Uncached() {
            }

            @Override
            @TruffleBoundary
            public boolean accepts(Object receiver) {
                assert !(receiver instanceof NFISignature) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
                return receiver instanceof NFISignature;
            }

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

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

            @TruffleBoundary
            @Override
            public Object invokeMember(Object arg0Value_, String arg1Value, Object... arg2Value) throws ArityException, UnknownIdentifierException {
                // declared: true
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                NFISignature arg0Value = ((NFISignature) arg0Value_);
                if ((NFISignature.isBind(arg1Value))) {
                    return InvokeMember.doBind(arg0Value, arg1Value, arg2Value, SIGNATURE_LIBRARY_.getUncached((arg0Value)), (BranchProfile.getUncached()));
                }
                if ((NFISignature.isCreateClosure(arg1Value))) {
                    return InvokeMember.doCreateClosure(arg0Value, arg1Value, arg2Value, SIGNATURE_LIBRARY_.getUncached((arg0Value)), (BranchProfile.getUncached()));
                }
                return InvokeMember.doUnknown(arg0Value, arg1Value, arg2Value);
            }

            @TruffleBoundary
            @Override
            public boolean hasMembers(Object receiver) {
                // declared: true
                assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
                return ((NFISignature) receiver) .hasMembers();
            }

            @TruffleBoundary
            @Override
            public Object getMembers(Object receiver, boolean includeInternal) throws UnsupportedMessageException {
                // declared: true
                assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
                return ((NFISignature) receiver) .getMembers(includeInternal);
            }

            @TruffleBoundary
            @Override
            public boolean isMemberInvocable(Object receiver, String member) {
                // declared: true
                assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
                return ((NFISignature) receiver) .isMemberInvocable(member);
            }

        }
    }
    @GeneratedBy(NFISignature.class)
    public static final class SignatureLibraryEagerProvider implements EagerExportProvider {

        @Override
        public void ensureRegistered() {
            NFISignatureGen.init();
        }

        @Override
        public String getLibraryClassName() {
            return "com.oracle.truffle.nfi.api.SignatureLibrary";
        }

    }
    @GeneratedBy(NFISignature.class)
    private static final class SignatureLibraryExports extends LibraryExport {

        private SignatureLibraryExports() {
            super(SignatureLibrary.class, NFISignature.class, false, true, 1);
        }

        @Override
        protected SignatureLibrary createUncached(Object receiver) {
            assert receiver instanceof NFISignature;
            SignatureLibrary uncached = new Uncached();
            return uncached;
        }

        @Override
        protected SignatureLibrary createCached(Object receiver) {
            assert receiver instanceof NFISignature || receiver instanceof LibraryExport;
            return new Cached(receiver);
        }

        @GeneratedBy(NFISignature.class)
        private static final class Cached extends SignatureLibrary implements GenerateAOT.Provider {

            @Child private NFIBackendSignatureLibrary receiverNativeSignatureNFIBackendSignatureLibrary_;
            @CompilationFinal private volatile int state_0_;
            @CompilationFinal private volatile int exclude_;
            @Child private CreateClosureCachedData createClosure_cached_cache;
            @Child private CachedCallSignatureNode callNode__call_call_;

            protected Cached(Object receiver) {
                if (!(receiver instanceof LibraryExport)) {
                    NFISignature castReceiver = ((NFISignature) receiver) ;
                    this.receiverNativeSignatureNFIBackendSignatureLibrary_ = super.insert(N_F_I_BACKEND_SIGNATURE_LIBRARY_.create((castReceiver.nativeSignature)));
                }
            }

            @Override
            public boolean accepts(Object receiver) {
                assert !(receiver instanceof NFISignature) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
                if (!(receiver instanceof NFISignature)) {
                    return false;
                } else if (this.receiverNativeSignatureNFIBackendSignatureLibrary_ != null && !this.receiverNativeSignatureNFIBackendSignatureLibrary_.accepts((((NFISignature) receiver).nativeSignature))) {
                    return false;
                } else {
                    return true;
                }
            }

            @Override
            public Object bind(Object arg0Value_, Object arg1Value) {
                assert arg0Value_ instanceof NFISignature : "Invalid library usage. Library does not accept given receiver.";
                assert getRootNode() != null : "Invalid library usage. Cached library must be adopted by a RootNode before it is executed.";
                NFISignature arg0Value = ((NFISignature) arg0Value_);
                int state_0 = this.state_0_;
                if (CompilerDirectives.inInterpreter() && (state_0 & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                    return bindAndSpecialize(arg0Value, arg1Value);
                }
                if ((state_0 & 0b110) != 0 /* is-state_0 doSymbol(NFISignature, NFISymbol) || doOther(NFISignature, Object) */) {
                    if ((state_0 & 0b10) != 0 /* is-state_0 doSymbol(NFISignature, NFISymbol) */ && arg1Value instanceof NFISymbol) {
                        NFISymbol arg1Value_ = (NFISymbol) arg1Value;
                        return Bind.doSymbol(arg0Value, arg1Value_);
                    }
                    if ((state_0 & 0b100) != 0 /* is-state_0 doOther(NFISignature, Object) */) {
                        if (bindFallbackGuard_(state_0, arg0Value, arg1Value)) {
                            return Bind.doOther(arg0Value, arg1Value);
                        }
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return bindAndSpecialize(arg0Value, arg1Value);
            }

            private Object bindAndSpecialize(NFISignature arg0Value, Object arg1Value) {
                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_;
                    if (arg1Value instanceof NFISymbol) {
                        NFISymbol arg1Value_ = (NFISymbol) arg1Value;
                        this.state_0_ = state_0 = state_0 | 0b10 /* add-state_0 doSymbol(NFISignature, NFISymbol) */;
                        lock.unlock();
                        hasLock = false;
                        return Bind.doSymbol(arg0Value, arg1Value_);
                    }
                    this.state_0_ = state_0 = state_0 | 0b100 /* add-state_0 doOther(NFISignature, Object) */;
                    lock.unlock();
                    hasLock = false;
                    return Bind.doOther(arg0Value, arg1Value);
                } 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.callNode__call_call_ = super.insert((CachedCallSignatureNodeGen.create()));
                assert NodeUtil.assertRecursion(this.callNode__call_call_, 1);
                ((GenerateAOT.Provider) this.callNode__call_call_).prepareForAOT(language, root);
                this.state_0_ = state_0 = state_0 | 0b100111 /* add-state_0 AOT-prepared, doSymbol(NFISignature, NFISymbol), doOther(NFISignature, Object), call(NFISignature, Object, Object[], CachedCallSignatureNode) */;
            }

            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;
            }

            @ExplodeLoop
            @Override
            public Object createClosure(Object arg0Value_, Object arg1Value) {
                assert arg0Value_ instanceof NFISignature : "Invalid library usage. Library does not accept given receiver.";
                assert getRootNode() != null : "Invalid library usage. Cached library must be adopted by a RootNode before it is executed.";
                NFISignature arg0Value = ((NFISignature) arg0Value_);
                int state_0 = this.state_0_;
                if (CompilerDirectives.inInterpreter() && (state_0 & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                    return createClosureAndSpecialize(arg0Value, arg1Value);
                }
                if ((state_0 & 0b11000) != 0 /* is-state_0 doCached(NFISignature, Object, NFIClosure, NFIBackendSignatureLibrary, Object) || doCreate(NFISignature, Object, NFIBackendSignatureLibrary) */) {
                    if ((state_0 & 0b1000) != 0 /* is-state_0 doCached(NFISignature, Object, NFIClosure, NFIBackendSignatureLibrary, Object) */) {
                        CreateClosureCachedData s0_ = this.createClosure_cached_cache;
                        while (s0_ != null) {
                            if (!Assumption.isValidAssumption(s0_.assumption0_)) {
                                CompilerDirectives.transferToInterpreterAndInvalidate();
                                removeCached_(s0_);
                                return createClosureAndSpecialize(arg0Value, arg1Value);
                            }
                            assert (s0_.lib_.accepts(s0_.cachedClosure_.signature.nativeSignature));
                            if ((arg1Value == s0_.cachedClosure_.executable) && (arg0Value == s0_.cachedClosure_.signature)) {
                                return CreateClosure.doCached(arg0Value, arg1Value, s0_.cachedClosure_, s0_.lib_, s0_.cachedRet_);
                            }
                            s0_ = s0_.next_;
                        }
                    }
                    if ((state_0 & 0b10000) != 0 /* is-state_0 doCreate(NFISignature, Object, NFIBackendSignatureLibrary) */) {
                        {
                            NFIBackendSignatureLibrary createClosure_create_lib__ = this.receiverNativeSignatureNFIBackendSignatureLibrary_;
                            return CreateClosure.doCreate(arg0Value, arg1Value, createClosure_create_lib__);
                        }
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return createClosureAndSpecialize(arg0Value, arg1Value);
            }

            private Object createClosureAndSpecialize(NFISignature arg0Value, Object arg1Value) {
                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 doCached(NFISignature, Object, NFIClosure, NFIBackendSignatureLibrary, Object) */) {
                        int count0_ = 0;
                        CreateClosureCachedData s0_ = this.createClosure_cached_cache;
                        if ((state_0 & 0b1000) != 0 /* is-state_0 doCached(NFISignature, Object, NFIClosure, NFIBackendSignatureLibrary, Object) */) {
                            while (s0_ != null) {
                                assert (s0_.lib_.accepts(s0_.cachedClosure_.signature.nativeSignature));
                                if ((arg1Value == s0_.cachedClosure_.executable) && (arg0Value == s0_.cachedClosure_.signature) && Assumption.isValidAssumption(s0_.assumption0_)) {
                                    break;
                                }
                                s0_ = s0_.next_;
                                count0_++;
                            }
                        }
                        if (s0_ == null) {
                            {
                                NFIClosure cachedClosure__ = (CreateClosure.createClosure(arg1Value, arg0Value));
                                // assert (s0_.lib_.accepts(s0_.cachedClosure_.signature.nativeSignature));
                                if ((arg1Value == cachedClosure__.executable) && (arg0Value == cachedClosure__.signature)) {
                                    Assumption assumption0 = (NFILanguage.getSingleContextAssumption());
                                    if (Assumption.isValidAssumption(assumption0)) {
                                        if (count0_ < (3)) {
                                            s0_ = super.insert(new CreateClosureCachedData(createClosure_cached_cache));
                                            s0_.cachedClosure_ = cachedClosure__;
                                            s0_.lib_ = s0_.insertAccessor((N_F_I_BACKEND_SIGNATURE_LIBRARY_.create(cachedClosure__.signature.nativeSignature)));
                                            s0_.cachedRet_ = (s0_.lib_.createClosure(cachedClosure__.signature.nativeSignature, cachedClosure__));
                                            s0_.assumption0_ = assumption0;
                                            VarHandle.storeStoreFence();
                                            this.createClosure_cached_cache = s0_;
                                            this.state_0_ = state_0 = state_0 | 0b1000 /* add-state_0 doCached(NFISignature, Object, NFIClosure, NFIBackendSignatureLibrary, Object) */;
                                        }
                                    }
                                }
                            }
                        }
                        if (s0_ != null) {
                            lock.unlock();
                            hasLock = false;
                            return CreateClosure.doCached(arg0Value, arg1Value, s0_.cachedClosure_, s0_.lib_, s0_.cachedRet_);
                        }
                    }
                    {
                        NFIBackendSignatureLibrary createClosure_create_lib__ = null;
                        createClosure_create_lib__ = this.receiverNativeSignatureNFIBackendSignatureLibrary_;
                        this.exclude_ = exclude = exclude | 0b1 /* add-exclude doCached(NFISignature, Object, NFIClosure, NFIBackendSignatureLibrary, Object) */;
                        this.createClosure_cached_cache = null;
                        state_0 = state_0 & 0xfffffff7 /* remove-state_0 doCached(NFISignature, Object, NFIClosure, NFIBackendSignatureLibrary, Object) */;
                        this.state_0_ = state_0 = state_0 | 0b10000 /* add-state_0 doCreate(NFISignature, Object, NFIBackendSignatureLibrary) */;
                        lock.unlock();
                        hasLock = false;
                        return CreateClosure.doCreate(arg0Value, arg1Value, createClosure_create_lib__);
                    }
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

            void removeCached_(Object s0_) {
                Lock lock = getLock();
                lock.lock();
                try {
                    CreateClosureCachedData prev = null;
                    CreateClosureCachedData cur = this.createClosure_cached_cache;
                    while (cur != null) {
                        if (cur == s0_) {
                            if (prev == null) {
                                this.createClosure_cached_cache = cur.next_;
                                this.adoptChildren();
                            } else {
                                prev.next_ = cur.next_;
                                prev.adoptChildren();
                            }
                            break;
                        }
                        prev = cur;
                        cur = cur.next_;
                    }
                    if (this.createClosure_cached_cache == null) {
                        this.state_0_ = this.state_0_ & 0xfffffff7 /* remove-state_0 doCached(NFISignature, Object, NFIClosure, NFIBackendSignatureLibrary, Object) */;
                    }
                } finally {
                    lock.unlock();
                }
            }

            @Override
            public Object call(Object arg0Value_, Object arg1Value, Object... arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
                assert arg0Value_ instanceof NFISignature : "Invalid library usage. Library does not accept given receiver.";
                assert getRootNode() != null : "Invalid library usage. Cached library must be adopted by a RootNode before it is executed.";
                NFISignature arg0Value = ((NFISignature) arg0Value_);
                int state_0 = this.state_0_;
                if (CompilerDirectives.inInterpreter() && (state_0 & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                    return callNode_AndSpecialize(arg0Value, arg1Value, arg2Value);
                }
                if ((state_0 & 0b100000) != 0 /* is-state_0 call(NFISignature, Object, Object[], CachedCallSignatureNode) */) {
                    return arg0Value.call(arg1Value, arg2Value, this.callNode__call_call_);
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return callNode_AndSpecialize(arg0Value, arg1Value, arg2Value);
            }

            private Object callNode_AndSpecialize(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_;
                    this.callNode__call_call_ = super.insert((CachedCallSignatureNodeGen.create()));
                    this.state_0_ = state_0 = state_0 | 0b100000 /* add-state_0 call(NFISignature, Object, Object[], CachedCallSignatureNode) */;
                    lock.unlock();
                    hasLock = false;
                    return arg0Value.call(arg1Value, arg2Value, this.callNode__call_call_);
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

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

            @GeneratedBy(NFISignature.class)
            private static final class CreateClosureCachedData extends Node {

                @Child CreateClosureCachedData next_;
                @CompilationFinal NFIClosure cachedClosure_;
                @Child NFIBackendSignatureLibrary lib_;
                @CompilationFinal Object cachedRet_;
                @CompilationFinal Assumption assumption0_;

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

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

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

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

            protected Uncached() {
            }

            @Override
            @TruffleBoundary
            public boolean accepts(Object receiver) {
                assert !(receiver instanceof NFISignature) || DYNAMIC_DISPATCH_LIBRARY_.getUncached().dispatch(receiver) == null : "Invalid library export. Exported receiver with dynamic dispatch found but not expected.";
                return receiver instanceof NFISignature;
            }

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

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

            @TruffleBoundary
            @Override
            public Object bind(Object arg0Value_, Object arg1Value) {
                // declared: true
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                NFISignature arg0Value = ((NFISignature) arg0Value_);
                if (arg1Value instanceof NFISymbol) {
                    NFISymbol arg1Value_ = (NFISymbol) arg1Value;
                    return Bind.doSymbol(arg0Value, arg1Value_);
                }
                return Bind.doOther(arg0Value, arg1Value);
            }

            @TruffleBoundary
            @Override
            public Object createClosure(Object arg0Value_, Object arg1Value) {
                // declared: true
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                NFISignature arg0Value = ((NFISignature) arg0Value_);
                return CreateClosure.doCreate(arg0Value, arg1Value, N_F_I_BACKEND_SIGNATURE_LIBRARY_.getUncached((arg0Value.nativeSignature)));
            }

            @TruffleBoundary
            @Override
            public Object call(Object arg0Value_, Object arg1Value, Object... arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
                // declared: true
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                NFISignature arg0Value = ((NFISignature) arg0Value_);
                return arg0Value.call(arg1Value, arg2Value, (CachedCallSignatureNodeGen.getUncached()));
            }

        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy