src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/VerifyUsageWithEquals.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54328 37648a9c4a6a
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 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.
    30 import org.graalvm.compiler.nodes.ParameterNode;
    30 import org.graalvm.compiler.nodes.ParameterNode;
    31 import org.graalvm.compiler.nodes.StructuredGraph;
    31 import org.graalvm.compiler.nodes.StructuredGraph;
    32 import org.graalvm.compiler.nodes.ValueNode;
    32 import org.graalvm.compiler.nodes.ValueNode;
    33 import org.graalvm.compiler.nodes.calc.ObjectEqualsNode;
    33 import org.graalvm.compiler.nodes.calc.ObjectEqualsNode;
    34 import org.graalvm.compiler.nodes.java.LoadFieldNode;
    34 import org.graalvm.compiler.nodes.java.LoadFieldNode;
       
    35 import org.graalvm.compiler.nodes.spi.CoreProviders;
    35 import org.graalvm.compiler.nodes.spi.UncheckedInterfaceProvider;
    36 import org.graalvm.compiler.nodes.spi.UncheckedInterfaceProvider;
    36 import org.graalvm.compiler.nodes.type.StampTool;
    37 import org.graalvm.compiler.nodes.type.StampTool;
    37 import org.graalvm.compiler.phases.VerifyPhase;
    38 import org.graalvm.compiler.phases.VerifyPhase;
    38 import org.graalvm.compiler.phases.tiers.PhaseContext;
       
    39 
    39 
    40 import jdk.vm.ci.meta.JavaField;
    40 import jdk.vm.ci.meta.JavaField;
    41 import jdk.vm.ci.meta.JavaKind;
    41 import jdk.vm.ci.meta.JavaKind;
    42 import jdk.vm.ci.meta.JavaMethod;
    42 import jdk.vm.ci.meta.JavaMethod;
    43 import jdk.vm.ci.meta.JavaType;
    43 import jdk.vm.ci.meta.JavaType;
    49 /**
    49 /**
    50  * For certain types, object identity should not be used for object equality check. This phase
    50  * For certain types, object identity should not be used for object equality check. This phase
    51  * checks the correct usage of the given type. Equality checks with == or != (except null checks)
    51  * checks the correct usage of the given type. Equality checks with == or != (except null checks)
    52  * results in an {@link AssertionError}.
    52  * results in an {@link AssertionError}.
    53  */
    53  */
    54 public class VerifyUsageWithEquals extends VerifyPhase<PhaseContext> {
    54 public class VerifyUsageWithEquals extends VerifyPhase<CoreProviders> {
    55 
    55 
    56     @Override
    56     @Override
    57     public boolean checkContract() {
    57     public boolean checkContract() {
    58         return false;
    58         return false;
    59     }
    59     }
   141         }
   141         }
   142         return false;
   142         return false;
   143     }
   143     }
   144 
   144 
   145     @Override
   145     @Override
   146     protected void verify(StructuredGraph graph, PhaseContext context) {
   146     protected void verify(StructuredGraph graph, CoreProviders context) {
   147         for (ObjectEqualsNode cn : graph.getNodes().filter(ObjectEqualsNode.class)) {
   147         for (ObjectEqualsNode cn : graph.getNodes().filter(ObjectEqualsNode.class)) {
   148             // bail out if we compare an object of type klass with == or != (except null checks)
   148             // bail out if we compare an object of type klass with == or != (except null checks)
   149             ResolvedJavaMethod method = graph.method();
   149             ResolvedJavaMethod method = graph.method();
   150             ResolvedJavaType restrictedType = context.getMetaAccess().lookupJavaType(restrictedClass);
   150             ResolvedJavaType restrictedType = context.getMetaAccess().lookupJavaType(restrictedClass);
   151 
   151