src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/ConditionalEliminationTest5.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/ConditionalEliminationTest5.java

Print this page




   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.core.test;
  24 

  25 import org.junit.Test;
  26 
  27 import org.graalvm.compiler.api.directives.GraalDirectives;
  28 
  29 /**
  30  * Collection of tests for
  31  * {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} including those
  32  * that triggered bugs in this phase.
  33  */
  34 public class ConditionalEliminationTest5 extends ConditionalEliminationTestBase {
  35 
  36     interface A {
  37     }
  38 
  39     interface B extends A {
  40     }
  41 




  42     static final class DistinctA {
  43     }
  44 
  45     static final class DistinctB {
  46     }
  47 
  48     public static int reference1Snippet(Object a) {
  49         if (a instanceof B) {
  50             return 1;
  51         }
  52         return 2;
  53     }
  54 
  55     public static int test1Snippet(Object a) {
  56         if (a instanceof B) {
  57             if (a instanceof A) {
  58                 return 1;
  59             }
  60         }
  61         return 2;


  98         }
  99         return 2;
 100     }
 101 
 102     @SuppressWarnings("all")
 103     public static int test3Snippet(Object a, Object b) {
 104         if (a instanceof DistinctA) {
 105             DistinctA proxyA = (DistinctA) a;
 106             if (b instanceof DistinctB) {
 107                 if (proxyA == b) {
 108                     return 42;
 109                 }
 110                 return 1;
 111             }
 112         }
 113         return 2;
 114     }
 115 
 116     @Test
 117     public void test3() {
 118         testConditionalElimination("test3Snippet", "reference3Snippet", true);
 119     }
 120 
 121     public static int reference4Snippet(Object a) {
 122         if (!(a instanceof B)) {
 123             GraalDirectives.deoptimize();
 124         }
 125         return 1;
 126     }
 127 
 128     public static int test4Snippet1(Object a) {
 129         if (!(a instanceof B)) {
 130             GraalDirectives.deoptimize();
 131         }
 132         if (!(a instanceof A)) {
 133             GraalDirectives.deoptimize();
 134         }
 135         return 1;
 136     }
 137 
 138     public static int test4Snippet2(Object a) {
 139         if (!(a instanceof A)) {
 140             GraalDirectives.deoptimize();





 141         }




 142         if (!(a instanceof B)) {
 143             GraalDirectives.deoptimize();






















 144         }
 145         return 1;
 146     }
 147 
 148     @Test
 149     public void test4() {
 150         testConditionalElimination("test4Snippet1", "reference4Snippet");
 151         testConditionalElimination("test4Snippet2", "reference4Snippet");








 152     }
 153 }


   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.core.test;
  24 
  25 import org.junit.Ignore;
  26 import org.junit.Test;
  27 
  28 import org.graalvm.compiler.api.directives.GraalDirectives;
  29 
  30 /**
  31  * Collection of tests for
  32  * {@link org.graalvm.compiler.phases.common.DominatorConditionalEliminationPhase} including those
  33  * that triggered bugs in this phase.
  34  */
  35 public class ConditionalEliminationTest5 extends ConditionalEliminationTestBase {
  36 
  37     interface A {
  38     }
  39 
  40     interface B extends A {
  41     }
  42 
  43     interface C extends B {
  44 
  45     }
  46 
  47     static final class DistinctA {
  48     }
  49 
  50     static final class DistinctB {
  51     }
  52 
  53     public static int reference1Snippet(Object a) {
  54         if (a instanceof B) {
  55             return 1;
  56         }
  57         return 2;
  58     }
  59 
  60     public static int test1Snippet(Object a) {
  61         if (a instanceof B) {
  62             if (a instanceof A) {
  63                 return 1;
  64             }
  65         }
  66         return 2;


 103         }
 104         return 2;
 105     }
 106 
 107     @SuppressWarnings("all")
 108     public static int test3Snippet(Object a, Object b) {
 109         if (a instanceof DistinctA) {
 110             DistinctA proxyA = (DistinctA) a;
 111             if (b instanceof DistinctB) {
 112                 if (proxyA == b) {
 113                     return 42;
 114                 }
 115                 return 1;
 116             }
 117         }
 118         return 2;
 119     }
 120 
 121     @Test
 122     public void test3() {
 123         testConditionalElimination("test3Snippet", "reference3Snippet", true, false);
 124     }
 125 
 126     public static int reference4Snippet(Object a) {
 127         if (!(a instanceof B)) {
 128             GraalDirectives.deoptimizeAndInvalidate();
 129         }
 130         return 1;
 131     }
 132 
 133     public static int test4Snippet1(Object a) {
 134         if (!(a instanceof B)) {
 135             GraalDirectives.deoptimizeAndInvalidate();
 136         }
 137         if (!(a instanceof A)) {
 138             GraalDirectives.deoptimizeAndInvalidate();
 139         }
 140         return 1;
 141     }
 142 
 143     public static int test4Snippet2(Object a) {
 144         if (!(a instanceof A)) {
 145             GraalDirectives.deoptimizeAndInvalidate();
 146         }
 147         if (!(a instanceof B)) {
 148             GraalDirectives.deoptimizeAndInvalidate();
 149         }
 150         return 1;
 151     }
 152 
 153     @SuppressWarnings({"cast", "unused"})
 154     public static int test4Snippet3(Object a) {
 155         Object pi = (A) a;
 156         if (!(a instanceof B)) {
 157             GraalDirectives.deoptimizeAndInvalidate();
 158         }
 159         return 1;
 160     }
 161 
 162     public static int test4Snippet4(Object a) {
 163         if (!(a instanceof A)) {
 164             GraalDirectives.deoptimizeAndInvalidate();
 165         }
 166         if (!(((A) a) instanceof B)) {
 167             GraalDirectives.deoptimizeAndInvalidate();
 168         }
 169         return 1;
 170     }
 171 
 172     @SuppressWarnings({"cast"})
 173     public static int test4Snippet5(Object a) {
 174         Object pi = (A) a;
 175         if (pi == null) {
 176             GraalDirectives.deoptimizeAndInvalidate();
 177         }
 178         if (!(a instanceof B)) {
 179             GraalDirectives.deoptimizeAndInvalidate();
 180         }
 181         return 1;
 182     }
 183 
 184     @Test
 185     public void test4() {
 186         testConditionalElimination("test4Snippet1", "reference4Snippet");
 187         testConditionalElimination("test4Snippet2", "reference4Snippet");
 188         testConditionalElimination("test4Snippet3", "reference4Snippet");
 189         testConditionalElimination("test4Snippet5", "reference4Snippet");
 190     }
 191 
 192     @Ignore
 193     @Test
 194     public void test5() {
 195         testConditionalElimination("test4Snippet4", "reference4Snippet", false, true);
 196     }
 197 }
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/ConditionalEliminationTest5.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File