src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/ObjectEqualsNode.java
changeset 58533 46b0b7fe255c
parent 52910 583fd71c47d6
equal deleted inserted replaced
58532:b4f2e13d20ea 58533:46b0b7fe255c
     1 /*
     1 /*
     2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    37 import org.graalvm.compiler.nodes.LogicConstantNode;
    37 import org.graalvm.compiler.nodes.LogicConstantNode;
    38 import org.graalvm.compiler.nodes.LogicNode;
    38 import org.graalvm.compiler.nodes.LogicNode;
    39 import org.graalvm.compiler.nodes.NodeView;
    39 import org.graalvm.compiler.nodes.NodeView;
    40 import org.graalvm.compiler.nodes.StructuredGraph;
    40 import org.graalvm.compiler.nodes.StructuredGraph;
    41 import org.graalvm.compiler.nodes.ValueNode;
    41 import org.graalvm.compiler.nodes.ValueNode;
       
    42 import org.graalvm.compiler.nodes.extended.BoxNode;
    42 import org.graalvm.compiler.nodes.extended.GetClassNode;
    43 import org.graalvm.compiler.nodes.extended.GetClassNode;
       
    44 import org.graalvm.compiler.nodes.java.AbstractNewObjectNode;
    43 import org.graalvm.compiler.nodes.java.InstanceOfNode;
    45 import org.graalvm.compiler.nodes.java.InstanceOfNode;
    44 import org.graalvm.compiler.nodes.spi.Virtualizable;
    46 import org.graalvm.compiler.nodes.spi.Virtualizable;
    45 import org.graalvm.compiler.nodes.spi.VirtualizerTool;
    47 import org.graalvm.compiler.nodes.spi.VirtualizerTool;
       
    48 import org.graalvm.compiler.nodes.virtual.AllocatedObjectNode;
    46 import org.graalvm.compiler.nodes.virtual.VirtualBoxingNode;
    49 import org.graalvm.compiler.nodes.virtual.VirtualBoxingNode;
    47 import org.graalvm.compiler.nodes.virtual.VirtualObjectNode;
    50 import org.graalvm.compiler.nodes.virtual.VirtualObjectNode;
    48 import org.graalvm.compiler.options.OptionValues;
    51 import org.graalvm.compiler.options.OptionValues;
    49 
    52 
    50 import jdk.vm.ci.meta.Constant;
    53 import jdk.vm.ci.meta.Constant;
   108                 ValueNode object = getClassNode.getObject();
   111                 ValueNode object = getClassNode.getObject();
   109                 assert ((ObjectStamp) object.stamp(view)).nonNull();
   112                 assert ((ObjectStamp) object.stamp(view)).nonNull();
   110                 if (!type.isPrimitive() && (type.isConcrete() || type.isArray())) {
   113                 if (!type.isPrimitive() && (type.isConcrete() || type.isArray())) {
   111                     return InstanceOfNode.create(TypeReference.createExactTrusted(type), object);
   114                     return InstanceOfNode.create(TypeReference.createExactTrusted(type), object);
   112                 }
   115                 }
       
   116                 return LogicConstantNode.forBoolean(false);
       
   117             }
       
   118             if (nonConstant instanceof AbstractNewObjectNode || nonConstant instanceof AllocatedObjectNode) {
       
   119                 assert !(nonConstant instanceof BoxNode); // guard against class hierarchy changes
       
   120                 // a constant can never be equals to a new object
   113                 return LogicConstantNode.forBoolean(false);
   121                 return LogicConstantNode.forBoolean(false);
   114             }
   122             }
   115             return super.canonicalizeSymmetricConstant(constantReflection, metaAccess, options, smallestCompareWidth, condition, constant, nonConstant, mirrored, unorderedIsTrue, view);
   123             return super.canonicalizeSymmetricConstant(constantReflection, metaAccess, options, smallestCompareWidth, condition, constant, nonConstant, mirrored, unorderedIsTrue, view);
   116         }
   124         }
   117 
   125