7147416: LogCompilation tool does not work with post parse inlining

Fri, 24 Feb 2012 12:33:31 -0800

author
kvn
date
Fri, 24 Feb 2012 12:33:31 -0800
changeset 3605
c7987cbaf2ca
parent 3604
9a72c7ece7fb
child 3606
da4be62fb889

7147416: LogCompilation tool does not work with post parse inlining
Summary: fixed few problems in LogCompilation parser.
Reviewed-by: never

src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java file | annotate | diff | comparison | revisions
src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java	Tue Feb 21 11:55:05 2012 -0800
     1.2 +++ b/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java	Fri Feb 24 12:33:31 2012 -0800
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -33,6 +33,7 @@
    1.11      private boolean osr;
    1.12      private Method method;
    1.13      private CallSite call = new CallSite();
    1.14 +    private CallSite lateInlineCall = new CallSite();
    1.15      private int osrBci;
    1.16      private String icount;
    1.17      private String bcount;
    1.18 @@ -80,6 +81,13 @@
    1.19              sb.append(site);
    1.20              sb.append("\n");
    1.21          }
    1.22 +        if (getLateInlineCall().getCalls() != null) {
    1.23 +            sb.append("late inline:\n");
    1.24 +            for (CallSite site : getLateInlineCall().getCalls()) {
    1.25 +                sb.append(site);
    1.26 +                sb.append("\n");
    1.27 +            }
    1.28 +        }
    1.29          return sb.toString();
    1.30      }
    1.31  
    1.32 @@ -115,6 +123,12 @@
    1.33                      site.print(stream, indent + 2);
    1.34                  }
    1.35              }
    1.36 +            if (printInlining && lateInlineCall.getCalls() != null) {
    1.37 +                stream.println("late inline:");
    1.38 +                for (CallSite site : lateInlineCall.getCalls()) {
    1.39 +                    site.print(stream, indent + 2);
    1.40 +                }
    1.41 +            }
    1.42          }
    1.43      }
    1.44  
    1.45 @@ -215,7 +229,11 @@
    1.46      }
    1.47  
    1.48      public void setMethod(Method method) {
    1.49 -        this.method = method;
    1.50 +        // Don't change method if it is already set to avoid changing
    1.51 +        // it by post parse inlining info.
    1.52 +        if (getMethod() == null) {
    1.53 +            this.method = method;
    1.54 +        }
    1.55      }
    1.56  
    1.57      public CallSite getCall() {
    1.58 @@ -226,6 +244,10 @@
    1.59          this.call = call;
    1.60      }
    1.61  
    1.62 +    public CallSite getLateInlineCall() {
    1.63 +        return lateInlineCall;
    1.64 +    }
    1.65 +
    1.66      public double getElapsedTime() {
    1.67          return end - start;
    1.68      }
     2.1 --- a/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java	Tue Feb 21 11:55:05 2012 -0800
     2.2 +++ b/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java	Fri Feb 24 12:33:31 2012 -0800
     2.3 @@ -1,5 +1,5 @@
     2.4  /*
     2.5 - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
     2.6 + * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
     2.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.8   *
     2.9   * This code is free software; you can redistribute it and/or modify it
    2.10 @@ -146,6 +146,7 @@
    2.11      private CallSite site;
    2.12      private Stack<Phase> phaseStack = new Stack<Phase>();
    2.13      private UncommonTrapEvent currentTrap;
    2.14 +    private Stack<CallSite> late_inline_scope;
    2.15  
    2.16      long parseLong(String l) {
    2.17          try {
    2.18 @@ -302,6 +303,7 @@
    2.19              }
    2.20              events.add(compile);
    2.21              compiles.put(makeId(atts), compile);
    2.22 +            site = compile.getCall();
    2.23          } else if (qname.equals("type")) {
    2.24              type(search(atts, "id"), search(atts, "name"));
    2.25          } else if (qname.equals("bc")) {
    2.26 @@ -360,12 +362,22 @@
    2.27                  // uncommon trap inserted during parsing.
    2.28                  // ignore for now
    2.29              }
    2.30 +        } else if (qname.equals("late_inline")) {
    2.31 +            late_inline_scope = new Stack<CallSite>();
    2.32 +            site = new CallSite(-999, method(search(atts, "method")));
    2.33 +            late_inline_scope.push(site);
    2.34          } else if (qname.equals("jvms")) {
    2.35              // <jvms bci='4' method='java/io/DataInputStream readChar ()C' bytes='40' count='5815' iicount='20815'/>
    2.36              if (currentTrap != null) {
    2.37                  currentTrap.addJVMS(atts.getValue("method"), Integer.parseInt(atts.getValue("bci")));
    2.38 +            } else if (late_inline_scope != null) {
    2.39 +                bci = Integer.parseInt(search(atts, "bci"));
    2.40 +                site = new CallSite(bci, method(search(atts, "method")));
    2.41 +                late_inline_scope.push(site);
    2.42              } else {
    2.43 -                // Ignore <eliminate_allocation type='667'> and <eliminate_lock lock='1'>
    2.44 +                // Ignore <eliminate_allocation type='667'>,
    2.45 +                //        <eliminate_lock lock='1'>,
    2.46 +                //        <replace_string_concat arguments='2' string_alloc='0' multiple='0'>
    2.47              }
    2.48          } else if (qname.equals("nmethod")) {
    2.49              String id = makeId(atts);
    2.50 @@ -379,7 +391,7 @@
    2.51              Method m = method(search(atts, "method"));
    2.52              if (scopes.size() == 0) {
    2.53                  compile.setMethod(m);
    2.54 -                scopes.push(compile.getCall());
    2.55 +                scopes.push(site);
    2.56              } else {
    2.57                  if (site.getMethod() == m) {
    2.58                      scopes.push(site);
    2.59 @@ -393,7 +405,7 @@
    2.60              }
    2.61          } else if (qname.equals("parse_done")) {
    2.62              CallSite call = scopes.pop();
    2.63 -            call.setEndNodes(Integer.parseInt(search(atts, "nodes")));
    2.64 +            call.setEndNodes(Integer.parseInt(search(atts, "nodes", "1")));
    2.65              call.setTimeStamp(Double.parseDouble(search(atts, "stamp")));
    2.66              scopes.push(call);
    2.67          }
    2.68 @@ -408,6 +420,43 @@
    2.69              scopes.pop();
    2.70          } else if (qname.equals("uncommon_trap")) {
    2.71              currentTrap = null;
    2.72 +        } else if (qname.equals("late_inline")) {
    2.73 +            // Populate late inlining info.
    2.74 +
    2.75 +            // late_inline scopes are specified in reverse order:
    2.76 +            // compiled method should be on top of stack.
    2.77 +            CallSite caller = late_inline_scope.pop();
    2.78 +            Method m = compile.getMethod();
    2.79 +            if (m != caller.getMethod()) {
    2.80 +                System.out.println(m);
    2.81 +                System.out.println(caller.getMethod() + " bci: " + bci);
    2.82 +                throw new InternalError("call site and late_inline info don't match");
    2.83 +            }
    2.84 +
    2.85 +            // late_inline contains caller+bci info, convert it
    2.86 +            // to bci+callee info used by LogCompilation.
    2.87 +            site = compile.getLateInlineCall();
    2.88 +            do {
    2.89 +                bci = caller.getBci();
    2.90 +                // Next inlined call.
    2.91 +                caller = late_inline_scope.pop();
    2.92 +                CallSite callee =  new CallSite(bci, caller.getMethod());
    2.93 +                site.add(callee);
    2.94 +                site = callee;
    2.95 +            } while (!late_inline_scope.empty());
    2.96 +
    2.97 +            if (caller.getBci() != -999) {
    2.98 +                System.out.println(caller.getMethod());
    2.99 +                throw new InternalError("broken late_inline info");
   2.100 +            }
   2.101 +            if (site.getMethod() != caller.getMethod()) {
   2.102 +                System.out.println(site.getMethod());
   2.103 +                System.out.println(caller.getMethod());
   2.104 +                throw new InternalError("call site and late_inline info don't match");
   2.105 +            }
   2.106 +            // late_inline is followed by parse with scopes.size() == 0,
   2.107 +            // 'site' will be pushed to scopes.
   2.108 +            late_inline_scope = null;
   2.109          } else if (qname.equals("task")) {
   2.110              types.clear();
   2.111              methods.clear();

mercurial