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

Print this page




   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 java.util.ArrayList;
  26 import java.util.HashMap;
  27 import java.util.List;
  28 import java.util.Map;
  29 
  30 import org.junit.Test;
  31 
  32 import org.graalvm.compiler.debug.Debug;
  33 import org.graalvm.compiler.debug.DebugConfig;
  34 import org.graalvm.compiler.debug.DebugCounter;
  35 import org.graalvm.compiler.debug.DebugDumpHandler;
  36 import org.graalvm.compiler.debug.DebugMemUseTracker;
  37 import org.graalvm.compiler.debug.DebugMethodMetrics;
  38 import org.graalvm.compiler.debug.DebugTimer;
  39 import org.graalvm.compiler.debug.DebugValueFactory;
  40 import org.graalvm.compiler.debug.DebugVerifyHandler;
  41 import org.graalvm.compiler.debug.GraalDebugConfig;
  42 import org.graalvm.compiler.debug.internal.CounterImpl;
  43 import org.graalvm.compiler.debug.internal.MemUseTrackerImpl;
  44 import org.graalvm.compiler.debug.internal.TimerImpl;
  45 import org.graalvm.compiler.debug.internal.method.MethodMetricsImpl;
  46 import org.graalvm.compiler.debug.internal.method.MethodMetricsPrinter;
  47 import org.graalvm.compiler.options.OptionValue;
  48 import org.graalvm.compiler.options.OptionValue.OverrideScope;
  49 import org.graalvm.compiler.phases.Phase;
  50 
  51 import jdk.vm.ci.meta.ResolvedJavaMethod;
  52 
  53 // intercepting metrics
  54 public class MethodMetricsTestInterception01 extends MethodMetricsTest {
  55 
  56     @Override
  57     protected Phase additionalPhase() {
  58         return new MethodMetricPhases.CountingAddPhase();
  59     }
  60 
  61     @Override
  62     DebugConfig getConfig() {
  63         List<DebugDumpHandler> dumpHandlers = new ArrayList<>();
  64         List<DebugVerifyHandler> verifyHandlers = new ArrayList<>();

  65         GraalDebugConfig debugConfig = new GraalDebugConfig(
  66                         GraalDebugConfig.Options.Log.getValue(),

  67                         "CountingAddPhase",
  68                         GraalDebugConfig.Options.TrackMemUse.getValue(),
  69                         "CountingAddPhase",
  70                         GraalDebugConfig.Options.Dump.getValue(),
  71                         GraalDebugConfig.Options.Verify.getValue(),
  72                         "MethodMetricsTest$TestApplication.*",
  73                         "CountingAddPhase",
  74                         System.out, dumpHandlers, verifyHandlers);
  75         return debugConfig;
  76     }
  77 
  78     @Override
  79     protected OverrideScope getOScope() {
  80         Map<OptionValue<?>, Object> mapping = new HashMap<>();
  81         mapping.put(MethodMetricsPrinter.Options.MethodMeterPrintAscii, true);
  82         return OptionValue.override(mapping);
  83     }
  84 
  85     private DebugValueFactory factory;
  86 
  87     @Test
  88     @Override
  89     @SuppressWarnings("try")
  90     public void test() throws Throwable {
  91         factory = Debug.getDebugValueFactory();
  92         Debug.setDebugValueFactory(new DebugValueFactory() {
  93             @Override
  94             public DebugTimer createTimer(String name, boolean conditional) {
  95                 return new TimerImpl(name, conditional, true);
  96             }
  97 
  98             @Override
  99             public DebugCounter createCounter(String name, boolean conditional) {
 100                 return CounterImpl.create(name, conditional, true);
 101             }
 102 
 103             @Override
 104             public DebugMethodMetrics createMethodMetrics(ResolvedJavaMethod method) {




   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 java.util.ArrayList;

  26 import java.util.List;

  27 
  28 import org.junit.Test;
  29 
  30 import org.graalvm.compiler.debug.Debug;
  31 import org.graalvm.compiler.debug.DebugConfig;
  32 import org.graalvm.compiler.debug.DebugCounter;
  33 import org.graalvm.compiler.debug.DebugDumpHandler;
  34 import org.graalvm.compiler.debug.DebugMemUseTracker;
  35 import org.graalvm.compiler.debug.DebugMethodMetrics;
  36 import org.graalvm.compiler.debug.DebugTimer;
  37 import org.graalvm.compiler.debug.DebugValueFactory;
  38 import org.graalvm.compiler.debug.DebugVerifyHandler;
  39 import org.graalvm.compiler.debug.GraalDebugConfig;
  40 import org.graalvm.compiler.debug.internal.CounterImpl;
  41 import org.graalvm.compiler.debug.internal.MemUseTrackerImpl;
  42 import org.graalvm.compiler.debug.internal.TimerImpl;
  43 import org.graalvm.compiler.debug.internal.method.MethodMetricsImpl;
  44 import org.graalvm.compiler.options.OptionValues;


  45 import org.graalvm.compiler.phases.Phase;
  46 
  47 import jdk.vm.ci.meta.ResolvedJavaMethod;
  48 
  49 // intercepting metrics
  50 public class MethodMetricsTestInterception01 extends MethodMetricsTest {
  51 
  52     @Override
  53     protected Phase additionalPhase() {
  54         return new MethodMetricPhases.CountingAddPhase();
  55     }
  56 
  57     @Override
  58     DebugConfig getConfig() {
  59         List<DebugDumpHandler> dumpHandlers = new ArrayList<>();
  60         List<DebugVerifyHandler> verifyHandlers = new ArrayList<>();
  61         OptionValues options = getInitialOptions();
  62         GraalDebugConfig debugConfig = new GraalDebugConfig(
  63                         options,
  64                         GraalDebugConfig.Options.Log.getValue(options),
  65                         "CountingAddPhase",
  66                         GraalDebugConfig.Options.TrackMemUse.getValue(options),
  67                         "CountingAddPhase",
  68                         GraalDebugConfig.Options.Dump.getValue(options),
  69                         GraalDebugConfig.Options.Verify.getValue(options),
  70                         "MethodMetricsTest$TestApplication.*",
  71                         "CountingAddPhase",
  72                         System.out, dumpHandlers, verifyHandlers);
  73         return debugConfig;
  74     }
  75 







  76     private DebugValueFactory factory;
  77 
  78     @Test
  79     @Override
  80     @SuppressWarnings("try")
  81     public void test() throws Throwable {
  82         factory = Debug.getDebugValueFactory();
  83         Debug.setDebugValueFactory(new DebugValueFactory() {
  84             @Override
  85             public DebugTimer createTimer(String name, boolean conditional) {
  86                 return new TimerImpl(name, conditional, true);
  87             }
  88 
  89             @Override
  90             public DebugCounter createCounter(String name, boolean conditional) {
  91                 return CounterImpl.create(name, conditional, true);
  92             }
  93 
  94             @Override
  95             public DebugMethodMetrics createMethodMetrics(ResolvedJavaMethod method) {


src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/debug/MethodMetricsTestInterception01.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File