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

Print this page




   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 static org.graalvm.compiler.core.GraalCompiler.compileGraph;
  26 import static org.graalvm.compiler.core.common.GraalOptions.OptAssumptions;
  27 import static org.junit.Assert.assertNotNull;
  28 import jdk.vm.ci.code.site.Call;
  29 import jdk.vm.ci.code.site.Infopoint;
  30 import jdk.vm.ci.code.site.InfopointReason;
  31 import jdk.vm.ci.meta.ResolvedJavaMethod;
  32 
  33 import org.junit.Test;
  34 
  35 import org.graalvm.compiler.code.CompilationResult;
  36 import org.graalvm.compiler.lir.asm.CompilationResultBuilderFactory;
  37 import org.graalvm.compiler.nodes.FullInfopointNode;
  38 import org.graalvm.compiler.nodes.StructuredGraph;
  39 import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
  40 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
  41 import org.graalvm.compiler.phases.OptimisticOptimizations;
  42 import org.graalvm.compiler.phases.PhaseSuite;
  43 import org.graalvm.compiler.phases.tiers.HighTierContext;
  44 





  45 /**
  46  * Test that infopoints in {@link CompilationResult}s have correctly assigned reasons.
  47  */
  48 public class InfopointReasonTest extends GraalCompilerTest {
  49 
  50     public static final String[] STRINGS = new String[]{"world", "everyone", "you"};
  51 
  52     public String testMethod() {
  53         StringBuilder sb = new StringBuilder("Hello ");
  54         for (String s : STRINGS) {
  55             sb.append(s).append(", ");
  56         }
  57         sb.replace(sb.length() - 2, sb.length(), "!");
  58         return sb.toString();
  59     }
  60 
  61     @Test
  62     public void callInfopoints() {
  63         final ResolvedJavaMethod method = getResolvedJavaMethod("testMethod");
  64         final StructuredGraph graph = parseEager(method, AllowAssumptions.YES);
  65         final CompilationResult cr = compileGraph(graph, graph.method(), getProviders(), getBackend(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, graph.getProfilingInfo(),
  66                         getSuites(), getLIRSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default);
  67         for (Infopoint sp : cr.getInfopoints()) {
  68             assertNotNull(sp.reason);
  69             if (sp instanceof Call) {
  70                 assertDeepEquals(InfopointReason.CALL, sp.reason);
  71             }
  72         }
  73     }
  74 
  75     @Test
  76     public void lineInfopoints() {
  77         final ResolvedJavaMethod method = getResolvedJavaMethod("testMethod");
  78         final StructuredGraph graph = parseDebug(method, AllowAssumptions.from(OptAssumptions.getValue()));
  79         int graphLineSPs = 0;
  80         for (FullInfopointNode ipn : graph.getNodes().filter(FullInfopointNode.class)) {
  81             if (ipn.getReason() == InfopointReason.BYTECODE_POSITION) {
  82                 ++graphLineSPs;
  83             }
  84         }
  85         assertTrue(graphLineSPs > 0);
  86         PhaseSuite<HighTierContext> graphBuilderSuite = getCustomGraphBuilderSuite(GraphBuilderConfiguration.getDefault(getDefaultGraphBuilderPlugins()).withFullInfopoints(true));
  87         final CompilationResult cr = compileGraph(graph, graph.method(), getProviders(), getBackend(), graphBuilderSuite, OptimisticOptimizations.ALL, graph.getProfilingInfo(), getSuites(),
  88                         getLIRSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default);
  89         int lineSPs = 0;
  90         for (Infopoint sp : cr.getInfopoints()) {
  91             assertNotNull(sp.reason);
  92             if (sp.reason == InfopointReason.BYTECODE_POSITION) {
  93                 ++lineSPs;
  94             }
  95         }
  96         assertTrue(lineSPs > 0);
  97     }
  98 
  99 }


   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 static org.graalvm.compiler.core.GraalCompiler.compileGraph;
  26 import static org.graalvm.compiler.core.common.GraalOptions.OptAssumptions;
  27 import static org.junit.Assert.assertNotNull;




  28 
  29 import org.junit.Test;
  30 
  31 import org.graalvm.compiler.code.CompilationResult;
  32 import org.graalvm.compiler.lir.asm.CompilationResultBuilderFactory;
  33 import org.graalvm.compiler.nodes.FullInfopointNode;
  34 import org.graalvm.compiler.nodes.StructuredGraph;
  35 import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
  36 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
  37 import org.graalvm.compiler.phases.OptimisticOptimizations;
  38 import org.graalvm.compiler.phases.PhaseSuite;
  39 import org.graalvm.compiler.phases.tiers.HighTierContext;
  40 
  41 import jdk.vm.ci.code.site.Call;
  42 import jdk.vm.ci.code.site.Infopoint;
  43 import jdk.vm.ci.code.site.InfopointReason;
  44 import jdk.vm.ci.meta.ResolvedJavaMethod;
  45 
  46 /**
  47  * Test that infopoints in {@link CompilationResult}s have correctly assigned reasons.
  48  */
  49 public class InfopointReasonTest extends GraalCompilerTest {
  50 
  51     public static final String[] STRINGS = new String[]{"world", "everyone", "you"};
  52 
  53     public String testMethod() {
  54         StringBuilder sb = new StringBuilder("Hello ");
  55         for (String s : STRINGS) {
  56             sb.append(s).append(", ");
  57         }
  58         sb.replace(sb.length() - 2, sb.length(), "!");
  59         return sb.toString();
  60     }
  61 
  62     @Test
  63     public void callInfopoints() {
  64         final ResolvedJavaMethod method = getResolvedJavaMethod("testMethod");
  65         final StructuredGraph graph = parseEager(method, AllowAssumptions.YES);
  66         final CompilationResult cr = compileGraph(graph, graph.method(), getProviders(), getBackend(), getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, graph.getProfilingInfo(),
  67                         createSuites(graph.getOptions()), createLIRSuites(graph.getOptions()), new CompilationResult(), CompilationResultBuilderFactory.Default);
  68         for (Infopoint sp : cr.getInfopoints()) {
  69             assertNotNull(sp.reason);
  70             if (sp instanceof Call) {
  71                 assertDeepEquals(InfopointReason.CALL, sp.reason);
  72             }
  73         }
  74     }
  75 
  76     @Test
  77     public void lineInfopoints() {
  78         final ResolvedJavaMethod method = getResolvedJavaMethod("testMethod");
  79         final StructuredGraph graph = parseDebug(method, AllowAssumptions.ifTrue(OptAssumptions.getValue(getInitialOptions())));
  80         int graphLineSPs = 0;
  81         for (FullInfopointNode ipn : graph.getNodes().filter(FullInfopointNode.class)) {
  82             if (ipn.getReason() == InfopointReason.BYTECODE_POSITION) {
  83                 ++graphLineSPs;
  84             }
  85         }
  86         assertTrue(graphLineSPs > 0);
  87         PhaseSuite<HighTierContext> graphBuilderSuite = getCustomGraphBuilderSuite(GraphBuilderConfiguration.getDefault(getDefaultGraphBuilderPlugins()).withFullInfopoints(true));
  88         final CompilationResult cr = compileGraph(graph, graph.method(), getProviders(), getBackend(), graphBuilderSuite, OptimisticOptimizations.ALL, graph.getProfilingInfo(),
  89                         createSuites(graph.getOptions()), createLIRSuites(graph.getOptions()), new CompilationResult(), CompilationResultBuilderFactory.Default);
  90         int lineSPs = 0;
  91         for (Infopoint sp : cr.getInfopoints()) {
  92             assertNotNull(sp.reason);
  93             if (sp.reason == InfopointReason.BYTECODE_POSITION) {
  94                 ++lineSPs;
  95             }
  96         }
  97         assertTrue(lineSPs > 0);
  98     }
  99 
 100 }
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/InfopointReasonTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File