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

org.jruby.truffle.language.objects.MetaClassNodeGen Maven / Gradle / Ivy

// CheckStyle: start generated
package org.jruby.truffle.language.objects;

import com.oracle.truffle.api.Assumption;
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.dsl.internal.SpecializationNode;
import com.oracle.truffle.api.dsl.internal.SpecializedNode;
import com.oracle.truffle.api.dsl.internal.SuppressFBWarnings;
import com.oracle.truffle.api.frame.Frame;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.InvalidAssumptionException;
import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Shape;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.RubyTypes;
import org.jruby.truffle.language.RubyTypesGen;

@GeneratedBy(MetaClassNode.class)
@SuppressFBWarnings("SA_LOCAL_SELF_COMPARISON")
public final class MetaClassNodeGen extends MetaClassNode implements SpecializedNode {

    @Child private RubyNode object_;
    @CompilationFinal private Class objectType_;
    @CompilationFinal private boolean excludeMetaClassCached_;
    @CompilationFinal private boolean excludeUpdateShapeAndMetaClass_;
    @Child private BaseNode_ specialization_;

    private MetaClassNodeGen(RubyNode object) {
        this.object_ = object;
        this.specialization_ = UninitializedNode_.create(this);
    }

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

    @Override
    public DynamicObject executeMetaClass(Object objectValue) {
        return specialization_.executeDynamicObject1(objectValue);
    }

    @Override
    public Object execute(VirtualFrame frameValue) {
        return specialization_.execute(frameValue);
    }

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

    @Override
    public DynamicObject executeDynamicObject(VirtualFrame frameValue) {
        return specialization_.executeDynamicObject0(frameValue);
    }

    @Override
    public SpecializationNode getSpecializationNode() {
        return specialization_;
    }

    @Override
    public Node deepCopy() {
        return SpecializationNode.updateRoot(super.deepCopy());
    }

    public static MetaClassNode create(RubyNode object) {
        return new MetaClassNodeGen(object);
    }

    @GeneratedBy(MetaClassNode.class)
    private abstract static class BaseNode_ extends SpecializationNode {

        @CompilationFinal protected MetaClassNodeGen root;

        BaseNode_(MetaClassNodeGen root, int index) {
            super(index);
            this.root = root;
        }

        @Override
        protected final void setRoot(Node root) {
            this.root = (MetaClassNodeGen) root;
        }

        @Override
        protected final Node[] getSuppliedChildren() {
            return new Node[] {root.object_};
        }

        @Override
        public final Object acceptAndExecute(Frame frameValue, Object objectValue) {
            return this.executeDynamicObject1(objectValue);
        }

        public abstract DynamicObject executeDynamicObject1(Object objectValue);

        public Object execute(VirtualFrame frameValue) {
            Object objectValue_ = executeObject_(frameValue);
            return executeDynamicObject1(objectValue_);
        }

        public void executeVoid(VirtualFrame frameValue) {
            execute(frameValue);
            return;
        }

        public DynamicObject executeDynamicObject0(VirtualFrame frameValue) {
            return (DynamicObject) execute(frameValue);
        }

        @Override
        protected final SpecializationNode createNext(Frame frameValue, Object objectValue) {
            if (objectValue instanceof Boolean) {
                boolean objectValue_ = (boolean) objectValue;
                if ((objectValue_)) {
                    return MetaClassTrueNode_.create(root);
                } else {
                    return MetaClassFalseNode_.create(root);
                }
            }
            if (RubyTypesGen.isImplicitInteger(objectValue)) {
                return MetaClassIntNode_.create(root, objectValue);
            }
            if (RubyTypesGen.isImplicitLong(objectValue)) {
                return MetaClassLongNode_.create(root, objectValue);
            }
            if (RubyTypesGen.isImplicitDouble(objectValue)) {
                return MetaClassDoubleNode_.create(root, objectValue);
            }
            if (objectValue instanceof DynamicObject) {
                DynamicObject objectValue_ = (DynamicObject) objectValue;
                Shape cachedShape6 = (objectValue_.getShape());
                if ((objectValue_.getShape() == cachedShape6)) {
                    if (!root.excludeMetaClassCached_) {
                        DynamicObject metaClass6 = (MetaClassNode.getMetaClass(cachedShape6));
                        Assumption assumption0_6 = (cachedShape6.getValidAssumption());
                        if (isValid(assumption0_6)) {
                            SpecializationNode s = MetaClassCachedNode_.create(root, cachedShape6, metaClass6, assumption0_6);
                            if (countSame(s) < (root.getCacheLimit())) {
                                return s;
                            }
                        }
                    }
                }
                if ((ShapeCachingGuards.updateShape(objectValue_))) {
                    if (!root.excludeUpdateShapeAndMetaClass_) {
                        return UpdateShapeAndMetaClassNode_.create(root);
                    }
                }
                root.excludeMetaClassCached_ = true;
                root.excludeUpdateShapeAndMetaClass_ = true;
                return MetaClassUncachedNode_.create(root);
            }
            return null;
        }

