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

com.oracle.truffle.nfi.backend.libffi.LibFFISignatureGen Maven / Gradle / Ivy

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

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.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.EncapsulatingNodeReference;
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.backend.libffi.LibFFIClosure.MonomorphicClosureInfo;
import com.oracle.truffle.nfi.backend.libffi.LibFFIClosure.PolymorphicClosureInfo;
import com.oracle.truffle.nfi.backend.libffi.LibFFISignature.CachedSignatureInfo;
import com.oracle.truffle.nfi.backend.libffi.LibFFISignature.Call;
import com.oracle.truffle.nfi.backend.libffi.LibFFISignature.CreateClosure;
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(LibFFISignature.class)
@SuppressWarnings("unused")
public final class LibFFISignatureGen {

    private static final LibraryFactory DYNAMIC_DISPATCH_LIBRARY_ = LibraryFactory.resolve(DynamicDispatchLibrary.class);
    private static final LibraryFactory INTEROP_LIBRARY_ = LibraryFactory.resolve(InteropLibrary.class);

    static  {
        LibraryExport.register(LibFFISignature.class, new NFIBackendSignatureLibraryExports());
    }

    private LibFFISignatureGen() {
    }

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

    @GeneratedBy(LibFFISignature.class)
    public static final class NFIBackendSignatureLibraryEagerProvider implements EagerExportProvider {

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

        @Override
        public String getLibraryClassName() {
            return "com.oracle.truffle.nfi.backend.spi.NFIBackendSignatureLibrary";
        }

    }
    @GeneratedBy(LibFFISignature.class)
    private static final class NFIBackendSignatureLibraryExports extends LibraryExport {

        private NFIBackendSignatureLibraryExports() {
            super(NFIBackendSignatureLibrary.class, LibFFISignature.class, false, true, 1);
        }

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

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

        @GeneratedBy(LibFFISignature.class)
        private static final class Cached extends NFIBackendSignatureLibrary implements GenerateAOT.Provider {

            @CompilationFinal private volatile int state_0_;
            @CompilationFinal private volatile int exclude_;
            @Child private FunctionExecuteNode call_callLibFFI_functionExecute_;
            @Child private CallCallGeneric0Data call_callGeneric0_cache;
            @CompilationFinal private BranchProfile call_callGeneric1_isExecutable_;
            @CompilationFinal private BranchProfile call_callGeneric1_toNative_;
            @CompilationFinal private BranchProfile call_callGeneric1_error_;
            @Child private FunctionExecuteNode call_callGeneric1_functionExecute_;
            @Child private CreateClosureCachedExecutableData createClosure_cachedExecutable_cache;
            @Child private CreateClosureCachedSignatureData createClosure_cachedSignature_cache;

            protected Cached() {
            }

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

