Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotProfilingInfo.java @ 5541:b4c406861c33
More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 09 Jun 2012 16:52:12 +0200 |
parents | 9da759562a42 |
children | b6617d13ea44 |
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 */ | |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.hotspot.ri; |
4446 | 24 |
5510
426c605c9d3c
Move cri.ci to api.code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5507
diff
changeset
|
25 import com.oracle.graal.api.code.*; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5506
diff
changeset
|
26 import com.oracle.graal.api.meta.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
27 import com.oracle.graal.debug.*; |
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
28 import com.oracle.graal.hotspot.*; |
4446 | 29 |
30 | |
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
|
31 public final class HotSpotProfilingInfo extends CompilerObject implements ProfilingInfo { |
4446 | 32 |
33 private static final long serialVersionUID = -8307682725047864875L; | |
4561
35ca3ade314d
enabled nmethod statistics for product build
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4553
diff
changeset
|
34 private static final DebugMetric metricInsufficentSpace = Debug.metric("InsufficientSpaceForProfilingData"); |
4446 | 35 |
36 private int position; | |
37 private int hintPosition; | |
38 private int hintBCI; | |
39 private HotSpotMethodDataAccessor dataAccessor; | |
40 private HotSpotMethodData methodData; | |
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
|
41 private final int codeSize; |
4446 | 42 |
5530
9da759562a42
Remove compiler member field from HotSpot's implementation of the Ri* interfaces.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5526
diff
changeset
|
43 public HotSpotProfilingInfo(HotSpotMethodData methodData, int codeSize) { |
4446 | 44 this.methodData = methodData; |
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
|
45 this.codeSize = codeSize; |
4446 | 46 hintPosition = 0; |
47 hintBCI = -1; | |
48 } | |
49 | |
50 @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
|
51 public int codeSize() { |
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
|
52 return codeSize; |
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
|
53 } |
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
|
54 |
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 @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
|
56 public JavaTypeProfile getTypeProfile(int bci) { |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
57 findBCI(bci, false); |
4446 | 58 return dataAccessor.getTypeProfile(methodData, position); |
59 } | |
60 | |
61 @Override | |
62 public double getBranchTakenProbability(int bci) { | |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
63 findBCI(bci, false); |
4446 | 64 return dataAccessor.getBranchTakenProbability(methodData, position); |
65 } | |
66 | |
67 @Override | |
68 public double[] getSwitchProbabilities(int bci) { | |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
69 findBCI(bci, false); |
4446 | 70 return dataAccessor.getSwitchProbabilities(methodData, position); |
71 } | |
72 | |
73 @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
|
74 public ExceptionSeen getExceptionSeen(int bci) { |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
75 findBCI(bci, true); |
4457
5acf4a974e4a
fixed framestate for inlining multiple methods
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4450
diff
changeset
|
76 return dataAccessor.getExceptionSeen(methodData, position); |
4446 | 77 } |
78 | |
79 @Override | |
80 public int getExecutionCount(int bci) { | |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
81 findBCI(bci, false); |
4446 | 82 return dataAccessor.getExecutionCount(methodData, position); |
83 } | |
84 | |
5114
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5061
diff
changeset
|
85 @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
|
86 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
|
87 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
|
88 } |
dad1ac9dba7d
finished first implementation of disabling runtime feedback selectively based on deoptimization history
Christian Haeubl <christian.haeubl@oracle.com>
parents:
5061
diff
changeset
|
89 |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
90 private void findBCI(int targetBCI, boolean searchExtraData) { |
4446 | 91 assert targetBCI >= 0 : "invalid BCI"; |
92 | |
93 if (methodData.hasNormalData()) { | |
94 int currentPosition = targetBCI < hintBCI ? 0 : hintPosition; | |
95 HotSpotMethodDataAccessor currentAccessor; | |
96 while ((currentAccessor = methodData.getNormalData(currentPosition)) != null) { | |
97 int currentBCI = currentAccessor.getBCI(methodData, currentPosition); | |
98 if (currentBCI == targetBCI) { | |
99 normalDataFound(currentAccessor, currentPosition, currentBCI); | |
100 return; | |
101 } else if (currentBCI > targetBCI) { | |
102 break; | |
103 } | |
104 currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition); | |
105 } | |
106 } | |
107 | |
4527
a0cca63cd366
fixed exceptionSeen profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4476
diff
changeset
|
108 boolean exceptionPossiblyNotRecorded = false; |
4450
d585b608bd78
more efficient methodData access
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4447
diff
changeset
|
109 if (searchExtraData && methodData.hasExtraData()) { |
4476
00efac2934d3
methodData bugfix
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4457
diff
changeset
|
110 int currentPosition = methodData.getExtraDataBeginOffset(); |
4446 | 111 HotSpotMethodDataAccessor currentAccessor; |
112 while ((currentAccessor = methodData.getExtraData(currentPosition)) != null) { | |
113 int currentBCI = currentAccessor.getBCI(methodData, currentPosition); | |
114 if (currentBCI == targetBCI) { | |
115 extraDataFound(currentAccessor, currentPosition); | |
116 return; | |
117 } | |
118 currentPosition = currentPosition + currentAccessor.getSize(methodData, currentPosition); | |
119 } | |
4527
a0cca63cd366
fixed exceptionSeen profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4476
diff
changeset
|
120 |
4553
7d0d849abf80
added option to summarize debug values
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4527
diff
changeset
|
121 if (!methodData.isWithin(currentPosition)) { |
7d0d849abf80
added option to summarize debug values
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4527
diff
changeset
|
122 exceptionPossiblyNotRecorded = true; |
4561
35ca3ade314d
enabled nmethod statistics for product build
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4553
diff
changeset
|
123 metricInsufficentSpace.increment(); |
4553
7d0d849abf80
added option to summarize debug values
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4527
diff
changeset
|
124 } |
4446 | 125 } |
126 | |
4527
a0cca63cd366
fixed exceptionSeen profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4476
diff
changeset
|
127 noDataFound(exceptionPossiblyNotRecorded); |
4446 | 128 } |
129 | |
130 private void normalDataFound(HotSpotMethodDataAccessor data, int pos, int bci) { | |
131 setCurrentData(data, pos); | |
132 this.hintPosition = position; | |
133 this.hintBCI = bci; | |
134 } | |
135 | |
136 private void extraDataFound(HotSpotMethodDataAccessor data, int pos) { | |
137 setCurrentData(data, pos); | |
138 } | |
139 | |
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
|
140 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
|
141 HotSpotMethodDataAccessor accessor = HotSpotMethodData.getNoDataAccessor(exceptionPossiblyNotRecorded); |
4527
a0cca63cd366
fixed exceptionSeen profiling information
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4476
diff
changeset
|
142 setCurrentData(accessor, -1); |
4446 | 143 } |
144 | |
145 private void setCurrentData(HotSpotMethodDataAccessor dataAccessor, int position) { | |
146 this.dataAccessor = dataAccessor; | |
147 this.position = position; | |
148 } | |
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
|
149 |
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
|
150 @Override |
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
|
151 public String toString() { |
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
|
152 return "HotSpotProfilingInfo<" + CiUtil.profileToString(this, null, "; ") + ">"; |
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
|
153 } |
4446 | 154 } |