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