            @ExplodeLoop
            @Override
            public Object call(Object arg0Value_, Object arg1Value, Object... arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
                assert this.accepts(arg0Value_) : "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.";
                LibFFISignature arg0Value = ((LibFFISignature) arg0Value_);
                int state_0 = this.state_0_;
                if (CompilerDirectives.inInterpreter() && (state_0 & 0b1) != 0 /* is-state_0 AOT-prepared */) {
                    return callAndSpecialize(arg0Value, arg1Value, arg2Value);
                }
                if ((state_0 & 0b1110) != 0 /* is-state_0 callLibFFI(LibFFISignature, LibFFISymbol, Object[], FunctionExecuteNode) || callGeneric(LibFFISignature, Object, Object[], InteropLibrary, BranchProfile, BranchProfile, BranchProfile, FunctionExecuteNode) || callGeneric(LibFFISignature, Object, Object[], InteropLibrary, BranchProfile, BranchProfile, BranchProfile, FunctionExecuteNode) */) {
                    if ((state_0 & 0b10) != 0 /* is-state_0 callLibFFI(LibFFISignature, LibFFISymbol, Object[], FunctionExecuteNode) */ && arg1Value instanceof LibFFISymbol) {
                        LibFFISymbol arg1Value_ = (LibFFISymbol) arg1Value;
                        return Call.callLibFFI(arg0Value, arg1Value_, arg2Value, this.call_callLibFFI_functionExecute_);
                    }
                    if ((state_0 & 0b1100) != 0 /* is-state_0 callGeneric(LibFFISignature, Object, Object[], InteropLibrary, BranchProfile, BranchProfile, BranchProfile, FunctionExecuteNode) || callGeneric(LibFFISignature, Object, Object[], InteropLibrary, BranchProfile, BranchProfile, BranchProfile, FunctionExecuteNode) */) {
                        if ((state_0 & 0b100) != 0 /* is-state_0 callGeneric(LibFFISignature, Object, Object[], InteropLibrary, BranchProfile, BranchProfile, BranchProfile, FunctionExecuteNode) */) {
                            CallCallGeneric0Data s1_ = this.call_callGeneric0_cache;
                            while (s1_ != null) {
                                if ((s1_.interop_.accepts(arg1Value))) {
                                    return Call.callGeneric(arg0Value, arg1Value, arg2Value, s1_.interop_, s1_.isExecutable_, s1_.toNative_, s1_.error_, s1_.functionExecute_);
                                }
                                s1_ = s1_.next_;
                            }
                        }
                        if ((state_0 & 0b1000) != 0 /* is-state_0 callGeneric(LibFFISignature, Object, Object[], InteropLibrary, BranchProfile, BranchProfile, BranchProfile, FunctionExecuteNode) */) {
                            return this.call_CallGeneric1Boundary(state_0, arg0Value, arg1Value, arg2Value);
                        }
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return callAndSpecialize(arg0Value, arg1Value, arg2Value);
            }

            @SuppressWarnings("static-method")
            @TruffleBoundary
            private Object call_CallGeneric1Boundary(int state_0, LibFFISignature arg0Value, Object arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
                EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                Node prev_ = encapsulating_.set(this);
                try {
                    {
                        InteropLibrary call_callGeneric1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                        return Call.callGeneric(arg0Value, arg1Value, arg2Value, call_callGeneric1_interop__, this.call_callGeneric1_isExecutable_, this.call_callGeneric1_toNative_, this.call_callGeneric1_error_, this.call_callGeneric1_functionExecute_);
                    }
                } finally {
                    encapsulating_.set(prev_);
                }
            }

            private Object callAndSpecialize(LibFFISignature arg0Value, Object arg1Value, Object[] arg2Value) throws ArityException, UnsupportedTypeException {
                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 (arg1Value instanceof LibFFISymbol) {
                        LibFFISymbol arg1Value_ = (LibFFISymbol) arg1Value;
                        this.call_callLibFFI_functionExecute_ = super.insert((FunctionExecuteNodeGen.create()));
                        this.state_0_ = state_0 = state_0 | 0b10 /* add-state_0 callLibFFI(LibFFISignature, LibFFISymbol, Object[], FunctionExecuteNode) */;
                        lock.unlock();
                        hasLock = false;
                        return Call.callLibFFI(arg0Value, arg1Value_, arg2Value, this.call_callLibFFI_functionExecute_);
                    }
                    if (((exclude & 0b1)) == 0 /* is-not-exclude callGeneric(LibFFISignature, Object, Object[], InteropLibrary, BranchProfile, BranchProfile, BranchProfile, FunctionExecuteNode) */) {
                        int count1_ = 0;
                        CallCallGeneric0Data s1_ = this.call_callGeneric0_cache;
                        if ((state_0 & 0b100) != 0 /* is-state_0 callGeneric(LibFFISignature, Object, Object[], InteropLibrary, BranchProfile, BranchProfile, BranchProfile, FunctionExecuteNode) */) {
                            while (s1_ != null) {
                                if ((s1_.interop_.accepts(arg1Value))) {
                                    break;
                                }
                                s1_ = s1_.next_;
                                count1_++;
                            }
                        }
                        if (s1_ == null) {
                            // assert (s1_.interop_.accepts(arg1Value));
                            if (count1_ < (3)) {
                                s1_ = super.insert(new CallCallGeneric0Data(call_callGeneric0_cache));
                                s1_.interop_ = s1_.insertAccessor((INTEROP_LIBRARY_.create(arg1Value)));
                                s1_.isExecutable_ = (BranchProfile.create());
                                s1_.toNative_ = (BranchProfile.create());
                                s1_.error_ = (BranchProfile.create());
                                s1_.functionExecute_ = s1_.insertAccessor((FunctionExecuteNodeGen.create()));
                                VarHandle.storeStoreFence();
                                this.call_callGeneric0_cache = s1_;
                                this.state_0_ = state_0 = state_0 | 0b100 /* add-state_0 callGeneric(LibFFISignature, Object, Object[], InteropLibrary, BranchProfile, BranchProfile, BranchProfile, FunctionExecuteNode) */;
                            }
                        }
                        if (s1_ != null) {
                            lock.unlock();
                            hasLock = false;
                            return Call.callGeneric(arg0Value, arg1Value, arg2Value, s1_.interop_, s1_.isExecutable_, s1_.toNative_, s1_.error_, s1_.functionExecute_);
                        }
                    }
                    {
                        InteropLibrary call_callGeneric1_interop__ = null;
                        {
                            EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                            Node prev_ = encapsulating_.set(this);
                            try {
                                call_callGeneric1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                                this.call_callGeneric1_isExecutable_ = (BranchProfile.create());
                                this.call_callGeneric1_toNative_ = (BranchProfile.create());
                                this.call_callGeneric1_error_ = (BranchProfile.create());
                                this.call_callGeneric1_functionExecute_ = super.insert((FunctionExecuteNodeGen.create()));
                                this.exclude_ = exclude = exclude | 0b1 /* add-exclude callGeneric(LibFFISignature, Object, Object[], InteropLibrary, BranchProfile, BranchProfile, BranchProfile, FunctionExecuteNode) */;
                                this.call_callGeneric0_cache = null;
                                state_0 = state_0 & 0xfffffffb /* remove-state_0 callGeneric(LibFFISignature, Object, Object[], InteropLibrary, BranchProfile, BranchProfile, BranchProfile, FunctionExecuteNode) */;
                                this.state_0_ = state_0 = state_0 | 0b1000 /* add-state_0 callGeneric(LibFFISignature, Object, Object[], InteropLibrary, BranchProfile, BranchProfile, BranchProfile, FunctionExecuteNode) */;
                                lock.unlock();
                                hasLock = false;
                                return Call.callGeneric(arg0Value, arg1Value, arg2Value, call_callGeneric1_interop__, this.call_callGeneric1_isExecutable_, this.call_callGeneric1_toNative_, this.call_callGeneric1_error_, this.call_callGeneric1_functionExecute_);
                            } finally {
                                encapsulating_.set(prev_);
                            }
                        }
                    }
                } 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  */) {
                        CallCallGeneric0Data s1_ = this.call_callGeneric0_cache;
                        if ((s1_ == null || s1_.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.call_callLibFFI_functionExecute_ = super.insert((FunctionExecuteNodeGen.create()));
                assert NodeUtil.assertRecursion(this.call_callLibFFI_functionExecute_, 1);
                ((GenerateAOT.Provider) this.call_callLibFFI_functionExecute_).prepareForAOT(language, root);
                this.state_0_ = state_0 = state_0 | 0b1000011 /* add-state_0 AOT-prepared, callLibFFI(LibFFISignature, LibFFISymbol, Object[], FunctionExecuteNode), createClosure(LibFFISignature, Object, NFIBackendSignatureLibrary) */;
            }

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

            @ExplodeLoop
            @Override
            public Object createClosure(Object arg0Value_, Object arg1Value) {
                assert this.accepts(arg0Value_) : "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.";
                LibFFISignature arg0Value = ((LibFFISignature) 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 & 0b1110000) != 0 /* is-state_0 doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo) || doCachedSignature(LibFFISignature, Object, CachedSignatureInfo, NFIBackendSignatureLibrary, PolymorphicClosureInfo) || createClosure(LibFFISignature, Object, NFIBackendSignatureLibrary) */) {
                    if ((state_0 & 0b10000) != 0 /* is-state_0 doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo) */) {
                        CreateClosureCachedExecutableData s0_ = this.createClosure_cachedExecutable_cache;
                        while (s0_ != null) {
                            if (!Assumption.isValidAssumption(s0_.assumption0_)) {
                                CompilerDirectives.transferToInterpreterAndInvalidate();
                                removeCachedExecutable_(s0_);
                                return createClosureAndSpecialize(arg0Value, arg1Value);
                            }
                            if ((arg0Value.signatureInfo == s0_.cachedSignatureInfo_) && (arg1Value == s0_.cachedExecutable_)) {
                                NFIBackendSignatureLibrary self__ = (this);
                                return CreateClosure.doCachedExecutable(arg0Value, arg1Value, s0_.cachedSignatureInfo_, s0_.cachedExecutable_, self__, s0_.cachedClosureInfo_);
                            }
                            s0_ = s0_.next_;
                        }
                    }
                    if ((state_0 & 0b100000) != 0 /* is-state_0 doCachedSignature(LibFFISignature, Object, CachedSignatureInfo, NFIBackendSignatureLibrary, PolymorphicClosureInfo) */) {
                        CreateClosureCachedSignatureData s1_ = this.createClosure_cachedSignature_cache;
                        while (s1_ != null) {
                            if ((arg0Value.signatureInfo == s1_.cachedSignatureInfo_)) {
                                NFIBackendSignatureLibrary self__1 = (this);
                                return CreateClosure.doCachedSignature(arg0Value, arg1Value, s1_.cachedSignatureInfo_, self__1, s1_.cachedClosureInfo_);
                            }
                            s1_ = s1_.next_;
                        }
                    }
                    if ((state_0 & 0b1000000) != 0 /* is-state_0 createClosure(LibFFISignature, Object, NFIBackendSignatureLibrary) */) {
                        {
                            NFIBackendSignatureLibrary createClosure_createClosure_self__ = (this);
                            return CreateClosure.createClosure(arg0Value, arg1Value, createClosure_createClosure_self__);
                        }
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return createClosureAndSpecialize(arg0Value, arg1Value);
            }

            private LibFFIClosure createClosureAndSpecialize(LibFFISignature 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_;
                    {
                        NFIBackendSignatureLibrary self__ = null;
                        if (((exclude & 0b10)) == 0 /* is-not-exclude doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo) */) {
                            int count0_ = 0;
                            CreateClosureCachedExecutableData s0_ = this.createClosure_cachedExecutable_cache;
                            if ((state_0 & 0b10000) != 0 /* is-state_0 doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo) */) {
                                while (s0_ != null) {
                                    if ((arg0Value.signatureInfo == s0_.cachedSignatureInfo_) && (arg1Value == s0_.cachedExecutable_) && Assumption.isValidAssumption(s0_.assumption0_)) {
                                        self__ = (this);
                                        break;
                                    }
                                    s0_ = s0_.next_;
                                    count0_++;
                                }
                            }
                            if (s0_ == null) {
                                // assert (arg0Value.signatureInfo == s0_.cachedSignatureInfo_);
                                // assert (arg1Value == s0_.cachedExecutable_);
                                {
                                    Assumption assumption0 = (LibFFILanguage.getSingleContextAssumption());
                                    if (Assumption.isValidAssumption(assumption0)) {
                                        if (count0_ < (3)) {
                                            s0_ = super.insert(new CreateClosureCachedExecutableData(createClosure_cachedExecutable_cache));
                                            s0_.cachedSignatureInfo_ = (arg0Value.signatureInfo);
                                            s0_.cachedExecutable_ = (arg1Value);
                                            self__ = (this);
                                            s0_.cachedClosureInfo_ = (MonomorphicClosureInfo.create(s0_.cachedSignatureInfo_, s0_.cachedExecutable_));
                                            s0_.assumption0_ = assumption0;
                                            VarHandle.storeStoreFence();
                                            this.createClosure_cachedExecutable_cache = s0_;
                                            this.state_0_ = state_0 = state_0 | 0b10000 /* add-state_0 doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo) */;
                                        }
                                    }
                                }
                            }
                            if (s0_ != null) {
                                lock.unlock();
                                hasLock = false;
                                return CreateClosure.doCachedExecutable(arg0Value, arg1Value, s0_.cachedSignatureInfo_, s0_.cachedExecutable_, self__, s0_.cachedClosureInfo_);
                            }
                        }
                    }
                    {
                        NFIBackendSignatureLibrary self__1 = null;
                        if (((exclude & 0b100)) == 0 /* is-not-exclude doCachedSignature(LibFFISignature, Object, CachedSignatureInfo, NFIBackendSignatureLibrary, PolymorphicClosureInfo) */) {
                            int count1_ = 0;
                            CreateClosureCachedSignatureData s1_ = this.createClosure_cachedSignature_cache;
                            if ((state_0 & 0b100000) != 0 /* is-state_0 doCachedSignature(LibFFISignature, Object, CachedSignatureInfo, NFIBackendSignatureLibrary, PolymorphicClosureInfo) */) {
                                while (s1_ != null) {
                                    if ((arg0Value.signatureInfo == s1_.cachedSignatureInfo_)) {
                                        self__1 = (this);
                                        break;
                                    }
                                    s1_ = s1_.next_;
                                    count1_++;
                                }
                            }
                            if (s1_ == null) {
                                // assert (arg0Value.signatureInfo == s1_.cachedSignatureInfo_);
                                if (count1_ < (3)) {
                                    s1_ = super.insert(new CreateClosureCachedSignatureData(createClosure_cachedSignature_cache));
                                    s1_.cachedSignatureInfo_ = (arg0Value.signatureInfo);
                                    self__1 = (this);
                                    s1_.cachedClosureInfo_ = (PolymorphicClosureInfo.create(s1_.cachedSignatureInfo_));
                                    VarHandle.storeStoreFence();
                                    this.createClosure_cachedSignature_cache = s1_;
                                    this.exclude_ = exclude = exclude | 0b10 /* add-exclude doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo) */;
                                    this.createClosure_cachedExecutable_cache = null;
                                    state_0 = state_0 & 0xffffffef /* remove-state_0 doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo) */;
                                    this.state_0_ = state_0 = state_0 | 0b100000 /* add-state_0 doCachedSignature(LibFFISignature, Object, CachedSignatureInfo, NFIBackendSignatureLibrary, PolymorphicClosureInfo) */;
                                }
                            }
                            if (s1_ != null) {
                                lock.unlock();
                                hasLock = false;
                                return CreateClosure.doCachedSignature(arg0Value, arg1Value, s1_.cachedSignatureInfo_, self__1, s1_.cachedClosureInfo_);
                            }
                        }
                    }
                    {
                        NFIBackendSignatureLibrary createClosure_createClosure_self__ = null;
                        createClosure_createClosure_self__ = (this);
                        this.exclude_ = exclude = exclude | 0b110 /* add-exclude doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo), doCachedSignature(LibFFISignature, Object, CachedSignatureInfo, NFIBackendSignatureLibrary, PolymorphicClosureInfo) */;
                        this.createClosure_cachedExecutable_cache = null;
                        this.createClosure_cachedSignature_cache = null;
                        state_0 = state_0 & 0xffffffcf /* remove-state_0 doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo), doCachedSignature(LibFFISignature, Object, CachedSignatureInfo, NFIBackendSignatureLibrary, PolymorphicClosureInfo) */;
                        this.state_0_ = state_0 = state_0 | 0b1000000 /* add-state_0 createClosure(LibFFISignature, Object, NFIBackendSignatureLibrary) */;
                        lock.unlock();
                        hasLock = false;
                        return CreateClosure.createClosure(arg0Value, arg1Value, createClosure_createClosure_self__);
                    }
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

            void removeCachedExecutable_(Object s0_) {
                Lock lock = getLock();
                lock.lock();
                try {
                    CreateClosureCachedExecutableData prev = null;
                    CreateClosureCachedExecutableData cur = this.createClosure_cachedExecutable_cache;
                    while (cur != null) {
                        if (cur == s0_) {
                            if (prev == null) {
                                this.createClosure_cachedExecutable_cache = cur.next_;
                                this.adoptChildren();
                            } else {
                                prev.next_ = cur.next_;
                                prev.adoptChildren();
                            }
                            break;
                        }
                        prev = cur;
                        cur = cur.next_;
                    }
                    if (this.createClosure_cachedExecutable_cache == null) {
                        this.state_0_ = this.state_0_ & 0xffffffef /* remove-state_0 doCachedExecutable(LibFFISignature, Object, CachedSignatureInfo, Object, NFIBackendSignatureLibrary, MonomorphicClosureInfo) */;
                    }
                } finally {
                    lock.unlock();
                }
            }

            @GeneratedBy(LibFFISignature.class)
            private static final class CallCallGeneric0Data extends Node {

                @Child CallCallGeneric0Data next_;
                @Child InteropLibrary interop_;
                @CompilationFinal BranchProfile isExecutable_;
                @CompilationFinal BranchProfile toNative_;
                @CompilationFinal BranchProfile error_;
                @Child FunctionExecuteNode functionExecute_;

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

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

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

            }
            @GeneratedBy(LibFFISignature.class)
            private static final class CreateClosureCachedExecutableData extends Node {

                @Child CreateClosureCachedExecutableData next_;
                @CompilationFinal CachedSignatureInfo cachedSignatureInfo_;
                @CompilationFinal Object cachedExecutable_;
                @CompilationFinal MonomorphicClosureInfo cachedClosureInfo_;
                @CompilationFinal Assumption assumption0_;

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

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

            }
            @GeneratedBy(LibFFISignature.class)
            private static final class CreateClosureCachedSignatureData extends Node {

                @Child CreateClosureCachedSignatureData next_;
                @CompilationFinal CachedSignatureInfo cachedSignatureInfo_;
                @CompilationFinal PolymorphicClosureInfo cachedClosureInfo_;

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

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

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

            protected Uncached() {
            }

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

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

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

            @TruffleBoundary
            @Override
            public Object call(Object arg0Value_, Object arg1Value, Object... arg2Value) throws ArityException, UnsupportedTypeException {
                // declared: true
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                LibFFISignature arg0Value = ((LibFFISignature) arg0Value_);
                if (arg1Value instanceof LibFFISymbol) {
                    LibFFISymbol arg1Value_ = (LibFFISymbol) arg1Value;
                    return Call.callLibFFI(arg0Value, arg1Value_, arg2Value, (FunctionExecuteNodeGen.getUncached()));
                }
                return Call.callGeneric(arg0Value, arg1Value, arg2Value, (INTEROP_LIBRARY_.getUncached(arg1Value)), (BranchProfile.getUncached()), (BranchProfile.getUncached()), (BranchProfile.getUncached()), (FunctionExecuteNodeGen.getUncached()));
            }

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

        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy