< prev index next >
src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/UncommonTrapEvent.java
Print this page
rev 8632 : 6900757: minor bug fixes to LogCompilation tool
* improve internal error reporting (point to XML element causing trouble)
* fix comparator for sorting by name and start
* make tool more robust wrt. incorrect options and files not found
* make inlining decision output more clear
* adopt uncommon traps history printing
* properly mention compiler in generated logs
* add options for printing time stamps and omitting compilation IDs
* add option for comparing compilation logs
* overall code cleanup and API documentation
*** 19,61 ****
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
-
package com.sun.hotspot.tools.compiler;
import java.io.PrintStream;
class UncommonTrapEvent extends BasicLogEvent {
private final String reason;
private final String action;
private int count;
! private String jvms = "";
UncommonTrapEvent(double s, String i, String r, String a, int c) {
super(s, i);
reason = r;
action = a;
count = c;
}
-
- public void addJVMS(String method, int bci) {
- setJvms(getJvms() + " @" + bci + " " + method + "\n");
- }
-
public void updateCount(UncommonTrapEvent trap) {
setCount(Math.max(getCount(), trap.getCount()));
}
! public void print(PrintStream stream) {
! stream.printf("%s uncommon trap %.3f %s %s\n", getId(), getStart(), getReason(), getAction());
! stream.print(getJvms());
}
public String getReason() {
return reason;
}
public String getAction() {
--- 19,83 ----
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package com.sun.hotspot.tools.compiler;
import java.io.PrintStream;
+ import java.util.ArrayList;
+ import java.util.List;
+ /**
+ * Represents an uncommon trap encountered during a compilation.
+ */
class UncommonTrapEvent extends BasicLogEvent {
private final String reason;
private final String action;
+
+ /**
+ * Denote how many times this trap has been encountered.
+ */
private int count;
!
! /**
! * The name of the bytecode instruction at which the trap occurred.
! */
! private String bytecode;
!
! private List<String> jvmsMethods = new ArrayList<>();
!
! private List<Integer> jvmsBCIs = new ArrayList<>();
UncommonTrapEvent(double s, String i, String r, String a, int c) {
super(s, i);
reason = r;
action = a;
count = c;
}
public void updateCount(UncommonTrapEvent trap) {
setCount(Math.max(getCount(), trap.getCount()));
}
! public void print(PrintStream stream, boolean printID) {
! if (printID) {
! stream.print(getId() + " ");
! }
! stream.printf("uncommon trap %s %s %s\n", bytecode, getReason(), getAction());
! int indent = 2;
! for (int j = 0; j < jvmsMethods.size(); j++) {
! for (int i = 0; i < indent; i++) {
! stream.print(' ');
! }
! stream.println("@ " + jvmsBCIs.get(j) + " " + jvmsMethods.get(j));
! indent += 2;
! }
}
+
public String getReason() {
return reason;
}
public String getAction() {
*** 68,84 ****
public void setCount(int count) {
this.count = count;
}
! public String getJvms() {
! return jvms;
}
-
- public void setJvms(String jvms) {
- this.jvms = jvms;
}
! public void setCompilation(Compilation compilation) {
! this.compilation = compilation;
}
}
--- 90,147 ----
public void setCount(int count) {
this.count = count;
}
! /**
! * Set the compilation for this event. This involves identifying the call
! * site to which this uncommon trap event belongs. In addition to setting
! * the {@link #compilation} link, this method will consequently also set
! * the {@link #bytecode} field.
! */
! public void setCompilation(Compilation compilation) {
! super.setCompilation(compilation);
! // Attempt to associate a bytecode with with this trap
! CallSite site = compilation.getCall();
! int i = 0;
! try {
! List<UncommonTrap> traps = site.getTraps();
! while (i + 1 < jvmsMethods.size()) {
! if (!jvmsMethods.get(i).equals(site.getMethod().getFullName())) {
! throw new InternalError(jvmsMethods.get(i) + " != " + site.getMethod().getFullName());
! }
! CallSite result = null;
! for (CallSite call : site.getCalls()) {
! if (call.getBci() == jvmsBCIs.get(i) &&
! call.getMethod().getFullName().equals(jvmsMethods.get(i + 1)) &&
! call.getReceiver() == null) {
! result = call;
! i++;
! break;
! }
! }
! if (result == null) {
! throw new InternalError("couldn't find call site");
! }
! site = result;
! traps = site.getTraps();
! }
! for (UncommonTrap trap : traps) {
! if (trap.getBCI() == jvmsBCIs.get(i) &&
! trap.getReason().equals(getReason()) &&
! trap.getAction().equals(getAction())) {
! bytecode = trap.getBytecode();
! return;
! }
! }
! throw new InternalError("couldn't find bytecode");
! } catch (Exception e) {
! bytecode = "<unknown>";
}
}
! public void addMethodAndBCI(String method, int bci) {
! jvmsMethods.add(0, method);
! jvmsBCIs.add(0, bci);
}
+
}
< prev index next >