Skip to content

Commit

Permalink
Add recent updates from OpenJDK.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Feb 8, 2013
1 parent 5a705e4 commit f3807d9
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 27 deletions.
6 changes: 3 additions & 3 deletions README
Expand Up @@ -13,6 +13,6 @@ Adding the -i option with also report inlining like PrintInlining.


More information about the LogCompilation output can be found at More information about the LogCompilation output can be found at


http://wikis.sun.com/display/HotSpotInternals/LogCompilation+overview https://wikis.oracle.com/display/HotSpotInternals/LogCompilation+overview
http://wikis.sun.com/display/HotSpotInternals/PrintCompilation https://wikis.oracle.com/display/HotSpotInternals/PrintCompilation
http://wikis.sun.com/display/HotSpotInternals/LogCompilation+tool https://wikis.oracle.com/display/HotSpotInternals/LogCompilation+tool
42 changes: 37 additions & 5 deletions src/com/sun/hotspot/tools/compiler/CallSite.java
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -37,6 +37,9 @@ public class CallSite {
private int receiver_count; private int receiver_count;
private String reason; private String reason;
private List<CallSite> calls; private List<CallSite> calls;
private int endNodes;
private int endLiveNodes;
private double timeStamp;


CallSite() { CallSite() {
} }
Expand Down Expand Up @@ -93,18 +96,22 @@ public void print(PrintStream stream, int indent) {
emit(stream, indent); emit(stream, indent);
String m = getMethod().getHolder().replace('/', '.') + "::" + getMethod().getName(); String m = getMethod().getHolder().replace('/', '.') + "::" + getMethod().getName();
if (getReason() == null) { if (getReason() == null) {
stream.println(" @ " + getBci() + " " + m + " (" + getMethod().getBytes() + " bytes)"); stream.print(" @ " + getBci() + " " + m + " (" + getMethod().getBytes() + " bytes)");


} else { } else {
if (isCompat()) { if (isCompat()) {
stream.println(" @ " + getBci() + " " + m + " " + getReason()); stream.print(" @ " + getBci() + " " + m + " " + getReason());
} else { } else {
stream.println("- @ " + getBci() + " " + m + stream.print("- @ " + getBci() + " " + m +
" (" + getMethod().getBytes() + " bytes) " + getReason()); " (" + getMethod().getBytes() + " bytes) " + getReason());
} }
} }
if (getEndNodes() > 0) {
stream.printf(" (end time: %6.4f nodes: %d live: %d)", getTimeStamp(), getEndNodes(), getEndLiveNodes());
}
stream.println("");
if (getReceiver() != null) { if (getReceiver() != null) {
emit(stream, indent + 3); emit(stream, indent + 4);
// stream.println("type profile " + method.holder + " -> " + receiver + " (" + // stream.println("type profile " + method.holder + " -> " + receiver + " (" +
// receiver_count + "/" + count + "," + (receiver_count * 100 / count) + "%)"); // receiver_count + "/" + count + "," + (receiver_count * 100 / count) + "%)");
stream.println("type profile " + getMethod().getHolder() + " -> " + getReceiver() + " (" + stream.println("type profile " + getMethod().getHolder() + " -> " + getReceiver() + " (" +
Expand Down Expand Up @@ -180,4 +187,29 @@ public static boolean isCompat() {
public static void setCompat(boolean aCompat) { public static void setCompat(boolean aCompat) {
compat = aCompat; compat = aCompat;
} }

void setEndNodes(int n) {
endNodes = n;
}

public int getEndNodes() {
return endNodes;
}

void setEndLiveNodes(int n) {
endLiveNodes = n;
}

public int getEndLiveNodes() {
return endLiveNodes;
}

void setTimeStamp(double time) {
timeStamp = time;
}

public double getTimeStamp() {
return timeStamp;
}

} }
26 changes: 24 additions & 2 deletions src/com/sun/hotspot/tools/compiler/Compilation.java
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -33,6 +33,7 @@ public class Compilation implements LogEvent {
private boolean osr; private boolean osr;
private Method method; private Method method;
private CallSite call = new CallSite(); private CallSite call = new CallSite();
private CallSite lateInlineCall = new CallSite();
private int osrBci; private int osrBci;
private String icount; private String icount;
private String bcount; private String bcount;
Expand Down Expand Up @@ -80,6 +81,13 @@ public String toString() {
sb.append(site); sb.append(site);
sb.append("\n"); sb.append("\n");
} }
if (getLateInlineCall().getCalls() != null) {
sb.append("late inline:\n");
for (CallSite site : getLateInlineCall().getCalls()) {
sb.append(site);
sb.append("\n");
}
}
return sb.toString(); return sb.toString();
} }


Expand Down Expand Up @@ -115,6 +123,12 @@ public void print(PrintStream stream, int indent, boolean printInlining) {
site.print(stream, indent + 2); site.print(stream, indent + 2);
} }
} }
if (printInlining && lateInlineCall.getCalls() != null) {
stream.println("late inline:");
for (CallSite site : lateInlineCall.getCalls()) {
site.print(stream, indent + 2);
}
}
} }
} }


Expand Down Expand Up @@ -215,7 +229,11 @@ public Method getMethod() {
} }


public void setMethod(Method method) { public void setMethod(Method method) {
this.method = method; // Don't change method if it is already set to avoid changing
// it by post parse inlining info.
if (getMethod() == null) {
this.method = method;
}
} }


public CallSite getCall() { public CallSite getCall() {
Expand All @@ -226,6 +244,10 @@ public void setCall(CallSite call) {
this.call = call; this.call = call;
} }


public CallSite getLateInlineCall() {
return lateInlineCall;
}

public double getElapsedTime() { public double getElapsedTime() {
return end - start; return end - start;
} }
Expand Down
12 changes: 8 additions & 4 deletions src/com/sun/hotspot/tools/compiler/LogCompilation.java
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -37,13 +37,13 @@
public class LogCompilation extends DefaultHandler implements ErrorHandler, Constants { public class LogCompilation extends DefaultHandler implements ErrorHandler, Constants {


public static void usage(int exitcode) { public static void usage(int exitcode) {
System.out.println("Usage: LogCompilation [ -v ] [ -c ] [ -s ] [ -e | -N ] file1 ..."); System.out.println("Usage: LogCompilation [ -v ] [ -c ] [ -s ] [ -e | -n ] file1 ...");
System.out.println(" -c: clean up malformed 1.5 xml"); System.out.println(" -c: clean up malformed 1.5 xml");
System.out.println(" -i: print inlining decisions"); System.out.println(" -i: print inlining decisions");
System.out.println(" -S: print compilation statistics"); System.out.println(" -S: print compilation statistics");
System.out.println(" -s: sort events by start time"); System.out.println(" -s: sort events by start time");
System.out.println(" -e: sort events by elapsed time"); System.out.println(" -e: sort events by elapsed time");
System.out.println(" -N: sort events by name and start"); System.out.println(" -n: sort events by name and start");
System.exit(exitcode); System.exit(exitcode);
} }


Expand Down Expand Up @@ -126,7 +126,6 @@ public static void printStatistics(ArrayList<LogEvent> events, PrintStream out)
maxattempts = Math.max(maxattempts,c.getAttempts()); maxattempts = Math.max(maxattempts,c.getAttempts());
elapsed += c.getElapsedTime(); elapsed += c.getElapsedTime();
for (Phase phase : c.getPhases()) { for (Phase phase : c.getPhases()) {
out.printf("\t%s %6.4f\n", phase.getName(), phase.getElapsedTime());
Double v = phaseTime.get(phase.getName()); Double v = phaseTime.get(phase.getName());
if (v == null) { if (v == null) {
v = Double.valueOf(0.0); v = Double.valueOf(0.0);
Expand All @@ -138,6 +137,11 @@ public static void printStatistics(ArrayList<LogEvent> events, PrintStream out)
v2 = Integer.valueOf(0); v2 = Integer.valueOf(0);
} }
phaseNodes.put(phase.getName(), Integer.valueOf(v2.intValue() + phase.getNodes())); phaseNodes.put(phase.getName(), Integer.valueOf(v2.intValue() + phase.getNodes()));
/* Print phase name, elapsed time, nodes at the start of the phase,
nodes created in the phase, live nodes at the start of the phase,
live nodes added in the phase.
*/
out.printf("\t%s %6.4f %d %d %d %d\n", phase.getName(), phase.getElapsedTime(), phase.getStartNodes(), phase.getNodes(), phase.getStartLiveNodes(), phase.getLiveNodes());
} }
} else if (e instanceof MakeNotEntrantEvent) { } else if (e instanceof MakeNotEntrantEvent) {
MakeNotEntrantEvent mne = (MakeNotEntrantEvent) e; MakeNotEntrantEvent mne = (MakeNotEntrantEvent) e;
Expand Down
83 changes: 73 additions & 10 deletions src/com/sun/hotspot/tools/compiler/LogParser.java
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -146,6 +146,7 @@ public int hashCode() {
private CallSite site; private CallSite site;
private Stack<Phase> phaseStack = new Stack<Phase>(); private Stack<Phase> phaseStack = new Stack<Phase>();
private UncommonTrapEvent currentTrap; private UncommonTrapEvent currentTrap;
private Stack<CallSite> late_inline_scope;


long parseLong(String l) { long parseLong(String l) {
try { try {
Expand Down Expand Up @@ -223,7 +224,6 @@ String search(Attributes attr, String name, String defaultValue) {
throw new InternalError("can't find " + name); throw new InternalError("can't find " + name);
} }
int indent = 0; int indent = 0;
String compile_id;


String type(String id) { String type(String id) {
String result = types.get(id); String result = types.get(id);
Expand Down Expand Up @@ -267,12 +267,18 @@ public void startElement(String uri,
if (qname.equals("phase")) { if (qname.equals("phase")) {
Phase p = new Phase(search(atts, "name"), Phase p = new Phase(search(atts, "name"),
Double.parseDouble(search(atts, "stamp")), Double.parseDouble(search(atts, "stamp")),
Integer.parseInt(search(atts, "nodes"))); Integer.parseInt(search(atts, "nodes", "0")),
Integer.parseInt(search(atts, "live")));
phaseStack.push(p); phaseStack.push(p);
} else if (qname.equals("phase_done")) { } else if (qname.equals("phase_done")) {
Phase p = phaseStack.pop(); Phase p = phaseStack.pop();
p.setEndNodes(Integer.parseInt(search(atts, "nodes"))); if (! p.getId().equals(search(atts, "name"))) {
System.out.println("phase: " + p.getId());
throw new InternalError("phase name mismatch");
}
p.setEnd(Double.parseDouble(search(atts, "stamp"))); p.setEnd(Double.parseDouble(search(atts, "stamp")));
p.setEndNodes(Integer.parseInt(search(atts, "nodes", "0")));
p.setEndLiveNodes(Integer.parseInt(search(atts, "live")));
compile.getPhases().add(p); compile.getPhases().add(p);
} else if (qname.equals("task")) { } else if (qname.equals("task")) {
compile = new Compilation(Integer.parseInt(search(atts, "compile_id", "-1"))); compile = new Compilation(Integer.parseInt(search(atts, "compile_id", "-1")));
Expand Down Expand Up @@ -302,6 +308,7 @@ public void startElement(String uri,
} }
events.add(compile); events.add(compile);
compiles.put(makeId(atts), compile); compiles.put(makeId(atts), compile);
site = compile.getCall();
} else if (qname.equals("type")) { } else if (qname.equals("type")) {
type(search(atts, "id"), search(atts, "name")); type(search(atts, "id"), search(atts, "name"));
} else if (qname.equals("bc")) { } else if (qname.equals("bc")) {
Expand All @@ -315,13 +322,16 @@ public void startElement(String uri,
m.setName(search(atts, "name")); m.setName(search(atts, "name"));
m.setReturnType(type(search(atts, "return"))); m.setReturnType(type(search(atts, "return")));
m.setArguments(search(atts, "arguments", "void")); m.setArguments(search(atts, "arguments", "void"));
m.setBytes(search(atts, "bytes"));
m.setIICount(search(atts, "iicount")); if (search(atts, "unloaded", "0").equals("0")) {
m.setFlags(search(atts, "flags")); m.setBytes(search(atts, "bytes"));
m.setIICount(search(atts, "iicount"));
m.setFlags(search(atts, "flags"));
}
methods.put(id, m); methods.put(id, m);
} else if (qname.equals("call")) { } else if (qname.equals("call")) {
site = new CallSite(bci, method(search(atts, "method"))); site = new CallSite(bci, method(search(atts, "method")));
site.setCount(Integer.parseInt(search(atts, "count"))); site.setCount(Integer.parseInt(search(atts, "count", "0")));
String receiver = atts.getValue("receiver"); String receiver = atts.getValue("receiver");
if (receiver != null) { if (receiver != null) {
site.setReceiver(type(receiver)); site.setReceiver(type(receiver));
Expand Down Expand Up @@ -360,12 +370,22 @@ public void startElement(String uri,
// uncommon trap inserted during parsing. // uncommon trap inserted during parsing.
// ignore for now // ignore for now
} }
} else if (qname.equals("late_inline")) {
late_inline_scope = new Stack<CallSite>();
site = new CallSite(-999, method(search(atts, "method")));
late_inline_scope.push(site);
} else if (qname.equals("jvms")) { } else if (qname.equals("jvms")) {
// <jvms bci='4' method='java/io/DataInputStream readChar ()C' bytes='40' count='5815' iicount='20815'/> // <jvms bci='4' method='java/io/DataInputStream readChar ()C' bytes='40' count='5815' iicount='20815'/>
if (currentTrap != null) { if (currentTrap != null) {
currentTrap.addJVMS(atts.getValue("method"), Integer.parseInt(atts.getValue("bci"))); currentTrap.addJVMS(atts.getValue("method"), Integer.parseInt(atts.getValue("bci")));
} else if (late_inline_scope != null) {
bci = Integer.parseInt(search(atts, "bci"));
site = new CallSite(bci, method(search(atts, "method")));
late_inline_scope.push(site);
} else { } else {
System.err.println("Missing uncommon_trap for jvms"); // Ignore <eliminate_allocation type='667'>,
// <eliminate_lock lock='1'>,
// <replace_string_concat arguments='2' string_alloc='0' multiple='0'>
} }
} else if (qname.equals("nmethod")) { } else if (qname.equals("nmethod")) {
String id = makeId(atts); String id = makeId(atts);
Expand All @@ -379,7 +399,7 @@ public void startElement(String uri,
Method m = method(search(atts, "method")); Method m = method(search(atts, "method"));
if (scopes.size() == 0) { if (scopes.size() == 0) {
compile.setMethod(m); compile.setMethod(m);
scopes.push(compile.getCall()); scopes.push(site);
} else { } else {
if (site.getMethod() == m) { if (site.getMethod() == m) {
scopes.push(site); scopes.push(site);
Expand All @@ -391,6 +411,12 @@ public void startElement(String uri,
throw new InternalError("call site and parse don't match"); throw new InternalError("call site and parse don't match");
} }
} }
} else if (qname.equals("parse_done")) {
CallSite call = scopes.pop();
call.setEndNodes(Integer.parseInt(search(atts, "nodes", "1")));
call.setEndLiveNodes(Integer.parseInt(search(atts, "live", "1")));
call.setTimeStamp(Double.parseDouble(search(atts, "stamp")));
scopes.push(call);
} }
} }


Expand All @@ -403,6 +429,43 @@ public void endElement(String uri,
scopes.pop(); scopes.pop();
} else if (qname.equals("uncommon_trap")) { } else if (qname.equals("uncommon_trap")) {
currentTrap = null; currentTrap = null;
} else if (qname.equals("late_inline")) {
// Populate late inlining info.

// late_inline scopes are specified in reverse order:
// compiled method should be on top of stack.
CallSite caller = late_inline_scope.pop();
Method m = compile.getMethod();
if (m != caller.getMethod()) {
System.out.println(m);
System.out.println(caller.getMethod() + " bci: " + bci);
throw new InternalError("call site and late_inline info don't match");
}

// late_inline contains caller+bci info, convert it
// to bci+callee info used by LogCompilation.
site = compile.getLateInlineCall();
do {
bci = caller.getBci();
// Next inlined call.
caller = late_inline_scope.pop();
CallSite callee = new CallSite(bci, caller.getMethod());
site.add(callee);
site = callee;
} while (!late_inline_scope.empty());

if (caller.getBci() != -999) {
System.out.println(caller.getMethod());
throw new InternalError("broken late_inline info");
}
if (site.getMethod() != caller.getMethod()) {
System.out.println(site.getMethod());
System.out.println(caller.getMethod());
throw new InternalError("call site and late_inline info don't match");
}
// late_inline is followed by parse with scopes.size() == 0,
// 'site' will be pushed to scopes.
late_inline_scope = null;
} else if (qname.equals("task")) { } else if (qname.equals("task")) {
types.clear(); types.clear();
methods.clear(); methods.clear();
Expand Down

0 comments on commit f3807d9

Please sign in to comment.