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

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/debug/VerifyMethodMetricsTest.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.debug;
  24 
  25 import static org.graalvm.compiler.core.common.CompilationIdentifier.INVALID_COMPILATION_ID;
  26 
  27 import java.lang.reflect.Method;
  28 import java.lang.reflect.Modifier;
  29 
  30 import org.junit.Test;
  31 
  32 import org.graalvm.compiler.api.test.Graal;
  33 import org.graalvm.compiler.debug.Debug;
  34 import org.graalvm.compiler.debug.DebugConfigScope;
  35 import org.graalvm.compiler.debug.DebugMethodMetrics;
  36 import org.graalvm.compiler.graph.Node;
  37 import org.graalvm.compiler.java.GraphBuilderPhase;
  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.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
  42 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
  43 import org.graalvm.compiler.phases.OptimisticOptimizations;
  44 import org.graalvm.compiler.phases.Phase;
  45 import org.graalvm.compiler.phases.PhaseSuite;
  46 import org.graalvm.compiler.phases.VerifyPhase.VerificationError;
  47 import org.graalvm.compiler.phases.tiers.HighTierContext;
  48 import org.graalvm.compiler.phases.util.Providers;
  49 import org.graalvm.compiler.phases.verify.VerifyDebugUsage;
  50 import org.graalvm.compiler.runtime.RuntimeProvider;

  51 
  52 import jdk.vm.ci.meta.MetaAccessProvider;
  53 import jdk.vm.ci.meta.ResolvedJavaMethod;
  54 
  55 /**
  56  *
  57  * Tests to verify that the usage of method metrics does not generate compile time overhead through
  58  * eager evaluation of arguments.
  59  */
  60 public class VerifyMethodMetricsTest {
  61 
  62     private static class InvalidCCP_ToString01Inc extends Phase {
  63         @Override
  64         protected void run(StructuredGraph graph) {
  65             DebugMethodMetrics m = Debug.methodMetrics(graph.method());
  66             for (Node n : graph.getNodes()) {
  67                 m.incrementMetric(n.toString());
  68             }
  69         }
  70     }


 239     }
 240 
 241     @Test
 242     public void testLogValidConcatInc() {
 243         testDebugUsageClass(ValidCCP_ConcatInc.class);
 244     }
 245 
 246     @SuppressWarnings("try")
 247     private static void testDebugUsageClass(Class<?> c) {
 248         RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
 249         Providers providers = rt.getHostBackend().getProviders();
 250         MetaAccessProvider metaAccess = providers.getMetaAccess();
 251         PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
 252         Plugins plugins = new Plugins(new InvocationPlugins(metaAccess));
 253         GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
 254         graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
 255         HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
 256         for (Method m : c.getDeclaredMethods()) {
 257             if (!Modifier.isNative(m.getModifiers()) && !Modifier.isAbstract(m.getModifiers())) {
 258                 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
 259                 StructuredGraph graph = new StructuredGraph(method, AllowAssumptions.NO, INVALID_COMPILATION_ID);
 260                 graphBuilderSuite.apply(graph, context);
 261                 try (DebugConfigScope s = Debug.disableIntercept()) {
 262                     new VerifyDebugUsage().apply(graph, context);
 263                 }
 264             }
 265         }
 266     }
 267 }


   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.debug;
  24 
  25 import static org.graalvm.compiler.core.test.GraalCompilerTest.getInitialOptions;
  26 
  27 import java.lang.reflect.Method;
  28 import java.lang.reflect.Modifier;
  29 


  30 import org.graalvm.compiler.api.test.Graal;
  31 import org.graalvm.compiler.debug.Debug;
  32 import org.graalvm.compiler.debug.DebugConfigScope;
  33 import org.graalvm.compiler.debug.DebugMethodMetrics;
  34 import org.graalvm.compiler.graph.Node;
  35 import org.graalvm.compiler.java.GraphBuilderPhase;
  36 import org.graalvm.compiler.nodes.StructuredGraph;

  37 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
  38 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins;
  39 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
  40 import org.graalvm.compiler.phases.OptimisticOptimizations;
  41 import org.graalvm.compiler.phases.Phase;
  42 import org.graalvm.compiler.phases.PhaseSuite;
  43 import org.graalvm.compiler.phases.VerifyPhase.VerificationError;
  44 import org.graalvm.compiler.phases.tiers.HighTierContext;
  45 import org.graalvm.compiler.phases.util.Providers;
  46 import org.graalvm.compiler.phases.verify.VerifyDebugUsage;
  47 import org.graalvm.compiler.runtime.RuntimeProvider;
  48 import org.junit.Test;
  49 
  50 import jdk.vm.ci.meta.MetaAccessProvider;
  51 import jdk.vm.ci.meta.ResolvedJavaMethod;
  52 
  53 /**
  54  *
  55  * Tests to verify that the usage of method metrics does not generate compile time overhead through
  56  * eager evaluation of arguments.
  57  */
  58 public class VerifyMethodMetricsTest {
  59 
  60     private static class InvalidCCP_ToString01Inc extends Phase {
  61         @Override
  62         protected void run(StructuredGraph graph) {
  63             DebugMethodMetrics m = Debug.methodMetrics(graph.method());
  64             for (Node n : graph.getNodes()) {
  65                 m.incrementMetric(n.toString());
  66             }
  67         }
  68     }


 237     }
 238 
 239     @Test
 240     public void testLogValidConcatInc() {
 241         testDebugUsageClass(ValidCCP_ConcatInc.class);
 242     }
 243 
 244     @SuppressWarnings("try")
 245     private static void testDebugUsageClass(Class<?> c) {
 246         RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
 247         Providers providers = rt.getHostBackend().getProviders();
 248         MetaAccessProvider metaAccess = providers.getMetaAccess();
 249         PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
 250         Plugins plugins = new Plugins(new InvocationPlugins(metaAccess));
 251         GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
 252         graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
 253         HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
 254         for (Method m : c.getDeclaredMethods()) {
 255             if (!Modifier.isNative(m.getModifiers()) && !Modifier.isAbstract(m.getModifiers())) {
 256                 ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
 257                 StructuredGraph graph = new StructuredGraph.Builder(getInitialOptions()).method(method).build();
 258                 graphBuilderSuite.apply(graph, context);
 259                 try (DebugConfigScope s = Debug.disableIntercept()) {
 260                     new VerifyDebugUsage().apply(graph, context);
 261                 }
 262             }
 263         }
 264     }
 265 }
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/debug/VerifyMethodMetricsTest.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File