        @Override
        protected final SpecializationNode createFallback() {
            return FallbackNode_.create(root);
        }

        @Override
        protected final SpecializationNode createPolymorphic() {
            return PolymorphicNode_.create(root);
        }

        protected final BaseNode_ getNext() {
            return (BaseNode_) this.next;
        }

        protected final Object executeObject_(Frame frameValue) {
            Class objectType_ = root.objectType_;
            try {
                if (objectType_ == boolean.class) {
                    return root.object_.executeBoolean((VirtualFrame) frameValue);
                } else if (objectType_ == double.class) {
                    return root.object_.executeDouble((VirtualFrame) frameValue);
                } else if (objectType_ == int.class) {
                    return root.object_.executeInteger((VirtualFrame) frameValue);
                } else if (objectType_ == long.class) {
                    return root.object_.executeLong((VirtualFrame) frameValue);
                } else if (objectType_ == null) {
                    CompilerDirectives.transferToInterpreterAndInvalidate();
                    Class _type = Object.class;
                    try {
                        Object _value = root.object_.execute((VirtualFrame) frameValue);
                        if (_value instanceof Boolean) {
                            _type = boolean.class;
                        } else if (_value instanceof Double) {
                            _type = double.class;
                        } else if (_value instanceof Integer) {
                            _type = int.class;
                        } else if (_value instanceof Long) {
                            _type = long.class;
                        } else {
                            _type = Object.class;
                        }
                        return _value;
                    } finally {
                        root.objectType_ = _type;
                    }
                } else {
                    return root.object_.execute((VirtualFrame) frameValue);
                }
            } catch (UnexpectedResultException ex) {
                root.objectType_ = Object.class;
                return ex.getResult();
            }
        }

    }
    @GeneratedBy(MetaClassNode.class)
    private static final class UninitializedNode_ extends BaseNode_ {

        UninitializedNode_(MetaClassNodeGen root) {
            super(root, 2147483647);
        }

        @Override
        public DynamicObject executeDynamicObject1(Object objectValue) {
            return (DynamicObject) uninitialized(null, objectValue);
        }

        static BaseNode_ create(MetaClassNodeGen root) {
            return new UninitializedNode_(root);
        }

    }
    @GeneratedBy(MetaClassNode.class)
    private static final class PolymorphicNode_ extends BaseNode_ {

        PolymorphicNode_(MetaClassNodeGen root) {
            super(root, 0);
        }

        @Override
        public SpecializationNode merge(SpecializationNode newNode, Frame frameValue, Object objectValue) {
            return polymorphicMerge(newNode, super.merge(newNode, frameValue, objectValue));
        }

        @Override
        public DynamicObject executeDynamicObject1(Object objectValue) {
            return getNext().executeDynamicObject1(objectValue);
        }

        static BaseNode_ create(MetaClassNodeGen root) {
            return new PolymorphicNode_(root);
        }

    }
    @GeneratedBy(methodName = "metaClassTrue(boolean)", value = MetaClassNode.class)
    private static final class MetaClassTrueNode_ extends BaseNode_ {

        MetaClassTrueNode_(MetaClassNodeGen root) {
            super(root, 1);
        }

        @Override
        public Object execute(VirtualFrame frameValue) {
            return executeDynamicObject0(frameValue);
        }

