1 /* 2 * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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.microbenchmarks.lir; 24 25 import java.util.HashMap; 26 27 import org.openjdk.jmh.annotations.Benchmark; 28 29 import org.graalvm.compiler.lir.gen.LIRGenerationResult; 30 import org.graalvm.compiler.lir.phases.LIRSuites; 31 import org.graalvm.compiler.microbenchmarks.graal.GraalBenchmark; 32 import org.graalvm.compiler.microbenchmarks.graal.util.MethodSpec; 33 34 public class RegisterAllocationTimeBenchmark extends GraalBenchmark { 35 36 // Checkstyle: stop method name check 37 public static class LSRA_Allocation extends GraalCompilerState.AllocationStage { 38 @SuppressWarnings("try") 39 @Override 40 protected LIRSuites createLIRSuites() { 41 return super.createLIRSuites(); 42 } 43 } 44 45 @MethodSpec(declaringClass = String.class, name = "equals") 46 public static class LSRA_StringEquals extends LSRA_Allocation { 47 } 48 49 @MethodSpec(declaringClass = HashMap.class, name = "computeIfAbsent") 50 public static class LSRA_HashMapComputeIfAbsent extends LSRA_Allocation { 51 } 52 53 @Benchmark 54 public LIRGenerationResult lsra_STRING_equals(LSRA_StringEquals s) { 55 return s.compile(); 56 } 57 58 @Benchmark 59 public LIRGenerationResult lsra_HASHMAP_computeIfAbsent(LSRA_HashMapComputeIfAbsent s) { 60 return s.compile(); 61 } 62 63 public static class TraceRA_Allocation extends GraalCompilerState.AllocationStage { 64 @SuppressWarnings("try") 65 @Override 66 protected LIRSuites createLIRSuites() { 67 return super.createLIRSuites(); 68 } 69 } 70 71 @MethodSpec(declaringClass = String.class, name = "equals") 72 public static class TraceRA_StringEquals extends TraceRA_Allocation { 73 } 74 75 @MethodSpec(declaringClass = HashMap.class, name = "computeIfAbsent") 76 public static class TraceRA_HashMapComputeIfAbsent extends TraceRA_Allocation { 77 } 78 79 @Benchmark 80 public LIRGenerationResult tracera_STRING_equals(TraceRA_StringEquals s) { 81 return s.compile(); 82 } 83 84 @Benchmark 85 public LIRGenerationResult tracera_HASHMAP_computeIfAbsent(TraceRA_HashMapComputeIfAbsent s) { 86 return s.compile(); 87 } 88 // Checkstyle: resume method name check 89 }