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

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

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

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.library.DynamicDispatchLibrary;
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.NodeCost;
import com.oracle.truffle.nfi.backend.spi.NFIBackendLibrary;
import com.oracle.truffle.nfi.backend.spi.types.NativeSimpleType;
import com.oracle.truffle.nfi.backend.spi.util.ProfiledArrayBuilder.ArrayBuilderFactory;
import java.util.concurrent.locks.Lock;

@GeneratedBy(LibFFINFIBackend.class)
final class LibFFINFIBackendGen {

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

    static  {
        LibraryExport.register(LibFFINFIBackend.class, new NFIBackendLibraryExports());
    }

    private LibFFINFIBackendGen() {
    }

    @GeneratedBy(LibFFINFIBackend.class)
    private static final class NFIBackendLibraryExports extends LibraryExport {

        private NFIBackendLibraryExports() {
            super(NFIBackendLibrary.class, LibFFINFIBackend.class, false, false, 0);
        }

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

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

        @GeneratedBy(LibFFINFIBackend.class)
        private static final class Cached extends NFIBackendLibrary {

            @Child private InteropLibrary receiverInteropLibrary_;
            @CompilationFinal private volatile int state_0_;
            @CompilationFinal private ArrayBuilderFactory createSignatureBuilderNode__createSignatureBuilder_builderFactory_;

            protected Cached(Object receiver) {
                LibFFINFIBackend castReceiver = ((LibFFINFIBackend) receiver) ;
                this.receiverInteropLibrary_ = super.insert(INTEROP_LIBRARY_.create((castReceiver)));
            }

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

            @Override
            public Object getSimpleType(Object arg0Value_, NativeSimpleType arg1Value) {
                assert arg0Value_ instanceof LibFFINFIBackend : "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.";
                LibFFINFIBackend arg0Value = ((LibFFINFIBackend) arg0Value_);
                {
                    InteropLibrary getSimpleTypeNode__getSimpleType_self__ = this.receiverInteropLibrary_;
                    return arg0Value.getSimpleType(arg1Value, getSimpleTypeNode__getSimpleType_self__);
                }
            }

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

            @Override
            public Object getArrayType(Object arg0Value_, NativeSimpleType arg1Value) {
                assert arg0Value_ instanceof LibFFINFIBackend : "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.";
                LibFFINFIBackend arg0Value = ((LibFFINFIBackend) arg0Value_);
                {
                    InteropLibrary getArrayTypeNode__getArrayType_self__ = this.receiverInteropLibrary_;
                    return arg0Value.getArrayType(arg1Value, getArrayTypeNode__getArrayType_self__);
                }
            }

            @Override
            public Object getEnvType(Object arg0Value_) {
                assert arg0Value_ instanceof LibFFINFIBackend : "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.";
                LibFFINFIBackend arg0Value = ((LibFFINFIBackend) arg0Value_);
                {
                    InteropLibrary getEnvTypeNode__getEnvType_self__ = this.receiverInteropLibrary_;
                    return arg0Value.getEnvType(getEnvTypeNode__getEnvType_self__);
                }
            }

            @Override
            public Object createSignatureBuilder(Object arg0Value_) {
                assert arg0Value_ instanceof LibFFINFIBackend : "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.";
                LibFFINFIBackend arg0Value = ((LibFFINFIBackend) arg0Value_);
                int state_0 = this.state_0_;
                if (state_0 != 0 /* is-state_0 createSignatureBuilder(LibFFINFIBackend, NFIBackendLibrary, ArrayBuilderFactory) */) {
                    {
                        NFIBackendLibrary createSignatureBuilderNode__createSignatureBuilder_self__ = (this);
                        return arg0Value.createSignatureBuilder(createSignatureBuilderNode__createSignatureBuilder_self__, this.createSignatureBuilderNode__createSignatureBuilder_builderFactory_);
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return createSignatureBuilderNode_AndSpecialize(arg0Value);
            }

            private Object createSignatureBuilderNode_AndSpecialize(LibFFINFIBackend arg0Value) {
                Lock lock = getLock();
                boolean hasLock = true;
                lock.lock();
                try {
                    int state_0 = this.state_0_;
                    {
                        NFIBackendLibrary createSignatureBuilderNode__createSignatureBuilder_self__ = null;
                        createSignatureBuilderNode__createSignatureBuilder_self__ = (this);
                        this.createSignatureBuilderNode__createSignatureBuilder_builderFactory_ = (ArrayBuilderFactory.create());
                        this.state_0_ = state_0 = state_0 | 0b1 /* add-state_0 createSignatureBuilder(LibFFINFIBackend, NFIBackendLibrary, ArrayBuilderFactory) */;
                        lock.unlock();
                        hasLock = false;
                        return arg0Value.createSignatureBuilder(createSignatureBuilderNode__createSignatureBuilder_self__, this.createSignatureBuilderNode__createSignatureBuilder_builderFactory_);
                    }
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

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

            protected Uncached() {
            }

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

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

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

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

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

            @TruffleBoundary
            @Override
            public Object getEnvType(Object arg0Value_) {
                // declared: true
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                LibFFINFIBackend arg0Value = ((LibFFINFIBackend) arg0Value_);
                return arg0Value.getEnvType(INTEROP_LIBRARY_.getUncached((arg0Value)));
            }

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

        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy