378 }
379 if (lateInlining && scopes.size() == 0) {
380 site.setReason(search(atts, "reason"));
381 lateInlining = false;
382 } else {
383 scopes.peek().last().setReason(search(atts, "reason"));
384 }
385 } else if (qname.equals("inline_success")) {
386 if (methodHandleSite != null) {
387 throw new InternalError("method handle site should have been replaced");
388 }
389 if (lateInlining && scopes.size() == 0) {
390 site.setReason(null);
391 }
392 } else if (qname.equals("failure")) {
393 failureReason = search(atts, "reason");
394 } else if (qname.equals("task_done")) {
395 compile.setEnd(Double.parseDouble(search(atts, "stamp")));
396 if (Integer.parseInt(search(atts, "success")) == 0) {
397 compile.setFailureReason(failureReason);
398 }
399 } else if (qname.equals("make_not_entrant")) {
400 String id = makeId(atts);
401 NMethod nm = nmethods.get(id);
402 if (nm == null) throw new InternalError();
403 LogEvent e = new MakeNotEntrantEvent(Double.parseDouble(search(atts, "stamp")), id,
404 atts.getValue("zombie") != null, nm);
405 events.add(e);
406 } else if (qname.equals("uncommon_trap")) {
407 String id = atts.getValue("compile_id");
408 if (id != null) {
409 id = makeId(atts);
410 currentTrap = new UncommonTrapEvent(Double.parseDouble(search(atts, "stamp")),
411 id,
412 atts.getValue("reason"),
413 atts.getValue("action"),
414 Integer.parseInt(search(atts, "count", "0")));
415 events.add(currentTrap);
416 } else {
417 // uncommon trap inserted during parsing.
434 } else {
435 // Ignore <eliminate_allocation type='667'>,
436 // <eliminate_lock lock='1'>,
437 // <replace_string_concat arguments='2' string_alloc='0' multiple='0'>
438 }
439 } else if (qname.equals("inline_id")) {
440 if (methodHandleSite != null) {
441 throw new InternalError("method handle site should have been replaced");
442 }
443 long id = Long.parseLong(search(atts, "id"));
444 site.setInlineId(id);
445 } else if (qname.equals("nmethod")) {
446 String id = makeId(atts);
447 NMethod nm = new NMethod(Double.parseDouble(search(atts, "stamp")),
448 id,
449 parseLong(atts.getValue("address")),
450 parseLong(atts.getValue("size")));
451 nmethods.put(id, nm);
452 events.add(nm);
453 } else if (qname.equals("parse")) {
454 if (methodHandleSite != null) {
455 throw new InternalError("method handle site should have been replaced");
456 }
457 Method m = method(search(atts, "method"));
458 if (lateInlining && scopes.size() == 0) {
459 if (site.getMethod() != m) {
460 System.out.println(site.getMethod());
461 System.out.println(m);
462 throw new InternalError("Unexpected method mismatch during late inlining");
463 }
464 }
465 if (scopes.size() == 0 && !lateInlining) {
466 compile.setMethod(m);
467 scopes.push(site);
468 } else {
469 if (site.getMethod() == m) {
470 scopes.push(site);
471 } else if (scopes.peek().getCalls().size() > 2 && m == scopes.peek().last(-2).getMethod()) {
472 scopes.push(scopes.peek().last(-2));
473 } else {
512 throw new InternalError("call site and late_inline info don't match");
513 }
514
515 // late_inline contains caller+bci info, convert it
516 // to bci+callee info used by LogCompilation.
517 CallSite lateInlineSite = compile.getLateInlineCall();
518 ArrayDeque<CallSite> thisCallScopes = new ArrayDeque<CallSite>();
519 do {
520 bci = caller.getBci();
521 // Next inlined call.
522 caller = lateInlineScope.pop();
523 CallSite callee = new CallSite(bci, caller.getMethod());
524 callee.setInlineId(caller.getInlineId());
525 thisCallScopes.addLast(callee);
526 lateInlineSite.add(callee);
527 lateInlineSite = callee;
528 } while (!lateInlineScope.empty());
529
530 site = compile.getCall().findCallSite(thisCallScopes);
531 if (site == null) {
532 System.out.println(caller.getMethod() + " bci: " + bci);
533 throw new InternalError("couldn't find call site");
534 }
535 lateInlining = true;
536
537 if (caller.getBci() != -999) {
538 System.out.println(caller.getMethod());
539 throw new InternalError("broken late_inline info");
540 }
541 if (site.getMethod() != caller.getMethod()) {
542 if (site.getInlineId() == caller.getInlineId()) {
543 site.setMethod(caller.getMethod());
544 } else {
545 System.out.println(site.getMethod());
546 System.out.println(caller.getMethod());
547 throw new InternalError("call site and late_inline info don't match");
548 }
549 }
550 // late_inline is followed by parse with scopes.size() == 0,
551 // 'site' will be pushed to scopes.
|
378 }
379 if (lateInlining && scopes.size() == 0) {
380 site.setReason(search(atts, "reason"));
381 lateInlining = false;
382 } else {
383 scopes.peek().last().setReason(search(atts, "reason"));
384 }
385 } else if (qname.equals("inline_success")) {
386 if (methodHandleSite != null) {
387 throw new InternalError("method handle site should have been replaced");
388 }
389 if (lateInlining && scopes.size() == 0) {
390 site.setReason(null);
391 }
392 } else if (qname.equals("failure")) {
393 failureReason = search(atts, "reason");
394 } else if (qname.equals("task_done")) {
395 compile.setEnd(Double.parseDouble(search(atts, "stamp")));
396 if (Integer.parseInt(search(atts, "success")) == 0) {
397 compile.setFailureReason(failureReason);
398 failureReason = null;
399 }
400 } else if (qname.equals("make_not_entrant")) {
401 String id = makeId(atts);
402 NMethod nm = nmethods.get(id);
403 if (nm == null) throw new InternalError();
404 LogEvent e = new MakeNotEntrantEvent(Double.parseDouble(search(atts, "stamp")), id,
405 atts.getValue("zombie") != null, nm);
406 events.add(e);
407 } else if (qname.equals("uncommon_trap")) {
408 String id = atts.getValue("compile_id");
409 if (id != null) {
410 id = makeId(atts);
411 currentTrap = new UncommonTrapEvent(Double.parseDouble(search(atts, "stamp")),
412 id,
413 atts.getValue("reason"),
414 atts.getValue("action"),
415 Integer.parseInt(search(atts, "count", "0")));
416 events.add(currentTrap);
417 } else {
418 // uncommon trap inserted during parsing.
435 } else {
436 // Ignore <eliminate_allocation type='667'>,
437 // <eliminate_lock lock='1'>,
438 // <replace_string_concat arguments='2' string_alloc='0' multiple='0'>
439 }
440 } else if (qname.equals("inline_id")) {
441 if (methodHandleSite != null) {
442 throw new InternalError("method handle site should have been replaced");
443 }
444 long id = Long.parseLong(search(atts, "id"));
445 site.setInlineId(id);
446 } else if (qname.equals("nmethod")) {
447 String id = makeId(atts);
448 NMethod nm = new NMethod(Double.parseDouble(search(atts, "stamp")),
449 id,
450 parseLong(atts.getValue("address")),
451 parseLong(atts.getValue("size")));
452 nmethods.put(id, nm);
453 events.add(nm);
454 } else if (qname.equals("parse")) {
455 if (failureReason != null && scopes.size() == 0 && !lateInlining) {
456 failureReason = null;
457 compile.reset();
458 site = compile.getCall();
459 }
460
461 if (methodHandleSite != null) {
462 throw new InternalError("method handle site should have been replaced");
463 }
464 Method m = method(search(atts, "method"));
465 if (lateInlining && scopes.size() == 0) {
466 if (site.getMethod() != m) {
467 System.out.println(site.getMethod());
468 System.out.println(m);
469 throw new InternalError("Unexpected method mismatch during late inlining");
470 }
471 }
472 if (scopes.size() == 0 && !lateInlining) {
473 compile.setMethod(m);
474 scopes.push(site);
475 } else {
476 if (site.getMethod() == m) {
477 scopes.push(site);
478 } else if (scopes.peek().getCalls().size() > 2 && m == scopes.peek().last(-2).getMethod()) {
479 scopes.push(scopes.peek().last(-2));
480 } else {
519 throw new InternalError("call site and late_inline info don't match");
520 }
521
522 // late_inline contains caller+bci info, convert it
523 // to bci+callee info used by LogCompilation.
524 CallSite lateInlineSite = compile.getLateInlineCall();
525 ArrayDeque<CallSite> thisCallScopes = new ArrayDeque<CallSite>();
526 do {
527 bci = caller.getBci();
528 // Next inlined call.
529 caller = lateInlineScope.pop();
530 CallSite callee = new CallSite(bci, caller.getMethod());
531 callee.setInlineId(caller.getInlineId());
532 thisCallScopes.addLast(callee);
533 lateInlineSite.add(callee);
534 lateInlineSite = callee;
535 } while (!lateInlineScope.empty());
536
537 site = compile.getCall().findCallSite(thisCallScopes);
538 if (site == null) {
539 System.out.println("call scopes:");
540 for (CallSite c : thisCallScopes) {
541 System.out.println(c.getMethod() + " " + c.getBci() + " " + c.getInlineId());
542 }
543 CallSite c = thisCallScopes.getLast();
544 if (c.getInlineId() != 0) {
545 System.out.println("Looking for call site in entire tree:");
546 ArrayDeque<CallSite> stack = compile.getCall().findCallSite2(c);
547 for (CallSite c2 : stack) {
548 System.out.println(c2.getMethod() + " " + c2.getBci() + " " + c2.getInlineId());
549 }
550 }
551 System.out.println(caller.getMethod() + " bci: " + bci);
552 throw new InternalError("couldn't find call site");
553 }
554 lateInlining = true;
555
556 if (caller.getBci() != -999) {
557 System.out.println(caller.getMethod());
558 throw new InternalError("broken late_inline info");
559 }
560 if (site.getMethod() != caller.getMethod()) {
561 if (site.getInlineId() == caller.getInlineId()) {
562 site.setMethod(caller.getMethod());
563 } else {
564 System.out.println(site.getMethod());
565 System.out.println(caller.getMethod());
566 throw new InternalError("call site and late_inline info don't match");
567 }
568 }
569 // late_inline is followed by parse with scopes.size() == 0,
570 // 'site' will be pushed to scopes.
|