1 /* 2 * Copyright (c) 2011, 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 jdk.vm.ci.hotspot; 24 25 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; 26 import jdk.vm.ci.meta.JavaMethodProfile; 27 import jdk.vm.ci.meta.JavaTypeProfile; 28 import jdk.vm.ci.meta.ProfilingInfo; 29 import jdk.vm.ci.meta.TriState; 30 31 /** 32 * Interface for accessor objects that encapsulate the logic for accessing the different kinds of 33 * data in a HotSpot methodDataOop. This interface is similar to the interface {@link ProfilingInfo} 34 * , but most methods require a MethodDataObject and the exact position within the methodData. 35 */ 36 public interface HotSpotMethodDataAccessor { 37 38 /** 39 * {@code DataLayout} tag values. 40 */ 41 enum Tag { 42 No(config().dataLayoutNoTag), 43 BitData(config().dataLayoutBitDataTag), 44 CounterData(config().dataLayoutCounterDataTag), 45 JumpData(config().dataLayoutJumpDataTag), 46 ReceiverTypeData(config().dataLayoutReceiverTypeDataTag), 47 VirtualCallData(config().dataLayoutVirtualCallDataTag), 48 RetData(config().dataLayoutRetDataTag), 49 BranchData(config().dataLayoutBranchDataTag), 50 MultiBranchData(config().dataLayoutMultiBranchDataTag), 51 ArgInfoData(config().dataLayoutArgInfoDataTag), 52 CallTypeData(config().dataLayoutCallTypeDataTag), 53 VirtualCallTypeData(config().dataLayoutVirtualCallTypeDataTag), 54 ParametersTypeData(config().dataLayoutParametersTypeDataTag), 55 SpeculativeTrapData(config().dataLayoutSpeculativeTrapDataTag); 56 57 private final int value; 58 59 Tag(int value) { 60 this.value = value; 61 } 62 63 public int getValue() { 64 return value; 65 } 66 67 public static Tag getEnum(int value) { 68 Tag result = values()[value]; 69 assert value == result.value; 70 return result; 71 } 72 } 73 74 /** 75 * Returns the {@link Tag} stored in the LayoutData header. 76 * 77 * @return tag stored in the LayoutData header 78 */ 79 Tag getTag(); 80 81 /** 82 * Returns the BCI stored in the LayoutData header. 83 * 84 * @return An integer ≥ 0 and ≤ Short.MAX_VALUE, or -1 if not supported. 85 */ 86 int getBCI(HotSpotMethodData data, int position); 87 88 /** 89 * Computes the size for the specific data at the given position. 90 * 91 * @return An integer > 0. 92 */ 93 int getSize(HotSpotMethodData data, int position); 94 95 JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position); 96 97 JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position); 98 99 double getBranchTakenProbability(HotSpotMethodData data, int position); 100 101 double[] getSwitchProbabilities(HotSpotMethodData data, int position); 102 103 TriState getExceptionSeen(HotSpotMethodData data, int position); 104 105 TriState getNullSeen(HotSpotMethodData data, int position); 106 107 int getExecutionCount(HotSpotMethodData data, int position); 108 109 StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos); 110 }