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

com.oracle.truffle.sl.nodes.expression.SLWritePropertyNodeGen Maven / Gradle / Ivy

// CheckStyle: start generated
package com.oracle.truffle.sl.nodes.expression;

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.frame.VirtualFrame;
import com.oracle.truffle.api.interop.InteropLibrary;
import com.oracle.truffle.api.library.LibraryFactory;
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.nodes.NodeUtil;
import com.oracle.truffle.api.nodes.ExplodeLoop.LoopExplosionKind;
import com.oracle.truffle.sl.nodes.SLExpressionNode;
import com.oracle.truffle.sl.nodes.expression.SLWritePropertyNode;
import com.oracle.truffle.sl.nodes.util.SLToMemberNode;
import com.oracle.truffle.sl.nodes.util.SLToMemberNodeGen;
import java.util.concurrent.locks.Lock;

@GeneratedBy(SLWritePropertyNode.class)
@SuppressWarnings("unused")
public final class SLWritePropertyNodeGen extends SLWritePropertyNode {

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

    @Child private SLExpressionNode receiverNode_;
    @Child private SLExpressionNode nameNode_;
    @Child private SLExpressionNode valueNode_;
    @CompilationFinal private int state_;
    @CompilationFinal private int exclude_;
    @Child private Write0Data write0_cache;
    @Child private Write2Data write2_cache;
    @Child private SLToMemberNode write3_asMember_;

    private SLWritePropertyNodeGen(SLExpressionNode receiverNode, SLExpressionNode nameNode, SLExpressionNode valueNode) {
        this.receiverNode_ = receiverNode;
        this.nameNode_ = nameNode;
        this.valueNode_ = valueNode;
    }

    @ExplodeLoop(kind = LoopExplosionKind.FULL_EXPLODE_UNTIL_RETURN)
    @Override
    public Object executeGeneric(VirtualFrame frameValue) {
        int state = state_;
        Object receiverNodeValue_ = this.receiverNode_.executeGeneric(frameValue);
        Object nameNodeValue_ = this.nameNode_.executeGeneric(frameValue);
        Object valueNodeValue_ = this.valueNode_.executeGeneric(frameValue);
        if (state != 0 /* is-active write(Object, Object, Object, InteropLibrary, InteropLibrary) || write(Object, Object, Object, InteropLibrary, InteropLibrary) || write(Object, Object, Object, InteropLibrary, SLToMemberNode) || write(Object, Object, Object, InteropLibrary, SLToMemberNode) */) {
            if ((state & 0b1) != 0 /* is-active write(Object, Object, Object, InteropLibrary, InteropLibrary) */) {
                Write0Data s1_ = this.write0_cache;
                while (s1_ != null) {
                    if ((s1_.arrays_.accepts(receiverNodeValue_)) && (s1_.numbers_.accepts(nameNodeValue_)) && (s1_.arrays_.hasArrayElements(receiverNodeValue_))) {
                        return write(receiverNodeValue_, nameNodeValue_, valueNodeValue_, s1_.arrays_, s1_.numbers_);
                    }
                    s1_ = s1_.next_;
                }
            }
            if ((state & 0b10) != 0 /* is-active write(Object, Object, Object, InteropLibrary, InteropLibrary) */) {
                Node prev_ = NodeUtil.pushEncapsulatingNode(this);
                try {
                    if (((INTEROP_LIBRARY_.getUncached(receiverNodeValue_)).hasArrayElements(receiverNodeValue_))) {
                        return write(receiverNodeValue_, nameNodeValue_, valueNodeValue_, (INTEROP_LIBRARY_.getUncached(receiverNodeValue_)), (INTEROP_LIBRARY_.getUncached(nameNodeValue_)));
                    }
                } finally {
                    NodeUtil.popEncapsulatingNode(prev_);
                }
            }
            if ((state & 0b100) != 0 /* is-active write(Object, Object, Object, InteropLibrary, SLToMemberNode) */) {
                Write2Data s3_ = this.write2_cache;
                while (s3_ != null) {
                    if ((s3_.objectLibrary_.accepts(receiverNodeValue_))) {
                        return write(receiverNodeValue_, nameNodeValue_, valueNodeValue_, s3_.objectLibrary_, s3_.asMember_);
                    }
                    s3_ = s3_.next_;
                }
            }
            if ((state & 0b1000) != 0 /* is-active write(Object, Object, Object, InteropLibrary, SLToMemberNode) */) {
                return this.write3Boundary(state, receiverNodeValue_, nameNodeValue_, valueNodeValue_);
            }
        }
        CompilerDirectives.transferToInterpreterAndInvalidate();
        return executeAndSpecialize(receiverNodeValue_, nameNodeValue_, valueNodeValue_);
    }

