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

com.oracle.truffle.sl.nodes.expression.SLEqualNodeGen 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.dsl.GeneratedBy;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.interop.TruffleObject;
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.SLTypes;
import com.oracle.truffle.sl.nodes.SLTypesGen;
import com.oracle.truffle.sl.runtime.SLBigNumber;
import com.oracle.truffle.sl.runtime.SLFunction;
import com.oracle.truffle.sl.runtime.SLNull;
import java.util.concurrent.locks.Lock;

@GeneratedBy(SLEqualNode.class)
public final class SLEqualNodeGen extends SLEqualNode {

    @Child private SLExpressionNode leftNode_;
    @Child private SLExpressionNode rightNode_;
    @CompilationFinal private int state_;

    private SLEqualNodeGen(SLExpressionNode leftNode, SLExpressionNode rightNode) {
        this.leftNode_ = leftNode;
        this.rightNode_ = rightNode;
    }

    @Override
    public Object executeGeneric(VirtualFrame frameValue) {
        int state = state_;
        if ((state & 0b111111110) == 0 /* only-active equal(long, long) */ && (state & 0b111111111) != 0  /* is-not equal(long, long) && equal(SLBigNumber, SLBigNumber) && equal(boolean, boolean) && equal(String, String) && equal(SLFunction, SLFunction) && equal(SLNull, SLNull) && equal(TruffleObject, TruffleObject) && equal(Object, Object) && typeError(Object, Object) */) {
            return executeGeneric_long_long0(frameValue, state);
        } else if ((state & 0b111111011) == 0 /* only-active equal(boolean, boolean) */ && (state & 0b111111111) != 0  /* is-not equal(long, long) && equal(SLBigNumber, SLBigNumber) && equal(boolean, boolean) && equal(String, String) && equal(SLFunction, SLFunction) && equal(SLNull, SLNull) && equal(TruffleObject, TruffleObject) && equal(Object, Object) && typeError(Object, Object) */) {
            return executeGeneric_boolean_boolean1(frameValue, state);
        } else {
            return executeGeneric_generic2(frameValue, state);
        }
    }

    private Object executeGeneric_long_long0(VirtualFrame frameValue, int state) {
        long leftNodeValue_;
        try {
            leftNodeValue_ = this.leftNode_.executeLong(frameValue);
        } catch (UnexpectedResultException ex) {
            Object rightNodeValue = this.rightNode_.executeGeneric(frameValue);
            return executeAndSpecialize(ex.getResult(), rightNodeValue);
        }
        long rightNodeValue_;
        try {
            rightNodeValue_ = this.rightNode_.executeLong(frameValue);
        } catch (UnexpectedResultException ex) {
            return executeAndSpecialize(leftNodeValue_, ex.getResult());
        }
        assert (state & 0b1) != 0 /* is-active equal(long, long) */;
        return equal(leftNodeValue_, rightNodeValue_);
    }

    private Object executeGeneric_boolean_boolean1(VirtualFrame frameValue, int state) {
        boolean leftNodeValue_;
        try {
            leftNodeValue_ = this.leftNode_.executeBoolean(frameValue);
        } catch (UnexpectedResultException ex) {
            Object rightNodeValue = this.rightNode_.executeGeneric(frameValue);
            return executeAndSpecialize(ex.getResult(), rightNodeValue);
        }
        boolean rightNodeValue_;
        try {
            rightNodeValue_ = this.rightNode_.executeBoolean(frameValue);
        } catch (UnexpectedResultException ex) {
            return executeAndSpecialize(leftNodeValue_, ex.getResult());
        }
        assert (state & 0b100) != 0 /* is-active equal(boolean, boolean) */;
        return equal(leftNodeValue_, rightNodeValue_);
    }

    private Object executeGeneric_generic2(VirtualFrame frameValue, int state) {
        Object leftNodeValue_ = this.leftNode_.executeGeneric(frameValue);
        Object rightNodeValue_ = this.rightNode_.executeGeneric(frameValue);
        if ((state & 0b1) != 0 /* is-active equal(long, long) */ && leftNodeValue_ instanceof Long) {
            long leftNodeValue__ = (long) leftNodeValue_;
            if (rightNodeValue_ instanceof Long) {
                long rightNodeValue__ = (long) rightNodeValue_;
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b10) != 0 /* is-active equal(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state & 0b11000000000) >>> 9 /* extract-implicit-active 0:SLBigNumber */, leftNodeValue_)) {
            SLBigNumber leftNodeValue__ = SLTypesGen.asImplicitSLBigNumber((state & 0b11000000000) >>> 9 /* extract-implicit-active 0:SLBigNumber */, leftNodeValue_);
            if (SLTypesGen.isImplicitSLBigNumber((state & 0b1100000000000) >>> 11 /* extract-implicit-active 1:SLBigNumber */, rightNodeValue_)) {
                SLBigNumber rightNodeValue__ = SLTypesGen.asImplicitSLBigNumber((state & 0b1100000000000) >>> 11 /* extract-implicit-active 1:SLBigNumber */, rightNodeValue_);
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b100) != 0 /* is-active equal(boolean, boolean) */ && leftNodeValue_ instanceof Boolean) {
            boolean leftNodeValue__ = (boolean) leftNodeValue_;
            if (rightNodeValue_ instanceof Boolean) {
                boolean rightNodeValue__ = (boolean) rightNodeValue_;
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b1000) != 0 /* is-active equal(String, String) */ && leftNodeValue_ instanceof String) {
            String leftNodeValue__ = (String) leftNodeValue_;
            if (rightNodeValue_ instanceof String) {
                String rightNodeValue__ = (String) rightNodeValue_;
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b10000) != 0 /* is-active equal(SLFunction, SLFunction) */ && leftNodeValue_ instanceof SLFunction) {
            SLFunction leftNodeValue__ = (SLFunction) leftNodeValue_;
            if (rightNodeValue_ instanceof SLFunction) {
                SLFunction rightNodeValue__ = (SLFunction) rightNodeValue_;
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b100000) != 0 /* is-active equal(SLNull, SLNull) */ && SLTypes.isSLNull(leftNodeValue_)) {
            SLNull leftNodeValue__ = SLTypes.asSLNull(leftNodeValue_);
            if (SLTypes.isSLNull(rightNodeValue_)) {
                SLNull rightNodeValue__ = SLTypes.asSLNull(rightNodeValue_);
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b1000000) != 0 /* is-active equal(TruffleObject, TruffleObject) */ && leftNodeValue_ instanceof TruffleObject) {
            TruffleObject leftNodeValue__ = (TruffleObject) leftNodeValue_;
            if (rightNodeValue_ instanceof TruffleObject) {
                TruffleObject rightNodeValue__ = (TruffleObject) rightNodeValue_;
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b110000000) != 0 /* is-active equal(Object, Object) || typeError(Object, Object) */) {
            if ((state & 0b10000000) != 0 /* is-active equal(Object, Object) */) {
                if ((SLEqualNode.differentClasses(leftNodeValue_, rightNodeValue_))) {
                    return equal(leftNodeValue_, rightNodeValue_);
                }
            }
            if ((state & 0b100000000) != 0 /* is-active typeError(Object, Object) */) {
                if (fallbackGuard_(state, leftNodeValue_, rightNodeValue_)) {
                    return typeError(leftNodeValue_, rightNodeValue_);
                }
            }
        }
        CompilerDirectives.transferToInterpreterAndInvalidate();
        return executeAndSpecialize(leftNodeValue_, rightNodeValue_);
    }

    @Override
    public boolean executeBoolean(VirtualFrame frameValue) throws UnexpectedResultException {
        int state = state_;
        if ((state & 0b100000000) != 0 /* is-active typeError(Object, Object) */) {
            return SLTypesGen.expectBoolean(executeGeneric(frameValue));
        }
        if ((state & 0b11111110) == 0 /* only-active equal(long, long) */ && (state & 0b11111111) != 0  /* is-not equal(long, long) && equal(SLBigNumber, SLBigNumber) && equal(boolean, boolean) && equal(String, String) && equal(SLFunction, SLFunction) && equal(SLNull, SLNull) && equal(TruffleObject, TruffleObject) && equal(Object, Object) */) {
            return executeBoolean_long_long3(frameValue, state);
        } else if ((state & 0b11111011) == 0 /* only-active equal(boolean, boolean) */ && (state & 0b11111111) != 0  /* is-not equal(long, long) && equal(SLBigNumber, SLBigNumber) && equal(boolean, boolean) && equal(String, String) && equal(SLFunction, SLFunction) && equal(SLNull, SLNull) && equal(TruffleObject, TruffleObject) && equal(Object, Object) */) {
            return executeBoolean_boolean_boolean4(frameValue, state);
        } else {
            return executeBoolean_generic5(frameValue, state);
        }
    }

    private boolean executeBoolean_long_long3(VirtualFrame frameValue, int state) throws UnexpectedResultException {
        long leftNodeValue_;
        try {
            leftNodeValue_ = this.leftNode_.executeLong(frameValue);
        } catch (UnexpectedResultException ex) {
            Object rightNodeValue = this.rightNode_.executeGeneric(frameValue);
            return SLTypesGen.expectBoolean(executeAndSpecialize(ex.getResult(), rightNodeValue));
        }
        long rightNodeValue_;
        try {
            rightNodeValue_ = this.rightNode_.executeLong(frameValue);
        } catch (UnexpectedResultException ex) {
            return SLTypesGen.expectBoolean(executeAndSpecialize(leftNodeValue_, ex.getResult()));
        }
        assert (state & 0b1) != 0 /* is-active equal(long, long) */;
        return equal(leftNodeValue_, rightNodeValue_);
    }

    private boolean executeBoolean_boolean_boolean4(VirtualFrame frameValue, int state) throws UnexpectedResultException {
        boolean leftNodeValue_;
        try {
            leftNodeValue_ = this.leftNode_.executeBoolean(frameValue);
        } catch (UnexpectedResultException ex) {
            Object rightNodeValue = this.rightNode_.executeGeneric(frameValue);
            return SLTypesGen.expectBoolean(executeAndSpecialize(ex.getResult(), rightNodeValue));
        }
        boolean rightNodeValue_;
        try {
            rightNodeValue_ = this.rightNode_.executeBoolean(frameValue);
        } catch (UnexpectedResultException ex) {
            return SLTypesGen.expectBoolean(executeAndSpecialize(leftNodeValue_, ex.getResult()));
        }
        assert (state & 0b100) != 0 /* is-active equal(boolean, boolean) */;
        return equal(leftNodeValue_, rightNodeValue_);
    }

    private boolean executeBoolean_generic5(VirtualFrame frameValue, int state) throws UnexpectedResultException {
        Object leftNodeValue_ = this.leftNode_.executeGeneric(frameValue);
        Object rightNodeValue_ = this.rightNode_.executeGeneric(frameValue);
        if ((state & 0b1) != 0 /* is-active equal(long, long) */ && leftNodeValue_ instanceof Long) {
            long leftNodeValue__ = (long) leftNodeValue_;
            if (rightNodeValue_ instanceof Long) {
                long rightNodeValue__ = (long) rightNodeValue_;
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b10) != 0 /* is-active equal(SLBigNumber, SLBigNumber) */ && SLTypesGen.isImplicitSLBigNumber((state & 0b11000000000) >>> 9 /* extract-implicit-active 0:SLBigNumber */, leftNodeValue_)) {
            SLBigNumber leftNodeValue__ = SLTypesGen.asImplicitSLBigNumber((state & 0b11000000000) >>> 9 /* extract-implicit-active 0:SLBigNumber */, leftNodeValue_);
            if (SLTypesGen.isImplicitSLBigNumber((state & 0b1100000000000) >>> 11 /* extract-implicit-active 1:SLBigNumber */, rightNodeValue_)) {
                SLBigNumber rightNodeValue__ = SLTypesGen.asImplicitSLBigNumber((state & 0b1100000000000) >>> 11 /* extract-implicit-active 1:SLBigNumber */, rightNodeValue_);
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b100) != 0 /* is-active equal(boolean, boolean) */ && leftNodeValue_ instanceof Boolean) {
            boolean leftNodeValue__ = (boolean) leftNodeValue_;
            if (rightNodeValue_ instanceof Boolean) {
                boolean rightNodeValue__ = (boolean) rightNodeValue_;
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b1000) != 0 /* is-active equal(String, String) */ && leftNodeValue_ instanceof String) {
            String leftNodeValue__ = (String) leftNodeValue_;
            if (rightNodeValue_ instanceof String) {
                String rightNodeValue__ = (String) rightNodeValue_;
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b10000) != 0 /* is-active equal(SLFunction, SLFunction) */ && leftNodeValue_ instanceof SLFunction) {
            SLFunction leftNodeValue__ = (SLFunction) leftNodeValue_;
            if (rightNodeValue_ instanceof SLFunction) {
                SLFunction rightNodeValue__ = (SLFunction) rightNodeValue_;
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b100000) != 0 /* is-active equal(SLNull, SLNull) */ && SLTypes.isSLNull(leftNodeValue_)) {
            SLNull leftNodeValue__ = SLTypes.asSLNull(leftNodeValue_);
            if (SLTypes.isSLNull(rightNodeValue_)) {
                SLNull rightNodeValue__ = SLTypes.asSLNull(rightNodeValue_);
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b1000000) != 0 /* is-active equal(TruffleObject, TruffleObject) */ && leftNodeValue_ instanceof TruffleObject) {
            TruffleObject leftNodeValue__ = (TruffleObject) leftNodeValue_;
            if (rightNodeValue_ instanceof TruffleObject) {
                TruffleObject rightNodeValue__ = (TruffleObject) rightNodeValue_;
                return equal(leftNodeValue__, rightNodeValue__);
            }
        }
        if ((state & 0b10000000) != 0 /* is-active equal(Object, Object) */) {
            if ((SLEqualNode.differentClasses(leftNodeValue_, rightNodeValue_))) {
                return equal(leftNodeValue_, rightNodeValue_);
            }
        }
        CompilerDirectives.transferToInterpreterAndInvalidate();
        return SLTypesGen.expectBoolean(executeAndSpecialize(leftNodeValue_, rightNodeValue_));
    }

    @Override
    public void executeVoid(VirtualFrame frameValue) {
        int state = state_;
        try {
            if ((state & 0b100000000) == 0 /* only-active equal(long, long) && equal(SLBigNumber, SLBigNumber) && equal(boolean, boolean) && equal(String, String) && equal(SLFunction, SLFunction) && equal(SLNull, SLNull) && equal(TruffleObject, TruffleObject) && equal(Object, Object) */ && (state & 0b111111111) != 0  /* is-not equal(long, long) && equal(SLBigNumber, SLBigNumber) && equal(boolean, boolean) && equal(String, String) && equal(SLFunction, SLFunction) && equal(SLNull, SLNull) && equal(TruffleObject, TruffleObject) && equal(Object, Object) && typeError(Object, Object) */) {
                executeBoolean(frameValue);
                return;
            }
            executeGeneric(frameValue);
            return;
        } catch (UnexpectedResultException ex) {
            return;
        }
    }

    private Object executeAndSpecialize(Object leftNodeValue, Object rightNodeValue) {
        Lock lock = getLock();
        boolean hasLock = true;
        lock.lock();
        int state = state_;
        int oldState = (state & 0b111111111);
        try {
            if (leftNodeValue instanceof Long) {
                long leftNodeValue_ = (long) leftNodeValue;
                if (rightNodeValue instanceof Long) {
                    long rightNodeValue_ = (long) rightNodeValue;
                    this.state_ = state = state | 0b1 /* add-active equal(long, long) */;
                    lock.unlock();
                    hasLock = false;
                    return equal(leftNodeValue_, rightNodeValue_);
                }
            }
            {
                int sLBigNumberCast0;
                if ((sLBigNumberCast0 = SLTypesGen.specializeImplicitSLBigNumber(leftNodeValue)) != 0) {
                    SLBigNumber leftNodeValue_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast0, leftNodeValue);
                    int sLBigNumberCast1;
                    if ((sLBigNumberCast1 = SLTypesGen.specializeImplicitSLBigNumber(rightNodeValue)) != 0) {
                        SLBigNumber rightNodeValue_ = SLTypesGen.asImplicitSLBigNumber(sLBigNumberCast1, rightNodeValue);
                        state = (state | (sLBigNumberCast0 << 9) /* set-implicit-active 0:SLBigNumber */);
                        state = (state | (sLBigNumberCast1 << 11) /* set-implicit-active 1:SLBigNumber */);
                        this.state_ = state = state | 0b10 /* add-active equal(SLBigNumber, SLBigNumber) */;
                        lock.unlock();
                        hasLock = false;
                        return equal(leftNodeValue_, rightNodeValue_);
                    }
                }
            }
            if (leftNodeValue instanceof Boolean) {
                boolean leftNodeValue_ = (boolean) leftNodeValue;
                if (rightNodeValue instanceof Boolean) {
                    boolean rightNodeValue_ = (boolean) rightNodeValue;
                    this.state_ = state = state | 0b100 /* add-active equal(boolean, boolean) */;
                    lock.unlock();
                    hasLock = false;
                    return equal(leftNodeValue_, rightNodeValue_);
                }
            }
            if (leftNodeValue instanceof String) {
                String leftNodeValue_ = (String) leftNodeValue;
                if (rightNodeValue instanceof String) {
                    String rightNodeValue_ = (String) rightNodeValue;
                    this.state_ = state = state | 0b1000 /* add-active equal(String, String) */;
                    lock.unlock();
                    hasLock = false;
                    return equal(leftNodeValue_, rightNodeValue_);
                }
            }
            if (leftNodeValue instanceof SLFunction) {
                SLFunction leftNodeValue_ = (SLFunction) leftNodeValue;
                if (rightNodeValue instanceof SLFunction) {
                    SLFunction rightNodeValue_ = (SLFunction) rightNodeValue;
                    this.state_ = state = state | 0b10000 /* add-active equal(SLFunction, SLFunction) */;
                    lock.unlock();
                    hasLock = false;
                    return equal(leftNodeValue_, rightNodeValue_);
                }
            }
            if (SLTypes.isSLNull(leftNodeValue)) {
                SLNull leftNodeValue_ = SLTypes.asSLNull(leftNodeValue);
                if (SLTypes.isSLNull(rightNodeValue)) {
                    SLNull rightNodeValue_ = SLTypes.asSLNull(rightNodeValue);
                    this.state_ = state = state | 0b100000 /* add-active equal(SLNull, SLNull) */;
                    lock.unlock();
                    hasLock = false;
                    return equal(leftNodeValue_, rightNodeValue_);
                }
            }
            if (leftNodeValue instanceof TruffleObject) {
                TruffleObject leftNodeValue_ = (TruffleObject) leftNodeValue;
                if (rightNodeValue instanceof TruffleObject) {
                    TruffleObject rightNodeValue_ = (TruffleObject) rightNodeValue;
                    this.state_ = state = state | 0b1000000 /* add-active equal(TruffleObject, TruffleObject) */;
                    lock.unlock();
                    hasLock = false;
                    return equal(leftNodeValue_, rightNodeValue_);
                }
            }
            if ((SLEqualNode.differentClasses(leftNodeValue, rightNodeValue))) {
                this.state_ = state = state | 0b10000000 /* add-active equal(Object, Object) */;
                lock.unlock();
                hasLock = false;
                return equal(leftNodeValue, rightNodeValue);
            }
            this.state_ = state = state | 0b100000000 /* add-active typeError(Object, Object) */;
            lock.unlock();
            hasLock = false;
            return typeError(leftNodeValue, rightNodeValue);
        } finally {
            if (oldState != 0) {
                checkForPolymorphicSpecialize(oldState);
            }
            if (hasLock) {
                lock.unlock();
            }
        }
    }

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

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

    private static boolean fallbackGuard_(int state, Object leftNodeValue, Object rightNodeValue) {
        if (((state & 0b100)) == 0 /* is-not-active equal(boolean, boolean) */ && leftNodeValue instanceof Boolean && rightNodeValue instanceof Boolean) {
            return false;
        }
        if (((state & 0b1000)) == 0 /* is-not-active equal(String, String) */ && leftNodeValue instanceof String && rightNodeValue instanceof String) {
            return false;
        }
        if (((state & 0b1000000)) == 0 /* is-not-active equal(TruffleObject, TruffleObject) */ && leftNodeValue instanceof TruffleObject && rightNodeValue instanceof TruffleObject) {
            return false;
        }
        if (((state & 0b10000000)) == 0 /* is-not-active equal(Object, Object) */ && (SLEqualNode.differentClasses(leftNodeValue, rightNodeValue))) {
            return false;
        }
        return true;
    }

    public static SLEqualNode create(SLExpressionNode leftNode, SLExpressionNode rightNode) {
        return new SLEqualNodeGen(leftNode, rightNode);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy