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

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

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

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.dsl.UnsupportedSpecializationException;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.interop.UnsupportedMessageException;
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.EncapsulatingNodeReference;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.nfi.LongDoubleUtil.FP80Number;
import com.oracle.truffle.nfi.LongDoubleUtil.FP80Number.Serialize;
import com.oracle.truffle.nfi.api.SerializableLibrary;
import java.util.concurrent.locks.Lock;

@GeneratedBy(FP80Number.class)
@SuppressWarnings("unused")
final class FP80NumberGen {

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

    static  {
        LibraryExport.register(FP80Number.class, new SerializableLibraryExports());
    }

    private FP80NumberGen() {
    }

    @GeneratedBy(FP80Number.class)
    private static final class SerializableLibraryExports extends LibraryExport {

        private SerializableLibraryExports() {
            super(SerializableLibrary.class, FP80Number.class, false, false, 0);
        }

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

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

        @GeneratedBy(FP80Number.class)
        private static final class Cached extends SerializableLibrary {

            @Child private InteropLibrary receiverNumberInteropLibrary_;
            @CompilationFinal private volatile int state_0_;
            @CompilationFinal private volatile int exclude_;
            @Child private InteropLibrary long0_bufferInterop_;
            @Child private InteropLibrary double0_bufferInterop_;

            protected Cached(Object receiver) {
                FP80Number castReceiver = ((FP80Number) receiver) ;
                this.receiverNumberInteropLibrary_ = super.insert(INTEROP_LIBRARY_.create((castReceiver.number)));
            }

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

