annotate graal/com.oracle.max.graal.hotspot/src/com/oracle/max/graal/hotspot/ri/HotSpotMethodData.java @ 4457:5acf4a974e4a

fixed framestate for inlining multiple methods
author Christian Haeubl <christian.haeubl@oracle.com>
date Tue, 31 Jan 2012 17:09:11 -0800
parents f4c82dd4619e
children ed73455e9c03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
1 /*
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
4 *
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
8 *
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
13 * accompanied this code).
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
14 *
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
18 *
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
21 * questions.
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
22 */
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
23 package com.oracle.max.graal.hotspot.ri;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
24
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
25 import sun.misc.*;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
26
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
27 import com.oracle.max.cri.ri.*;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
28 import com.oracle.max.graal.hotspot.*;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
29 import com.oracle.max.graal.hotspot.Compiler;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
30
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
31
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
32 public final class HotSpotMethodData extends CompilerObject {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
33
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
34 /**
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
35 *
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
36 */
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
37 private static final long serialVersionUID = -8873133496591225071L;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
38
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
39 static {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
40 config = CompilerImpl.getInstance().getConfig();
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
41 }
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
42
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
43 // TODO (ch) use same logic as in NodeClass?
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
44 private static final Unsafe unsafe = Unsafe.getUnsafe();
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
45 private static final HotSpotMethodDataAccessor NO_DATA_ACCESSOR = new NoMethodData();
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
46 private static final HotSpotVMConfig config;
4448
9e8e92c3ff17 first parts for inlining multiple methods, added Simplifiable to switch nodes, some documentation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4447
diff changeset
47 // sorted by tag
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
48 private static final HotSpotMethodDataAccessor[] PROFILE_DATA_ACCESSORS = {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
49 null, new BitData(), new CounterData(), new JumpData(),
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
50 new TypeCheckData(), new VirtualCallData(), new RetData(),
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
51 new BranchData(), new MultiBranchData(), new ArgInfoData()
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
52 };
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
53
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
54 private Object hotspotMirror;
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
55 private int normalDataSize;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
56 private int extraDataSize;
4446
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
57 private boolean mature;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
58
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
59 private HotSpotMethodData(Compiler compiler) {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
60 super(compiler);
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
61 throw new IllegalStateException("this constructor is never actually called, because the objects are allocated from within the VM");
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
62 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
63
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
64 public boolean hasNormalData() {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
65 return normalDataSize > 0;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
66 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
67
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
68 public boolean hasExtraData() {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
69 return extraDataSize > 0;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
70 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
71
4446
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
72 public boolean isMature() {
4455
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4453
diff changeset
73 // TODO (ch) maturity of profiling information is an issue in general. Not all optimizations require mature data as long as the code
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4453
diff changeset
74 // does deoptimize/recompile on violations (might decrease startup and increase peak performance).
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4453
diff changeset
75 // Maturity is currently used on several levels:
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4453
diff changeset
76 // 1) whole method data
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4453
diff changeset
77 // 2) individual branch/switch profiling data
b788ebbb7ef8 cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4453
diff changeset
78 // 3) MatureInvocationCount for eliminating exception edges
4446
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
79 if (!mature) {
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
80 mature = compiler.getVMEntries().HotSpotMethodData_isMature(this);
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
81 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
82 return mature;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
83 }
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
84
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
85 public boolean isWithin(int position) {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
86 return position >= 0 && position < normalDataSize + extraDataSize;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
87 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
88
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
89 public HotSpotMethodDataAccessor getNormalData(int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
90 if (position >= normalDataSize) {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
91 return null;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
92 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
93
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
94 HotSpotMethodDataAccessor result = getData(position, 0);
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
95 assert result != null : "NO_DATA tag is not allowed";
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
96 return result;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
97 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
98
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
99 public HotSpotMethodDataAccessor getExtraData(int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
100 if (position >= extraDataSize) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
101 return null;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
102 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
103 return getData(position, normalDataSize);
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
104 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
105
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
106 public static HotSpotMethodDataAccessor getNoMethodData() {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
107 return NO_DATA_ACCESSOR;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
108 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
109
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
110 private HotSpotMethodDataAccessor getData(int position, int displacement) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
111 assert position >= 0 : "out of bounds";
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
112 int tag = AbstractMethodData.readTag(this, displacement + position);
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
113 assert tag >= 0 && tag < PROFILE_DATA_ACCESSORS.length : "illegal tag";
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
114 return PROFILE_DATA_ACCESSORS[tag];
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
115 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
116
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
117 private int readUnsignedByte(int position, int offsetInBytes) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
118 long fullOffsetInBytes = computeFullOffset(position, offsetInBytes);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
119 return unsafe.getByte(hotspotMirror, fullOffsetInBytes) & 0xFF;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
120 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
121
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
122 private int readUnsignedShort(int position, int offsetInBytes) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
123 long fullOffsetInBytes = computeFullOffset(position, offsetInBytes);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
124 return unsafe.getShort(hotspotMirror, fullOffsetInBytes) & 0xFFFF;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
125 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
126
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
127 private long readUnsignedInt(int position, int offsetInBytes) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
128 long fullOffsetInBytes = computeFullOffset(position, offsetInBytes);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
129 return unsafe.getInt(hotspotMirror, fullOffsetInBytes) & 0xFFFFFFFFL;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
130 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
131
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
132 private int readUnsignedIntAsSignedInt(int position, int offsetInBytes) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
133 long value = readUnsignedInt(position, offsetInBytes);
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
134 return truncateLongToInt(value);
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
135 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
136
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
137 private int readInt(int position, int offsetInBytes) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
138 long fullOffsetInBytes = computeFullOffset(position, offsetInBytes);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
139 return unsafe.getInt(hotspotMirror, fullOffsetInBytes);
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
140 }
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
141
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
142 private Object readObject(int position, int offsetInBytes) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
143 long fullOffsetInBytes = computeFullOffset(position, offsetInBytes);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
144 return unsafe.getObject(hotspotMirror, fullOffsetInBytes);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
145 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
146
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
147 private static int truncateLongToInt(long value) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
148 return value > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) value;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
149 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
150
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
151 private static int computeFullOffset(int position, int offsetInBytes) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
152 return config.methodDataOopDataOffset + position + offsetInBytes;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
153 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
154
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
155 private static int cellIndexToOffset(int cells) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
156 return config.dataLayoutHeaderSize + cellsToBytes(cells);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
157 }
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
158
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
159 private static int cellsToBytes(int cells) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
160 return cells * config.dataLayoutCellSize;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
161 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
162
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
163 private abstract static class AbstractMethodData implements HotSpotMethodDataAccessor {
4457
5acf4a974e4a fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4456
diff changeset
164 private static final int EXCEPTIONS_MASK = 0x08;
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
165
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
166 private final int tag;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
167 private final int staticSize;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
168
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
169 protected AbstractMethodData(int tag, int staticSize) {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
170 this.tag = tag;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
171 this.staticSize = staticSize;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
172 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
173
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
174 public int getTag() {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
175 return tag;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
176 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
177
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
178 public static int readTag(HotSpotMethodData data, int position) {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
179 return data.readUnsignedByte(position, config.dataLayoutTagOffset);
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
180 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
181
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
182 @Override
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
183 public int getBCI(HotSpotMethodData data, int position) {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
184 return data.readUnsignedShort(position, config.dataLayoutBCIOffset);
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
185 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
186
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
187 @Override
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
188 public int getSize(HotSpotMethodData data, int position) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
189 return staticSize + getDynamicSize(data, position);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
190 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
191
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
192 @Override
4457
5acf4a974e4a fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4456
diff changeset
193 public boolean getExceptionSeen(HotSpotMethodData data, int position) {
5acf4a974e4a fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4456
diff changeset
194 return (getFlags(data, position) & EXCEPTIONS_MASK) != 0;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
195 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
196
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
197 @Override
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
198 public RiTypeProfile getTypeProfile(HotSpotMethodData data, int position) {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
199 return null;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
200 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
201
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
202 @Override
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
203 public double getBranchTakenProbability(HotSpotMethodData data, int position) {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
204 return -1;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
205 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
206
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
207 @Override
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
208 public double[] getSwitchProbabilities(HotSpotMethodData data, int position) {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
209 return null;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
210 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
211
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
212 @Override
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
213 public int getExecutionCount(HotSpotMethodData data, int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
214 return -1;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
215 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
216
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
217 protected int getFlags(HotSpotMethodData data, int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
218 return data.readUnsignedByte(position, config.dataLayoutFlagsOffset);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
219 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
220
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
221 protected int getDynamicSize(@SuppressWarnings("unused") HotSpotMethodData data, @SuppressWarnings("unused") int position) {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
222 return 0;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
223 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
224 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
225
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
226 private static class NoMethodData extends AbstractMethodData {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
227 private static final int NO_DATA_TAG = 0;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
228 private static final int NO_DATA_SIZE = cellIndexToOffset(0);
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
229
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
230 protected NoMethodData() {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
231 super(NO_DATA_TAG, NO_DATA_SIZE);
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
232 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
233
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
234 @Override
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
235 public int getBCI(HotSpotMethodData data, int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
236 return -1;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
237 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
238
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
239
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
240 @Override
4457
5acf4a974e4a fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4456
diff changeset
241 public boolean getExceptionSeen(HotSpotMethodData data, int position) {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
242 return false;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
243 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
244 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
245
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
246 private static class BitData extends AbstractMethodData {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
247 private static final int BIT_DATA_TAG = 1;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
248 private static final int BIT_DATA_SIZE = cellIndexToOffset(0);
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
249 private static final int BIT_DATA_NULL_SEEN_FLAG = 0x01;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
250
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
251 private BitData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
252 super(BIT_DATA_TAG, BIT_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
253 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
254
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
255 protected BitData(int tag, int staticSize) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
256 super(tag, staticSize);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
257 }
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
258
4452
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
259 @SuppressWarnings("unused")
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
260 public boolean getNullSeen(HotSpotMethodData data, int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
261 return (getFlags(data, position) & BIT_DATA_NULL_SEEN_FLAG) != 0;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
262 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
263 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
264
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
265 private static class CounterData extends BitData {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
266 private static final int COUNTER_DATA_TAG = 2;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
267 private static final int COUNTER_DATA_SIZE = cellIndexToOffset(1);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
268 private static final int COUNTER_DATA_COUNT_OFFSET = cellIndexToOffset(0);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
269
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
270 public CounterData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
271 super(COUNTER_DATA_TAG, COUNTER_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
272 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
273
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
274 protected CounterData(int tag, int staticSize) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
275 super(tag, staticSize);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
276 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
277
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
278 @Override
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
279 public int getExecutionCount(HotSpotMethodData data, int position) {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
280 return getCounterValue(data, position);
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
281 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
282
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
283 protected int getCounterValue(HotSpotMethodData data, int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
284 return data.readUnsignedIntAsSignedInt(position, COUNTER_DATA_COUNT_OFFSET);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
285 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
286 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
287
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
288 private static class JumpData extends AbstractMethodData {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
289 private static final int JUMP_DATA_TAG = 3;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
290 private static final int JUMP_DATA_SIZE = cellIndexToOffset(2);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
291 protected static final int TAKEN_COUNT_OFFSET = cellIndexToOffset(0);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
292 protected static final int TAKEN_DISPLACEMENT_OFFSET = cellIndexToOffset(1);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
293
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
294 public JumpData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
295 super(JUMP_DATA_TAG, JUMP_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
296 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
297
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
298 protected JumpData(int tag, int staticSize) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
299 super(tag, staticSize);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
300 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
301
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
302 @Override
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
303 public double getBranchTakenProbability(HotSpotMethodData data, int position) {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
304 return 1;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
305 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
306
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
307 @Override
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
308 public int getExecutionCount(HotSpotMethodData data, int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
309 return data.readUnsignedIntAsSignedInt(position, TAKEN_COUNT_OFFSET);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
310 }
4452
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
311
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
312 @SuppressWarnings("unused")
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
313 public int getTakenDisplacement(HotSpotMethodData data, int position) {
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
314 return data.readInt(position, TAKEN_DISPLACEMENT_OFFSET);
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
315 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
316 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
317
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
318 private abstract static class AbstractTypeData extends CounterData {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
319 private static final int RECEIVER_TYPE_DATA_ROW_SIZE = cellsToBytes(2);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
320 private static final int RECEIVER_TYPE_DATA_SIZE = cellIndexToOffset(1) + RECEIVER_TYPE_DATA_ROW_SIZE * config.typeProfileWidth;
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
321 private static final int RECEIVER_TYPE_DATA_FIRST_RECEIVER_OFFSET = cellIndexToOffset(1);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
322 private static final int RECEIVER_TYPE_DATA_FIRST_COUNT_OFFSET = cellIndexToOffset(2);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
323
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
324 protected AbstractTypeData(int tag) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
325 super(tag, RECEIVER_TYPE_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
326 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
327
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
328 @Override
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
329 public RiTypeProfile getTypeProfile(HotSpotMethodData data, int position) {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
330 int typeProfileWidth = config.typeProfileWidth;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
331
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
332 RiResolvedType[] sparseTypes = new RiResolvedType[typeProfileWidth];
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
333 double[] counts = new double[typeProfileWidth];
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
334 long totalCount = 0;
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
335 int entries = 0;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
336
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
337 for (int i = 0; i < typeProfileWidth; i++) {
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
338 Object receiverKlassOop = data.readObject(position, getReceiverOffset(i));
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
339 if (receiverKlassOop != null) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
340 Object graalMirror = unsafe.getObject(receiverKlassOop, (long) config.graalMirrorKlassOffset);
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
341 if (graalMirror == null) {
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
342 Class<?> javaClass = (Class<?>) unsafe.getObject(receiverKlassOop, (long) config.classMirrorOffset);
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
343 graalMirror = CompilerImpl.getInstance().getVMEntries().getType(javaClass);
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
344 assert graalMirror != null : "must not return null";
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
345 }
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
346 sparseTypes[entries] = (RiResolvedType) graalMirror;
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
347
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
348 long count = data.readUnsignedInt(position, getCountOffset(i));
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
349 totalCount += count;
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
350 counts[entries] = count;
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
351
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
352 entries++;
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
353 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
354 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
355
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
356 totalCount += getTypesNotRecordedExecutionCount(data, position);
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
357 return createRiTypeProfile(sparseTypes, counts, totalCount, entries);
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
358 }
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
359
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
360 protected abstract long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position);
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
361
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
362 private static RiTypeProfile createRiTypeProfile(RiResolvedType[] sparseTypes, double[] counts, long totalCount, int entries) {
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
363 RiResolvedType[] types;
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
364 double[] probabilities;
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
365
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
366 if (entries <= 0) {
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
367 return null;
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
368 } else if (entries < sparseTypes.length) {
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
369 RiResolvedType[] compactedTypes = new RiResolvedType[entries];
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
370 System.arraycopy(sparseTypes, 0, compactedTypes, 0, entries);
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
371 types = compactedTypes;
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
372 probabilities = new double[entries];
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
373 } else {
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
374 types = sparseTypes;
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
375 probabilities = counts;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
376 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
377
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
378 double totalProbability = 0.0;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
379 for (int i = 0; i < entries; i++) {
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
380 double p = counts[i] / totalCount;
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
381 probabilities[i] = p;
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
382 totalProbability += p;
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
383 }
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
384
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
385 double notRecordedTypeProbability = entries < config.typeProfileWidth ? 0.0 : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability));
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
386 return new RiTypeProfile(types, notRecordedTypeProbability, probabilities);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
387 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
388
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
389 private static int getReceiverOffset(int row) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
390 return RECEIVER_TYPE_DATA_FIRST_RECEIVER_OFFSET + row * RECEIVER_TYPE_DATA_ROW_SIZE;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
391 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
392
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
393 protected static int getCountOffset(int row) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
394 return RECEIVER_TYPE_DATA_FIRST_COUNT_OFFSET + row * RECEIVER_TYPE_DATA_ROW_SIZE;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
395 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
396 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
397
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
398 private static class TypeCheckData extends AbstractTypeData {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
399 private static final int RECEIVER_TYPE_DATA_TAG = 4;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
400
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
401 public TypeCheckData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
402 super(RECEIVER_TYPE_DATA_TAG);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
403 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
404
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
405 @Override
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
406 public int getExecutionCount(HotSpotMethodData data, int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
407 return -1;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
408 }
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
409
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
410 @Override
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
411 protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) {
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
412 // TODO (ch) if types do not fit, profiling is skipped for typechecks
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
413 return 0;
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
414 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
415 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
416
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
417 private static class VirtualCallData extends AbstractTypeData {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
418 private static final int VIRTUAL_CALL_DATA_TAG = 5;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
419
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
420 public VirtualCallData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
421 super(VIRTUAL_CALL_DATA_TAG);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
422 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
423
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
424 @Override
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
425 public int getExecutionCount(HotSpotMethodData data, int position) {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
426 int typeProfileWidth = config.typeProfileWidth;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
427
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
428 long total = 0;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
429 for (int i = 0; i < typeProfileWidth; i++) {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
430 total += data.readUnsignedInt(position, getCountOffset(i));
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
431 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
432
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
433 total += getCounterValue(data, position);
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
434 return truncateLongToInt(total);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
435 }
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
436
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
437 @Override
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
438 protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) {
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
439 return getCounterValue(data, position);
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
440 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
441 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
442
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
443 private static class RetData extends CounterData {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
444 private static final int RET_DATA_TAG = 6;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
445 private static final int RET_DATA_ROW_SIZE = cellsToBytes(3);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
446 private static final int RET_DATA_SIZE = cellIndexToOffset(1) + RET_DATA_ROW_SIZE * config.bciProfileWidth;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
447
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
448 public RetData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
449 super(RET_DATA_TAG, RET_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
450 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
451 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
452
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
453 private static class BranchData extends JumpData {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
454 private static final int BRANCH_DATA_TAG = 7;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
455 private static final int BRANCH_DATA_SIZE = cellIndexToOffset(3);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
456 private static final int NOT_TAKEN_COUNT_OFFSET = cellIndexToOffset(2);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
457 private static final int BRANCH_DATA_MATURE_COUNT = 40;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
458
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
459 public BranchData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
460 super(BRANCH_DATA_TAG, BRANCH_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
461 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
462
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
463 @Override
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
464 public double getBranchTakenProbability(HotSpotMethodData data, int position) {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
465 long takenCount = data.readUnsignedInt(position, TAKEN_COUNT_OFFSET);
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
466 long notTakenCount = data.readUnsignedInt(position, NOT_TAKEN_COUNT_OFFSET);
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
467 long total = takenCount + notTakenCount;
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
468
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
469 if (total < BRANCH_DATA_MATURE_COUNT) {
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
470 return -1;
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
471 } else {
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
472 return takenCount / (double) total;
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
473 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
474 }
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
475
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
476 @Override
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
477 public int getExecutionCount(HotSpotMethodData data, int position) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
478 long count = data.readUnsignedInt(position, TAKEN_COUNT_OFFSET) + data.readUnsignedInt(position, NOT_TAKEN_COUNT_OFFSET);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
479 return truncateLongToInt(count);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
480 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
481 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
482
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
483 private static class ArrayData extends AbstractMethodData {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
484 private static final int ARRAY_DATA_LENGTH_OFFSET = cellIndexToOffset(0);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
485 protected static final int ARRAY_DATA_START_OFFSET = cellIndexToOffset(1);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
486
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
487 public ArrayData(int tag, int staticSize) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
488 super(tag, staticSize);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
489 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
490
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
491 @Override
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
492 protected int getDynamicSize(HotSpotMethodData data, int position) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
493 return cellsToBytes(getLength(data, position));
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
494 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
495
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
496 protected static int getLength(HotSpotMethodData data, int position) {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
497 return data.readInt(position, ARRAY_DATA_LENGTH_OFFSET);
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
498 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
499 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
500
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
501 private static class MultiBranchData extends ArrayData {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
502 private static final int MULTI_BRANCH_DATA_TAG = 8;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
503 private static final int MULTI_BRANCH_DATA_SIZE = cellIndexToOffset(1);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
504 private static final int MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS = 2;
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
505 private static final int MULTI_BRANCH_DATA_ROW_SIZE = cellsToBytes(MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
506 private static final int MULTI_BRANCH_DATA_FIRST_COUNT_OFFSET = ARRAY_DATA_START_OFFSET + cellsToBytes(0);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
507 private static final int MULTI_BRANCH_DATA_FIRST_DISPLACEMENT_OFFSET = ARRAY_DATA_START_OFFSET + cellsToBytes(1);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
508
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
509 public MultiBranchData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
510 super(MULTI_BRANCH_DATA_TAG, MULTI_BRANCH_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
511 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
512
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
513 @Override
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
514 public double[] getSwitchProbabilities(HotSpotMethodData data, int position) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
515 int arrayLength = getLength(data, position);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
516 assert arrayLength > 0 : "switch must have at least the default case";
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
517 assert arrayLength % MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS == 0 : "array must have full rows";
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
518
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
519 int length = arrayLength / MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS;
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
520 long totalCount = 0;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
521 double[] result = new double[length];
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
522
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
523 // default case is first in HotSpot but last for the compiler
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
524 long count = readCount(data, position, 0);
4446
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
525 totalCount += count;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
526 result[length - 1] = count;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
527
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
528 for (int i = 1; i < length; i++) {
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
529 count = readCount(data, position, i);
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
530 totalCount += count;
4446
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
531 result[i - 1] = count;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
532 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
533
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
534 if (totalCount < 10 * (length + 2)) {
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
535 return null;
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
536 } else {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
537 for (int i = 0; i < length; i++) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
538 result[i] = result[i] / totalCount;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
539 }
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
540 return result;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
541 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
542 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
543
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
544 private static long readCount(HotSpotMethodData data, int position, int i) {
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
545 int offset;
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
546 long count;
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
547 offset = getCountOffset(i);
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
548 count = data.readUnsignedInt(position, offset);
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
549 return count;
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
550 }
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
551
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
552 @Override
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
553 public int getExecutionCount(HotSpotMethodData data, int position) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
554 int arrayLength = getLength(data, position);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
555 assert arrayLength > 0 : "switch must have at least the default case";
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
556 assert arrayLength % MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS == 0 : "array must have full rows";
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
557
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
558 int length = arrayLength / MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS;
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
559 long totalCount = 0;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
560 for (int i = 0; i < length; i++) {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
561 int offset = getCountOffset(i);
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
562 totalCount += data.readUnsignedInt(position, offset);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
563 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
564
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
565 return truncateLongToInt(totalCount);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
566 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
567
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
568 private static int getCountOffset(int index) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
569 return MULTI_BRANCH_DATA_FIRST_COUNT_OFFSET + index * MULTI_BRANCH_DATA_ROW_SIZE;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
570 }
4452
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
571
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
572 @SuppressWarnings("unused")
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
573 private static int getDisplacementOffset(int index) {
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
574 return MULTI_BRANCH_DATA_FIRST_DISPLACEMENT_OFFSET + index * MULTI_BRANCH_DATA_ROW_SIZE;
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
575 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
576 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
577
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
578 private static class ArgInfoData extends ArrayData {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
579 private static final int ARG_INFO_DATA_TAG = 9;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
580 private static final int ARG_INFO_DATA_SIZE = cellIndexToOffset(1);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
581
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
582 public ArgInfoData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
583 super(ARG_INFO_DATA_TAG, ARG_INFO_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
584 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
585 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
586 }