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

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

There is a newer version: 1.0.0-rc7
Show newest version
// CheckStyle: start generated
package com.oracle.truffle.sl.nodes.access;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.dsl.GeneratedBy;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.interop.Message;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.sl.nodes.SLExpressionNode;
import com.oracle.truffle.sl.runtime.SLContext;
import java.util.concurrent.locks.Lock;

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

    @Child private SLExpressionNode receiverNode_;
    @Child private SLExpressionNode nameNode_;
    @Child private SLExpressionNode valueNode_;
    @CompilationFinal private int state_;
    @Child private SLWritePropertyCacheNode write_writeNode_;
    @Child private Node writeForeign_foreignWriteNode_;

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

    @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 & 0b1) != 0 /* is-active write(DynamicObject, Object, Object, SLWritePropertyCacheNode) */ && receiverNodeValue_ instanceof DynamicObject) {
            DynamicObject receiverNodeValue__ = (DynamicObject) receiverNodeValue_;
            if ((SLContext.isSLObject(receiverNodeValue__))) {
                return write(receiverNodeValue__, nameNodeValue_, valueNodeValue_, this.write_writeNode_);
            }
        }
        CompilerDirectives.transferToInterpreterAndInvalidate();
        return executeAndSpecialize(receiverNodeValue_, nameNodeValue_, valueNodeValue_);
    }

    @Override
    public void executeVoid(VirtualFrame frameValue) {
        int state = state_;
        if ((state & 0b1) != 0 /* is-active write(DynamicObject, Object, Object, SLWritePropertyCacheNode) */) {
            executeGeneric(frameValue);
            return;
        }
        Object receiverNodeValue_ = this.receiverNode_.executeGeneric(frameValue);
        Object nameNodeValue_ = this.nameNode_.executeGeneric(frameValue);
        Object valueNodeValue_ = this.valueNode_.executeGeneric(frameValue);
        if ((state & 0b110) != 0 /* is-active writeForeign(TruffleObject, Object, Object, Node) || updateShape(Object, Object, Object) */) {
            if ((state & 0b10) != 0 /* is-active writeForeign(TruffleObject, Object, Object, Node) */ && receiverNodeValue_ instanceof TruffleObject) {
                TruffleObject receiverNodeValue__ = (TruffleObject) receiverNodeValue_;
                if ((!(SLContext.isSLObject(receiverNodeValue__)))) {
                    writeForeign(receiverNodeValue__, nameNodeValue_, valueNodeValue_, this.writeForeign_foreignWriteNode_);
                    return;
                }
            }
            if ((state & 0b100) != 0 /* is-active updateShape(Object, Object, Object) */) {
                if (fallbackGuard_(receiverNodeValue_, nameNodeValue_, valueNodeValue_)) {
                    updateShape(receiverNodeValue_, nameNodeValue_, valueNodeValue_);
                    return;
                }
            }
        }
        CompilerDirectives.transferToInterpreterAndInvalidate();
        executeAndSpecialize(receiverNodeValue_, nameNodeValue_, valueNodeValue_);
        return;
    }

    private Object executeAndSpecialize(Object receiverNodeValue, Object nameNodeValue, Object valueNodeValue) {
        Lock lock = getLock();
        boolean hasLock = true;
        lock.lock();
        int state = state_;
        int oldState = state;
        try {
            if (receiverNodeValue instanceof DynamicObject) {
                DynamicObject receiverNodeValue_ = (DynamicObject) receiverNodeValue;
                if ((SLContext.isSLObject(receiverNodeValue_))) {
                    this.write_writeNode_ = super.insert((SLWritePropertyCacheNode.create()));
                    this.state_ = state = state | 0b1 /* add-active write(DynamicObject, Object, Object, SLWritePropertyCacheNode) */;
                    lock.unlock();
                    hasLock = false;
                    return write(receiverNodeValue_, nameNodeValue, valueNodeValue, this.write_writeNode_);
                }
            }
            if (receiverNodeValue instanceof TruffleObject) {
                TruffleObject receiverNodeValue_ = (TruffleObject) receiverNodeValue;
                if ((!(SLContext.isSLObject(receiverNodeValue_)))) {
                    this.writeForeign_foreignWriteNode_ = super.insert((Message.WRITE.createNode()));
                    this.state_ = state = state | 0b10 /* add-active writeForeign(TruffleObject, Object, Object, Node) */;
                    lock.unlock();
                    hasLock = false;
                    writeForeign(receiverNodeValue_, nameNodeValue, valueNodeValue, this.writeForeign_foreignWriteNode_);
                    return null;
                }
            }
            this.state_ = state = state | 0b100 /* add-active updateShape(Object, Object, Object) */;
            lock.unlock();
            hasLock = false;
            updateShape(receiverNodeValue, nameNodeValue, valueNodeValue);
            return null;
        } finally {
            if (oldState != 0) {
                checkForPolymorphicSpecialize(oldState);
            }
            if (hasLock) {
                lock.unlock();
            }
        }
    }

    private void checkForPolymorphicSpecialize(int oldState) {
        int newState = this.state_;
        if ((oldState ^ newState) != 0) {
            this.reportPolymorphicSpecialize();
        }
    }

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

    @SuppressWarnings("unused")
    private static boolean fallbackGuard_(Object receiverNodeValue, Object nameNodeValue, Object valueNodeValue) {
        if (receiverNodeValue instanceof DynamicObject) {
            DynamicObject receiverNodeValue_ = (DynamicObject) receiverNodeValue;
            if ((SLContext.isSLObject(receiverNodeValue_))) {
                return false;
            }
        }
        if (receiverNodeValue instanceof TruffleObject) {
            TruffleObject receiverNodeValue_ = (TruffleObject) receiverNodeValue;
            if ((!(SLContext.isSLObject(receiverNodeValue_)))) {
                return false;
            }
        }
        return true;
    }

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

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy