Mercurial > hg > graal-jvmci-8
comparison jvmci/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodDataAccessor.java @ 23717:41fa89f93355
removed jdk.vm.ci.hotspot.HotSpotMethodDataAccessor.Tag (JDK-8159613)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 30 Jun 2016 22:07:57 +0200 |
parents | 4b58c92e939b |
children | a52d7039723b |
comparison
equal
deleted
inserted
replaced
23716:74c4e0459c11 | 23717:41fa89f93355 |
---|---|
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; | 1 package jdk.vm.ci.hotspot; |
24 | 2 |
25 import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; | |
26 import jdk.vm.ci.meta.JavaMethodProfile; | 3 import jdk.vm.ci.meta.JavaMethodProfile; |
27 import jdk.vm.ci.meta.JavaTypeProfile; | 4 import jdk.vm.ci.meta.JavaTypeProfile; |
28 import jdk.vm.ci.meta.ProfilingInfo; | 5 import jdk.vm.ci.meta.ProfilingInfo; |
29 import jdk.vm.ci.meta.TriState; | 6 import jdk.vm.ci.meta.TriState; |
30 | 7 |
31 /** | 8 /** |
32 * Interface for accessor objects that encapsulate the logic for accessing the different kinds of | 9 * Base class for accessing the different kinds of data in a HotSpot {@code MethodData}. This is |
33 * data in a HotSpot methodDataOop. This interface is similar to the interface {@link ProfilingInfo} | 10 * similar to {@link ProfilingInfo}, but most methods require a {@link HotSpotMethodData} and the |
34 * , but most methods require a MethodDataObject and the exact position within the methodData. | 11 * exact position within the method data. |
35 */ | 12 */ |
36 public interface HotSpotMethodDataAccessor { | 13 abstract class HotSpotMethodDataAccessor { |
37 | 14 |
38 /** | 15 final int tag; |
39 * {@code DataLayout} tag values. | 16 final int staticSize; |
40 */ | 17 final HotSpotVMConfig config; |
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 | 18 |
57 private final int value; | 19 protected HotSpotMethodDataAccessor(HotSpotVMConfig config, int tag, int staticSize) { |
58 | 20 this.config = config; |
59 Tag(int value) { | 21 this.tag = tag; |
60 this.value = value; | 22 this.staticSize = staticSize; |
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 } | 23 } |
73 | 24 |
74 /** | 25 /** |
75 * Returns the {@link Tag} stored in the LayoutData header. | 26 * Returns the tag stored in the LayoutData header. |
76 * | 27 * |
77 * @return tag stored in the LayoutData header | 28 * @return tag stored in the LayoutData header |
78 */ | 29 */ |
79 Tag getTag(); | 30 int getTag() { |
31 return tag; | |
32 } | |
33 | |
34 static int readTag(HotSpotVMConfig config, HotSpotMethodData data, int position) { | |
35 final int tag = data.readUnsignedByte(position, config.dataLayoutTagOffset); | |
36 assert tag >= config.dataLayoutNoTag && tag <= config.dataLayoutSpeculativeTrapDataTag : "profile data tag out of bounds: " + tag; | |
37 return tag; | |
38 } | |
80 | 39 |
81 /** | 40 /** |
82 * Returns the BCI stored in the LayoutData header. | 41 * Returns the BCI stored in the LayoutData header. |
83 * | 42 * |
84 * @return An integer ≥ 0 and ≤ Short.MAX_VALUE, or -1 if not supported. | 43 * @return an integer between 0 and {@link Short#MAX_VALUE} inclusive, or -1 if not supported |
85 */ | 44 */ |
86 int getBCI(HotSpotMethodData data, int position); | 45 int getBCI(HotSpotMethodData data, int position) { |
46 return data.readUnsignedShort(position, config.dataLayoutBCIOffset); | |
47 } | |
87 | 48 |
88 /** | 49 /** |
89 * Computes the size for the specific data at the given position. | 50 * Computes the size for the specific data at the given position. |
90 * | 51 * |
91 * @return An integer > 0. | 52 * @return a value greater than 0 |
92 */ | 53 */ |
93 int getSize(HotSpotMethodData data, int position); | 54 final int getSize(HotSpotMethodData data, int position) { |
55 int size = staticSize + getDynamicSize(data, position); | |
56 // Sanity check against VM | |
57 int vmSize = HotSpotJVMCIRuntime.runtime().compilerToVm.methodDataProfileDataSize(data.metaspaceMethodData, position); | |
58 assert size == vmSize : size + " != " + vmSize; | |
59 return size; | |
60 } | |
94 | 61 |
95 JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position); | 62 TriState getExceptionSeen(HotSpotMethodData data, int position) { |
63 final int exceptionsMask = 1 << config.bitDataExceptionSeenFlag; | |
64 return TriState.get((getFlags(data, position) & exceptionsMask) != 0); | |
65 } | |
96 | 66 |
97 JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position); | 67 /** |
68 * @param data | |
69 * @param position | |
70 */ | |
71 JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position) { | |
72 return null; | |
73 } | |
98 | 74 |
99 double getBranchTakenProbability(HotSpotMethodData data, int position); | 75 /** |
76 * @param data | |
77 * @param position | |
78 */ | |
79 JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position) { | |
80 return null; | |
81 } | |
100 | 82 |
101 double[] getSwitchProbabilities(HotSpotMethodData data, int position); | 83 /** |
84 * @param data | |
85 * @param position | |
86 */ | |
87 double getBranchTakenProbability(HotSpotMethodData data, int position) { | |
88 return -1; | |
89 } | |
102 | 90 |
103 TriState getExceptionSeen(HotSpotMethodData data, int position); | 91 /** |
92 * @param data | |
93 * @param position | |
94 */ | |
95 double[] getSwitchProbabilities(HotSpotMethodData data, int position) { | |
96 return null; | |
97 } | |
104 | 98 |
105 TriState getNullSeen(HotSpotMethodData data, int position); | 99 /** |
100 * @param data | |
101 * @param position | |
102 */ | |
103 int getExecutionCount(HotSpotMethodData data, int position) { | |
104 return -1; | |
105 } | |
106 | 106 |
107 int getExecutionCount(HotSpotMethodData data, int position); | 107 /** |
108 * @param data | |
109 * @param position | |
110 */ | |
111 TriState getNullSeen(HotSpotMethodData data, int position) { | |
112 return TriState.UNKNOWN; | |
113 } | |
108 | 114 |
109 StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos); | 115 protected int getFlags(HotSpotMethodData data, int position) { |
116 return data.readUnsignedByte(position, config.dataLayoutFlagsOffset); | |
117 } | |
118 | |
119 /** | |
120 * @param data | |
121 * @param position | |
122 */ | |
123 protected int getDynamicSize(HotSpotMethodData data, int position) { | |
124 return 0; | |
125 } | |
126 | |
127 abstract StringBuilder appendTo(StringBuilder sb, HotSpotMethodData data, int pos); | |
128 | |
110 } | 129 } |