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

com.oracle.truffle.sl.nodes.local.SLScopedNodeGen Maven / Gradle / Ivy

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

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.TruffleLanguage.ContextReference;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.frame.Frame;
import com.oracle.truffle.api.interop.NodeLibrary;
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.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.sl.SLLanguage;
import com.oracle.truffle.sl.runtime.SLContext;
import java.util.concurrent.locks.Lock;

@GeneratedBy(SLScopedNode.class)
final class SLScopedNodeGen {

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

    static  {
        LibraryExport.register(SLScopedNode.class, new NodeLibraryExports());
    }

    private SLScopedNodeGen() {
    }

    @GeneratedBy(SLScopedNode.class)
    private static final class NodeLibraryExports extends LibraryExport {

        private NodeLibraryExports() {
            super(NodeLibrary.class, SLScopedNode.class, false);
        }

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

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

        @GeneratedBy(SLScopedNode.class)
        private static final class Cached extends NodeLibrary {

            private final Class receiverClass_;
            @CompilationFinal private volatile int state_;
            @CompilationFinal private SLScopedNode node;
            @CompilationFinal private ContextReference sLLanguageContextReference_;
            @CompilationFinal private Node getScopeNode__blockNode_;

            Cached(Object originalReceiver) {
                SLScopedNode receiver = ((SLScopedNode) originalReceiver) ;
                this.node = (receiver);
                this.receiverClass_ = receiver.getClass();
            }

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

            private boolean accepts_(Object arg0Value_) {
                SLScopedNode arg0Value = CompilerDirectives.castExact(arg0Value_, receiverClass_);
                return arg0Value.accepts(this.node);
            }

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

            @Override
            public boolean hasScope(Object receiver, Frame frame) {
                assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
                assert getRootNode() != null : "Invalid libray usage. Cached library must be adopted by a RootNode before it is executed.";
                return (CompilerDirectives.castExact(receiver, receiverClass_)).hasScope(frame);
            }

