HotSpotCompilationIdentifier.java revision 12657:6ef01bd40ce2
150477Speter/* 220973Swosch * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 311496Sphk * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 411496Sphk * 5110160Sseanc * This code is free software; you can redistribute it and/or modify it 6110160Sseanc * under the terms of the GNU General Public License version 2 only, as 711496Sphk * published by the Free Software Foundation. 8110160Sseanc * 9110160Sseanc * This code is distributed in the hope that it will be useful, but WITHOUT 1011497Sphk * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11116997Ssam * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12110160Sseanc * version 2 for more details (a copy is included in the LICENSE file that 13110160Sseanc * accompanied this code). 1491501Sjoe * 1591501Sjoe * You should have received a copy of the GNU General Public License version 16116997Ssam * 2 along with this work; if not, write to the Free Software Foundation, 17109007Sdes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18109024Sschweikh * 1941896Scracauer * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2041896Scracauer * or visit www.oracle.com if you need additional information or have any 21104442Swollman * questions. 2241896Scracauer */ 2318871Swollmanpackage org.graalvm.compiler.hotspot; 2418871Swollman 2521914Smsmithimport org.graalvm.compiler.core.common.CompilationIdentifier; 2621914Smsmithimport org.graalvm.compiler.core.common.CompilationRequestIdentifier; 2786113Sphkimport org.graalvm.compiler.debug.GraalError; 2886113Sphk 2941826Scracauerimport jdk.vm.ci.hotspot.HotSpotCompilationRequest; 3041826Scracauerimport jdk.vm.ci.runtime.JVMCICompiler; 3186781Ssheldonh 3241826Scracauer/** 3394737Sdes * {@link CompilationIdentifier} for a {@linkplain HotSpotCompilationRequest hotspot compilation 3422205Sjoerg * request}. 35109007Sdes */ 3638973Sjbpublic class HotSpotCompilationIdentifier implements CompilationRequestIdentifier { 3741896Scracauer private final HotSpotCompilationRequest request; 3841896Scracauer 39109007Sdes public HotSpotCompilationIdentifier(HotSpotCompilationRequest request) { 40 this.request = request; 41 } 42 43 public boolean isOsrCompilation() { 44 return request.getEntryBCI() != JVMCICompiler.INVOCATION_ENTRY_BCI; 45 } 46 47 @Override 48 public final String toString() { 49 return toString(Verbosity.DETAILED); 50 } 51 52 @Override 53 public String toString(Verbosity verbosity) { 54 return buildString(new StringBuilder(), verbosity).toString(); 55 } 56 57 protected StringBuilder buildString(StringBuilder sb, Verbosity verbosity) { 58 switch (verbosity) { 59 case ID: 60 buildID(sb); 61 break; 62 case NAME: 63 buildName(sb); 64 break; 65 case DETAILED: 66 buildID(sb); 67 sb.append('['); 68 buildName(sb); 69 if (isOsrCompilation()) { 70 sb.append("@"); 71 sb.append(request.getEntryBCI()); 72 } 73 sb.append(']'); 74 break; 75 default: 76 throw new GraalError("unknown verbosity: " + verbosity); 77 } 78 return sb; 79 } 80 81 protected StringBuilder buildName(StringBuilder sb) { 82 return sb.append(request.getMethod().format("%H.%n(%p)")); 83 } 84 85 protected StringBuilder buildID(StringBuilder sb) { 86 if (isOsrCompilation()) { 87 sb.append("HotSpotOSRCompilation-"); 88 } else { 89 sb.append("HotSpotCompilation-"); 90 } 91 return sb.append(request.getId()); 92 } 93 94 @Override 95 public HotSpotCompilationRequest getRequest() { 96 return request; 97 } 98 99} 100