    @TruffleBoundary
    private Object write3Boundary(int state, Object receiverNodeValue_, Object nameNodeValue_, Object valueNodeValue_) {
        Node prev_ = NodeUtil.pushEncapsulatingNode(this);
        try {
            return write(receiverNodeValue_, nameNodeValue_, valueNodeValue_, (INTEROP_LIBRARY_.getUncached(receiverNodeValue_)), this.write3_asMember_);
        } finally {
            NodeUtil.popEncapsulatingNode(prev_);
        }
    }

    @Override
    public void executeVoid(VirtualFrame frameValue) {
        executeGeneric(frameValue);
        return;
    }

    private Object executeAndSpecialize(Object receiverNodeValue, Object nameNodeValue, Object valueNodeValue) {
        Lock lock = getLock();
        boolean hasLock = true;
        lock.lock();
        int state = state_;
        int exclude = exclude_;
        int oldState = state;
        int oldExclude = exclude;
        int oldCacheCount = state == 0 ? 0 : countCaches();
        try {
            if (((exclude & 0b1)) == 0 /* is-not-excluded write(Object, Object, Object, InteropLibrary, InteropLibrary) */) {
                int count1_ = 0;
                Write0Data s1_ = this.write0_cache;
                if ((state & 0b1) != 0 /* is-active write(Object, Object, Object, InteropLibrary, InteropLibrary) */) {
                    while (s1_ != null) {
                        if ((s1_.arrays_.accepts(receiverNodeValue)) && (s1_.numbers_.accepts(nameNodeValue)) && (s1_.arrays_.hasArrayElements(receiverNodeValue))) {
                            break;
                        }
                        s1_ = s1_.next_;
                        count1_++;
                    }
                }
                if (s1_ == null) {
                    {
                        InteropLibrary arrays__ = super.insert((INTEROP_LIBRARY_.create(receiverNodeValue)));
                        // assert (s1_.arrays_.accepts(receiverNodeValue));
                        // assert (s1_.numbers_.accepts(nameNodeValue));
                        if ((arrays__.hasArrayElements(receiverNodeValue)) && count1_ < (SLWritePropertyNode.LIBRARY_LIMIT)) {
                            s1_ = super.insert(new Write0Data(write0_cache));
                            s1_.arrays_ = s1_.insertAccessor(arrays__);
                            s1_.numbers_ = s1_.insertAccessor((INTEROP_LIBRARY_.create(nameNodeValue)));
                            this.write0_cache = s1_;
                            this.state_ = state = state | 0b1 /* add-active write(Object, Object, Object, InteropLibrary, InteropLibrary) */;
                        }
                    }
                }
                if (s1_ != null) {
                    lock.unlock();
                    hasLock = false;
                    return write(receiverNodeValue, nameNodeValue, valueNodeValue, s1_.arrays_, s1_.numbers_);
                }
            }
            {
                Node prev_ = NodeUtil.pushEncapsulatingNode(this);
                try {
                    {
                        InteropLibrary write1_arrays__ = (INTEROP_LIBRARY_.getUncached(receiverNodeValue));
                        if ((write1_arrays__.hasArrayElements(receiverNodeValue))) {
                            this.exclude_ = exclude = exclude | 0b1 /* add-excluded write(Object, Object, Object, InteropLibrary, InteropLibrary) */;
                            this.write0_cache = null;
                            state = state & 0xfffffffe /* remove-active write(Object, Object, Object, InteropLibrary, InteropLibrary) */;
                            this.state_ = state = state | 0b10 /* add-active write(Object, Object, Object, InteropLibrary, InteropLibrary) */;
                            lock.unlock();
                            hasLock = false;
                            return write(receiverNodeValue, nameNodeValue, valueNodeValue, write1_arrays__, (INTEROP_LIBRARY_.getUncached(nameNodeValue)));
                        }
                    }
                } finally {
                    NodeUtil.popEncapsulatingNode(prev_);
                }
            }
            if (((exclude & 0b10)) == 0 /* is-not-excluded write(Object, Object, Object, InteropLibrary, SLToMemberNode) */) {
                int count3_ = 0;
                Write2Data s3_ = this.write2_cache;
                if ((state & 0b100) != 0 /* is-active write(Object, Object, Object, InteropLibrary, SLToMemberNode) */) {
                    while (s3_ != null) {
                        if ((s3_.objectLibrary_.accepts(receiverNodeValue))) {
                            break;
                        }
                        s3_ = s3_.next_;
                        count3_++;
                    }
                }
                if (s3_ == null) {
                    // assert (s3_.objectLibrary_.accepts(receiverNodeValue));
                    if (count3_ < (SLWritePropertyNode.LIBRARY_LIMIT)) {
                        s3_ = super.insert(new Write2Data(write2_cache));
                        s3_.objectLibrary_ = s3_.insertAccessor((INTEROP_LIBRARY_.create(receiverNodeValue)));
                        s3_.asMember_ = s3_.insertAccessor((SLToMemberNodeGen.create()));
                        this.write2_cache = s3_;
                        this.state_ = state = state | 0b100 /* add-active write(Object, Object, Object, InteropLibrary, SLToMemberNode) */;
                    }
                }
                if (s3_ != null) {
                    lock.unlock();
                    hasLock = false;
                    return write(receiverNodeValue, nameNodeValue, valueNodeValue, s3_.objectLibrary_, s3_.asMember_);
                }
            }
            {
                Node prev_ = NodeUtil.pushEncapsulatingNode(this);
                try {
                    this.write3_asMember_ = super.insert((SLToMemberNodeGen.create()));
                    this.exclude_ = exclude = exclude | 0b10 /* add-excluded write(Object, Object, Object, InteropLibrary, SLToMemberNode) */;
                    this.write2_cache = null;
                    state = state & 0xfffffffb /* remove-active write(Object, Object, Object, InteropLibrary, SLToMemberNode) */;
                    this.state_ = state = state | 0b1000 /* add-active write(Object, Object, Object, InteropLibrary, SLToMemberNode) */;
                    lock.unlock();
                    hasLock = false;
                    return write(receiverNodeValue, nameNodeValue, valueNodeValue, (INTEROP_LIBRARY_.getUncached(receiverNodeValue)), this.write3_asMember_);
                } finally {
                    NodeUtil.popEncapsulatingNode(prev_);
                }
            }
        } finally {
            if (oldState != 0 || oldExclude != 0) {
                checkForPolymorphicSpecialize(oldState, oldExclude, oldCacheCount);
            }
            if (hasLock) {
                lock.unlock();
            }
        }
    }

    private void checkForPolymorphicSpecialize(int oldState, int oldExclude, int oldCacheCount) {
        int newState = this.state_;
        int newExclude = this.exclude_;
        if ((oldState ^ newState) != 0 || (oldExclude ^ newExclude) != 0 || oldCacheCount < countCaches()) {
            this.reportPolymorphicSpecialize();
        }
    }

    private int countCaches() {
        int cacheCount = 0;
        Write0Data s1_ = this.write0_cache;
        while (s1_ != null) {
            cacheCount++;
            s1_= s1_.next_;
        }
        Write2Data s3_ = this.write2_cache;
        while (s3_ != null) {
            cacheCount++;
            s3_= s3_.next_;
        }
        return cacheCount;
    }

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

    public static SLWritePropertyNode create(SLExpressionNode receiverNode, SLExpressionNode nameNode, SLExpressionNode valueNode) {
        return new SLWritePropertyNodeGen(receiverNode, nameNode, valueNode);
    }

    @GeneratedBy(SLWritePropertyNode.class)
    private static final class Write0Data extends Node {

        @Child Write0Data next_;
        @Child InteropLibrary arrays_;
        @Child InteropLibrary numbers_;

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

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

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

    }
    @GeneratedBy(SLWritePropertyNode.class)
    private static final class Write2Data extends Node {

        @Child Write2Data next_;
        @Child InteropLibrary objectLibrary_;
        @Child SLToMemberNode asMember_;

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

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

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

    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy