author | bharadwaj |
Tue, 27 Nov 2012 17:24:15 -0800 | |
changeset 14623 | 70c4c1be0a14 |
parent 11960 | 57898a1b4b44 |
child 14628 | 74164bb6ec39 |
permissions | -rw-r--r-- |
2126 | 1 |
/* |
11960
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
2 |
* Copyright (c) 2009, 2012, 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 |
/** |
|
26 |
* A SAX based parser of LogCompilation output from HotSpot. It takes a complete |
|
27 |
* @author never |
|
28 |
*/ |
|
29 |
||
30 |
package com.sun.hotspot.tools.compiler; |
|
31 |
||
32 |
import java.io.FileReader; |
|
33 |
import java.io.Reader; |
|
34 |
import java.util.ArrayList; |
|
35 |
import java.util.Collections; |
|
36 |
import java.util.Comparator; |
|
37 |
import java.util.HashMap; |
|
38 |
import java.util.LinkedHashMap; |
|
39 |
import java.util.Stack; |
|
40 |
import javax.xml.parsers.SAXParser; |
|
41 |
import javax.xml.parsers.SAXParserFactory; |
|
42 |
import org.xml.sax.Attributes; |
|
43 |
import org.xml.sax.ErrorHandler; |
|
44 |
import org.xml.sax.InputSource; |
|
45 |
import org.xml.sax.helpers.DefaultHandler; |
|
46 |
||
47 |
public class LogParser extends DefaultHandler implements ErrorHandler, Constants { |
|
48 |
||
49 |
static final HashMap<String, String> typeMap; |
|
50 |
static { |
|
51 |
typeMap = new HashMap<String, String>(); |
|
52 |
typeMap.put("[I", "int[]"); |
|
53 |
typeMap.put("[C", "char[]"); |
|
54 |
typeMap.put("[Z", "boolean[]"); |
|
55 |
typeMap.put("[L", "Object[]"); |
|
56 |
typeMap.put("[B", "byte[]"); |
|
57 |
} |
|
58 |
||
59 |
static Comparator<LogEvent> sortByStart = new Comparator<LogEvent>() { |
|
60 |
||
61 |
public int compare(LogEvent a, LogEvent b) { |
|
62 |
double difference = (a.getStart() - b.getStart()); |
|
63 |
if (difference < 0) { |
|
64 |
return -1; |
|
65 |
} |
|
66 |
if (difference > 0) { |
|
67 |
return 1; |
|
68 |
} |
|
69 |
return 0; |
|
70 |
} |
|
71 |
||
72 |
@Override |
|
73 |
public boolean equals(Object other) { |
|
74 |
return false; |
|
75 |
} |
|
76 |
||
77 |
@Override |
|
78 |
public int hashCode() { |
|
79 |
return 7; |
|
80 |
} |
|
81 |
}; |
|
82 |
static Comparator<LogEvent> sortByNameAndStart = new Comparator<LogEvent>() { |
|
83 |
||
84 |
public int compare(LogEvent a, LogEvent b) { |
|
85 |
Compilation c1 = a.getCompilation(); |
|
86 |
Compilation c2 = b.getCompilation(); |
|
87 |
if (c1 != null && c2 != null) { |
|
88 |
int result = c1.getMethod().toString().compareTo(c2.getMethod().toString()); |
|
89 |
if (result != 0) { |
|
90 |
return result; |
|
91 |
} |
|
92 |
} |
|
93 |
double difference = (a.getStart() - b.getStart()); |
|
94 |
if (difference < 0) { |
|
95 |
return -1; |
|
96 |
} |
|
97 |
if (difference > 0) { |
|
98 |
return 1; |
|
99 |
} |
|
100 |
return 0; |
|
101 |
} |
|
102 |
||
103 |
public boolean equals(Object other) { |
|
104 |
return false; |
|
105 |
} |
|
106 |
||
107 |
@Override |
|
108 |
public int hashCode() { |
|
109 |
return 7; |
|
110 |
} |
|
111 |
}; |
|
112 |
static Comparator<LogEvent> sortByElapsed = new Comparator<LogEvent>() { |
|
113 |
||
114 |
public int compare(LogEvent a, LogEvent b) { |
|
115 |
double difference = (a.getElapsedTime() - b.getElapsedTime()); |
|
116 |
if (difference < 0) { |
|
117 |
return -1; |
|
118 |
} |
|
119 |
if (difference > 0) { |
|
120 |
return 1; |
|
121 |
} |
|
122 |
return 0; |
|
123 |
} |
|
124 |
||
125 |
@Override |
|
126 |
public boolean equals(Object other) { |
|
127 |
return false; |
|
128 |
} |
|
129 |
||
130 |
@Override |
|
131 |
public int hashCode() { |
|
132 |
return 7; |
|
133 |
} |
|
134 |
}; |
|
135 |
||
136 |
private ArrayList<LogEvent> events = new ArrayList<LogEvent>(); |
|
137 |
||
138 |
private HashMap<String, String> types = new HashMap<String, String>(); |
|
139 |
private HashMap<String, Method> methods = new HashMap<String, Method>(); |
|
140 |
private LinkedHashMap<String, NMethod> nmethods = new LinkedHashMap<String, NMethod>(); |
|
141 |
private HashMap<String, Compilation> compiles = new HashMap<String, Compilation>(); |
|
142 |
private String failureReason; |
|
143 |
private int bci; |
|
144 |
private Stack<CallSite> scopes = new Stack<CallSite>(); |
|
145 |
private Compilation compile; |
|
146 |
private CallSite site; |
|
147 |
private Stack<Phase> phaseStack = new Stack<Phase>(); |
|
148 |
private UncommonTrapEvent currentTrap; |
|
11960
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
149 |
private Stack<CallSite> late_inline_scope; |
2126 | 150 |
|
151 |
long parseLong(String l) { |
|
152 |
try { |
|
153 |
return Long.decode(l).longValue(); |
|
154 |
} catch (NumberFormatException nfe) { |
|
155 |
int split = l.length() - 8; |
|
156 |
String s1 = "0x" + l.substring(split); |
|
157 |
String s2 = l.substring(0, split); |
|
158 |
long v1 = Long.decode(s1).longValue() & 0xffffffffL; |
|
159 |
long v2 = (Long.decode(s2).longValue() & 0xffffffffL) << 32; |
|
160 |
if (!l.equals("0x" + Long.toHexString(v1 + v2))) { |
|
161 |
System.out.println(l); |
|
162 |
System.out.println(s1); |
|
163 |
System.out.println(s2); |
|
164 |
System.out.println(v1); |
|
165 |
System.out.println(v2); |
|
166 |
System.out.println(Long.toHexString(v1 + v2)); |
|
167 |
throw new InternalError("bad conversion"); |
|
168 |
} |
|
169 |
return v1 + v2; |
|
170 |
} |
|
171 |
} |
|
172 |
||
173 |
public static ArrayList<LogEvent> parse(String file, boolean cleanup) throws Exception { |
|
174 |
return parse(new FileReader(file), cleanup); |
|
175 |
} |
|
176 |
||
177 |
public static ArrayList<LogEvent> parse(Reader reader, boolean cleanup) throws Exception { |
|
178 |
// Create the XML input factory |
|
179 |
SAXParserFactory factory = SAXParserFactory.newInstance(); |
|
180 |
||
181 |
// Create the XML LogEvent reader |
|
182 |
SAXParser p = factory.newSAXParser(); |
|
183 |
||
184 |
if (cleanup) { |
|
185 |
// some versions of the log have slightly malformed XML, so clean it |
|
186 |
// up before passing it to SAX |
|
187 |
reader = new LogCleanupReader(reader); |
|
188 |
} |
|
189 |
||
190 |
LogParser log = new LogParser(); |
|
191 |
p.parse(new InputSource(reader), log); |
|
192 |
||
193 |
// Associate compilations with their NMethods |
|
194 |
for (NMethod nm : log.nmethods.values()) { |
|
195 |
Compilation c = log.compiles.get(nm.getId()); |
|
196 |
nm.setCompilation(c); |
|
197 |
// Native wrappers for methods don't have a compilation |
|
198 |
if (c != null) { |
|
199 |
c.setNMethod(nm); |
|
200 |
} |
|
201 |
} |
|
202 |
||
203 |
// Initially we want the LogEvent log sorted by timestamp |
|
204 |
Collections.sort(log.events, sortByStart); |
|
205 |
||
206 |
return log.events; |
|
207 |
} |
|
208 |
||
209 |
String search(Attributes attr, String name) { |
|
210 |
return search(attr, name, null); |
|
211 |
} |
|
212 |
||
213 |
String search(Attributes attr, String name, String defaultValue) { |
|
214 |
String result = attr.getValue(name); |
|
215 |
if (result != null) { |
|
216 |
return result; |
|
217 |
} |
|
218 |
if (defaultValue != null) { |
|
219 |
return defaultValue; |
|
220 |
} |
|
221 |
for (int i = 0; i < attr.getLength(); i++) { |
|
222 |
System.out.println(attr.getQName(i) + " " + attr.getValue(attr.getQName(i))); |
|
223 |
} |
|
224 |
throw new InternalError("can't find " + name); |
|
225 |
} |
|
226 |
int indent = 0; |
|
227 |
String compile_id; |
|
228 |
||
229 |
String type(String id) { |
|
230 |
String result = types.get(id); |
|
231 |
if (result == null) { |
|
232 |
throw new InternalError(id); |
|
233 |
} |
|
234 |
String remapped = typeMap.get(result); |
|
235 |
if (remapped != null) { |
|
236 |
return remapped; |
|
237 |
} |
|
238 |
return result; |
|
239 |
} |
|
240 |
||
241 |
void type(String id, String name) { |
|
242 |
assert type(id) == null; |
|
243 |
types.put(id, name); |
|
244 |
} |
|
245 |
||
246 |
Method method(String id) { |
|
247 |
Method result = methods.get(id); |
|
248 |
if (result == null) { |
|
249 |
throw new InternalError(id); |
|
250 |
} |
|
251 |
return result; |
|
252 |
} |
|
253 |
||
254 |
public String makeId(Attributes atts) { |
|
255 |
String id = atts.getValue("compile_id"); |
|
256 |
String kind = atts.getValue("kind"); |
|
257 |
if (kind != null && kind.equals("osr")) { |
|
258 |
id += "%"; |
|
259 |
} |
|
260 |
return id; |
|
261 |
} |
|
262 |
||
263 |
@Override |
|
264 |
public void startElement(String uri, |
|
265 |
String localName, |
|
266 |
String qname, |
|
267 |
Attributes atts) { |
|
268 |
if (qname.equals("phase")) { |
|
269 |
Phase p = new Phase(search(atts, "name"), |
|
270 |
Double.parseDouble(search(atts, "stamp")), |
|
14623
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
11960
diff
changeset
|
271 |
Integer.parseInt(search(atts, "nodes")), |
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
11960
diff
changeset
|
272 |
Integer.parseInt(search(atts, "live"))); |
2126 | 273 |
phaseStack.push(p); |
274 |
} else if (qname.equals("phase_done")) { |
|
275 |
Phase p = phaseStack.pop(); |
|
14623
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
11960
diff
changeset
|
276 |
if (! p.getId().equals(search(atts, "name"))) { |
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
11960
diff
changeset
|
277 |
System.out.println("phase: " + p.getId()); |
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
11960
diff
changeset
|
278 |
throw new InternalError("phase name mismatch"); |
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
11960
diff
changeset
|
279 |
} |
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
11960
diff
changeset
|
280 |
p.setEnd(Double.parseDouble(search(atts, "stamp"))); |
2126 | 281 |
p.setEndNodes(Integer.parseInt(search(atts, "nodes"))); |
14623
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
11960
diff
changeset
|
282 |
p.setEndLiveNodes(Integer.parseInt(search(atts, "live"))); |
2126 | 283 |
compile.getPhases().add(p); |
284 |
} else if (qname.equals("task")) { |
|
285 |
compile = new Compilation(Integer.parseInt(search(atts, "compile_id", "-1"))); |
|
286 |
compile.setStart(Double.parseDouble(search(atts, "stamp"))); |
|
287 |
compile.setICount(search(atts, "count", "0")); |
|
288 |
compile.setBCount(search(atts, "backedge_count", "0")); |
|
289 |
||
290 |
String method = atts.getValue("method"); |
|
291 |
int space = method.indexOf(' '); |
|
292 |
method = method.substring(0, space) + "::" + |
|
293 |
method.substring(space + 1, method.indexOf(' ', space + 1) + 1); |
|
294 |
String compiler = atts.getValue("compiler"); |
|
295 |
if (compiler == null) { |
|
296 |
compiler = ""; |
|
297 |
} |
|
298 |
String kind = atts.getValue("compile_kind"); |
|
299 |
if (kind == null) { |
|
300 |
kind = "normal"; |
|
301 |
} |
|
302 |
if (kind.equals("osr")) { |
|
303 |
compile.setOsr(true); |
|
304 |
compile.setOsr_bci(Integer.parseInt(search(atts, "osr_bci"))); |
|
305 |
} else if (kind.equals("c2i")) { |
|
306 |
compile.setSpecial("--- adapter " + method); |
|
307 |
} else { |
|
308 |
compile.setSpecial(compile.getId() + " " + method + " (0 bytes)"); |
|
309 |
} |
|
310 |
events.add(compile); |
|
311 |
compiles.put(makeId(atts), compile); |
|
11960
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
312 |
site = compile.getCall(); |
2126 | 313 |
} else if (qname.equals("type")) { |
314 |
type(search(atts, "id"), search(atts, "name")); |
|
315 |
} else if (qname.equals("bc")) { |
|
316 |
bci = Integer.parseInt(search(atts, "bci")); |
|
317 |
} else if (qname.equals("klass")) { |
|
318 |
type(search(atts, "id"), search(atts, "name")); |
|
319 |
} else if (qname.equals("method")) { |
|
320 |
String id = search(atts, "id"); |
|
321 |
Method m = new Method(); |
|
322 |
m.setHolder(type(search(atts, "holder"))); |
|
323 |
m.setName(search(atts, "name")); |
|
324 |
m.setReturnType(type(search(atts, "return"))); |
|
325 |
m.setArguments(search(atts, "arguments", "void")); |
|
326 |
m.setBytes(search(atts, "bytes")); |
|
327 |
m.setIICount(search(atts, "iicount")); |
|
328 |
m.setFlags(search(atts, "flags")); |
|
329 |
methods.put(id, m); |
|
330 |
} else if (qname.equals("call")) { |
|
331 |
site = new CallSite(bci, method(search(atts, "method"))); |
|
332 |
site.setCount(Integer.parseInt(search(atts, "count"))); |
|
333 |
String receiver = atts.getValue("receiver"); |
|
334 |
if (receiver != null) { |
|
335 |
site.setReceiver(type(receiver)); |
|
336 |
site.setReceiver_count(Integer.parseInt(search(atts, "receiver_count"))); |
|
337 |
} |
|
338 |
scopes.peek().add(site); |
|
339 |
} else if (qname.equals("regalloc")) { |
|
340 |
compile.setAttempts(Integer.parseInt(search(atts, "attempts"))); |
|
341 |
} else if (qname.equals("inline_fail")) { |
|
342 |
scopes.peek().last().setReason(search(atts, "reason")); |
|
343 |
} else if (qname.equals("failure")) { |
|
344 |
failureReason = search(atts, "reason"); |
|
345 |
} else if (qname.equals("task_done")) { |
|
346 |
compile.setEnd(Double.parseDouble(search(atts, "stamp"))); |
|
347 |
if (Integer.parseInt(search(atts, "success")) == 0) { |
|
348 |
compile.setFailureReason(failureReason); |
|
349 |
} |
|
350 |
} else if (qname.equals("make_not_entrant")) { |
|
351 |
String id = makeId(atts); |
|
352 |
NMethod nm = nmethods.get(id); |
|
353 |
if (nm == null) throw new InternalError(); |
|
354 |
LogEvent e = new MakeNotEntrantEvent(Double.parseDouble(search(atts, "stamp")), id, |
|
355 |
atts.getValue("zombie") != null, nm); |
|
356 |
events.add(e); |
|
357 |
} else if (qname.equals("uncommon_trap")) { |
|
358 |
String id = atts.getValue("compile_id"); |
|
359 |
if (id != null) { |
|
360 |
id = makeId(atts); |
|
361 |
currentTrap = new UncommonTrapEvent(Double.parseDouble(search(atts, "stamp")), |
|
362 |
id, |
|
363 |
atts.getValue("reason"), |
|
364 |
atts.getValue("action"), |
|
365 |
Integer.parseInt(search(atts, "count", "0"))); |
|
366 |
events.add(currentTrap); |
|
367 |
} else { |
|
368 |
// uncommon trap inserted during parsing. |
|
369 |
// ignore for now |
|
370 |
} |
|
11960
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
371 |
} else if (qname.equals("late_inline")) { |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
372 |
late_inline_scope = new Stack<CallSite>(); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
373 |
site = new CallSite(-999, method(search(atts, "method"))); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
374 |
late_inline_scope.push(site); |
2126 | 375 |
} else if (qname.equals("jvms")) { |
376 |
// <jvms bci='4' method='java/io/DataInputStream readChar ()C' bytes='40' count='5815' iicount='20815'/> |
|
377 |
if (currentTrap != null) { |
|
378 |
currentTrap.addJVMS(atts.getValue("method"), Integer.parseInt(atts.getValue("bci"))); |
|
11960
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
379 |
} else if (late_inline_scope != null) { |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
380 |
bci = Integer.parseInt(search(atts, "bci")); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
381 |
site = new CallSite(bci, method(search(atts, "method"))); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
382 |
late_inline_scope.push(site); |
2126 | 383 |
} else { |
11960
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
384 |
// Ignore <eliminate_allocation type='667'>, |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
385 |
// <eliminate_lock lock='1'>, |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
386 |
// <replace_string_concat arguments='2' string_alloc='0' multiple='0'> |
2126 | 387 |
} |
388 |
} else if (qname.equals("nmethod")) { |
|
389 |
String id = makeId(atts); |
|
390 |
NMethod nm = new NMethod(Double.parseDouble(search(atts, "stamp")), |
|
391 |
id, |
|
392 |
parseLong(atts.getValue("address")), |
|
393 |
parseLong(atts.getValue("size"))); |
|
394 |
nmethods.put(id, nm); |
|
395 |
events.add(nm); |
|
396 |
} else if (qname.equals("parse")) { |
|
397 |
Method m = method(search(atts, "method")); |
|
398 |
if (scopes.size() == 0) { |
|
399 |
compile.setMethod(m); |
|
11960
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
400 |
scopes.push(site); |
2126 | 401 |
} else { |
402 |
if (site.getMethod() == m) { |
|
403 |
scopes.push(site); |
|
404 |
} else if (scopes.peek().getCalls().size() > 2 && m == scopes.peek().last(-2).getMethod()) { |
|
405 |
scopes.push(scopes.peek().last(-2)); |
|
406 |
} else { |
|
407 |
System.out.println(site.getMethod()); |
|
408 |
System.out.println(m); |
|
409 |
throw new InternalError("call site and parse don't match"); |
|
410 |
} |
|
411 |
} |
|
10563
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
412 |
} else if (qname.equals("parse_done")) { |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
413 |
CallSite call = scopes.pop(); |
11960
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
414 |
call.setEndNodes(Integer.parseInt(search(atts, "nodes", "1"))); |
14623
70c4c1be0a14
7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents:
11960
diff
changeset
|
415 |
call.setEndLiveNodes(Integer.parseInt(search(atts, "live", "1"))); |
10563
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
416 |
call.setTimeStamp(Double.parseDouble(search(atts, "stamp"))); |
b9b82ff9f0e9
7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents:
5547
diff
changeset
|
417 |
scopes.push(call); |
2126 | 418 |
} |
419 |
} |
|
420 |
||
421 |
@Override |
|
422 |
public void endElement(String uri, |
|
423 |
String localName, |
|
424 |
String qname) { |
|
425 |
if (qname.equals("parse")) { |
|
426 |
indent -= 2; |
|
427 |
scopes.pop(); |
|
428 |
} else if (qname.equals("uncommon_trap")) { |
|
429 |
currentTrap = null; |
|
11960
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
430 |
} else if (qname.equals("late_inline")) { |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
431 |
// Populate late inlining info. |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
432 |
|
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
433 |
// late_inline scopes are specified in reverse order: |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
434 |
// compiled method should be on top of stack. |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
435 |
CallSite caller = late_inline_scope.pop(); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
436 |
Method m = compile.getMethod(); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
437 |
if (m != caller.getMethod()) { |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
438 |
System.out.println(m); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
439 |
System.out.println(caller.getMethod() + " bci: " + bci); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
440 |
throw new InternalError("call site and late_inline info don't match"); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
441 |
} |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
442 |
|
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
443 |
// late_inline contains caller+bci info, convert it |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
444 |
// to bci+callee info used by LogCompilation. |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
445 |
site = compile.getLateInlineCall(); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
446 |
do { |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
447 |
bci = caller.getBci(); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
448 |
// Next inlined call. |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
449 |
caller = late_inline_scope.pop(); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
450 |
CallSite callee = new CallSite(bci, caller.getMethod()); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
451 |
site.add(callee); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
452 |
site = callee; |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
453 |
} while (!late_inline_scope.empty()); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
454 |
|
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
455 |
if (caller.getBci() != -999) { |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
456 |
System.out.println(caller.getMethod()); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
457 |
throw new InternalError("broken late_inline info"); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
458 |
} |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
459 |
if (site.getMethod() != caller.getMethod()) { |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
460 |
System.out.println(site.getMethod()); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
461 |
System.out.println(caller.getMethod()); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
462 |
throw new InternalError("call site and late_inline info don't match"); |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
463 |
} |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
464 |
// late_inline is followed by parse with scopes.size() == 0, |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
465 |
// 'site' will be pushed to scopes. |
57898a1b4b44
7147416: LogCompilation tool does not work with post parse inlining
kvn
parents:
10563
diff
changeset
|
466 |
late_inline_scope = null; |
2126 | 467 |
} else if (qname.equals("task")) { |
468 |
types.clear(); |
|
469 |
methods.clear(); |
|
470 |
site = null; |
|
471 |
} |
|
472 |
} |
|
473 |
||
474 |
@Override |
|
475 |
public void warning(org.xml.sax.SAXParseException e) { |
|
476 |
System.err.println(e.getMessage() + " at line " + e.getLineNumber() + ", column " + e.getColumnNumber()); |
|
477 |
e.printStackTrace(); |
|
478 |
} |
|
479 |
||
480 |
@Override |
|
481 |
public void error(org.xml.sax.SAXParseException e) { |
|
482 |
System.err.println(e.getMessage() + " at line " + e.getLineNumber() + ", column " + e.getColumnNumber()); |
|
483 |
e.printStackTrace(); |
|
484 |
} |
|
485 |
||
486 |
@Override |
|
487 |
public void fatalError(org.xml.sax.SAXParseException e) { |
|
488 |
System.err.println(e.getMessage() + " at line " + e.getLineNumber() + ", column " + e.getColumnNumber()); |
|
489 |
e.printStackTrace(); |
|
490 |
} |
|
491 |
} |