Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotProfilingInfo.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 | c76b43ed5089 |
children | 4158612eca60 b2aea23ee2b1 |
rev | line source |
---|---|
4446 | 1 /* |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
5548
8872bc0eebdf
Renaming hotspot.ri => hotspot.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5547
diff
changeset
|
23 package com.oracle.graal.hotspot.meta; |
4446 | 24 |
9928
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
25 import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; |
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
26 |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5506
diff
changeset
|
27 import com.oracle.graal.api.meta.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
28 import com.oracle.graal.debug.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
29 import com.oracle.graal.hotspot.*; |
9928
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
30 import com.oracle.graal.phases.*; |
4446 | 31 |
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:
5530
diff
changeset
|
32 public final class HotSpotProfilingInfo extends CompilerObject implements ProfilingInfo { |
4446 | 33 |
34 private static final long serialVersionUID = -8307682725047864875L; | |
4561
35ca3ade314d
enabled nmethod statistics for product build
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4553
diff
changeset
|
35 private static final DebugMetric metricInsufficentSpace = Debug.metric("InsufficientSpaceForProfilingData"); |
4446 | 36 |
9928
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
37 private final HotSpotMethodData methodData; |
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
38 private final HotSpotResolvedJavaMethod method; |
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
39 |
4446 | 40 private int position; |
41 private int hintPosition; | |
42 private int hintBCI; | |
43 private HotSpotMethodDataAccessor dataAccessor; | |
44 | |
9928
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
45 public HotSpotProfilingInfo(HotSpotMethodData methodData, HotSpotResolvedJavaMethod method) { |
4446 | 46 this.methodData = methodData; |
9928
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
47 this.method = method; |
4446 | 48 hintPosition = 0; |
49 hintBCI = -1; | |
50 } | |
51 | |
52 @Override | |
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:
5719
diff
changeset
|
53 public int getCodeSize() { |
9928
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
54 return method.getCodeSize(); |
5346
4c3d953f8131
added mechanism (enabled by -G:PICache and -G:PiFilter) for saving/loading method profiling info to/from disk
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
55 } |
4c3d953f8131
added mechanism (enabled by -G:PICache and -G:PiFilter) for saving/loading method profiling info to/from disk
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
56 |
4c3d953f8131
added mechanism (enabled by -G:PICache and -G:PiFilter) for saving/loading method profiling info to/from disk
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
57 @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:
5530
diff
changeset
|
58 public JavaTypeProfile getTypeProfile(int bci) { |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
59 findBCI(bci, false); |
4446 | 60 return dataAccessor.getTypeProfile(methodData, position); |
61 } | |
62 | |
63 @Override | |
9760
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8610
diff
changeset
|
64 public JavaMethodProfile getMethodProfile(int bci) { |
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8610
diff
changeset
|
65 findBCI(bci, false); |
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8610
diff
changeset
|
66 return dataAccessor.getMethodProfile(methodData, position); |
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8610
diff
changeset
|
67 } |
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8610
diff
changeset
|
68 |
c76b43ed5089
Added infrastructure for recording invoked methods in the profiling information.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
8610
diff
changeset
|
69 @Override |
4446 | 70 public double getBranchTakenProbability(int bci) { |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
71 findBCI(bci, false); |
4446 | 72 return dataAccessor.getBranchTakenProbability(methodData, position); |
73 } | |
74 | |
75 @Override | |
76 public double[] getSwitchProbabilities(int bci) { | |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
77 findBCI(bci, false); |
4446 | 78 return dataAccessor.getSwitchProbabilities(methodData, position); |
79 } | |
80 | |
81 @Override | |
8610
5407d1dd6450
API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7530
diff
changeset
|
82 public TriState getExceptionSeen(int bci) { |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
83 findBCI(bci, true); |
4457
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4450
diff
changeset
|
84 return dataAccessor.getExceptionSeen(methodData, position); |
4446 | 85 } |
86 | |
87 @Override | |
8610
5407d1dd6450
API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7530
diff
changeset
|
88 public TriState getNullSeen(int bci) { |
5407d1dd6450
API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7530
diff
changeset
|
89 findBCI(bci, false); |
5407d1dd6450
API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7530
diff
changeset
|
90 return dataAccessor.getNullSeen(methodData, position); |
5407d1dd6450
API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7530
diff
changeset
|
91 } |
5407d1dd6450
API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7530
diff
changeset
|
92 |
5407d1dd6450
API to access nullness profiling information for instanceof, checkcast, and aastore
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7530
diff
changeset
|
93 @Override |
4446 | 94 public int getExecutionCount(int bci) { |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
95 findBCI(bci, false); |
4446 | 96 return dataAccessor.getExecutionCount(methodData, position); |
97 } | |
98 | |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5061
diff
changeset
|
99 @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:
5530
diff
changeset
|
100 public int getDeoptimizationCount(DeoptimizationReason reason) { |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5061
diff
changeset
|
101 return methodData.getDeoptimizationCount(reason); |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5061
diff
changeset
|
102 } |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5061
diff
changeset
|
103 |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
104 private void findBCI(int targetBCI, boolean searchExtraData) { |
4446 | 105 assert targetBCI >= 0 : "invalid BCI"; |
106 | |
107 if (methodData.hasNormalData()) { | |
108 int currentPosition = targetBCI < hintBCI ? 0 : hintPosition; | |
109 HotSpotMethodDataAccessor currentAccessor; | |
110 while ((currentAccessor = methodData.getNormalData(currentPosition)) != null) { | |
111 int currentBCI = currentAccessor.getBCI(methodData, currentPosition); | |
112 if (currentBCI == targetBCI) { | |
113 normalDataFound(currentAccessor, currentPosition, currentBCI); | |
114 return; | |
115 } else if (currentBCI > targetBCI) { | |
116 break; | |
117 } | |
118 currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition); | |
119 } | |
120 } | |
121 | |
4527
a0cca63cd366
fixed exceptionSeen profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4476
diff
changeset
|
122 boolean exceptionPossiblyNotRecorded = false; |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
123 if (searchExtraData && methodData.hasExtraData()) { |
4476
00efac2934d3
methodData bugfix
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
124 int currentPosition = methodData.getExtraDataBeginOffset(); |
4446 | 125 HotSpotMethodDataAccessor currentAccessor; |
126 while ((currentAccessor = methodData.getExtraData(currentPosition)) != null) { | |
127 int currentBCI = currentAccessor.getBCI(methodData, currentPosition); | |
128 if (currentBCI == targetBCI) { | |
129 extraDataFound(currentAccessor, currentPosition); | |
130 return; | |
131 } | |
132 currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition); | |
133 } | |
4527
a0cca63cd366
fixed exceptionSeen profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4476
diff
changeset
|
134 |
4553
7d0d849abf80
added option to summarize debug values
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4527
diff
changeset
|
135 if (!methodData.isWithin(currentPosition)) { |
7d0d849abf80
added option to summarize debug values
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4527
diff
changeset
|
136 exceptionPossiblyNotRecorded = true; |
4561
35ca3ade314d
enabled nmethod statistics for product build
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4553
diff
changeset
|
137 metricInsufficentSpace.increment(); |
4553
7d0d849abf80
added option to summarize debug values
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4527
diff
changeset
|
138 } |
4446 | 139 } |
140 | |
4527
a0cca63cd366
fixed exceptionSeen profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4476
diff
changeset
|
141 noDataFound(exceptionPossiblyNotRecorded); |
4446 | 142 } |
143 | |
144 private void normalDataFound(HotSpotMethodDataAccessor data, int pos, int bci) { | |
145 setCurrentData(data, pos); | |
146 this.hintPosition = position; | |
147 this.hintBCI = bci; | |
148 } | |
149 | |
150 private void extraDataFound(HotSpotMethodDataAccessor data, int pos) { | |
151 setCurrentData(data, pos); | |
152 } | |
153 | |
4564
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4561
diff
changeset
|
154 private void noDataFound(boolean exceptionPossiblyNotRecorded) { |
8fc6920e064b
avoid recursive inlining, escape analysis does no longer restart inlining with level 0, bugfixes
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4561
diff
changeset
|
155 HotSpotMethodDataAccessor accessor = HotSpotMethodData.getNoDataAccessor(exceptionPossiblyNotRecorded); |
4527
a0cca63cd366
fixed exceptionSeen profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4476
diff
changeset
|
156 setCurrentData(accessor, -1); |
4446 | 157 } |
158 | |
159 private void setCurrentData(HotSpotMethodDataAccessor dataAccessor, int position) { | |
160 this.dataAccessor = dataAccessor; | |
161 this.position = position; | |
162 } | |
5346
4c3d953f8131
added mechanism (enabled by -G:PICache and -G:PiFilter) for saving/loading method profiling info to/from disk
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
163 |
4c3d953f8131
added mechanism (enabled by -G:PICache and -G:PiFilter) for saving/loading method profiling info to/from disk
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
164 @Override |
9928
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
165 public boolean isMature() { |
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
166 return method.invocationCount() >= graalRuntime().getConfig().interpreterProfilingThreshold + GraalOptions.MatureProfilingInformationThreshold.getValue(); |
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
167 } |
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
168 |
a9311ec68721
Avoid graph caching if immature or no profiling information was used for graph building.
Christian Haeubl <haeubl@ssw.jku.at>
parents:
9760
diff
changeset
|
169 @Override |
5346
4c3d953f8131
added mechanism (enabled by -G:PICache and -G:PiFilter) for saving/loading method profiling info to/from disk
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
170 public String toString() { |
5719
429accae15aa
moved some methods from CodeUtil to MetaUtil
Doug Simon <doug.simon@oracle.com>
parents:
5548
diff
changeset
|
171 return "HotSpotProfilingInfo<" + MetaUtil.profileToString(this, null, "; ") + ">"; |
5346
4c3d953f8131
added mechanism (enabled by -G:PICache and -G:PiFilter) for saving/loading method profiling info to/from disk
Doug Simon <doug.simon@oracle.com>
parents:
5321
diff
changeset
|
172 } |
4446 | 173 } |