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

com.oracle.truffle.polyglot.PolyglotMapFactory Maven / Gradle / Ivy

Go to download

Truffle is a multi-language framework for executing dynamic languages that achieves high performance when combined with Graal.

There is a newer version: 24.1.1
Show newest version
// CheckStyle: start generated
package com.oracle.truffle.polyglot;

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.LibraryFactory;
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.profiles.BranchProfile;
import com.oracle.truffle.polyglot.PolyglotLanguageContext.ToGuestValueNode;
import com.oracle.truffle.polyglot.PolyglotLanguageContextFactory.ToGuestValueNodeGen;
import com.oracle.truffle.polyglot.PolyglotMap.Cache;
import com.oracle.truffle.polyglot.PolyglotMap.Cache.ContainsKeyNode;
import com.oracle.truffle.polyglot.PolyglotMap.Cache.EntrySet;
import com.oracle.truffle.polyglot.PolyglotMap.Cache.GetNode;
import com.oracle.truffle.polyglot.PolyglotMap.Cache.PolyglotMapNode;
import com.oracle.truffle.polyglot.PolyglotMap.Cache.Put;
import com.oracle.truffle.polyglot.PolyglotMap.Cache.RemoveBoolean;
import com.oracle.truffle.polyglot.PolyglotMap.Cache.RemoveNode;
import java.util.concurrent.locks.Lock;

@GeneratedBy(PolyglotMap.class)
@SuppressWarnings("unused")
final class PolyglotMapFactory {

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

    @GeneratedBy(Cache.class)
    static final class CacheFactory {

        @GeneratedBy(ContainsKeyNode.class)
        static final class ContainsKeyNodeGen extends ContainsKeyNode {

            @CompilationFinal private volatile int state_;
            @CompilationFinal private volatile int exclude_;
            @Child private Cached0Data cached0_cache;

            private ContainsKeyNodeGen(Cache cache) {
                super(cache);
            }

            @ExplodeLoop
            @Override
            protected Object executeImpl(PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                int state = state_;
                if (state != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary) || doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary) */) {
                    if ((state & 0b1) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary) */) {
                        Cached0Data s1_ = this.cached0_cache;
                        while (s1_ != null) {
                            if ((s1_.interop_.accepts(arg1Value))) {
                                return doCached(arg0Value, arg1Value, arg2Value, s1_.interop_);
                            }
                            s1_ = s1_.next_;
                        }
                    }
                    if ((state & 0b10) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary) */) {
                        return this.cached1Boundary(state, arg0Value, arg1Value, arg2Value);
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
            }

            @SuppressWarnings("static-method")
            @TruffleBoundary
            private Object cached1Boundary(int state, PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                Node prev_ = encapsulating_.set(this);
                try {
                    {
                        InteropLibrary cached1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                        return doCached(arg0Value, arg1Value, arg2Value, cached1_interop__);
                    }
                } finally {
                    encapsulating_.set(prev_);
                }
            }

            private Object executeAndSpecialize(PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                Lock lock = getLock();
                boolean hasLock = true;
                lock.lock();
                int state = state_;
                int exclude = exclude_;
                try {
                    if ((exclude) == 0 /* is-not-excluded doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary) */) {
                        int count1_ = 0;
                        Cached0Data s1_ = this.cached0_cache;
                        if ((state & 0b1) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary) */) {
                            while (s1_ != null) {
                                if ((s1_.interop_.accepts(arg1Value))) {
                                    break;
                                }
                                s1_ = s1_.next_;
                                count1_++;
                            }
                        }
                        if (s1_ == null) {
                            // assert (s1_.interop_.accepts(arg1Value));
                            if (count1_ < (PolyglotMapNode.LIMIT)) {
                                s1_ = super.insert(new Cached0Data(cached0_cache));
                                s1_.interop_ = s1_.insertAccessor((INTEROP_LIBRARY_.create(arg1Value)));
                                this.cached0_cache = s1_;
                                this.state_ = state = state | 0b1 /* add-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary) */;
                            }
                        }
                        if (s1_ != null) {
                            lock.unlock();
                            hasLock = false;
                            return doCached(arg0Value, arg1Value, arg2Value, s1_.interop_);
                        }
                    }
                    {
                        InteropLibrary cached1_interop__ = null;
                        {
                            EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                            Node prev_ = encapsulating_.set(this);
                            try {
                                cached1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                                this.exclude_ = exclude = exclude | 0b1 /* add-excluded doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary) */;
                                this.cached0_cache = null;
                                state = state & 0xfffffffe /* remove-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary) */;
                                this.state_ = state = state | 0b10 /* add-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary) */;
                                lock.unlock();
                                hasLock = false;
                                return doCached(arg0Value, arg1Value, arg2Value, cached1_interop__);
                            } finally {
                                encapsulating_.set(prev_);
                            }
                        }
                    }
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

            @Override
            public NodeCost getCost() {
                int state = state_;
                if (state == 0b0) {
                    return NodeCost.UNINITIALIZED;
                } else if ((state & (state - 1)) == 0 /* is-single-active  */) {
                    Cached0Data s1_ = this.cached0_cache;
                    if ((s1_ == null || s1_.next_ == null)) {
                        return NodeCost.MONOMORPHIC;
                    }
                }
                return NodeCost.POLYMORPHIC;
            }

            public static ContainsKeyNode create(Cache cache) {
                return new ContainsKeyNodeGen(cache);
            }

            @GeneratedBy(ContainsKeyNode.class)
            private static final class Cached0Data extends Node {

                @Child Cached0Data next_;
                @Child InteropLibrary interop_;

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

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

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

            }
        }
        @GeneratedBy(EntrySet.class)
        static final class EntrySetNodeGen extends EntrySet {

            @CompilationFinal private volatile int state_;
            @CompilationFinal private volatile int exclude_;
            @Child private Cached0Data cached0_cache;
            @Child private ToHostNode cached1_toHost_;
            @CompilationFinal private BranchProfile cached1_error_;

            private EntrySetNodeGen(Cache cache) {
                super(cache);
            }