        @Override
        public DynamicObject executeDynamicObject0(VirtualFrame frameValue) {
            boolean objectValue_;
            try {
                objectValue_ = root.object_.executeBoolean(frameValue);
            } catch (UnexpectedResultException ex) {
                return getNext().executeDynamicObject1(ex.getResult());
            }
            if ((objectValue_)) {
                return root.metaClassTrue(objectValue_);
            }
            return getNext().executeDynamicObject1(objectValue_);
        }

        @Override
        public DynamicObject executeDynamicObject1(Object objectValue) {
            if (objectValue instanceof Boolean) {
                boolean objectValue_ = (boolean) objectValue;
                if ((objectValue_)) {
                    return root.metaClassTrue(objectValue_);
                }
            }
            return getNext().executeDynamicObject1(objectValue);
        }

        static BaseNode_ create(MetaClassNodeGen root) {
            return new MetaClassTrueNode_(root);
        }

    }
    @GeneratedBy(methodName = "metaClassFalse(boolean)", value = MetaClassNode.class)
    private static final class MetaClassFalseNode_ extends BaseNode_ {

        MetaClassFalseNode_(MetaClassNodeGen root) {
            super(root, 2);
        }

        @Override
        public Object execute(VirtualFrame frameValue) {
            return executeDynamicObject0(frameValue);
        }

        @Override
        public DynamicObject executeDynamicObject0(VirtualFrame frameValue) {
            boolean objectValue_;
            try {
                objectValue_ = root.object_.executeBoolean(frameValue);
            } catch (UnexpectedResultException ex) {
                return getNext().executeDynamicObject1(ex.getResult());
            }
            if ((!(objectValue_))) {
                return root.metaClassFalse(objectValue_);
            }
            return getNext().executeDynamicObject1(objectValue_);
        }

        @Override
        public DynamicObject executeDynamicObject1(Object objectValue) {
            if (objectValue instanceof Boolean) {
                boolean objectValue_ = (boolean) objectValue;
                if ((!(objectValue_))) {
                    return root.metaClassFalse(objectValue_);
                }
            }
            return getNext().executeDynamicObject1(objectValue);
        }

        static BaseNode_ create(MetaClassNodeGen root) {
            return new MetaClassFalseNode_(root);
        }

    }
    @GeneratedBy(methodName = "metaClassInt(int)", value = MetaClassNode.class)
    private static final class MetaClassIntNode_ extends BaseNode_ {

        private final Class objectImplicitType;

        MetaClassIntNode_(MetaClassNodeGen root, Object objectValue) {
            super(root, 3);
            this.objectImplicitType = RubyTypesGen.getImplicitIntegerClass(objectValue);
        }

        @Override
        public boolean isSame(SpecializationNode other) {
            return super.isSame(other) && this.objectImplicitType == ((MetaClassIntNode_) other).objectImplicitType;
        }

        @Override
        public Object execute(VirtualFrame frameValue) {
            return executeDynamicObject0(frameValue);
        }

        @Override
        public DynamicObject executeDynamicObject0(VirtualFrame frameValue) {
            int objectValue_;
            try {
                if (objectImplicitType == int.class) {
                    objectValue_ = root.object_.executeInteger(frameValue);
                } else {
                    Object objectValue__ = executeObject_(frameValue);
                    objectValue_ = RubyTypesGen.expectImplicitInteger(objectValue__, objectImplicitType);
                }
            } catch (UnexpectedResultException ex) {
                return getNext().executeDynamicObject1(ex.getResult());
            }
            return root.metaClassInt(objectValue_);
        }

        @Override
        public DynamicObject executeDynamicObject1(Object objectValue) {
            if (RubyTypesGen.isImplicitInteger(objectValue, objectImplicitType)) {
                int objectValue_ = RubyTypesGen.asImplicitInteger(objectValue, objectImplicitType);
                return root.metaClassInt(objectValue_);
            }
            return getNext().executeDynamicObject1(objectValue);
        }

        static BaseNode_ create(MetaClassNodeGen root, Object objectValue) {
            return new MetaClassIntNode_(root, objectValue);
        }

    }
    @GeneratedBy(methodName = "metaClassLong(long)", value = MetaClassNode.class)
    private static final class MetaClassLongNode_ extends BaseNode_ {

        private final Class objectImplicitType;

