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

com.oracle.truffle.sl.builtins.SLIsInstanceBuiltinFactory Maven / Gradle / Ivy

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

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.NodeFactory;
import com.oracle.truffle.api.dsl.UnsupportedSpecializationException;
import com.oracle.truffle.api.frame.VirtualFrame;
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.sl.nodes.SLExpressionNode;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.locks.Lock;

@GeneratedBy(SLIsInstanceBuiltin.class)
@SuppressWarnings("unused")
public final class SLIsInstanceBuiltinFactory implements NodeFactory {

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

    private SLIsInstanceBuiltinFactory() {
    }

    @Override
    public Class getNodeClass() {
        return SLIsInstanceBuiltin.class;
    }

    @Override
    public List> getExecutionSignature() {
        return Arrays.asList(SLExpressionNode.class, SLExpressionNode.class);
    }

    @Override
    public List>> getNodeSignatures() {
        return Arrays.asList(Arrays.asList(SLExpressionNode[].class));
    }

    @Override
    public SLIsInstanceBuiltin createNode(Object... arguments) {
        if (arguments.length == 1 && (arguments[0] == null || arguments[0] instanceof SLExpressionNode[])) {
            return create((SLExpressionNode[]) arguments[0]);
        } else {
            throw new IllegalArgumentException("Invalid create signature.");
        }
    }

    public static NodeFactory getInstance() {
        return INSTANCE;
    }

    public static SLIsInstanceBuiltin create(SLExpressionNode[] arguments) {
        return new SLIsInstanceBuiltinNodeGen(arguments);
    }

    @GeneratedBy(SLIsInstanceBuiltin.class)
    public static final class SLIsInstanceBuiltinNodeGen extends SLIsInstanceBuiltin {

        @Child private SLExpressionNode arguments0_;
        @Child private SLExpressionNode arguments1_;
        @CompilationFinal private volatile int state_;
        @CompilationFinal private volatile int exclude_;
        @Child private Default0Data default0_cache;

        private SLIsInstanceBuiltinNodeGen(SLExpressionNode[] arguments) {
            this.arguments0_ = arguments != null && 0 < arguments.length ? arguments[0] : null;
            this.arguments1_ = arguments != null && 1 < arguments.length ? arguments[1] : null;
        }

        @ExplodeLoop
        @Override
        protected Object execute(VirtualFrame frameValue) {
            int state = state_;
            Object arguments0Value_ = this.arguments0_.executeGeneric(frameValue);
            Object arguments1Value_ = this.arguments1_.executeGeneric(frameValue);
            if (state != 0 /* is-active doDefault(Object, Object, InteropLibrary) || doDefault(Object, Object, InteropLibrary) */) {
                if ((state & 0b1) != 0 /* is-active doDefault(Object, Object, InteropLibrary) */) {
                    Default0Data s1_ = this.default0_cache;
                    while (s1_ != null) {
                        if ((s1_.metaLib_.accepts(arguments0Value_)) && (s1_.metaLib_.isMetaObject(arguments0Value_))) {
                            return doDefault(arguments0Value_, arguments1Value_, s1_.metaLib_);
                        }
                        s1_ = s1_.next_;
                    }
                }
                if ((state & 0b10) != 0 /* is-active doDefault(Object, Object, InteropLibrary) */) {
                    EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                    Node prev_ = encapsulating_.set(this);
                    try {
                        {
                            InteropLibrary default1_metaLib__ = (INTEROP_LIBRARY_.getUncached());
                            if ((default1_metaLib__.isMetaObject(arguments0Value_))) {
                                return this.default1Boundary(state, arguments0Value_, arguments1Value_);
                            }
                        }
                    } finally {
                        encapsulating_.set(prev_);
                    }
                }
            }
            CompilerDirectives.transferToInterpreterAndInvalidate();
            return executeAndSpecialize(arguments0Value_, arguments1Value_);
        }

        @SuppressWarnings("static-method")
        @TruffleBoundary
        private Object default1Boundary(int state, Object arguments0Value_, Object arguments1Value_) {
            {
                InteropLibrary default1_metaLib__ = (INTEROP_LIBRARY_.getUncached());
                return doDefault(arguments0Value_, arguments1Value_, default1_metaLib__);
            }
        }

        private Object executeAndSpecialize(Object arguments0Value, Object arguments1Value) {
            Lock lock = getLock();
            boolean hasLock = true;
            lock.lock();
            int state = state_;
            int exclude = exclude_;
            try {
                if ((exclude) == 0 /* is-not-excluded doDefault(Object, Object, InteropLibrary) */) {
                    int count1_ = 0;
                    Default0Data s1_ = this.default0_cache;
                    if ((state & 0b1) != 0 /* is-active doDefault(Object, Object, InteropLibrary) */) {
                        while (s1_ != null) {
                            if ((s1_.metaLib_.accepts(arguments0Value)) && (s1_.metaLib_.isMetaObject(arguments0Value))) {
                                break;
                            }
                            s1_ = s1_.next_;
                            count1_++;
                        }
                    }
                    if (s1_ == null) {
                        {
                            InteropLibrary metaLib__ = super.insert((INTEROP_LIBRARY_.create(arguments0Value)));
                            // assert (s1_.metaLib_.accepts(arguments0Value));
                            if ((metaLib__.isMetaObject(arguments0Value)) && count1_ < (3)) {
                                s1_ = super.insert(new Default0Data(default0_cache));
                                s1_.metaLib_ = s1_.insertAccessor(metaLib__);
                                this.default0_cache = s1_;
                                this.state_ = state = state | 0b1 /* add-active doDefault(Object, Object, InteropLibrary) */;
                            }
                        }
                    }
                    if (s1_ != null) {
                        lock.unlock();
                        hasLock = false;
                        return doDefault(arguments0Value, arguments1Value, s1_.metaLib_);
                    }
                }
                {
                    InteropLibrary default1_metaLib__ = null;
                    {
                        EncapsulatingNodeReference encapsulating_ = EncapsulatingNodeReference.getCurrent();
                        Node prev_ = encapsulating_.set(this);
                        try {
                            {
                                default1_metaLib__ = (INTEROP_LIBRARY_.getUncached());
                                if ((default1_metaLib__.isMetaObject(arguments0Value))) {
                                    this.exclude_ = exclude = exclude | 0b1 /* add-excluded doDefault(Object, Object, InteropLibrary) */;
                                    this.default0_cache = null;
                                    state = state & 0xfffffffe /* remove-active doDefault(Object, Object, InteropLibrary) */;
                                    this.state_ = state = state | 0b10 /* add-active doDefault(Object, Object, InteropLibrary) */;
                                    lock.unlock();
                                    hasLock = false;
                                    return doDefault(arguments0Value, arguments1Value, default1_metaLib__);
                                }
                            }
                        } finally {
                            encapsulating_.set(prev_);
                        }
                    }
                }
                throw new UnsupportedSpecializationException(this, new Node[] {this.arguments0_, this.arguments1_}, arguments0Value, arguments1Value);
            } 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  */) {
                Default0Data s1_ = this.default0_cache;
                if ((s1_ == null || s1_.next_ == null)) {
                    return NodeCost.MONOMORPHIC;
                }
            }
            return NodeCost.POLYMORPHIC;
        }

        @GeneratedBy(SLIsInstanceBuiltin.class)
        private static final class Default0Data extends Node {

            @Child Default0Data next_;
            @Child InteropLibrary metaLib_;

            Default0Data(Default0Data 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