src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/MemoryGraphCanonicalizeTest.java
changeset 58877 aec7bf35d6f5
parent 52910 583fd71c47d6
equal deleted inserted replaced
58876:1a8d65e71a66 58877:aec7bf35d6f5
     1 /*
     1 /*
     2  * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2017, 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.
    26 package org.graalvm.compiler.core.test;
    26 package org.graalvm.compiler.core.test;
    27 
    27 
    28 import org.graalvm.compiler.nodes.StructuredGraph;
    28 import org.graalvm.compiler.nodes.StructuredGraph;
    29 import org.graalvm.compiler.nodes.memory.WriteNode;
    29 import org.graalvm.compiler.nodes.memory.WriteNode;
    30 import org.graalvm.compiler.nodes.spi.LoweringTool;
    30 import org.graalvm.compiler.nodes.spi.LoweringTool;
    31 import org.graalvm.compiler.phases.common.CanonicalizerPhase;
       
    32 import org.graalvm.compiler.phases.common.FloatingReadPhase;
    31 import org.graalvm.compiler.phases.common.FloatingReadPhase;
    33 import org.graalvm.compiler.phases.common.IncrementalCanonicalizerPhase;
    32 import org.graalvm.compiler.phases.common.IncrementalCanonicalizerPhase;
    34 import org.graalvm.compiler.phases.common.LoweringPhase;
    33 import org.graalvm.compiler.phases.common.LoweringPhase;
    35 import org.graalvm.compiler.phases.tiers.HighTierContext;
    34 import org.graalvm.compiler.phases.tiers.HighTierContext;
    36 import org.junit.Test;
    35 import org.junit.Test;
    74     }
    73     }
    75 
    74 
    76     public void testGraph(String name, int expectedWrites) {
    75     public void testGraph(String name, int expectedWrites) {
    77         StructuredGraph graph = parseEager(name, StructuredGraph.AllowAssumptions.YES);
    76         StructuredGraph graph = parseEager(name, StructuredGraph.AllowAssumptions.YES);
    78         HighTierContext context = getDefaultHighTierContext();
    77         HighTierContext context = getDefaultHighTierContext();
    79         CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
    78         new LoweringPhase(createCanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    80         new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
    79         new IncrementalCanonicalizerPhase<>(createCanonicalizerPhase(), new FloatingReadPhase()).apply(graph, context);
    81         new IncrementalCanonicalizerPhase<>(canonicalizer, new FloatingReadPhase()).apply(graph, context);
    80         createCanonicalizerPhase().apply(graph, context);
    82         new CanonicalizerPhase().apply(graph, context);
       
    83         int writes = graph.getNodes().filter(WriteNode.class).count();
    81         int writes = graph.getNodes().filter(WriteNode.class).count();
    84         assertTrue(writes == expectedWrites, "Expected %d writes, found %d", expectedWrites, writes);
    82         assertTrue(writes == expectedWrites, "Expected %d writes, found %d", expectedWrites, writes);
    85     }
    83     }
    86 }
    84 }