001/* 002 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package jdk.internal.jvmci.hotspot; 024 025import static jdk.internal.jvmci.hotspot.HotSpotJVMCIRuntime.*; 026import jdk.internal.jvmci.meta.*; 027 028/** 029 * Interface for accessor objects that encapsulate the logic for accessing the different kinds of 030 * data in a HotSpot methodDataOop. This interface is similar to the interface {@link ProfilingInfo} 031 * , but most methods require a MethodDataObject and the exact position within the methodData. 032 */ 033public interface HotSpotMethodDataAccessor { 034 035 /** 036 * {@code DataLayout} tag values. 037 */ 038 enum Tag { 039 No(config().dataLayoutNoTag), 040 BitData(config().dataLayoutBitDataTag), 041 CounterData(config().dataLayoutCounterDataTag), 042 JumpData(config().dataLayoutJumpDataTag), 043 ReceiverTypeData(config().dataLayoutReceiverTypeDataTag), 044 VirtualCallData(config().dataLayoutVirtualCallDataTag), 045 RetData(config().dataLayoutRetDataTag), 046 BranchData(config().dataLayoutBranchDataTag), 047 MultiBranchData(config().dataLayoutMultiBranchDataTag), 048 ArgInfoData(config().dataLayoutArgInfoDataTag), 049 CallTypeData(config().dataLayoutCallTypeDataTag), 050 VirtualCallTypeData(config().dataLayoutVirtualCallTypeDataTag), 051 ParametersTypeData(config().dataLayoutParametersTypeDataTag), 052 SpeculativeTrapData(config().dataLayoutSpeculativeTrapDataTag); 053 054 private final int value; 055 056 private Tag(int value) { 057 this.value = value; 058 } 059 060 public int getValue() { 061 return value; 062 } 063 064 private static HotSpotVMConfig config() { 065 return runtime().getConfig(); 066 } 067 068 public static Tag getEnum(int value) { 069 Tag result = values()[value]; 070 assert value == result.value; 071 return result; 072 } 073 } 074 075 /** 076 * Returns the {@link Tag} stored in the LayoutData header. 077 * 078 * @return tag stored in the LayoutData header 079 */ 080 Tag getTag(); 081 082 /** 083 * Returns the BCI stored in the LayoutData header. 084 * 085 * @return An integer ≥ 0 and ≤ Short.MAX_VALUE, or -1 if not supported. 086 */ 087 int getBCI(HotSpotMethodData data, int position); 088 089 /** 090 * Computes the size for the specific data at the given position. 091 * 092 * @return An integer > 0. 093 */ 094 int getSize(HotSpotMethodData data, int position); 095 096 JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position); 097 098 JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position); 099 100 double getBranchTakenProbability(HotSpotMethodData data, int position); 101 102 double[] getSwitchProbabilities(HotSpotMethodData data, int position); 103 104 TriState getExceptionSeen(HotSpotMethodData data, int position); 105 106 TriState getNullSeen(HotSpotMethodData data, int position); 107 108 int getExecutionCount(HotSpotMethodData data, int position); 109 110 StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos); 111}