src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.microbenchmarks/src/org/graalvm/compiler/microbenchmarks/graal/util/GraphState.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.microbenchmarks/src/org/graalvm/compiler/microbenchmarks/graal/util

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.microbenchmarks/src/org/graalvm/compiler/microbenchmarks/graal/util/GraphState.java

Print this page




   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.microbenchmarks.graal.util;
  24 
  25 import static org.graalvm.compiler.microbenchmarks.graal.util.GraalUtil.getGraph;
  26 import static org.graalvm.compiler.microbenchmarks.graal.util.GraalUtil.getMethodFromMethodSpec;
  27 import jdk.vm.ci.meta.ResolvedJavaMethod;
  28 



  29 import org.openjdk.jmh.annotations.Level;
  30 import org.openjdk.jmh.annotations.Scope;
  31 import org.openjdk.jmh.annotations.Setup;
  32 import org.openjdk.jmh.annotations.State;
  33 
  34 import org.graalvm.compiler.debug.Debug;
  35 import org.graalvm.compiler.debug.DebugEnvironment;
  36 import org.graalvm.compiler.debug.internal.DebugScope;
  37 import org.graalvm.compiler.nodes.StructuredGraph;
  38 
  39 /**
  40  * State providing a new copy of a graph for each invocation of a benchmark. Subclasses of this
  41  * class are annotated with {@link MethodSpec} to specify the Java method that will be parsed to
  42  * obtain the original graph.
  43  */
  44 @State(Scope.Thread)
  45 public abstract class GraphState {
  46 
  47     @SuppressWarnings("try")
  48     public GraphState() {

  49         // Ensure a debug configuration for this thread is initialized
  50         if (Debug.isEnabled() && DebugScope.getConfig() == null) {
  51             DebugEnvironment.initialize(System.out);
  52         }
  53 
  54         GraalState graal = new GraalState();
  55         ResolvedJavaMethod method = graal.metaAccess.lookupJavaMethod(getMethodFromMethodSpec(getClass()));
  56         StructuredGraph structuredGraph = null;
  57         try (Debug.Scope s = Debug.scope("GraphState", method)) {
  58             structuredGraph = preprocessOriginal(getGraph(graal, method));
  59         } catch (Throwable t) {
  60             Debug.handle(t);
  61         }
  62         this.originalGraph = structuredGraph;
  63     }
  64 
  65     protected StructuredGraph preprocessOriginal(StructuredGraph structuredGraph) {
  66         return structuredGraph;
  67     }
  68 
  69     /**
  70      * Original graph from which the per-benchmark invocation {@link #graph} is cloned.
  71      */
  72     private final StructuredGraph originalGraph;
  73 
  74     /**


   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.microbenchmarks.graal.util;
  24 
  25 import static org.graalvm.compiler.microbenchmarks.graal.util.GraalUtil.getGraph;
  26 import static org.graalvm.compiler.microbenchmarks.graal.util.GraalUtil.getMethodFromMethodSpec;

  27 
  28 import org.graalvm.compiler.debug.Debug;
  29 import org.graalvm.compiler.debug.DebugEnvironment;
  30 import org.graalvm.compiler.nodes.StructuredGraph;
  31 import org.openjdk.jmh.annotations.Level;
  32 import org.openjdk.jmh.annotations.Scope;
  33 import org.openjdk.jmh.annotations.Setup;
  34 import org.openjdk.jmh.annotations.State;
  35 
  36 import jdk.vm.ci.meta.ResolvedJavaMethod;



  37 
  38 /**
  39  * State providing a new copy of a graph for each invocation of a benchmark. Subclasses of this
  40  * class are annotated with {@link MethodSpec} to specify the Java method that will be parsed to
  41  * obtain the original graph.
  42  */
  43 @State(Scope.Thread)
  44 public abstract class GraphState {
  45 
  46     @SuppressWarnings("try")
  47     public GraphState() {
  48         GraalState graal = new GraalState();
  49         // Ensure a debug configuration for this thread is initialized
  50         DebugEnvironment.ensureInitialized(graal.options);


  51 

  52         ResolvedJavaMethod method = graal.metaAccess.lookupJavaMethod(getMethodFromMethodSpec(getClass()));
  53         StructuredGraph structuredGraph = null;
  54         try (Debug.Scope s = Debug.scope("GraphState", method)) {
  55             structuredGraph = preprocessOriginal(getGraph(graal, method));
  56         } catch (Throwable t) {
  57             Debug.handle(t);
  58         }
  59         this.originalGraph = structuredGraph;
  60     }
  61 
  62     protected StructuredGraph preprocessOriginal(StructuredGraph structuredGraph) {
  63         return structuredGraph;
  64     }
  65 
  66     /**
  67      * Original graph from which the per-benchmark invocation {@link #graph} is cloned.
  68      */
  69     private final StructuredGraph originalGraph;
  70 
  71     /**
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.microbenchmarks/src/org/graalvm/compiler/microbenchmarks/graal/util/GraphState.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File