            @ExplodeLoop
            @Override
            protected Object executeImpl(PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                int state = state_;
                if (state != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) || doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */) {
                    if ((state & 0b1) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */) {
                        Cached0Data s1_ = this.cached0_cache;
                        while (s1_ != null) {
                            if ((s1_.interop_.accepts(arg1Value))) {
                                return doCached(arg0Value, arg1Value, arg2Value, s1_.interop_, s1_.toHost_, s1_.error_);
                            }
                            s1_ = s1_.next_;
                        }
                    }
                    if ((state & 0b10) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */) {
                        return this.cached1Boundary(state, arg0Value, arg1Value, arg2Value);
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
            }

            @SuppressWarnings("static-method")
            @TruffleBoundary
            private Object cached1Boundary(int state, PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                Node prev_ = encapsulating_.set(this);
                try {
                    {
                        InteropLibrary cached1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                        return doCached(arg0Value, arg1Value, arg2Value, cached1_interop__, this.cached1_toHost_, this.cached1_error_);
                    }
                } finally {
                    encapsulating_.set(prev_);
                }
            }

            private Object executeAndSpecialize(PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                Lock lock = getLock();
                boolean hasLock = true;
                lock.lock();
                int state = state_;
                int exclude = exclude_;
                try {
                    if ((exclude) == 0 /* is-not-excluded doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */) {
                        int count1_ = 0;
                        Cached0Data s1_ = this.cached0_cache;
                        if ((state & 0b1) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */) {
                            while (s1_ != null) {
                                if ((s1_.interop_.accepts(arg1Value))) {
                                    break;
                                }
                                s1_ = s1_.next_;
                                count1_++;
                            }
                        }
                        if (s1_ == null) {
                            // assert (s1_.interop_.accepts(arg1Value));
                            if (count1_ < (PolyglotMapNode.LIMIT)) {
                                s1_ = super.insert(new Cached0Data(cached0_cache));
                                s1_.interop_ = s1_.insertAccessor((INTEROP_LIBRARY_.create(arg1Value)));
                                s1_.toHost_ = s1_.insertAccessor((ToHostNodeGen.create()));
                                s1_.error_ = (BranchProfile.create());
                                this.cached0_cache = s1_;
                                this.state_ = state = state | 0b1 /* add-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */;
                            }
                        }
                        if (s1_ != null) {
                            lock.unlock();
                            hasLock = false;
                            return doCached(arg0Value, arg1Value, arg2Value, s1_.interop_, s1_.toHost_, s1_.error_);
                        }
                    }
                    {
                        InteropLibrary cached1_interop__ = null;
                        {
                            EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                            Node prev_ = encapsulating_.set(this);
                            try {
                                cached1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                                this.cached1_toHost_ = super.insert((ToHostNodeGen.create()));
                                this.cached1_error_ = (BranchProfile.create());
                                this.exclude_ = exclude = exclude | 0b1 /* add-excluded doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */;
                                this.cached0_cache = null;
                                state = state & 0xfffffffe /* remove-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */;
                                this.state_ = state = state | 0b10 /* add-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */;
                                lock.unlock();
                                hasLock = false;
                                return doCached(arg0Value, arg1Value, arg2Value, cached1_interop__, this.cached1_toHost_, this.cached1_error_);
                            } finally {
                                encapsulating_.set(prev_);
                            }
                        }
                    }
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

            @Override
            public NodeCost getCost() {
                int state = state_;
                if (state == 0b0) {
                    return NodeCost.UNINITIALIZED;
                } else if ((state & (state - 1)) == 0 /* is-single-active  */) {
                    Cached0Data s1_ = this.cached0_cache;
                    if ((s1_ == null || s1_.next_ == null)) {
                        return NodeCost.MONOMORPHIC;
                    }
                }
                return NodeCost.POLYMORPHIC;
            }

            public static EntrySet create(Cache cache) {
                return new EntrySetNodeGen(cache);
            }

            @GeneratedBy(EntrySet.class)
            private static final class Cached0Data extends Node {

                @Child Cached0Data next_;
                @Child InteropLibrary interop_;
                @Child ToHostNode toHost_;
                @CompilationFinal BranchProfile error_;

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

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

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

            }
        }
        @GeneratedBy(GetNode.class)
        static final class GetNodeGen extends GetNode {

            @CompilationFinal private volatile int state_;
            @CompilationFinal private volatile int exclude_;
            @Child private Cached0Data cached0_cache;
            @Child private ToHostNode cached1_toHost_;
            @CompilationFinal private BranchProfile cached1_error_;

            private GetNodeGen(Cache cache) {
                super(cache);
            }

            @ExplodeLoop
            @Override
            protected Object executeImpl(PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                int state = state_;
                if (state != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) || doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */) {
                    if ((state & 0b1) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */) {
                        Cached0Data s1_ = this.cached0_cache;
                        while (s1_ != null) {
                            if ((s1_.interop_.accepts(arg1Value))) {
                                return doCached(arg0Value, arg1Value, arg2Value, s1_.interop_, s1_.toHost_, s1_.error_);
                            }
                            s1_ = s1_.next_;
                        }
                    }
                    if ((state & 0b10) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */) {
                        return this.cached1Boundary(state, arg0Value, arg1Value, arg2Value);
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
            }

            @SuppressWarnings("static-method")
            @TruffleBoundary
            private Object cached1Boundary(int state, PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                Node prev_ = encapsulating_.set(this);
                try {
                    {
                        InteropLibrary cached1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                        return doCached(arg0Value, arg1Value, arg2Value, cached1_interop__, this.cached1_toHost_, this.cached1_error_);
                    }
                } finally {
                    encapsulating_.set(prev_);
                }
            }

            private Object executeAndSpecialize(PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                Lock lock = getLock();
                boolean hasLock = true;
                lock.lock();
                int state = state_;
                int exclude = exclude_;
                try {
                    if ((exclude) == 0 /* is-not-excluded doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */) {
                        int count1_ = 0;
                        Cached0Data s1_ = this.cached0_cache;
                        if ((state & 0b1) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */) {
                            while (s1_ != null) {
                                if ((s1_.interop_.accepts(arg1Value))) {
                                    break;
                                }
                                s1_ = s1_.next_;
                                count1_++;
                            }
                        }
                        if (s1_ == null) {
                            // assert (s1_.interop_.accepts(arg1Value));
                            if (count1_ < (PolyglotMapNode.LIMIT)) {
                                s1_ = super.insert(new Cached0Data(cached0_cache));
                                s1_.interop_ = s1_.insertAccessor((INTEROP_LIBRARY_.create(arg1Value)));
                                s1_.toHost_ = s1_.insertAccessor((ToHostNodeGen.create()));
                                s1_.error_ = (BranchProfile.create());
                                this.cached0_cache = s1_;
                                this.state_ = state = state | 0b1 /* add-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */;
                            }
                        }
                        if (s1_ != null) {
                            lock.unlock();
                            hasLock = false;
                            return doCached(arg0Value, arg1Value, arg2Value, s1_.interop_, s1_.toHost_, s1_.error_);
                        }
                    }
                    {
                        InteropLibrary cached1_interop__ = null;
                        {
                            EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                            Node prev_ = encapsulating_.set(this);
                            try {
                                cached1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                                this.cached1_toHost_ = super.insert((ToHostNodeGen.create()));
                                this.cached1_error_ = (BranchProfile.create());
                                this.exclude_ = exclude = exclude | 0b1 /* add-excluded doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */;
                                this.cached0_cache = null;
                                state = state & 0xfffffffe /* remove-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */;
                                this.state_ = state = state | 0b10 /* add-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToHostNode, BranchProfile) */;
                                lock.unlock();
                                hasLock = false;
                                return doCached(arg0Value, arg1Value, arg2Value, cached1_interop__, this.cached1_toHost_, this.cached1_error_);
                            } finally {
                                encapsulating_.set(prev_);
                            }
                        }
                    }
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

            @Override
            public NodeCost getCost() {
                int state = state_;
                if (state == 0b0) {
                    return NodeCost.UNINITIALIZED;
                } else if ((state & (state - 1)) == 0 /* is-single-active  */) {
                    Cached0Data s1_ = this.cached0_cache;
                    if ((s1_ == null || s1_.next_ == null)) {
                        return NodeCost.MONOMORPHIC;
                    }
                }
                return NodeCost.POLYMORPHIC;
            }

            public static GetNode create(Cache cache) {
                return new GetNodeGen(cache);
            }

            @GeneratedBy(GetNode.class)
            private static final class Cached0Data extends Node {

                @Child Cached0Data next_;
                @Child InteropLibrary interop_;
                @Child ToHostNode toHost_;
                @CompilationFinal BranchProfile error_;

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

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

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

            }
        }
        @GeneratedBy(Put.class)
        static final class PutNodeGen extends Put {

            @CompilationFinal private volatile int state_;
            @CompilationFinal private volatile int exclude_;
            @Child private Cached0Data cached0_cache;
            @Child private ToGuestValueNode cached1_toGuest_;
            @CompilationFinal private BranchProfile cached1_error_;

            private PutNodeGen(Cache cache) {
                super(cache);
            }

            @ExplodeLoop
            @Override
            protected Object executeImpl(PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                int state = state_;
                if (state != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToGuestValueNode, BranchProfile) || doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToGuestValueNode, BranchProfile) */) {
                    if ((state & 0b1) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToGuestValueNode, BranchProfile) */) {
                        Cached0Data s1_ = this.cached0_cache;
                        while (s1_ != null) {
                            if ((s1_.interop_.accepts(arg1Value))) {
                                return doCached(arg0Value, arg1Value, arg2Value, s1_.interop_, s1_.toGuest_, s1_.error_);
                            }
                            s1_ = s1_.next_;
                        }
                    }
                    if ((state & 0b10) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToGuestValueNode, BranchProfile) */) {
                        return this.cached1Boundary(state, arg0Value, arg1Value, arg2Value);
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
            }

            @SuppressWarnings("static-method")
            @TruffleBoundary
            private Object cached1Boundary(int state, PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                Node prev_ = encapsulating_.set(this);
                try {
                    {
                        InteropLibrary cached1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                        return doCached(arg0Value, arg1Value, arg2Value, cached1_interop__, this.cached1_toGuest_, this.cached1_error_);
                    }
                } finally {
                    encapsulating_.set(prev_);
                }
            }

            private Object executeAndSpecialize(PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                Lock lock = getLock();
                boolean hasLock = true;
                lock.lock();
                int state = state_;
                int exclude = exclude_;
                try {
                    if ((exclude) == 0 /* is-not-excluded doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToGuestValueNode, BranchProfile) */) {
                        int count1_ = 0;
                        Cached0Data s1_ = this.cached0_cache;
                        if ((state & 0b1) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToGuestValueNode, BranchProfile) */) {
                            while (s1_ != null) {
                                if ((s1_.interop_.accepts(arg1Value))) {
                                    break;
                                }
                                s1_ = s1_.next_;
                                count1_++;
                            }
                        }
                        if (s1_ == null) {
                            // assert (s1_.interop_.accepts(arg1Value));
                            if (count1_ < (PolyglotMapNode.LIMIT)) {
                                s1_ = super.insert(new Cached0Data(cached0_cache));
                                s1_.interop_ = s1_.insertAccessor((INTEROP_LIBRARY_.create(arg1Value)));
                                s1_.toGuest_ = s1_.insertAccessor((ToGuestValueNodeGen.create()));
                                s1_.error_ = (BranchProfile.create());
                                this.cached0_cache = s1_;
                                this.state_ = state = state | 0b1 /* add-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToGuestValueNode, BranchProfile) */;
                            }
                        }
                        if (s1_ != null) {
                            lock.unlock();
                            hasLock = false;
                            return doCached(arg0Value, arg1Value, arg2Value, s1_.interop_, s1_.toGuest_, s1_.error_);
                        }
                    }
                    {
                        InteropLibrary cached1_interop__ = null;
                        {
                            EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                            Node prev_ = encapsulating_.set(this);
                            try {
                                cached1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                                this.cached1_toGuest_ = super.insert((ToGuestValueNodeGen.create()));
                                this.cached1_error_ = (BranchProfile.create());
                                this.exclude_ = exclude = exclude | 0b1 /* add-excluded doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToGuestValueNode, BranchProfile) */;
                                this.cached0_cache = null;
                                state = state & 0xfffffffe /* remove-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToGuestValueNode, BranchProfile) */;
                                this.state_ = state = state | 0b10 /* add-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, ToGuestValueNode, BranchProfile) */;
                                lock.unlock();
                                hasLock = false;
                                return doCached(arg0Value, arg1Value, arg2Value, cached1_interop__, this.cached1_toGuest_, this.cached1_error_);
                            } finally {
                                encapsulating_.set(prev_);
                            }
                        }
                    }
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

            @Override
            public NodeCost getCost() {
                int state = state_;
                if (state == 0b0) {
                    return NodeCost.UNINITIALIZED;
                } else if ((state & (state - 1)) == 0 /* is-single-active  */) {
                    Cached0Data s1_ = this.cached0_cache;
                    if ((s1_ == null || s1_.next_ == null)) {
                        return NodeCost.MONOMORPHIC;
                    }
                }
                return NodeCost.POLYMORPHIC;
            }

            public static Put create(Cache cache) {
                return new PutNodeGen(cache);
            }

            @GeneratedBy(Put.class)
            private static final class Cached0Data extends Node {

                @Child Cached0Data next_;
                @Child InteropLibrary interop_;
                @Child ToGuestValueNode toGuest_;
                @CompilationFinal BranchProfile error_;

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

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

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

            }
        }
        @GeneratedBy(RemoveNode.class)
        static final class RemoveNodeGen extends RemoveNode {

            @CompilationFinal private volatile int state_;
            @CompilationFinal private volatile int exclude_;
            @Child private Cached0Data cached0_cache;
            @CompilationFinal private BranchProfile cached1_error_;

            private RemoveNodeGen(Cache cache) {
                super(cache);
            }

            @ExplodeLoop
            @Override
            protected Object executeImpl(PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                int state = state_;
                if (state != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) || doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */) {
                    if ((state & 0b1) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */) {
                        Cached0Data s1_ = this.cached0_cache;
                        while (s1_ != null) {
                            if ((s1_.interop_.accepts(arg1Value))) {
                                return doCached(arg0Value, arg1Value, arg2Value, s1_.interop_, s1_.error_);
                            }
                            s1_ = s1_.next_;
                        }
                    }
                    if ((state & 0b10) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */) {
                        return this.cached1Boundary(state, arg0Value, arg1Value, arg2Value);
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
            }

            @SuppressWarnings("static-method")
            @TruffleBoundary
            private Object cached1Boundary(int state, PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                Node prev_ = encapsulating_.set(this);
                try {
                    {
                        InteropLibrary cached1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                        return doCached(arg0Value, arg1Value, arg2Value, cached1_interop__, this.cached1_error_);
                    }
                } finally {
                    encapsulating_.set(prev_);
                }
            }

            private Object executeAndSpecialize(PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                Lock lock = getLock();
                boolean hasLock = true;
                lock.lock();
                int state = state_;
                int exclude = exclude_;
                try {
                    if ((exclude) == 0 /* is-not-excluded doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */) {
                        int count1_ = 0;
                        Cached0Data s1_ = this.cached0_cache;
                        if ((state & 0b1) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */) {
                            while (s1_ != null) {
                                if ((s1_.interop_.accepts(arg1Value))) {
                                    break;
                                }
                                s1_ = s1_.next_;
                                count1_++;
                            }
                        }
                        if (s1_ == null) {
                            // assert (s1_.interop_.accepts(arg1Value));
                            if (count1_ < (PolyglotMapNode.LIMIT)) {
                                s1_ = super.insert(new Cached0Data(cached0_cache));
                                s1_.interop_ = s1_.insertAccessor((INTEROP_LIBRARY_.create(arg1Value)));
                                s1_.error_ = (BranchProfile.create());
                                this.cached0_cache = s1_;
                                this.state_ = state = state | 0b1 /* add-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */;
                            }
                        }
                        if (s1_ != null) {
                            lock.unlock();
                            hasLock = false;
                            return doCached(arg0Value, arg1Value, arg2Value, s1_.interop_, s1_.error_);
                        }
                    }
                    {
                        InteropLibrary cached1_interop__ = null;
                        {
                            EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                            Node prev_ = encapsulating_.set(this);
                            try {
                                cached1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                                this.cached1_error_ = (BranchProfile.create());
                                this.exclude_ = exclude = exclude | 0b1 /* add-excluded doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */;
                                this.cached0_cache = null;
                                state = state & 0xfffffffe /* remove-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */;
                                this.state_ = state = state | 0b10 /* add-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */;
                                lock.unlock();
                                hasLock = false;
                                return doCached(arg0Value, arg1Value, arg2Value, cached1_interop__, this.cached1_error_);
                            } finally {
                                encapsulating_.set(prev_);
                            }
                        }
                    }
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

            @Override
            public NodeCost getCost() {
                int state = state_;
                if (state == 0b0) {
                    return NodeCost.UNINITIALIZED;
                } else if ((state & (state - 1)) == 0 /* is-single-active  */) {
                    Cached0Data s1_ = this.cached0_cache;
                    if ((s1_ == null || s1_.next_ == null)) {
                        return NodeCost.MONOMORPHIC;
                    }
                }
                return NodeCost.POLYMORPHIC;
            }

            public static RemoveNode create(Cache cache) {
                return new RemoveNodeGen(cache);
            }

            @GeneratedBy(RemoveNode.class)
            private static final class Cached0Data extends Node {

                @Child Cached0Data next_;
                @Child InteropLibrary interop_;
                @CompilationFinal BranchProfile error_;

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

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

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

            }
        }
        @GeneratedBy(RemoveBoolean.class)
        static final class RemoveBooleanNodeGen extends RemoveBoolean {

            @CompilationFinal private volatile int state_;
            @CompilationFinal private volatile int exclude_;
            @Child private Cached0Data cached0_cache;
            @CompilationFinal private BranchProfile cached1_error_;

            private RemoveBooleanNodeGen(Cache cache) {
                super(cache);
            }

            @ExplodeLoop
            @Override
            protected Object executeImpl(PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                int state = state_;
                if (state != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) || doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */) {
                    if ((state & 0b1) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */) {
                        Cached0Data s1_ = this.cached0_cache;
                        while (s1_ != null) {
                            if ((s1_.interop_.accepts(arg1Value))) {
                                return doCached(arg0Value, arg1Value, arg2Value, s1_.interop_, s1_.error_);
                            }
                            s1_ = s1_.next_;
                        }
                    }
                    if ((state & 0b10) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */) {
                        return this.cached1Boundary(state, arg0Value, arg1Value, arg2Value);
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return executeAndSpecialize(arg0Value, arg1Value, arg2Value);
            }

            @SuppressWarnings("static-method")
            @TruffleBoundary
            private Object cached1Boundary(int state, PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                Node prev_ = encapsulating_.set(this);
                try {
                    {
                        InteropLibrary cached1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                        return doCached(arg0Value, arg1Value, arg2Value, cached1_interop__, this.cached1_error_);
                    }
                } finally {
                    encapsulating_.set(prev_);
                }
            }

            private Object executeAndSpecialize(PolyglotLanguageContext arg0Value, Object arg1Value, Object[] arg2Value) {
                Lock lock = getLock();
                boolean hasLock = true;
                lock.lock();
                int state = state_;
                int exclude = exclude_;
                try {
                    if ((exclude) == 0 /* is-not-excluded doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */) {
                        int count1_ = 0;
                        Cached0Data s1_ = this.cached0_cache;
                        if ((state & 0b1) != 0 /* is-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */) {
                            while (s1_ != null) {
                                if ((s1_.interop_.accepts(arg1Value))) {
                                    break;
                                }
                                s1_ = s1_.next_;
                                count1_++;
                            }
                        }
                        if (s1_ == null) {
                            // assert (s1_.interop_.accepts(arg1Value));
                            if (count1_ < (PolyglotMapNode.LIMIT)) {
                                s1_ = super.insert(new Cached0Data(cached0_cache));
                                s1_.interop_ = s1_.insertAccessor((INTEROP_LIBRARY_.create(arg1Value)));
                                s1_.error_ = (BranchProfile.create());
                                this.cached0_cache = s1_;
                                this.state_ = state = state | 0b1 /* add-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */;
                            }
                        }
                        if (s1_ != null) {
                            lock.unlock();
                            hasLock = false;
                            return doCached(arg0Value, arg1Value, arg2Value, s1_.interop_, s1_.error_);
                        }
                    }
                    {
                        InteropLibrary cached1_interop__ = null;
                        {
                            EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                            Node prev_ = encapsulating_.set(this);
                            try {
                                cached1_interop__ = (INTEROP_LIBRARY_.getUncached(arg1Value));
                                this.cached1_error_ = (BranchProfile.create());
                                this.exclude_ = exclude = exclude | 0b1 /* add-excluded doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */;
                                this.cached0_cache = null;
                                state = state & 0xfffffffe /* remove-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */;
                                this.state_ = state = state | 0b10 /* add-active doCached(PolyglotLanguageContext, Object, Object[], InteropLibrary, BranchProfile) */;
                                lock.unlock();
                                hasLock = false;
                                return doCached(arg0Value, arg1Value, arg2Value, cached1_interop__, this.cached1_error_);
                            } finally {
                                encapsulating_.set(prev_);
                            }
                        }
                    }
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

            @Override
            public NodeCost getCost() {
                int state = state_;
                if (state == 0b0) {
                    return NodeCost.UNINITIALIZED;
                } else if ((state & (state - 1)) == 0 /* is-single-active  */) {
                    Cached0Data s1_ = this.cached0_cache;
                    if ((s1_ == null || s1_.next_ == null)) {
                        return NodeCost.MONOMORPHIC;
                    }
                }
                return NodeCost.POLYMORPHIC;
            }

            public static RemoveBoolean create(Cache cache) {
                return new RemoveBooleanNodeGen(cache);
            }

            @GeneratedBy(RemoveBoolean.class)
            private static final class Cached0Data extends Node {

                @Child Cached0Data next_;
                @Child InteropLibrary interop_;
                @CompilationFinal BranchProfile error_;

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

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

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

            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy