< prev index next >

src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 22,37 **** * */ /** * A SAX based parser of LogCompilation output from HotSpot. It takes a complete - * @author never */ package com.sun.hotspot.tools.compiler; import java.io.FileReader; import java.io.Reader; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; --- 22,37 ---- * */ /** * A SAX based parser of LogCompilation output from HotSpot. It takes a complete */ package com.sun.hotspot.tools.compiler; import java.io.FileReader; + import java.io.PrintStream; import java.io.Reader; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator;
*** 132,141 **** --- 132,179 ---- public int hashCode() { return 7; } }; + class Jvms { + Jvms(Method method, int bci) { + this.method = method; + this.bci = bci; + } + final public Method method; + final public int bci; + final public String toString() { + return "@" + bci + " " + method; + } + } + + class LockElimination extends BasicLogEvent { + + ArrayList<Jvms> jvms = new ArrayList<Jvms>(1); + final String kind; + final String classId; + final String tagName; + LockElimination(String tagName, double start, String id, String kind, String classId) { + super(start, id); + this.kind = kind; + this.classId = classId; + this.tagName = tagName; + } + + @Override + public void print(PrintStream stream) { + stream.printf("%s %s %s %s %.3f ", getId(), tagName, kind, classId, getStart()); + stream.print(jvms.toString()); + stream.print("\n"); + } + + void addJVMS(Method method, int bci) { + jvms.add(new Jvms(method, bci)); + } + + } + private ArrayList<LogEvent> events = new ArrayList<LogEvent>(); private HashMap<String, String> types = new HashMap<String, String>(); private HashMap<String, Method> methods = new HashMap<String, Method>(); private LinkedHashMap<String, NMethod> nmethods = new LinkedHashMap<String, NMethod>();
*** 145,154 **** --- 183,193 ---- private Stack<CallSite> scopes = new Stack<CallSite>(); private Compilation compile; private CallSite site; private CallSite methodHandleSite; private Stack<Phase> phaseStack = new Stack<Phase>(); + private LockElimination currentLockElimination; private UncommonTrapEvent currentTrap; private Stack<CallSite> lateInlineScope; private boolean lateInlining;
*** 190,200 **** --- 229,244 ---- // up before passing it to SAX reader = new LogCleanupReader(reader); } LogParser log = new LogParser(); + try { p.parse(new InputSource(reader), log); + } catch (Throwable th) { + th.printStackTrace(); + // Carry on with what we've got... + } // Associate compilations with their NMethods for (NMethod nm : log.nmethods.values()) { Compilation c = log.compiles.get(nm.getId()); nm.setCompilation(c);
*** 416,435 **** events.add(currentTrap); } else { // uncommon trap inserted during parsing. // ignore for now } } else if (qname.equals("late_inline")) { ! long inlineId = Long.parseLong(search(atts, "inline_id")); lateInlineScope = new Stack<CallSite>(); site = new CallSite(-999, method(search(atts, "method"))); site.setInlineId(inlineId); lateInlineScope.push(site); } else if (qname.equals("jvms")) { // <jvms bci='4' method='java/io/DataInputStream readChar ()C' bytes='40' count='5815' iicount='20815'/> if (currentTrap != null) { currentTrap.addJVMS(atts.getValue("method"), Integer.parseInt(atts.getValue("bci"))); } else if (lateInlineScope != null) { bci = Integer.parseInt(search(atts, "bci")); site = new CallSite(bci, method(search(atts, "method"))); lateInlineScope.push(site); } else { --- 460,495 ---- events.add(currentTrap); } else { // uncommon trap inserted during parsing. // ignore for now } + } else if (qname.startsWith("eliminate_lock")) { + String id = atts.getValue("compile_id"); + if (id != null) { + id = makeId(atts); + String kind = atts.getValue("kind"); + String classId = atts.getValue("class_id"); + currentLockElimination = new LockElimination(qname, Double.parseDouble(search(atts, "stamp")), id, kind, classId); + events.add(currentLockElimination); + } } else if (qname.equals("late_inline")) { ! long inlineId = 0; ! try { ! Long.parseLong(search(atts, "inline_id")); ! } catch (InternalError ex) { ! // 0 is an acceptable default value. ! } lateInlineScope = new Stack<CallSite>(); site = new CallSite(-999, method(search(atts, "method"))); site.setInlineId(inlineId); lateInlineScope.push(site); } else if (qname.equals("jvms")) { // <jvms bci='4' method='java/io/DataInputStream readChar ()C' bytes='40' count='5815' iicount='20815'/> if (currentTrap != null) { currentTrap.addJVMS(atts.getValue("method"), Integer.parseInt(atts.getValue("bci"))); + } else if (currentLockElimination != null) { + currentLockElimination.addJVMS(method(atts.getValue("method")), Integer.parseInt(atts.getValue("bci"))); } else if (lateInlineScope != null) { bci = Integer.parseInt(search(atts, "bci")); site = new CallSite(bci, method(search(atts, "method"))); lateInlineScope.push(site); } else {
*** 510,531 **** if (scopes.size() == 0) { lateInlining = false; } } else if (qname.equals("uncommon_trap")) { currentTrap = null; } else if (qname.equals("late_inline")) { // Populate late inlining info. if (scopes.size() != 0) { throw new InternalError("scopes should be empty for late inline"); } // late inline scopes are specified in reverse order: // compiled method should be on top of stack. CallSite caller = lateInlineScope.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. --- 570,593 ---- if (scopes.size() == 0) { lateInlining = false; } } else if (qname.equals("uncommon_trap")) { currentTrap = null; + } else if (qname.startsWith("eliminate_lock")) { + currentLockElimination = null; } else if (qname.equals("late_inline")) { // Populate late inlining info. if (scopes.size() != 0) { throw new InternalError("scopes should be empty for late inline"); } // late inline scopes are specified in reverse order: // compiled method should be on top of stack. CallSite caller = lateInlineScope.pop(); Method m = compile.getMethod(); if (m != caller.getMethod()) { ! System.err.println(m); ! System.err.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.
< prev index next >