            @Override
            public void serialize(Object arg0Value_, Object arg1Value) throws UnsupportedMessageException {
                assert arg0Value_ instanceof FP80Number : "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.";
                FP80Number arg0Value = ((FP80Number) arg0Value_);
                int state_0 = this.state_0_;
                if (state_0 != 0 /* is-state_0 doLong(FP80Number, Object, InteropLibrary, InteropLibrary) || doLong(FP80Number, Object, InteropLibrary, InteropLibrary) || doDouble(FP80Number, Object, InteropLibrary, InteropLibrary) || doDouble(FP80Number, Object, InteropLibrary, InteropLibrary) */) {
                    if ((state_0 & 0b1) != 0 /* is-state_0 doLong(FP80Number, Object, InteropLibrary, InteropLibrary) */) {
                        if ((this.long0_bufferInterop_.accepts(arg1Value))) {
                            InteropLibrary long0_numberInterop__ = this.receiverNumberInteropLibrary_;
                            if ((long0_numberInterop__.fitsInLong(arg0Value.number))) {
                                Serialize.doLong(arg0Value, arg1Value, long0_numberInterop__, this.long0_bufferInterop_);
                                return;
                            }
                        }
                    }
                    if ((state_0 & 0b10) != 0 /* is-state_0 doLong(FP80Number, Object, InteropLibrary, InteropLibrary) */) {
                        EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                        Node prev_ = encapsulating_.set(this);
                        try {
                            {
                                InteropLibrary long1_numberInterop__ = this.receiverNumberInteropLibrary_;
                                if ((long1_numberInterop__.fitsInLong(arg0Value.number))) {
                                    this.serialize_Long1Boundary(state_0, arg0Value, arg1Value);
                                    return;
                                }
                            }
                        } finally {
                            encapsulating_.set(prev_);
                        }
                    }
                    if ((state_0 & 0b100) != 0 /* is-state_0 doDouble(FP80Number, Object, InteropLibrary, InteropLibrary) */) {
                        if ((this.double0_bufferInterop_.accepts(arg1Value))) {
                            InteropLibrary double0_numberInterop__ = this.receiverNumberInteropLibrary_;
                            if ((double0_numberInterop__.fitsInDouble(arg0Value.number))) {
                                Serialize.doDouble(arg0Value, arg1Value, double0_numberInterop__, this.double0_bufferInterop_);
                                return;
                            }
                        }
                    }
                    if ((state_0 & 0b1000) != 0 /* is-state_0 doDouble(FP80Number, Object, InteropLibrary, InteropLibrary) */) {
                        EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                        Node prev_ = encapsulating_.set(this);
                        try {
                            {
                                InteropLibrary double1_numberInterop__ = this.receiverNumberInteropLibrary_;
                                if ((double1_numberInterop__.fitsInDouble(arg0Value.number))) {
                                    this.serialize_Double1Boundary(state_0, arg0Value, arg1Value);
                                    return;
                                }
                            }
                        } finally {
                            encapsulating_.set(prev_);
                        }
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                executeAndSpecialize(arg0Value, arg1Value);
                return;
            }

            @SuppressWarnings("static-method")
            @TruffleBoundary
            private void serialize_Long1Boundary(int state_0, FP80Number arg0Value, Object arg1Value) throws UnsupportedMessageException {
                {
                    InteropLibrary long1_numberInterop__ = this.receiverNumberInteropLibrary_;
                    InteropLibrary long1_bufferInterop__ = (INTEROP_LIBRARY_.getUncached());
                    Serialize.doLong(arg0Value, arg1Value, long1_numberInterop__, long1_bufferInterop__);
                    return;
                }
            }

            @SuppressWarnings("static-method")
            @TruffleBoundary
            private void serialize_Double1Boundary(int state_0, FP80Number arg0Value, Object arg1Value) throws UnsupportedMessageException {
                {
                    InteropLibrary double1_numberInterop__ = this.receiverNumberInteropLibrary_;
                    InteropLibrary double1_bufferInterop__ = (INTEROP_LIBRARY_.getUncached());
                    Serialize.doDouble(arg0Value, arg1Value, double1_numberInterop__, double1_bufferInterop__);
                    return;
                }
            }

            private void executeAndSpecialize(FP80Number arg0Value, Object arg1Value) {
                Lock lock = getLock();
                boolean hasLock = true;
                lock.lock();
                try {
                    int state_0 = this.state_0_;
                    int exclude = this.exclude_;
                    {
                        InteropLibrary long0_numberInterop__ = null;
                        if (((exclude & 0b1)) == 0 /* is-not-exclude doLong(FP80Number, Object, InteropLibrary, InteropLibrary) */) {
                            boolean Long0_duplicateFound_ = false;
                            if ((state_0 & 0b1) != 0 /* is-state_0 doLong(FP80Number, Object, InteropLibrary, InteropLibrary) */) {
                                if ((this.long0_bufferInterop_.accepts(arg1Value))) {
                                    long0_numberInterop__ = this.receiverNumberInteropLibrary_;
                                    if ((long0_numberInterop__.fitsInLong(arg0Value.number))) {
                                        Long0_duplicateFound_ = true;
                                    }
                                }
                            }
                            if (!Long0_duplicateFound_) {
                                {
                                    long0_numberInterop__ = this.receiverNumberInteropLibrary_;
                                    // assert (this.long0_bufferInterop_.accepts(arg1Value));
                                    if ((long0_numberInterop__.fitsInLong(arg0Value.number)) && ((state_0 & 0b1)) == 0 /* is-not-state_0 doLong(FP80Number, Object, InteropLibrary, InteropLibrary) */) {
                                        this.long0_bufferInterop_ = super.insert((INTEROP_LIBRARY_.create(arg1Value)));
                                        this.state_0_ = state_0 = state_0 | 0b1 /* add-state_0 doLong(FP80Number, Object, InteropLibrary, InteropLibrary) */;
                                        Long0_duplicateFound_ = true;
                                    }
                                }
                            }
                            if (Long0_duplicateFound_) {
                                lock.unlock();
                                hasLock = false;
                                Serialize.doLong(arg0Value, arg1Value, long0_numberInterop__, this.long0_bufferInterop_);
                                return;
                            }
                        }
                    }
                    {
                        InteropLibrary long1_bufferInterop__ = null;
                        InteropLibrary long1_numberInterop__ = null;
                        {
                            EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                            Node prev_ = encapsulating_.set(this);
                            try {
                                {
                                    long1_numberInterop__ = this.receiverNumberInteropLibrary_;
                                    if ((long1_numberInterop__.fitsInLong(arg0Value.number))) {
                                        long1_bufferInterop__ = (INTEROP_LIBRARY_.getUncached());
                                        this.exclude_ = exclude = exclude | 0b1 /* add-exclude doLong(FP80Number, Object, InteropLibrary, InteropLibrary) */;
                                        state_0 = state_0 & 0xfffffffe /* remove-state_0 doLong(FP80Number, Object, InteropLibrary, InteropLibrary) */;
                                        this.state_0_ = state_0 = state_0 | 0b10 /* add-state_0 doLong(FP80Number, Object, InteropLibrary, InteropLibrary) */;
                                        lock.unlock();
                                        hasLock = false;
                                        Serialize.doLong(arg0Value, arg1Value, long1_numberInterop__, long1_bufferInterop__);
                                        return;
                                    }
                                }
                            } finally {
                                encapsulating_.set(prev_);
                            }
                        }
                    }
                    {
                        InteropLibrary double0_numberInterop__ = null;
                        if (((exclude & 0b10)) == 0 /* is-not-exclude doDouble(FP80Number, Object, InteropLibrary, InteropLibrary) */) {
                            boolean Double0_duplicateFound_ = false;
                            if ((state_0 & 0b100) != 0 /* is-state_0 doDouble(FP80Number, Object, InteropLibrary, InteropLibrary) */) {
                                if ((this.double0_bufferInterop_.accepts(arg1Value))) {
                                    double0_numberInterop__ = this.receiverNumberInteropLibrary_;
                                    if ((double0_numberInterop__.fitsInDouble(arg0Value.number))) {
                                        Double0_duplicateFound_ = true;
                                    }
                                }
                            }
                            if (!Double0_duplicateFound_) {
                                {
                                    double0_numberInterop__ = this.receiverNumberInteropLibrary_;
                                    // assert (this.double0_bufferInterop_.accepts(arg1Value));
                                    if ((double0_numberInterop__.fitsInDouble(arg0Value.number)) && ((state_0 & 0b100)) == 0 /* is-not-state_0 doDouble(FP80Number, Object, InteropLibrary, InteropLibrary) */) {
                                        this.double0_bufferInterop_ = super.insert((INTEROP_LIBRARY_.create(arg1Value)));
                                        this.state_0_ = state_0 = state_0 | 0b100 /* add-state_0 doDouble(FP80Number, Object, InteropLibrary, InteropLibrary) */;
                                        Double0_duplicateFound_ = true;
                                    }
                                }
                            }
                            if (Double0_duplicateFound_) {
                                lock.unlock();
                                hasLock = false;
                                Serialize.doDouble(arg0Value, arg1Value, double0_numberInterop__, this.double0_bufferInterop_);
                                return;
                            }
                        }
                    }
                    {
                        InteropLibrary double1_bufferInterop__ = null;
                        InteropLibrary double1_numberInterop__ = null;
                        {
                            EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                            Node prev_ = encapsulating_.set(this);
                            try {
                                {
                                    double1_numberInterop__ = this.receiverNumberInteropLibrary_;
                                    if ((double1_numberInterop__.fitsInDouble(arg0Value.number))) {
                                        double1_bufferInterop__ = (INTEROP_LIBRARY_.getUncached());
                                        this.exclude_ = exclude = exclude | 0b10 /* add-exclude doDouble(FP80Number, Object, InteropLibrary, InteropLibrary) */;
                                        state_0 = state_0 & 0xfffffffb /* remove-state_0 doDouble(FP80Number, Object, InteropLibrary, InteropLibrary) */;
                                        this.state_0_ = state_0 = state_0 | 0b1000 /* add-state_0 doDouble(FP80Number, Object, InteropLibrary, InteropLibrary) */;
                                        lock.unlock();
                                        hasLock = false;
                                        Serialize.doDouble(arg0Value, arg1Value, double1_numberInterop__, double1_bufferInterop__);
                                        return;
                                    }
                                }
                            } finally {
                                encapsulating_.set(prev_);
                            }
                        }
                    }
                    throw new UnsupportedSpecializationException(this, new Node[] {null, null}, arg0Value, arg1Value);
                } 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 isSerializable(Object receiver) {
                assert receiver instanceof FP80Number : "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.";
                return (((FP80Number) receiver)).isSerializable();
            }

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

            protected Uncached() {
            }

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

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

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

            @TruffleBoundary
            @Override
            public void serialize(Object arg0Value_, Object arg1Value) {
                // declared: true
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                FP80Number arg0Value = ((FP80Number) arg0Value_);
                if ((INTEROP_LIBRARY_.getUncached((arg0Value.number)).fitsInLong(arg0Value.number))) {
                    Serialize.doLong(arg0Value, arg1Value, INTEROP_LIBRARY_.getUncached((arg0Value.number)), (INTEROP_LIBRARY_.getUncached(arg1Value)));
                    return;
                }
                if ((INTEROP_LIBRARY_.getUncached((arg0Value.number)).fitsInDouble(arg0Value.number))) {
                    Serialize.doDouble(arg0Value, arg1Value, INTEROP_LIBRARY_.getUncached((arg0Value.number)), (INTEROP_LIBRARY_.getUncached(arg1Value)));
                    return;
                }
                throw new UnsupportedSpecializationException(this, new Node[] {null, null}, arg0Value, arg1Value);
            }

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

        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy