annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java @ 9928:a9311ec68721

Avoid graph caching if immature or no profiling information was used for graph building.
author Christian Haeubl <haeubl@ssw.jku.at>
date Fri, 07 Jun 2013 14:36:45 +0200
parents 063a712fe8d8
children 3718acd022db
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 */
5548
8872bc0eebdf Renaming hotspot.ri => hotspot.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5541
diff changeset
23 package com.oracle.graal.hotspot.meta;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
24
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
25 import static com.oracle.graal.graph.UnsafeAccess.*;
7037
dd81042f4eb1 added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
26 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*;
4470
b7ec250cd29c fixes after merge
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4467
diff changeset
27
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
28 import java.util.*;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
29
5507
dc71b06d09f8 Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5506
diff changeset
30 import com.oracle.graal.api.meta.*;
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
31 import com.oracle.graal.api.meta.JavaMethodProfile.ProfiledMethod;
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6525
diff changeset
32 import com.oracle.graal.api.meta.JavaTypeProfile.ProfiledType;
8610
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
33 import com.oracle.graal.api.meta.ProfilingInfo.TriState;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
34 import com.oracle.graal.hotspot.*;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
35
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
36 /**
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
37 * Access to a HotSpot MethodData structure (defined in methodData.hpp).
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
38 */
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
39 public final class HotSpotMethodData extends CompilerObject {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
40
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
41 private static final long serialVersionUID = -8873133496591225071L;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
42
9289
261a43921c5e rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents: 8659
diff changeset
43 private static final HotSpotVMConfig config = graalRuntime().getConfig();
8610
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
44 private static final HotSpotMethodDataAccessor NO_DATA_NO_EXCEPTION_ACCESSOR = new NoMethodData(TriState.FALSE);
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
45 private static final HotSpotMethodDataAccessor NO_DATA_EXCEPTION_POSSIBLY_NOT_RECORDED_ACCESSOR = new NoMethodData(TriState.UNKNOWN);
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
46
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
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
48 private static final HotSpotMethodDataAccessor[] PROFILE_DATA_ACCESSORS = {null, new BitData(), new CounterData(), new JumpData(), new TypeCheckData(), new VirtualCallData(), new RetData(),
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
49 new BranchData(), new MultiBranchData(), new ArgInfoData()};
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
50
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
51 /**
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
52 * Reference to the C++ MethodData object.
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
53 */
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
54 private final long metaspaceMethodData;
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
55
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
56 private int normalDataSize;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
57 private int extraDataSize;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
58
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
59 HotSpotMethodData(long metaspaceMethodData) {
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
60 this.metaspaceMethodData = metaspaceMethodData;
9289
261a43921c5e rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents: 8659
diff changeset
61 graalRuntime().getCompilerToVM().initializeMethodData(metaspaceMethodData, this);
4439
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
4476
00efac2934d3 methodData bugfix
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4470
diff changeset
72 public int getExtraDataBeginOffset() {
00efac2934d3 methodData bugfix
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4470
diff changeset
73 return normalDataSize;
00efac2934d3 methodData bugfix
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4470
diff changeset
74 }
00efac2934d3 methodData bugfix
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4470
diff changeset
75
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
76 public boolean isWithin(int position) {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
77 return position >= 0 && position < normalDataSize + extraDataSize;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
78 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
79
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5534
diff changeset
80 public int getDeoptimizationCount(DeoptimizationReason reason) {
9289
261a43921c5e rename: HotSpotGraalRuntime.getInstance() -> graalRuntime()
Doug Simon <doug.simon@oracle.com>
parents: 8659
diff changeset
81 int reasonIndex = graalRuntime().getRuntime().convertDeoptReason(reason);
7159
3fbde10a77b0 replaced usage of Unsafe.get<kind>(Object object, long offset) where object == null with Unsafe.get<kind>(long address)
Doug Simon <doug.simon@oracle.com>
parents: 7154
diff changeset
82 return unsafe.getByte(metaspaceMethodData + config.methodDataOopTrapHistoryOffset + reasonIndex) & 0xFF;
5114
dad1ac9dba7d finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5061
diff changeset
83 }
dad1ac9dba7d finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents: 5061
diff changeset
84
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
85 public HotSpotMethodDataAccessor getNormalData(int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
86 if (position >= normalDataSize) {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
87 return null;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
88 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
89
4476
00efac2934d3 methodData bugfix
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4470
diff changeset
90 HotSpotMethodDataAccessor result = getData(position);
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
91 assert result != null : "NO_DATA tag is not allowed";
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
92 return result;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
93 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
94
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
95 public HotSpotMethodDataAccessor getExtraData(int position) {
4552
bc14f8e7d5ed fixed another endless recompilation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4551
diff changeset
96 if (position >= normalDataSize + extraDataSize) {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
97 return null;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
98 }
4476
00efac2934d3 methodData bugfix
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4470
diff changeset
99 return getData(position);
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
100 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
101
4564
8fc6920e064b avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4552
diff changeset
102 public static HotSpotMethodDataAccessor getNoDataAccessor(boolean exceptionPossiblyNotRecorded) {
8fc6920e064b avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4552
diff changeset
103 if (exceptionPossiblyNotRecorded) {
8fc6920e064b avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4552
diff changeset
104 return NO_DATA_EXCEPTION_POSSIBLY_NOT_RECORDED_ACCESSOR;
8fc6920e064b avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4552
diff changeset
105 } else {
8fc6920e064b avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4552
diff changeset
106 return NO_DATA_NO_EXCEPTION_ACCESSOR;
8fc6920e064b avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4552
diff changeset
107 }
4440
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
4476
00efac2934d3 methodData bugfix
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4470
diff changeset
110 private HotSpotMethodDataAccessor getData(int position) {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
111 assert position >= 0 : "out of bounds";
4476
00efac2934d3 methodData bugfix
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4470
diff changeset
112 int tag = AbstractMethodData.readTag(this, 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);
7159
3fbde10a77b0 replaced usage of Unsafe.get<kind>(Object object, long offset) where object == null with Unsafe.get<kind>(long address)
Doug Simon <doug.simon@oracle.com>
parents: 7154
diff changeset
119 return unsafe.getByte(metaspaceMethodData + 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);
7159
3fbde10a77b0 replaced usage of Unsafe.get<kind>(Object object, long offset) where object == null with Unsafe.get<kind>(long address)
Doug Simon <doug.simon@oracle.com>
parents: 7154
diff changeset
124 return unsafe.getShort(metaspaceMethodData + 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);
7159
3fbde10a77b0 replaced usage of Unsafe.get<kind>(Object object, long offset) where object == null with Unsafe.get<kind>(long address)
Doug Simon <doug.simon@oracle.com>
parents: 7154
diff changeset
129 return unsafe.getInt(metaspaceMethodData + 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);
7159
3fbde10a77b0 replaced usage of Unsafe.get<kind>(Object object, long offset) where object == null with Unsafe.get<kind>(long address)
Doug Simon <doug.simon@oracle.com>
parents: 7154
diff changeset
139 return unsafe.getInt(metaspaceMethodData + 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
7037
dd81042f4eb1 added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
142 private long readWord(int position, int offsetInBytes) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
143 long fullOffsetInBytes = computeFullOffset(position, offsetInBytes);
7037
dd81042f4eb1 added unit tests for ResolvedJavaType
Doug Simon <doug.simon@oracle.com>
parents: 6950
diff changeset
144 return unsafeReadWord(metaspaceMethodData + 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 {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
164
7154
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7084
diff changeset
165 /**
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7084
diff changeset
166 * Corresponds to DS_RECOMPILE_BIT defined in deoptimization.cpp.
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7084
diff changeset
167 */
8616
d343737786fe changed profiling of exceptions so that the ExceptionSeen flag also works without GRAALVM
Christian Haeubl <haeubl@ssw.jku.at>
parents: 8610
diff changeset
168 private static final int EXCEPTIONS_MASK = 0x2;
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
169
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
170 private final int tag;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
171 private final int staticSize;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
172
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
173 protected AbstractMethodData(int tag, int staticSize) {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
174 this.tag = tag;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
175 this.staticSize = staticSize;
4439
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 int getTag() {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
179 return tag;
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 public static int readTag(HotSpotMethodData data, int position) {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
183 return data.readUnsignedByte(position, config.dataLayoutTagOffset);
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
184 }
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 @Override
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
187 public int getBCI(HotSpotMethodData data, int position) {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
188 return data.readUnsignedShort(position, config.dataLayoutBCIOffset);
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
189 }
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 @Override
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
192 public int getSize(HotSpotMethodData data, int position) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
193 return staticSize + getDynamicSize(data, position);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
194 }
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 @Override
8610
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
197 public TriState getExceptionSeen(HotSpotMethodData data, int position) {
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
198 return TriState.get((getFlags(data, position) & EXCEPTIONS_MASK) != 0);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
199 }
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 @Override
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5534
diff changeset
202 public JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position) {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
203 return null;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
204 }
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 @Override
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
207 public JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position) {
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
208 return null;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
209 }
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
210
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
211 @Override
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
212 public double getBranchTakenProbability(HotSpotMethodData data, int position) {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
213 return -1;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
214 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
215
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
216 @Override
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
217 public double[] getSwitchProbabilities(HotSpotMethodData data, int position) {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
218 return null;
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
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
221 @Override
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
222 public int getExecutionCount(HotSpotMethodData data, int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
223 return -1;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
224 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
225
8610
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
226 @Override
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
227 public TriState getNullSeen(HotSpotMethodData data, int position) {
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
228 return TriState.UNKNOWN;
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
229 }
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
230
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
231 protected int getFlags(HotSpotMethodData data, int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
232 return data.readUnsignedByte(position, config.dataLayoutFlagsOffset);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
233 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
234
7556
630ea5001e33 Modified formatter settings to not insert line break after annotation on parameters.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
235 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
236 return 0;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
237 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
238 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
239
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
240 private static class NoMethodData extends AbstractMethodData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
241
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
242 private static final int NO_DATA_TAG = 0;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
243 private static final int NO_DATA_SIZE = cellIndexToOffset(0);
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
244
8610
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
245 private final TriState exceptionSeen;
4527
a0cca63cd366 fixed exceptionSeen profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4526
diff changeset
246
8610
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
247 protected NoMethodData(TriState exceptionSeen) {
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
248 super(NO_DATA_TAG, NO_DATA_SIZE);
4527
a0cca63cd366 fixed exceptionSeen profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4526
diff changeset
249 this.exceptionSeen = exceptionSeen;
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
250 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
251
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
252 @Override
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
253 public int getBCI(HotSpotMethodData data, int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
254 return -1;
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
255 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
256
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
257 @Override
8610
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
258 public TriState getExceptionSeen(HotSpotMethodData data, int position) {
4527
a0cca63cd366 fixed exceptionSeen profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4526
diff changeset
259 return exceptionSeen;
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
260 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
261 }
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
262
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
263 private static class BitData extends AbstractMethodData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
264
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
265 private static final int BIT_DATA_TAG = 1;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
266 private static final int BIT_DATA_SIZE = cellIndexToOffset(0);
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
267 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
268
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
269 private BitData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
270 super(BIT_DATA_TAG, BIT_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
271 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
272
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
273 protected BitData(int tag, int staticSize) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
274 super(tag, staticSize);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
275 }
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
276
8610
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
277 @Override
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
278 public TriState getNullSeen(HotSpotMethodData data, int position) {
5407d1dd6450 API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7556
diff changeset
279 return TriState.get((getFlags(data, position) & BIT_DATA_NULL_SEEN_FLAG) != 0);
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
280 }
4439
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
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
283 private static class CounterData extends BitData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
284
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
285 private static final int COUNTER_DATA_TAG = 2;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
286 private static final int COUNTER_DATA_SIZE = cellIndexToOffset(1);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
287 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
288
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
289 public CounterData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
290 super(COUNTER_DATA_TAG, COUNTER_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
291 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
292
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
293 protected CounterData(int tag, int staticSize) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
294 super(tag, staticSize);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
295 }
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 @Override
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
298 public int getExecutionCount(HotSpotMethodData data, int position) {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
299 return getCounterValue(data, position);
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
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
302 protected int getCounterValue(HotSpotMethodData data, int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
303 return data.readUnsignedIntAsSignedInt(position, COUNTER_DATA_COUNT_OFFSET);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
304 }
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
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
307 private static class JumpData extends AbstractMethodData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
308
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
309 private static final int JUMP_DATA_TAG = 3;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
310 private static final int JUMP_DATA_SIZE = cellIndexToOffset(2);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
311 protected static final int TAKEN_COUNT_OFFSET = cellIndexToOffset(0);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
312 protected static final int TAKEN_DISPLACEMENT_OFFSET = cellIndexToOffset(1);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
313
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
314 public JumpData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
315 super(JUMP_DATA_TAG, JUMP_DATA_SIZE);
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
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
318 protected JumpData(int tag, int staticSize) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
319 super(tag, staticSize);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
320 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
321
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
322 @Override
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
323 public double getBranchTakenProbability(HotSpotMethodData data, int position) {
5039
f3d2447db2d9 added detection for endless recompilation
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4564
diff changeset
324 return getExecutionCount(data, position) != 0 ? 1 : 0;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
325 }
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 @Override
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
328 public int getExecutionCount(HotSpotMethodData data, int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
329 return data.readUnsignedIntAsSignedInt(position, TAKEN_COUNT_OFFSET);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
330 }
4452
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
331
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
332 @SuppressWarnings("unused")
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
333 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
334 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
335 }
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
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
338 private abstract static class AbstractTypeData extends CounterData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
339
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
340 protected static final int TYPE_DATA_ROW_SIZE = cellsToBytes(2);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
341
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
342 protected static final int NONPROFILED_COUNT_OFFSET = cellIndexToOffset(1);
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
343 protected static final int TYPE_DATA_FIRST_TYPE_OFFSET = cellIndexToOffset(2);
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
344 protected static final int TYPE_DATA_FIRST_TYPE_COUNT_OFFSET = cellIndexToOffset(3);
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
345
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
346 protected AbstractTypeData(int tag, int staticSize) {
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
347 super(tag, staticSize);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
348 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
349
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
350 @Override
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5534
diff changeset
351 public JavaTypeProfile getTypeProfile(HotSpotMethodData data, int position) {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
352 int typeProfileWidth = config.typeProfileWidth;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
353
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5534
diff changeset
354 ResolvedJavaType[] types = new ResolvedJavaType[typeProfileWidth];
5335
439ca5ecc7dc types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents: 5321
diff changeset
355 long[] counts = new long[typeProfileWidth];
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
356 long totalCount = 0;
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
357 int entries = 0;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
358
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
359 for (int i = 0; i < typeProfileWidth; i++) {
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
360 long receiverKlass = data.readWord(position, getTypeOffset(i));
6950
41938af2b3d8 modifications to support non-perm-gen changes in HotSpot
Doug Simon <doug.simon@oracle.com>
parents: 6539
diff changeset
361 if (receiverKlass != 0) {
7084
9ba90252ce08 HotSpotResolvedJavaType is now the HotSpot implementation of ResolvedJavaType,
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7037
diff changeset
362 types[entries] = HotSpotResolvedObjectType.fromMetaspaceKlass(receiverKlass);
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
363 long count = data.readUnsignedInt(position, getTypeCountOffset(i));
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
364 totalCount += count;
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
365 counts[entries] = count;
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
366
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
367 entries++;
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
368 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
369 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
370
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
371 totalCount += getTypesNotRecordedExecutionCount(data, position);
8659
bc7bb895e359 incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents: 8616
diff changeset
372 return createTypeProfile(getNullSeen(data, position), types, counts, totalCount, entries);
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
373 }
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
374
7154
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7084
diff changeset
375 protected abstract long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position);
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
376
8659
bc7bb895e359 incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents: 8616
diff changeset
377 private static JavaTypeProfile createTypeProfile(TriState nullSeen, ResolvedJavaType[] types, long[] counts, long totalCount, int entries) {
9928
a9311ec68721 Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9864
diff changeset
378 if (entries <= 0 || totalCount <= 0) {
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
379 return null;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
380 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
381
5335
439ca5ecc7dc types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents: 5321
diff changeset
382 ProfiledType[] ptypes = new ProfiledType[entries];
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
383 double totalProbability = 0.0;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
384 for (int i = 0; i < entries; i++) {
5335
439ca5ecc7dc types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents: 5321
diff changeset
385 double p = counts[i];
439ca5ecc7dc types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents: 5321
diff changeset
386 p = p / totalCount;
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
387 totalProbability += p;
5335
439ca5ecc7dc types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents: 5321
diff changeset
388 ptypes[i] = new ProfiledType(types[i], p);
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
389 }
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
390
5335
439ca5ecc7dc types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents: 5321
diff changeset
391 Arrays.sort(ptypes);
439ca5ecc7dc types profiles are now sorted in descending order of each profiled type's probability
Doug Simon <doug.simon@oracle.com>
parents: 5321
diff changeset
392
4456
f4c82dd4619e inlining bugfixes and cleanup
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4455
diff changeset
393 double notRecordedTypeProbability = entries < config.typeProfileWidth ? 0.0 : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability));
7391
36dafe48bc38 added relevance-based inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7159
diff changeset
394 assert notRecordedTypeProbability == 0 || entries == config.typeProfileWidth;
8659
bc7bb895e359 incorporated null-seen information into JavaTypeProfile
Doug Simon <doug.simon@oracle.com>
parents: 8616
diff changeset
395 return new JavaTypeProfile(nullSeen, notRecordedTypeProbability, ptypes);
4439
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
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
398 private static int getTypeOffset(int row) {
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
399 return TYPE_DATA_FIRST_TYPE_OFFSET + row * TYPE_DATA_ROW_SIZE;
4439
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
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
402 protected static int getTypeCountOffset(int row) {
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
403 return TYPE_DATA_FIRST_TYPE_COUNT_OFFSET + row * TYPE_DATA_ROW_SIZE;
4439
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 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
406
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
407 private static class TypeCheckData extends AbstractTypeData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
408
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
409 private static final int TYPE_CHECK_DATA_TAG = 4;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
410 private static final int TYPE_CHECK_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * config.typeProfileWidth;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
411
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
412 public TypeCheckData() {
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
413 super(TYPE_CHECK_DATA_TAG, TYPE_CHECK_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
414 }
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 @Override
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
417 public int getExecutionCount(HotSpotMethodData data, int position) {
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
418 return -1;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
419 }
7154
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7084
diff changeset
420
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7084
diff changeset
421 @Override
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7084
diff changeset
422 protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) {
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
423 return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET);
7154
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7084
diff changeset
424 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
425 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
426
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
427 private static class VirtualCallData extends AbstractTypeData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
428
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
429 private static final int VIRTUAL_CALL_DATA_TAG = 5;
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
430 private static final int VIRTUAL_CALL_DATA_SIZE = cellIndexToOffset(2) + TYPE_DATA_ROW_SIZE * (config.typeProfileWidth + config.methodProfileWidth);
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
431 private static final int VIRTUAL_CALL_DATA_FIRST_METHOD_OFFSET = TYPE_DATA_FIRST_TYPE_OFFSET + TYPE_DATA_ROW_SIZE * config.typeProfileWidth;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
432 private static final int VIRTUAL_CALL_DATA_FIRST_METHOD_COUNT_OFFSET = TYPE_DATA_FIRST_TYPE_COUNT_OFFSET + TYPE_DATA_ROW_SIZE * config.typeProfileWidth;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
433
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
434 public VirtualCallData() {
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
435 super(VIRTUAL_CALL_DATA_TAG, VIRTUAL_CALL_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
436 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
437
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
438 @Override
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
439 public int getExecutionCount(HotSpotMethodData data, int position) {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
440 int typeProfileWidth = config.typeProfileWidth;
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 long total = 0;
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
443 for (int i = 0; i < typeProfileWidth; i++) {
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
444 total += data.readUnsignedInt(position, getTypeCountOffset(i));
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
445 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
446
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
447 total += getCounterValue(data, position);
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
448 return truncateLongToInt(total);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
449 }
7154
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7084
diff changeset
450
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7084
diff changeset
451 @Override
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7084
diff changeset
452 protected long getTypesNotRecordedExecutionCount(HotSpotMethodData data, int position) {
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7084
diff changeset
453 return getCounterValue(data, position);
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7084
diff changeset
454 }
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
455
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
456 private static long getMethodsNotRecordedExecutionCount(HotSpotMethodData data, int position) {
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
457 return data.readUnsignedIntAsSignedInt(position, NONPROFILED_COUNT_OFFSET);
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
458 }
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
459
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
460 @Override
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
461 public JavaMethodProfile getMethodProfile(HotSpotMethodData data, int position) {
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
462 int profileWidth = config.methodProfileWidth;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
463
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
464 ResolvedJavaMethod[] methods = new ResolvedJavaMethod[profileWidth];
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
465 long[] counts = new long[profileWidth];
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
466 long totalCount = 0;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
467 int entries = 0;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
468
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
469 for (int i = 0; i < profileWidth; i++) {
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
470 long method = data.readWord(position, getMethodOffset(i));
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
471 if (method != 0) {
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
472 methods[entries] = HotSpotResolvedJavaMethod.fromMetaspace(method);
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
473 long count = data.readUnsignedInt(position, getMethodCountOffset(i));
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
474 totalCount += count;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
475 counts[entries] = count;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
476
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
477 entries++;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
478 }
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
479 }
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
480
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
481 totalCount += getMethodsNotRecordedExecutionCount(data, position);
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
482 return createMethodProfile(methods, counts, totalCount, entries);
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
483 }
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
484
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
485 private static JavaMethodProfile createMethodProfile(ResolvedJavaMethod[] methods, long[] counts, long totalCount, int entries) {
9928
a9311ec68721 Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9864
diff changeset
486 if (entries <= 0 || totalCount <= 0) {
9760
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
487 return null;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
488 }
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
489
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
490 ProfiledMethod[] pmethods = new ProfiledMethod[entries];
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
491 double totalProbability = 0.0;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
492 for (int i = 0; i < entries; i++) {
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
493 double p = counts[i];
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
494 p = p / totalCount;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
495 totalProbability += p;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
496 pmethods[i] = new ProfiledMethod(methods[i], p);
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
497 }
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
498
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
499 Arrays.sort(pmethods);
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
500
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
501 double notRecordedMethodProbability = entries < config.methodProfileWidth ? 0.0 : Math.min(1.0, Math.max(0.0, 1.0 - totalProbability));
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
502 assert notRecordedMethodProbability == 0 || entries == config.methodProfileWidth;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
503 return new JavaMethodProfile(notRecordedMethodProbability, pmethods);
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
504 }
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
505
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
506 private static int getMethodOffset(int row) {
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
507 return VIRTUAL_CALL_DATA_FIRST_METHOD_OFFSET + row * TYPE_DATA_ROW_SIZE;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
508 }
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
509
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
510 private static int getMethodCountOffset(int row) {
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
511 return VIRTUAL_CALL_DATA_FIRST_METHOD_COUNT_OFFSET + row * TYPE_DATA_ROW_SIZE;
c76b43ed5089 Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9289
diff changeset
512 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
513 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
514
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
515 private static class RetData extends CounterData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
516
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
517 private static final int RET_DATA_TAG = 6;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
518 private static final int RET_DATA_ROW_SIZE = cellsToBytes(3);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
519 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
520
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
521 public RetData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
522 super(RET_DATA_TAG, RET_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
523 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
524 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
525
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
526 private static class BranchData extends JumpData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
527
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
528 private static final int BRANCH_DATA_TAG = 7;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
529 private static final int BRANCH_DATA_SIZE = cellIndexToOffset(3);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
530 private static final int NOT_TAKEN_COUNT_OFFSET = cellIndexToOffset(2);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
531
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
532 public BranchData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
533 super(BRANCH_DATA_TAG, BRANCH_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
534 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
535
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
536 @Override
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
537 public double getBranchTakenProbability(HotSpotMethodData data, int position) {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
538 long takenCount = data.readUnsignedInt(position, TAKEN_COUNT_OFFSET);
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
539 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
540 long total = takenCount + notTakenCount;
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
541
9928
a9311ec68721 Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9864
diff changeset
542 return total <= 0 ? -1 : takenCount / (double) total;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
543 }
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
544
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
545 @Override
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
546 public int getExecutionCount(HotSpotMethodData data, int position) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
547 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
548 return truncateLongToInt(count);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
549 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
550 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
551
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
552 private static class ArrayData extends AbstractMethodData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
553
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
554 private static final int ARRAY_DATA_LENGTH_OFFSET = cellIndexToOffset(0);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
555 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
556
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
557 public ArrayData(int tag, int staticSize) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
558 super(tag, staticSize);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
559 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
560
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
561 @Override
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
562 protected int getDynamicSize(HotSpotMethodData data, int position) {
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
563 return cellsToBytes(getLength(data, position));
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
564 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
565
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
566 protected static int getLength(HotSpotMethodData data, int position) {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
567 return data.readInt(position, ARRAY_DATA_LENGTH_OFFSET);
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
568 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
569 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
570
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
571 private static class MultiBranchData extends ArrayData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
572
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
573 private static final int MULTI_BRANCH_DATA_TAG = 8;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
574 private static final int MULTI_BRANCH_DATA_SIZE = cellIndexToOffset(1);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
575 private static final int MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS = 2;
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
576 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
577 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
578 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
579
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
580 public MultiBranchData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
581 super(MULTI_BRANCH_DATA_TAG, MULTI_BRANCH_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
582 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
583
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
584 @Override
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
585 public double[] getSwitchProbabilities(HotSpotMethodData data, int position) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
586 int arrayLength = getLength(data, position);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
587 assert arrayLength > 0 : "switch must have at least the default case";
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
588 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
589
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
590 int length = arrayLength / MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS;
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
591 long totalCount = 0;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
592 double[] result = new double[length];
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
593
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
594 // default case is first in HotSpot but last for the compiler
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
595 long count = readCount(data, position, 0);
4446
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
596 totalCount += count;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
597 result[length - 1] = count;
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
598
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
599 for (int i = 1; i < length; i++) {
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
600 count = readCount(data, position, i);
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
601 totalCount += count;
4446
48756b901156 bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4444
diff changeset
602 result[i - 1] = count;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
603 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
604
9928
a9311ec68721 Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9864
diff changeset
605 if (totalCount <= 0) {
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
606 return null;
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
607 } else {
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
608 for (int i = 0; i < length; i++) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
609 result[i] = result[i] / totalCount;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
610 }
4441
4e3aaf14cbc6 fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4440
diff changeset
611 return result;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
612 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
613 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
614
4447
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
615 private static long readCount(HotSpotMethodData data, int position, int i) {
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
616 int offset;
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
617 long count;
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
618 offset = getCountOffset(i);
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
619 count = data.readUnsignedInt(position, offset);
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
620 return count;
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
621 }
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4446
diff changeset
622
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
623 @Override
4440
271220b49abc profiling info fixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4439
diff changeset
624 public int getExecutionCount(HotSpotMethodData data, int position) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
625 int arrayLength = getLength(data, position);
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
626 assert arrayLength > 0 : "switch must have at least the default case";
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
627 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
628
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
629 int length = arrayLength / MULTI_BRANCH_DATA_ROW_SIZE_IN_CELLS;
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
630 long totalCount = 0;
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
631 for (int i = 0; i < length; i++) {
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
632 int offset = getCountOffset(i);
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
633 totalCount += data.readUnsignedInt(position, offset);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
634 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
635
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
636 return truncateLongToInt(totalCount);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
637 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
638
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
639 private static int getCountOffset(int index) {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
640 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
641 }
4452
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
642
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
643 @SuppressWarnings("unused")
b225da954a32 inlining of multiple trival methods at one call site works
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4448
diff changeset
644 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
645 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
646 }
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
647 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
648
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
649 private static class ArgInfoData extends ArrayData {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7391
diff changeset
650
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
651 private static final int ARG_INFO_DATA_TAG = 9;
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
652 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
653
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
654 public ArgInfoData() {
4444
7d9469b37f1f bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents: 4441
diff changeset
655 super(ARG_INFO_DATA_TAG, ARG_INFO_DATA_SIZE);
4439
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
656 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
657 }
f7251c729b31 profiling info first try
Christian Haeubl <christian.haeubl@oracle.com>
parents:
diff changeset
658 }