        MetaClassLongNode_(MetaClassNodeGen root, Object objectValue) {
            super(root, 4);
            this.objectImplicitType = RubyTypesGen.getImplicitLongClass(objectValue);
        }

        @Override
        public boolean isSame(SpecializationNode other) {
            return super.isSame(other) && this.objectImplicitType == ((MetaClassLongNode_) other).objectImplicitType;
        }

        @Override
        public Object execute(VirtualFrame frameValue) {
            return executeDynamicObject0(frameValue);
        }

        @Override
        public DynamicObject executeDynamicObject0(VirtualFrame frameValue) {
            long objectValue_;
            try {
                if (objectImplicitType == long.class) {
                    objectValue_ = root.object_.executeLong(frameValue);
                } else if (objectImplicitType == int.class) {
                    objectValue_ = RubyTypes.promoteToLong(root.object_.executeInteger(frameValue));
                } else {
                    Object objectValue__ = executeObject_(frameValue);
                    objectValue_ = RubyTypesGen.expectImplicitLong(objectValue__, objectImplicitType);
                }
            } catch (UnexpectedResultException ex) {
                return getNext().executeDynamicObject1(ex.getResult());
            }
            return root.metaClassLong(objectValue_);
        }

        @Override
        public DynamicObject executeDynamicObject1(Object objectValue) {
            if (RubyTypesGen.isImplicitLong(objectValue, objectImplicitType)) {
                long objectValue_ = RubyTypesGen.asImplicitLong(objectValue, objectImplicitType);
                return root.metaClassLong(objectValue_);
            }
            return getNext().executeDynamicObject1(objectValue);
        }

        static BaseNode_ create(MetaClassNodeGen root, Object objectValue) {
            return new MetaClassLongNode_(root, objectValue);
        }

    }
    @GeneratedBy(methodName = "metaClassDouble(double)", value = MetaClassNode.class)
    private static final class MetaClassDoubleNode_ extends BaseNode_ {

        private final Class objectImplicitType;

        MetaClassDoubleNode_(MetaClassNodeGen root, Object objectValue) {
            super(root, 5);
            this.objectImplicitType = RubyTypesGen.getImplicitDoubleClass(objectValue);
        }

        @Override
        public boolean isSame(SpecializationNode other) {
            return super.isSame(other) && this.objectImplicitType == ((MetaClassDoubleNode_) other).objectImplicitType;
        }

        @Override
        public Object execute(VirtualFrame frameValue) {
            return executeDynamicObject0(frameValue);
        }

        @Override
        public DynamicObject executeDynamicObject0(VirtualFrame frameValue) {
            double objectValue_;
            try {
                if (objectImplicitType == double.class) {
                    objectValue_ = root.object_.executeDouble(frameValue);
                } else {
                    Object objectValue__ = executeObject_(frameValue);
                    objectValue_ = RubyTypesGen.expectImplicitDouble(objectValue__, objectImplicitType);
                }
            } catch (UnexpectedResultException ex) {
                return getNext().executeDynamicObject1(ex.getResult());
            }
            return root.metaClassDouble(objectValue_);
        }

        @Override
        public DynamicObject executeDynamicObject1(Object objectValue) {
            if (RubyTypesGen.isImplicitDouble(objectValue, objectImplicitType)) {
                double objectValue_ = RubyTypesGen.asImplicitDouble(objectValue, objectImplicitType);
                return root.metaClassDouble(objectValue_);
            }
            return getNext().executeDynamicObject1(objectValue);
        }

        static BaseNode_ create(MetaClassNodeGen root, Object objectValue) {
            return new MetaClassDoubleNode_(root, objectValue);
        }

    }
    @GeneratedBy(methodName = "metaClassCached(DynamicObject, Shape, DynamicObject)", value = MetaClassNode.class)
    private static final class MetaClassCachedNode_ extends BaseNode_ {

        private final Shape cachedShape;
        private final DynamicObject metaClass;
        @CompilationFinal private final Assumption assumption0_;

        MetaClassCachedNode_(MetaClassNodeGen root, Shape cachedShape, DynamicObject metaClass, Assumption assumption0_) {
            super(root, 6);
            this.cachedShape = cachedShape;
            this.metaClass = metaClass;
            this.assumption0_ = assumption0_;
        }

        @Override
        public SpecializationNode merge(SpecializationNode newNode, Frame frameValue, Object objectValue) {
            if (newNode.getClass() == MetaClassUncachedNode_.class) {
                removeSame("Contained by metaClassUncached(DynamicObject)");
            }
            return super.merge(newNode, frameValue, objectValue);
        }

        @Override
        public boolean isIdentical(SpecializationNode other, Frame frameValue, Object objectValue) {
            if (objectValue instanceof DynamicObject) {
                DynamicObject objectValue_ = (DynamicObject) objectValue;
                if ((objectValue_.getShape() == this.cachedShape)) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public DynamicObject executeDynamicObject1(Object objectValue) {
            try {
                check(this.assumption0_);
            } catch (InvalidAssumptionException ae) {
                return (DynamicObject) removeThis("Assumption [assumption0] invalidated", null, objectValue);
            }
            if (objectValue instanceof DynamicObject) {
                DynamicObject objectValue_ = (DynamicObject) objectValue;
                if ((objectValue_.getShape() == this.cachedShape)) {
                    return root.metaClassCached(objectValue_, this.cachedShape, this.metaClass);
                }
            }
            return getNext().executeDynamicObject1(objectValue);
        }

        static BaseNode_ create(MetaClassNodeGen root, Shape cachedShape, DynamicObject metaClass, Assumption assumption0_) {
            return new MetaClassCachedNode_(root, cachedShape, metaClass, assumption0_);
        }

    }
    @GeneratedBy(methodName = "updateShapeAndMetaClass(DynamicObject)", value = MetaClassNode.class)
    private static final class UpdateShapeAndMetaClassNode_ extends BaseNode_ {

        UpdateShapeAndMetaClassNode_(MetaClassNodeGen root) {
            super(root, 7);
        }

        @Override
        public SpecializationNode merge(SpecializationNode newNode, Frame frameValue, Object objectValue) {
            if (newNode.getClass() == MetaClassUncachedNode_.class) {
                removeSame("Contained by metaClassUncached(DynamicObject)");
            }
            return super.merge(newNode, frameValue, objectValue);
        }

        @Override
        public DynamicObject executeDynamicObject1(Object objectValue) {
            if (objectValue instanceof DynamicObject) {
                DynamicObject objectValue_ = (DynamicObject) objectValue;
                if ((ShapeCachingGuards.updateShape(objectValue_))) {
                    return root.updateShapeAndMetaClass(objectValue_);
                }
            }
            return getNext().executeDynamicObject1(objectValue);
        }

        static BaseNode_ create(MetaClassNodeGen root) {
            return new UpdateShapeAndMetaClassNode_(root);
        }

    }
    @GeneratedBy(methodName = "metaClassUncached(DynamicObject)", value = MetaClassNode.class)
    private static final class MetaClassUncachedNode_ extends BaseNode_ {

        MetaClassUncachedNode_(MetaClassNodeGen root) {
            super(root, 8);
        }

        @Override
        public DynamicObject executeDynamicObject1(Object objectValue) {
            if (objectValue instanceof DynamicObject) {
                DynamicObject objectValue_ = (DynamicObject) objectValue;
                return root.metaClassUncached(objectValue_);
            }
            return getNext().executeDynamicObject1(objectValue);
        }

        static BaseNode_ create(MetaClassNodeGen root) {
            return new MetaClassUncachedNode_(root);
        }

    }
    @GeneratedBy(methodName = "metaClassFallback(Object)", value = MetaClassNode.class)
    private static final class FallbackNode_ extends BaseNode_ {

        FallbackNode_(MetaClassNodeGen root) {
            super(root, 2147483646);
        }

        @TruffleBoundary
        private boolean guardFallback(Object objectValue) {
            return createNext(null, objectValue) == null;
        }

        @Override
        public DynamicObject executeDynamicObject1(Object objectValue) {
            if (guardFallback(objectValue)) {
                return root.metaClassFallback(objectValue);
            }
            return getNext().executeDynamicObject1(objectValue);
        }

        static BaseNode_ create(MetaClassNodeGen root) {
            return new FallbackNode_(root);
        }

    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy