src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/EnumSwitchTest.java
changeset 58299 6df94ce3ab2f
parent 52910 583fd71c47d6
child 58877 aec7bf35d6f5
equal deleted inserted replaced
58298:0152ad7b38b8 58299:6df94ce3ab2f
     1 /*
     1 /*
     2  * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2016, 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.
    22  */
    22  */
    23 
    23 
    24 
    24 
    25 package org.graalvm.compiler.core.test;
    25 package org.graalvm.compiler.core.test;
    26 
    26 
    27 import org.junit.Test;
       
    28 
       
    29 import org.graalvm.compiler.nodes.StructuredGraph;
    27 import org.graalvm.compiler.nodes.StructuredGraph;
    30 import org.graalvm.compiler.nodes.extended.IntegerSwitchNode;
    28 import org.graalvm.compiler.nodes.extended.IntegerSwitchNode;
    31 import org.graalvm.compiler.nodes.java.LoadIndexedNode;
    29 import org.graalvm.compiler.nodes.java.LoadIndexedNode;
    32 import org.graalvm.compiler.options.OptionValues;
    30 import org.graalvm.compiler.options.OptionValues;
    33 import org.graalvm.compiler.phases.Phase;
    31 import org.graalvm.compiler.phases.Phase;
    34 import org.graalvm.compiler.phases.common.RemoveValueProxyPhase;
    32 import org.graalvm.compiler.phases.common.RemoveValueProxyPhase;
    35 import org.graalvm.compiler.phases.tiers.Suites;
    33 import org.graalvm.compiler.phases.tiers.Suites;
       
    34 import org.junit.Assume;
       
    35 import org.junit.Test;
    36 
    36 
    37 public class EnumSwitchTest extends GraalCompilerTest {
    37 public class EnumSwitchTest extends GraalCompilerTest {
    38 
    38 
    39     enum E {
    39     enum E {
    40         E0,
    40         E0,
   143     protected Suites createSuites(OptionValues options) {
   143     protected Suites createSuites(OptionValues options) {
   144         Suites ret = super.createSuites(options);
   144         Suites ret = super.createSuites(options);
   145         ret.getHighTier().prependPhase(new Phase() {
   145         ret.getHighTier().prependPhase(new Phase() {
   146             @Override
   146             @Override
   147             protected void run(StructuredGraph graph) {
   147             protected void run(StructuredGraph graph) {
       
   148                 Assume.assumeTrue(graph.getNodes().filter(LoadIndexedNode.class).first().array().isConstant());
   148                 /* Array load from the enum switch map. */
   149                 /* Array load from the enum switch map. */
   149                 assertTrue(graph.getNodes().filter(LoadIndexedNode.class).count() == 1);
   150                 assertTrue(graph.getNodes().filter(LoadIndexedNode.class).count() == 1);
   150                 /* The actual switch. */
   151                 /* The actual switch. */
   151                 assertTrue(graph.getNodes().filter(IntegerSwitchNode.class).count() == 1);
   152                 assertTrue(graph.getNodes().filter(IntegerSwitchNode.class).count() == 1);
   152             }
   153             }