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

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

There is a newer version: 24.1.1
Show newest version
// 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.dsl.GeneratedBy;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.sl.nodes.SLExpressionNode;
import com.oracle.truffle.sl.nodes.SLTypesGen;

@GeneratedBy(SLLogicalNotNode.class)
public final class SLLogicalNotNodeGen extends SLLogicalNotNode {

    @Child private SLExpressionNode valueNode_;
    @CompilationFinal private int state_;

    private SLLogicalNotNodeGen(SLExpressionNode valueNode) {
        this.valueNode_ = valueNode;
    }

    @Override
    public Object executeGeneric(VirtualFrame frameValue) {
        int state = state_;
        if ((state & 0b10) == 0 /* only-active doBoolean(boolean) */ && state != 0  /* is-not doBoolean(boolean) && typeError(Object) */) {
            return executeGeneric_boolean0(frameValue, state);
        } else {
            return executeGeneric_generic1(frameValue, state);
        }
    }

    private Object executeGeneric_boolean0(VirtualFrame frameValue, int state) {
        boolean valueNodeValue_;
        try {
            valueNodeValue_ = this.valueNode_.executeBoolean(frameValue);
        } catch (UnexpectedResultException ex) {
            return executeAndSpecialize(ex.getResult());
        }
        assert (state & 0b1) != 0 /* is-active doBoolean(boolean) */;
        return doBoolean(valueNodeValue_);
    }

    private Object executeGeneric_generic1(VirtualFrame frameValue, int state) {
        Object valueNodeValue_ = this.valueNode_.executeGeneric(frameValue);
        if ((state & 0b1) != 0 /* is-active doBoolean(boolean) */ && valueNodeValue_ instanceof Boolean) {
            boolean valueNodeValue__ = (boolean) valueNodeValue_;
            return doBoolean(valueNodeValue__);
        }
        if ((state & 0b10) != 0 /* is-active typeError(Object) */) {
            if (fallbackGuard_(state, valueNodeValue_)) {
                return typeError(valueNodeValue_);
            }
        }
        CompilerDirectives.transferToInterpreterAndInvalidate();
        return executeAndSpecialize(valueNodeValue_);
    }

    @Override
    public boolean executeBoolean(VirtualFrame frameValue) throws UnexpectedResultException {
        int state = state_;
        if ((state & 0b10) != 0 /* is-active typeError(Object) */) {
            return SLTypesGen.expectBoolean(executeGeneric(frameValue));
        }
        boolean valueNodeValue_;
        try {
            valueNodeValue_ = this.valueNode_.executeBoolean(frameValue);
        } catch (UnexpectedResultException ex) {
            return SLTypesGen.expectBoolean(executeAndSpecialize(ex.getResult()));
        }
        if ((state & 0b1) != 0 /* is-active doBoolean(boolean) */) {
            return doBoolean(valueNodeValue_);
        }
        CompilerDirectives.transferToInterpreterAndInvalidate();
        return SLTypesGen.expectBoolean(executeAndSpecialize(valueNodeValue_));
    }

    @Override
    public void executeVoid(VirtualFrame frameValue) {
        int state = state_;
        try {
            if ((state & 0b10) == 0 /* only-active doBoolean(boolean) */ && state != 0  /* is-not doBoolean(boolean) && typeError(Object) */) {
                executeBoolean(frameValue);
                return;
            }
            executeGeneric(frameValue);
            return;
        } catch (UnexpectedResultException ex) {
            return;
        }
    }

    private Object executeAndSpecialize(Object valueNodeValue) {
        int state = state_;
        if (valueNodeValue instanceof Boolean) {
            boolean valueNodeValue_ = (boolean) valueNodeValue;
            this.state_ = state = state | 0b1 /* add-active doBoolean(boolean) */;
            return doBoolean(valueNodeValue_);
        }
        this.state_ = state = state | 0b10 /* add-active typeError(Object) */;
        return typeError(valueNodeValue);
    }

    @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;
    }

    private static boolean fallbackGuard_(int state, Object valueNodeValue) {
        if (((state & 0b1)) == 0 /* is-not-active doBoolean(boolean) */ && valueNodeValue instanceof Boolean) {
            return false;
        }
        return true;
    }

    public static SLLogicalNotNode create(SLExpressionNode valueNode) {
        return new SLLogicalNotNodeGen(valueNode);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy