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
228 String type(String id) {
229 String result = types.get(id);
230 if (result == null) {
231 throw new InternalError(id);
232 }
233 String remapped = typeMap.get(result);
234 if (remapped != null) {
235 return remapped;
236 }
237 return result;
238 }
239
240 void type(String id, String name) {
241 assert type(id) == null;
242 types.put(id, name);
243 }
244
245 Method method(String id) {
251 }
252
253 public String makeId(Attributes atts) {
254 String id = atts.getValue("compile_id");
255 String kind = atts.getValue("kind");
256 if (kind != null && kind.equals("osr")) {
257 id += "%";
258 }
259 return id;
260 }
261
262 @Override
263 public void startElement(String uri,
264 String localName,
265 String qname,
266 Attributes atts) {
267 if (qname.equals("phase")) {
268 Phase p = new Phase(search(atts, "name"),
269 Double.parseDouble(search(atts, "stamp")),
270 Integer.parseInt(search(atts, "nodes", "0")),
271 Integer.parseInt(search(atts, "live")));
272 phaseStack.push(p);
273 } else if (qname.equals("phase_done")) {
274 Phase p = phaseStack.pop();
275 if (! p.getId().equals(search(atts, "name"))) {
276 System.out.println("phase: " + p.getId());
277 throw new InternalError("phase name mismatch");
278 }
279 p.setEnd(Double.parseDouble(search(atts, "stamp")));
280 p.setEndNodes(Integer.parseInt(search(atts, "nodes", "0")));
281 p.setEndLiveNodes(Integer.parseInt(search(atts, "live")));
282 compile.getPhases().add(p);
283 } else if (qname.equals("task")) {
284 compile = new Compilation(Integer.parseInt(search(atts, "compile_id", "-1")));
285 compile.setStart(Double.parseDouble(search(atts, "stamp")));
286 compile.setICount(search(atts, "count", "0"));
287 compile.setBCount(search(atts, "backedge_count", "0"));
288
289 String method = atts.getValue("method");
290 int space = method.indexOf(' ');
291 method = method.substring(0, space) + "::" +
292 method.substring(space + 1, method.indexOf(' ', space + 1) + 1);
293 String compiler = atts.getValue("compiler");
294 if (compiler == null) {
295 compiler = "";
296 }
297 String kind = atts.getValue("compile_kind");
298 if (kind == null) {
299 kind = "normal";
300 }
301 if (kind.equals("osr")) {
396 nmethods.put(id, nm);
397 events.add(nm);
398 } else if (qname.equals("parse")) {
399 Method m = method(search(atts, "method"));
400 if (scopes.size() == 0) {
401 compile.setMethod(m);
402 scopes.push(site);
403 } else {
404 if (site.getMethod() == m) {
405 scopes.push(site);
406 } else if (scopes.peek().getCalls().size() > 2 && m == scopes.peek().last(-2).getMethod()) {
407 scopes.push(scopes.peek().last(-2));
408 } else {
409 System.out.println(site.getMethod());
410 System.out.println(m);
411 throw new InternalError("call site and parse don't match");
412 }
413 }
414 } else if (qname.equals("parse_done")) {
415 CallSite call = scopes.pop();
416 call.setEndNodes(Integer.parseInt(search(atts, "nodes", "1")));
417 call.setEndLiveNodes(Integer.parseInt(search(atts, "live", "1")));
418 call.setTimeStamp(Double.parseDouble(search(atts, "stamp")));
419 scopes.push(call);
420 }
421 }
422
423 @Override
424 public void endElement(String uri,
425 String localName,
426 String qname) {
427 if (qname.equals("parse")) {
428 indent -= 2;
429 scopes.pop();
430 } else if (qname.equals("uncommon_trap")) {
431 currentTrap = null;
432 } else if (qname.equals("late_inline")) {
433 // Populate late inlining info.
434
435 // late_inline scopes are specified in reverse order:
436 // compiled method should be on top of stack.
437 CallSite caller = late_inline_scope.pop();
|
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 String result = attr.getValue(name);
211 if (result != null) {
212 return result;
213 } else {
214 throw new InternalError("can't find " + name);
215 }
216 }
217
218 String search(Attributes attr, String name, String defaultValue) {
219 String result = attr.getValue(name);
220 if (result != null) {
221 return result;
222 }
223 return defaultValue;
224 }
225 int indent = 0;
226
227 String type(String id) {
228 String result = types.get(id);
229 if (result == null) {
230 throw new InternalError(id);
231 }
232 String remapped = typeMap.get(result);
233 if (remapped != null) {
234 return remapped;
235 }
236 return result;
237 }
238
239 void type(String id, String name) {
240 assert type(id) == null;
241 types.put(id, name);
242 }
243
244 Method method(String id) {
250 }
251
252 public String makeId(Attributes atts) {
253 String id = atts.getValue("compile_id");
254 String kind = atts.getValue("kind");
255 if (kind != null && kind.equals("osr")) {
256 id += "%";
257 }
258 return id;
259 }
260
261 @Override
262 public void startElement(String uri,
263 String localName,
264 String qname,
265 Attributes atts) {
266 if (qname.equals("phase")) {
267 Phase p = new Phase(search(atts, "name"),
268 Double.parseDouble(search(atts, "stamp")),
269 Integer.parseInt(search(atts, "nodes", "0")),
270 Integer.parseInt(search(atts, "live", "0")));
271 phaseStack.push(p);
272 } else if (qname.equals("phase_done")) {
273 Phase p = phaseStack.pop();
274 String phaseName = search(atts, "name", null);
275 if (phaseName != null && !p.getId().equals(phaseName)) {
276 System.out.println("phase: " + p.getId());
277 throw new InternalError("phase name mismatch");
278 }
279 p.setEnd(Double.parseDouble(search(atts, "stamp")));
280 p.setEndNodes(Integer.parseInt(search(atts, "nodes", "0")));
281 p.setEndLiveNodes(Integer.parseInt(search(atts, "live", "0")));
282 compile.getPhases().add(p);
283 } else if (qname.equals("task")) {
284 compile = new Compilation(Integer.parseInt(search(atts, "compile_id", "-1")));
285 compile.setStart(Double.parseDouble(search(atts, "stamp")));
286 compile.setICount(search(atts, "count", "0"));
287 compile.setBCount(search(atts, "backedge_count", "0"));
288
289 String method = atts.getValue("method");
290 int space = method.indexOf(' ');
291 method = method.substring(0, space) + "::" +
292 method.substring(space + 1, method.indexOf(' ', space + 1) + 1);
293 String compiler = atts.getValue("compiler");
294 if (compiler == null) {
295 compiler = "";
296 }
297 String kind = atts.getValue("compile_kind");
298 if (kind == null) {
299 kind = "normal";
300 }
301 if (kind.equals("osr")) {
396 nmethods.put(id, nm);
397 events.add(nm);
398 } else if (qname.equals("parse")) {
399 Method m = method(search(atts, "method"));
400 if (scopes.size() == 0) {
401 compile.setMethod(m);
402 scopes.push(site);
403 } else {
404 if (site.getMethod() == m) {
405 scopes.push(site);
406 } else if (scopes.peek().getCalls().size() > 2 && m == scopes.peek().last(-2).getMethod()) {
407 scopes.push(scopes.peek().last(-2));
408 } else {
409 System.out.println(site.getMethod());
410 System.out.println(m);
411 throw new InternalError("call site and parse don't match");
412 }
413 }
414 } else if (qname.equals("parse_done")) {
415 CallSite call = scopes.pop();
416 call.setEndNodes(Integer.parseInt(search(atts, "nodes", "0")));
417 call.setEndLiveNodes(Integer.parseInt(search(atts, "live", "0")));
418 call.setTimeStamp(Double.parseDouble(search(atts, "stamp")));
419 scopes.push(call);
420 }
421 }
422
423 @Override
424 public void endElement(String uri,
425 String localName,
426 String qname) {
427 if (qname.equals("parse")) {
428 indent -= 2;
429 scopes.pop();
430 } else if (qname.equals("uncommon_trap")) {
431 currentTrap = null;
432 } else if (qname.equals("late_inline")) {
433 // Populate late inlining info.
434
435 // late_inline scopes are specified in reverse order:
436 // compiled method should be on top of stack.
437 CallSite caller = late_inline_scope.pop();
|