src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/LongNodeChainTest.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/LongNodeChainTest.java

Print this page




   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 jdk.vm.ci.meta.JavaConstant;
  26 
  27 import org.junit.Assert;
  28 import org.junit.Test;
  29 

  30 import org.graalvm.compiler.nodes.ConstantNode;
  31 import org.graalvm.compiler.nodes.ReturnNode;
  32 import org.graalvm.compiler.nodes.StructuredGraph;
  33 import org.graalvm.compiler.nodes.ValueNode;
  34 import org.graalvm.compiler.nodes.calc.AddNode;
  35 import org.graalvm.compiler.nodes.debug.OpaqueNode;

  36 import org.graalvm.compiler.phases.common.CanonicalizerPhase;
  37 import org.graalvm.compiler.phases.schedule.SchedulePhase;
  38 import org.graalvm.compiler.phases.schedule.SchedulePhase.SchedulingStrategy;
  39 import org.graalvm.compiler.phases.tiers.HighTierContext;
  40 
  41 public class LongNodeChainTest extends GraalCompilerTest {
  42 
  43     public static final int N = 10000;
  44 
  45     private static final SchedulingStrategy[] Strategies = new SchedulingStrategy[]{SchedulingStrategy.EARLIEST};
  46 
  47     @Test
  48     public void testLongAddChain() {
  49         longAddChain(true);
  50         longAddChain(false);
  51     }
  52 
  53     private void longAddChain(boolean reverse) {
  54         HighTierContext context = getDefaultHighTierContext();
  55         StructuredGraph graph = new StructuredGraph.Builder(getInitialOptions()).build();

  56         ValueNode constant = graph.unique(ConstantNode.forPrimitive(JavaConstant.INT_1));
  57         ValueNode value = null;
  58         if (reverse) {
  59             // Make sure the constant's stamp is not used to infer the add node's stamp.
  60             OpaqueNode opaque = graph.unique(new OpaqueNode(constant));
  61             constant = opaque;
  62             AddNode addNode = graph.unique(new AddNode(constant, constant));
  63             value = addNode;
  64             for (int i = 1; i < N; ++i) {
  65                 AddNode newAddNode = graph.addWithoutUnique(new AddNode(constant, constant));
  66                 addNode.setY(newAddNode);
  67                 addNode = newAddNode;
  68             }
  69             opaque.replaceAndDelete(opaque.getValue());
  70         } else {
  71             value = constant;
  72             for (int i = 0; i < N; ++i) {
  73                 value = graph.unique(new AddNode(constant, value));
  74             }
  75         }


   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 jdk.vm.ci.meta.JavaConstant;
  26 
  27 import org.junit.Assert;
  28 import org.junit.Test;
  29 import org.graalvm.compiler.debug.DebugHandlersFactory;
  30 import org.graalvm.compiler.debug.DebugContext;
  31 import org.graalvm.compiler.nodes.ConstantNode;
  32 import org.graalvm.compiler.nodes.ReturnNode;
  33 import org.graalvm.compiler.nodes.StructuredGraph;
  34 import org.graalvm.compiler.nodes.ValueNode;
  35 import org.graalvm.compiler.nodes.calc.AddNode;
  36 import org.graalvm.compiler.nodes.debug.OpaqueNode;
  37 import org.graalvm.compiler.options.OptionValues;
  38 import org.graalvm.compiler.phases.common.CanonicalizerPhase;
  39 import org.graalvm.compiler.phases.schedule.SchedulePhase;
  40 import org.graalvm.compiler.phases.schedule.SchedulePhase.SchedulingStrategy;
  41 import org.graalvm.compiler.phases.tiers.HighTierContext;
  42 
  43 public class LongNodeChainTest extends GraalCompilerTest {
  44 
  45     public static final int N = 10000;
  46 
  47     private static final SchedulingStrategy[] Strategies = new SchedulingStrategy[]{SchedulingStrategy.EARLIEST};
  48 
  49     @Test
  50     public void testLongAddChain() {
  51         longAddChain(true);
  52         longAddChain(false);
  53     }
  54 
  55     private void longAddChain(boolean reverse) {
  56         HighTierContext context = getDefaultHighTierContext();
  57         OptionValues options = getInitialOptions();
  58         StructuredGraph graph = new StructuredGraph.Builder(options, DebugContext.create(options, DebugHandlersFactory.LOADER)).build();
  59         ValueNode constant = graph.unique(ConstantNode.forPrimitive(JavaConstant.INT_1));
  60         ValueNode value = null;
  61         if (reverse) {
  62             // Make sure the constant's stamp is not used to infer the add node's stamp.
  63             OpaqueNode opaque = graph.unique(new OpaqueNode(constant));
  64             constant = opaque;
  65             AddNode addNode = graph.unique(new AddNode(constant, constant));
  66             value = addNode;
  67             for (int i = 1; i < N; ++i) {
  68                 AddNode newAddNode = graph.addWithoutUnique(new AddNode(constant, constant));
  69                 addNode.setY(newAddNode);
  70                 addNode = newAddNode;
  71             }
  72             opaque.replaceAndDelete(opaque.getValue());
  73         } else {
  74             value = constant;
  75             for (int i = 0; i < N; ++i) {
  76                 value = graph.unique(new AddNode(constant, value));
  77             }
  78         }
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/LongNodeChainTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File