author | roland |
Thu, 10 Apr 2014 11:38:12 +0200 | |
changeset 24002 | 4e6a72032a99 |
parent 22234 | da823d78ad65 |
child 24673 | 2ec56802b829 |
permissions | -rw-r--r-- |
2126 | 1 |
/* |
22234
da823d78ad65
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
19712
diff
changeset
|
2 |
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. |
2126 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2126
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2126
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2126
diff
changeset
|
21 |
* questions. |
2126 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
package com.sun.hotspot.tools.compiler; |
|
26 |
||
27 |
import java.io.PrintStream; |
|
24002
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
28 |
import java.util.ArrayDeque; |
2126 | 29 |
import java.util.ArrayList; |
30 |
import java.util.List; |
|
31 |
||
32 |
public class CallSite { |
|
33 |
||
34 |
private int bci; |
|
35 |
private Method method; |
|
36 |
private int count; |
|
37 |
private String receiver; |
|
38 |
private int receiver_count; |
|
39 |
private String reason; |
|
40 |
private List<CallSite> calls; |
|
10563
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
41 |
private int endNodes; |
14623
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
10563
diff
changeset
|
42 |
private int endLiveNodes; |
10563
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
43 |
private double timeStamp; |
24002
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
44 |
private long inlineId; |
2126 | 45 |
|
46 |
CallSite() { |
|
47 |
} |
|
48 |
||
49 |
CallSite(int bci, Method m) { |
|
50 |
this.bci = bci; |
|
51 |
this.method = m; |
|
52 |
} |
|
53 |
||
54 |
void add(CallSite site) { |
|
55 |
if (getCalls() == null) { |
|
56 |
setCalls(new ArrayList<CallSite>()); |
|
57 |
} |
|
58 |
getCalls().add(site); |
|
59 |
} |
|
60 |
||
61 |
CallSite last() { |
|
62 |
return last(-1); |
|
63 |
} |
|
64 |
||
65 |
CallSite last(int fromEnd) { |
|
66 |
return getCalls().get(getCalls().size() + fromEnd); |
|
67 |
} |
|
68 |
||
69 |
public String toString() { |
|
70 |
StringBuilder sb = new StringBuilder(); |
|
71 |
if (getReason() == null) { |
|
72 |
sb.append(" @ " + getBci() + " " + getMethod()); |
|
73 |
} else { |
|
74 |
sb.append("- @ " + getBci() + " " + getMethod() + " " + getReason()); |
|
75 |
} |
|
76 |
sb.append("\n"); |
|
77 |
if (getCalls() != null) { |
|
78 |
for (CallSite site : getCalls()) { |
|
79 |
sb.append(site); |
|
80 |
sb.append("\n"); |
|
81 |
} |
|
82 |
} |
|
83 |
return sb.toString(); |
|
84 |
} |
|
85 |
||
86 |
public void print(PrintStream stream) { |
|
87 |
print(stream, 0); |
|
88 |
} |
|
89 |
||
90 |
void emit(PrintStream stream, int indent) { |
|
91 |
for (int i = 0; i < indent; i++) { |
|
92 |
stream.print(' '); |
|
93 |
} |
|
94 |
} |
|
95 |
private static boolean compat = true; |
|
96 |
||
97 |
public void print(PrintStream stream, int indent) { |
|
98 |
emit(stream, indent); |
|
24002
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
99 |
String m = getMethod().getHolder() + "::" + getMethod().getName(); |
2126 | 100 |
if (getReason() == null) { |
10563
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
101 |
stream.print(" @ " + getBci() + " " + m + " (" + getMethod().getBytes() + " bytes)"); |
2126 | 102 |
|
103 |
} else { |
|
104 |
if (isCompat()) { |
|
10563
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
105 |
stream.print(" @ " + getBci() + " " + m + " " + getReason()); |
2126 | 106 |
} else { |
10563
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
107 |
stream.print("- @ " + getBci() + " " + m + |
2126 | 108 |
" (" + getMethod().getBytes() + " bytes) " + getReason()); |
109 |
} |
|
110 |
} |
|
19712
b0bdff06b6fb
8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents:
14623
diff
changeset
|
111 |
stream.printf(" (end time: %6.4f", getTimeStamp()); |
10563
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
112 |
if (getEndNodes() > 0) { |
19712
b0bdff06b6fb
8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents:
14623
diff
changeset
|
113 |
stream.printf(" nodes: %d live: %d", getEndNodes(), getEndLiveNodes()); |
10563
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
114 |
} |
19712
b0bdff06b6fb
8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents:
14623
diff
changeset
|
115 |
stream.println(")"); |
b0bdff06b6fb
8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents:
14623
diff
changeset
|
116 |
|
2126 | 117 |
if (getReceiver() != null) { |
10563
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
118 |
emit(stream, indent + 4); |
2126 | 119 |
// stream.println("type profile " + method.holder + " -> " + receiver + " (" + |
120 |
// receiver_count + "/" + count + "," + (receiver_count * 100 / count) + "%)"); |
|
121 |
stream.println("type profile " + getMethod().getHolder() + " -> " + getReceiver() + " (" + |
|
122 |
(getReceiverCount() * 100 / getCount()) + "%)"); |
|
123 |
} |
|
124 |
if (getCalls() != null) { |
|
125 |
for (CallSite site : getCalls()) { |
|
126 |
site.print(stream, indent + 2); |
|
127 |
} |
|
128 |
} |
|
129 |
} |
|
130 |
||
131 |
public int getBci() { |
|
132 |
return bci; |
|
133 |
} |
|
134 |
||
135 |
public void setBci(int bci) { |
|
136 |
this.bci = bci; |
|
137 |
} |
|
138 |
||
139 |
public Method getMethod() { |
|
140 |
return method; |
|
141 |
} |
|
142 |
||
143 |
public void setMethod(Method method) { |
|
144 |
this.method = method; |
|
145 |
} |
|
146 |
||
147 |
public int getCount() { |
|
148 |
return count; |
|
149 |
} |
|
150 |
||
151 |
public void setCount(int count) { |
|
152 |
this.count = count; |
|
153 |
} |
|
154 |
||
155 |
public String getReceiver() { |
|
156 |
return receiver; |
|
157 |
} |
|
158 |
||
159 |
public void setReceiver(String receiver) { |
|
160 |
this.receiver = receiver; |
|
161 |
} |
|
162 |
||
163 |
public int getReceiverCount() { |
|
164 |
return receiver_count; |
|
165 |
} |
|
166 |
||
167 |
public void setReceiver_count(int receiver_count) { |
|
168 |
this.receiver_count = receiver_count; |
|
169 |
} |
|
170 |
||
171 |
public String getReason() { |
|
172 |
return reason; |
|
173 |
} |
|
174 |
||
175 |
public void setReason(String reason) { |
|
176 |
this.reason = reason; |
|
177 |
} |
|
178 |
||
179 |
public List<CallSite> getCalls() { |
|
180 |
return calls; |
|
181 |
} |
|
182 |
||
183 |
public void setCalls(List<CallSite> calls) { |
|
184 |
this.calls = calls; |
|
185 |
} |
|
186 |
||
187 |
public static boolean isCompat() { |
|
188 |
return compat; |
|
189 |
} |
|
190 |
||
191 |
public static void setCompat(boolean aCompat) { |
|
192 |
compat = aCompat; |
|
193 |
} |
|
10563
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
194 |
|
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
195 |
void setEndNodes(int n) { |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
196 |
endNodes = n; |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
197 |
} |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
198 |
|
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
199 |
public int getEndNodes() { |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
200 |
return endNodes; |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
201 |
} |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
202 |
|
14623
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
10563
diff
changeset
|
203 |
void setEndLiveNodes(int n) { |
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
10563
diff
changeset
|
204 |
endLiveNodes = n; |
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
10563
diff
changeset
|
205 |
} |
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
10563
diff
changeset
|
206 |
|
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
10563
diff
changeset
|
207 |
public int getEndLiveNodes() { |
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
10563
diff
changeset
|
208 |
return endLiveNodes; |
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
10563
diff
changeset
|
209 |
} |
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
10563
diff
changeset
|
210 |
|
10563
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
211 |
void setTimeStamp(double time) { |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
212 |
timeStamp = time; |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
213 |
} |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
214 |
|
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
215 |
public double getTimeStamp() { |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
216 |
return timeStamp; |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
217 |
} |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
218 |
|
24002
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
219 |
private boolean matches(CallSite other) { |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
220 |
// Every late inline call site has a unique inline id. If the |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
221 |
// call site we're looking for has one then use it other rely |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
222 |
// on method name and bci. |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
223 |
if (other.inlineId != 0) { |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
224 |
return inlineId == other.inlineId; |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
225 |
} |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
226 |
return method.equals(other.method) && bci == other.bci; |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
227 |
} |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
228 |
|
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
229 |
public CallSite findCallSite(ArrayDeque<CallSite> sites) { |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
230 |
// Locate a late inline call site. Multiple chains of |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
231 |
// identical call sites with the same method name/bci are |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
232 |
// possible so we have to try them all until we find the late |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
233 |
// inline call site that has a matching inline id. |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
234 |
CallSite site = sites.pop(); |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
235 |
for (CallSite c : calls) { |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
236 |
if (c.matches(site)) { |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
237 |
if (!sites.isEmpty()) { |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
238 |
CallSite res = c.findCallSite(sites); |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
239 |
if (res != null) { |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
240 |
sites.push(site); |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
241 |
return res; |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
242 |
} |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
243 |
} else { |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
244 |
sites.push(site); |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
245 |
return c; |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
246 |
} |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
247 |
} |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
248 |
} |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
249 |
sites.push(site); |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
250 |
return null; |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
251 |
} |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
252 |
|
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
253 |
public long getInlineId() { |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
254 |
return inlineId; |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
255 |
} |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
256 |
|
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
257 |
public void setInlineId(long inlineId) { |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
258 |
this.inlineId = inlineId; |
4e6a72032a99
8005079: fix LogCompilation for incremental inlining
roland
parents:
22234
diff
changeset
|
259 |
} |
2126 | 260 |
} |