            @Override
            public Object getScope(Object arg0Value_, Frame arg1Value, boolean arg2Value) throws UnsupportedMessageException {
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                assert getRootNode() != null : "Invalid libray usage. Cached library must be adopted by a RootNode before it is executed.";
                SLScopedNode arg0Value = CompilerDirectives.castExact(arg0Value_, receiverClass_);
                int state = state_;
                if ((state & 0b1) != 0 /* is-active getScope(SLScopedNode, Frame, boolean, SLScopedNode, Node) */) {
                    return arg0Value.getScope(arg1Value, arg2Value, this.node, this.getScopeNode__blockNode_);
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return getScopeNode_AndSpecialize(arg0Value, arg1Value, arg2Value);
            }

            private Object getScopeNode_AndSpecialize(SLScopedNode arg0Value, Frame arg1Value, boolean arg2Value) {
                Lock lock = getLock();
                boolean hasLock = true;
                lock.lock();
                int state = state_;
                try {
                    this.getScopeNode__blockNode_ = (arg0Value.findBlock());
                    this.state_ = state = state | 0b1 /* add-active getScope(SLScopedNode, Frame, boolean, SLScopedNode, Node) */;
                    lock.unlock();
                    hasLock = false;
                    return arg0Value.getScope(arg1Value, arg2Value, this.node, this.getScopeNode__blockNode_);
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

            @Override
            public boolean hasRootInstance(Object arg0Value_, Frame arg1Value) {
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                assert getRootNode() != null : "Invalid libray usage. Cached library must be adopted by a RootNode before it is executed.";
                SLScopedNode arg0Value = CompilerDirectives.castExact(arg0Value_, receiverClass_);
                int state = state_;
                if ((state & 0b10) != 0 /* is-active hasRootInstance(SLScopedNode, Frame, ContextReference) */) {
                    {
                        ContextReference sLLanguageContextReference__ = this.sLLanguageContextReference_;
                        ContextReference hasRootInstanceNode__contextRef__ = sLLanguageContextReference__;
                        return arg0Value.hasRootInstance(arg1Value, hasRootInstanceNode__contextRef__);
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return hasRootInstanceNode_AndSpecialize(arg0Value, arg1Value);
            }

            private boolean hasRootInstanceNode_AndSpecialize(SLScopedNode arg0Value, Frame arg1Value) {
                Lock lock = getLock();
                boolean hasLock = true;
                lock.lock();
                int state = state_;
                try {
                    {
                        ContextReference hasRootInstanceNode__contextRef__ = null;
                        ContextReference sLLanguageContextReference__1 = this.sLLanguageContextReference_;
                        if (sLLanguageContextReference__1 == null) {
                            this.sLLanguageContextReference_ = sLLanguageContextReference__1 = super.lookupContextReference(SLLanguage.class);
                        }
                        hasRootInstanceNode__contextRef__ = sLLanguageContextReference__1;
                        this.state_ = state = state | 0b10 /* add-active hasRootInstance(SLScopedNode, Frame, ContextReference) */;
                        lock.unlock();
                        hasLock = false;
                        return arg0Value.hasRootInstance(arg1Value, hasRootInstanceNode__contextRef__);
                    }
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

            @Override
            public Object getRootInstance(Object arg0Value_, Frame arg1Value) throws UnsupportedMessageException {
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                assert getRootNode() != null : "Invalid libray usage. Cached library must be adopted by a RootNode before it is executed.";
                SLScopedNode arg0Value = CompilerDirectives.castExact(arg0Value_, receiverClass_);
                int state = state_;
                if ((state & 0b100) != 0 /* is-active getRootInstance(SLScopedNode, Frame, ContextReference) */) {
                    {
                        ContextReference sLLanguageContextReference__ = this.sLLanguageContextReference_;
                        ContextReference getRootInstanceNode__contextRef__ = sLLanguageContextReference__;
                        return arg0Value.getRootInstance(arg1Value, getRootInstanceNode__contextRef__);
                    }
                }
                CompilerDirectives.transferToInterpreterAndInvalidate();
                return getRootInstanceNode_AndSpecialize(arg0Value, arg1Value);
            }

            private Object getRootInstanceNode_AndSpecialize(SLScopedNode arg0Value, Frame arg1Value) throws UnsupportedMessageException {
                Lock lock = getLock();
                boolean hasLock = true;
                lock.lock();
                int state = state_;
                try {
                    {
                        ContextReference getRootInstanceNode__contextRef__ = null;
                        ContextReference sLLanguageContextReference__1 = this.sLLanguageContextReference_;
                        if (sLLanguageContextReference__1 == null) {
                            this.sLLanguageContextReference_ = sLLanguageContextReference__1 = super.lookupContextReference(SLLanguage.class);
                        }
                        getRootInstanceNode__contextRef__ = sLLanguageContextReference__1;
                        this.state_ = state = state | 0b100 /* add-active getRootInstance(SLScopedNode, Frame, ContextReference) */;
                        lock.unlock();
                        hasLock = false;
                        return arg0Value.getRootInstance(arg1Value, getRootInstanceNode__contextRef__);
                    }
                } finally {
                    if (hasLock) {
                        lock.unlock();
                    }
                }
            }

        }
        @GeneratedBy(SLScopedNode.class)
        private static final class Uncached extends NodeLibrary {

            private final Class receiverClass_;
            private final ContextReference sLLanguageContextReference_ = lookupContextReference(SLLanguage.class);

            Uncached(Object receiver) {
                this.receiverClass_ = ((SLScopedNode) receiver).getClass();
            }

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

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

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

            @TruffleBoundary
            @Override
            public boolean hasScope(Object receiver, Frame frame) {
                assert this.accepts(receiver) : "Invalid library usage. Library does not accept given receiver.";
                return ((SLScopedNode) receiver) .hasScope(frame);
            }

            @TruffleBoundary
            @Override
            public Object getScope(Object arg0Value_, Frame arg1Value, boolean arg2Value) {
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                SLScopedNode arg0Value = ((SLScopedNode) arg0Value_);
                return arg0Value.getScope(arg1Value, arg2Value, (arg0Value), (arg0Value.findBlock()));
            }

            @TruffleBoundary
            @Override
            public boolean hasRootInstance(Object arg0Value_, Frame arg1Value) {
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                SLScopedNode arg0Value = ((SLScopedNode) arg0Value_);
                return arg0Value.hasRootInstance(arg1Value, this.sLLanguageContextReference_);
            }

            @TruffleBoundary
            @Override
            public Object getRootInstance(Object arg0Value_, Frame arg1Value) throws UnsupportedMessageException {
                assert this.accepts(arg0Value_) : "Invalid library usage. Library does not accept given receiver.";
                SLScopedNode arg0Value = ((SLScopedNode) arg0Value_);
                return arg0Value.getRootInstance(arg1Value, this.sLLanguageContextReference_);
            }

            @TruffleBoundary
            private static boolean accepts_(Object arg0Value_) {
                SLScopedNode arg0Value = ((SLScopedNode) arg0Value_);
                return arg0Value.accepts((arg0Value));
            }

        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy