hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java
author bharadwaj
Tue, 27 Nov 2012 17:24:15 -0800
changeset 14623 70c4c1be0a14
parent 11960 57898a1b4b44
child 14628 74164bb6ec39
permissions -rw-r--r--
7092905: C2: Keep track of the number of dead nodes Summary: keep an (almost) accurate running count of the reachable (live) flow graph nodes. Reviewed-by: kvn, twisti, jrose, vlivanov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
     1
/*
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
     2
 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
     4
 *
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
     8
 *
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    13
 * accompanied this code).
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    14
 *
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2126
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2126
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2126
diff changeset
    21
 * questions.
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    22
 *
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    23
 */
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    24
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    25
/**
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    26
 * A SAX based parser of LogCompilation output from HotSpot.  It takes a complete
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    27
 * @author never
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    28
 */
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    29
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    30
package com.sun.hotspot.tools.compiler;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    31
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    32
import java.io.FileReader;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    33
import java.io.Reader;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    34
import java.util.ArrayList;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    35
import java.util.Collections;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    36
import java.util.Comparator;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    37
import java.util.HashMap;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    38
import java.util.LinkedHashMap;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    39
import java.util.Stack;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    40
import javax.xml.parsers.SAXParser;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    41
import javax.xml.parsers.SAXParserFactory;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    42
import org.xml.sax.Attributes;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    43
import org.xml.sax.ErrorHandler;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    44
import org.xml.sax.InputSource;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    45
import org.xml.sax.helpers.DefaultHandler;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    46
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    47
public class LogParser extends DefaultHandler implements ErrorHandler, Constants {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    48
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    49
    static final HashMap<String, String> typeMap;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    50
    static {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    51
        typeMap = new HashMap<String, String>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    52
        typeMap.put("[I", "int[]");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    53
        typeMap.put("[C", "char[]");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    54
        typeMap.put("[Z", "boolean[]");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    55
        typeMap.put("[L", "Object[]");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    56
        typeMap.put("[B", "byte[]");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    57
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    58
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    59
    static Comparator<LogEvent> sortByStart = new Comparator<LogEvent>() {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    60
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    61
        public int compare(LogEvent a, LogEvent b) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    62
            double difference = (a.getStart() - b.getStart());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    63
            if (difference < 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    64
                return -1;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    65
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    66
            if (difference > 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    67
                return 1;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    68
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    69
            return 0;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    70
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    71
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    72
        @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    73
        public boolean equals(Object other) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    74
            return false;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    75
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    76
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    77
        @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    78
        public int hashCode() {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    79
            return 7;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    80
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    81
    };
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    82
    static Comparator<LogEvent> sortByNameAndStart = new Comparator<LogEvent>() {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    83
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    84
        public int compare(LogEvent a, LogEvent b) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    85
            Compilation c1 = a.getCompilation();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    86
            Compilation c2 = b.getCompilation();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    87
            if (c1 != null && c2 != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    88
                int result = c1.getMethod().toString().compareTo(c2.getMethod().toString());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    89
                if (result != 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    90
                    return result;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    91
                }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    92
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    93
            double difference = (a.getStart() - b.getStart());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    94
            if (difference < 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    95
                return -1;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    96
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    97
            if (difference > 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    98
                return 1;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    99
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   100
            return 0;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   101
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   102
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   103
        public boolean equals(Object other) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   104
            return false;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   105
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   106
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   107
        @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   108
        public int hashCode() {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   109
            return 7;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   110
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   111
    };
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   112
    static Comparator<LogEvent> sortByElapsed = new Comparator<LogEvent>() {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   113
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   114
        public int compare(LogEvent a, LogEvent b) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   115
            double difference = (a.getElapsedTime() - b.getElapsedTime());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   116
            if (difference < 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   117
                return -1;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   118
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   119
            if (difference > 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   120
                return 1;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   121
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   122
            return 0;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   123
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   124
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   125
        @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   126
        public boolean equals(Object other) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   127
            return false;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   128
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   129
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   130
        @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   131
        public int hashCode() {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   132
            return 7;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   133
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   134
    };
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   135
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   136
    private ArrayList<LogEvent> events = new ArrayList<LogEvent>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   137
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   138
    private HashMap<String, String> types = new HashMap<String, String>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   139
    private HashMap<String, Method> methods = new HashMap<String, Method>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   140
    private LinkedHashMap<String, NMethod> nmethods = new LinkedHashMap<String, NMethod>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   141
    private HashMap<String, Compilation> compiles = new HashMap<String, Compilation>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   142
    private String failureReason;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   143
    private int bci;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   144
    private Stack<CallSite> scopes = new Stack<CallSite>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   145
    private Compilation compile;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   146
    private CallSite site;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   147
    private Stack<Phase> phaseStack = new Stack<Phase>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   148
    private UncommonTrapEvent currentTrap;
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   149
    private Stack<CallSite> late_inline_scope;
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   150
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   151
    long parseLong(String l) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   152
        try {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   153
            return Long.decode(l).longValue();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   154
        } catch (NumberFormatException nfe) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   155
            int split = l.length() - 8;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   156
            String s1 = "0x" + l.substring(split);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   157
            String s2 = l.substring(0, split);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   158
            long v1 = Long.decode(s1).longValue() & 0xffffffffL;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   159
            long v2 = (Long.decode(s2).longValue() & 0xffffffffL) << 32;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   160
            if (!l.equals("0x" + Long.toHexString(v1 + v2))) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   161
                System.out.println(l);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   162
                System.out.println(s1);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   163
                System.out.println(s2);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   164
                System.out.println(v1);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   165
                System.out.println(v2);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   166
                System.out.println(Long.toHexString(v1 + v2));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   167
                throw new InternalError("bad conversion");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   168
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   169
            return v1 + v2;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   170
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   171
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   172
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   173
    public static ArrayList<LogEvent> parse(String file, boolean cleanup) throws Exception {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   174
        return parse(new FileReader(file), cleanup);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   175
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   176
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   177
    public static ArrayList<LogEvent> parse(Reader reader, boolean cleanup) throws Exception {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   178
        // Create the XML input factory
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   179
        SAXParserFactory factory = SAXParserFactory.newInstance();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   180
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   181
        // Create the XML LogEvent reader
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   182
        SAXParser p = factory.newSAXParser();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   183
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   184
        if (cleanup) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   185
            // some versions of the log have slightly malformed XML, so clean it
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   186
            // up before passing it to SAX
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   187
            reader = new LogCleanupReader(reader);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   188
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   189
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   190
        LogParser log = new LogParser();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   191
        p.parse(new InputSource(reader), log);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   192
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   193
        // Associate compilations with their NMethods
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   194
        for (NMethod nm : log.nmethods.values()) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   195
            Compilation c = log.compiles.get(nm.getId());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   196
            nm.setCompilation(c);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   197
            // Native wrappers for methods don't have a compilation
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   198
            if (c != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   199
                c.setNMethod(nm);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   200
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   201
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   202
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   203
        // Initially we want the LogEvent log sorted by timestamp
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   204
        Collections.sort(log.events, sortByStart);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   205
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   206
        return log.events;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   207
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   208
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   209
    String search(Attributes attr, String name) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   210
        return search(attr, name, null);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   211
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   212
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   213
    String search(Attributes attr, String name, String defaultValue) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   214
        String result = attr.getValue(name);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   215
        if (result != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   216
            return result;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   217
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   218
        if (defaultValue != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   219
            return defaultValue;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   220
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   221
        for (int i = 0; i < attr.getLength(); i++) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   222
            System.out.println(attr.getQName(i) + " " + attr.getValue(attr.getQName(i)));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   223
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   224
        throw new InternalError("can't find " + name);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   225
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   226
    int indent = 0;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   227
    String compile_id;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   228
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   229
    String type(String id) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   230
        String result = types.get(id);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   231
        if (result == null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   232
            throw new InternalError(id);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   233
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   234
        String remapped = typeMap.get(result);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   235
        if (remapped != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   236
            return remapped;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   237
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   238
        return result;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   239
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   240
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   241
    void type(String id, String name) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   242
        assert type(id) == null;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   243
        types.put(id, name);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   244
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   245
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   246
    Method method(String id) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   247
        Method result = methods.get(id);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   248
        if (result == null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   249
            throw new InternalError(id);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   250
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   251
        return result;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   252
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   253
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   254
    public String makeId(Attributes atts) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   255
        String id = atts.getValue("compile_id");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   256
        String kind = atts.getValue("kind");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   257
        if (kind != null && kind.equals("osr")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   258
            id += "%";
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   259
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   260
        return id;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   261
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   262
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   263
    @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   264
    public void startElement(String uri,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   265
            String localName,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   266
            String qname,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   267
            Attributes atts) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   268
        if (qname.equals("phase")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   269
            Phase p = new Phase(search(atts, "name"),
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   270
                    Double.parseDouble(search(atts, "stamp")),
14623
70c4c1be0a14 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 11960
diff changeset
   271
                    Integer.parseInt(search(atts, "nodes")),
70c4c1be0a14 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 11960
diff changeset
   272
                    Integer.parseInt(search(atts, "live")));
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   273
            phaseStack.push(p);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   274
        } else if (qname.equals("phase_done")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   275
            Phase p = phaseStack.pop();
14623
70c4c1be0a14 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 11960
diff changeset
   276
            if (! p.getId().equals(search(atts, "name"))) {
70c4c1be0a14 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 11960
diff changeset
   277
                System.out.println("phase: " + p.getId());
70c4c1be0a14 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 11960
diff changeset
   278
                throw new InternalError("phase name mismatch");
70c4c1be0a14 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 11960
diff changeset
   279
            }
70c4c1be0a14 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 11960
diff changeset
   280
            p.setEnd(Double.parseDouble(search(atts, "stamp")));
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   281
            p.setEndNodes(Integer.parseInt(search(atts, "nodes")));
14623
70c4c1be0a14 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 11960
diff changeset
   282
            p.setEndLiveNodes(Integer.parseInt(search(atts, "live")));
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   283
            compile.getPhases().add(p);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   284
        } else if (qname.equals("task")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   285
            compile = new Compilation(Integer.parseInt(search(atts, "compile_id", "-1")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   286
            compile.setStart(Double.parseDouble(search(atts, "stamp")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   287
            compile.setICount(search(atts, "count", "0"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   288
            compile.setBCount(search(atts, "backedge_count", "0"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   289
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   290
            String method = atts.getValue("method");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   291
            int space = method.indexOf(' ');
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   292
            method = method.substring(0, space) + "::" +
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   293
                    method.substring(space + 1, method.indexOf(' ', space + 1) + 1);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   294
            String compiler = atts.getValue("compiler");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   295
            if (compiler == null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   296
                compiler = "";
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   297
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   298
            String kind = atts.getValue("compile_kind");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   299
            if (kind == null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   300
                kind = "normal";
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   301
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   302
            if (kind.equals("osr")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   303
                compile.setOsr(true);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   304
                compile.setOsr_bci(Integer.parseInt(search(atts, "osr_bci")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   305
            } else if (kind.equals("c2i")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   306
                compile.setSpecial("--- adapter " + method);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   307
            } else {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   308
                compile.setSpecial(compile.getId() + " " + method + " (0 bytes)");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   309
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   310
            events.add(compile);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   311
            compiles.put(makeId(atts), compile);
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   312
            site = compile.getCall();
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   313
        } else if (qname.equals("type")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   314
            type(search(atts, "id"), search(atts, "name"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   315
        } else if (qname.equals("bc")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   316
            bci = Integer.parseInt(search(atts, "bci"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   317
        } else if (qname.equals("klass")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   318
            type(search(atts, "id"), search(atts, "name"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   319
        } else if (qname.equals("method")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   320
            String id = search(atts, "id");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   321
            Method m = new Method();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   322
            m.setHolder(type(search(atts, "holder")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   323
            m.setName(search(atts, "name"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   324
            m.setReturnType(type(search(atts, "return")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   325
            m.setArguments(search(atts, "arguments", "void"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   326
            m.setBytes(search(atts, "bytes"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   327
            m.setIICount(search(atts, "iicount"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   328
            m.setFlags(search(atts, "flags"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   329
            methods.put(id, m);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   330
        } else if (qname.equals("call")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   331
            site = new CallSite(bci, method(search(atts, "method")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   332
            site.setCount(Integer.parseInt(search(atts, "count")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   333
            String receiver = atts.getValue("receiver");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   334
            if (receiver != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   335
                site.setReceiver(type(receiver));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   336
                site.setReceiver_count(Integer.parseInt(search(atts, "receiver_count")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   337
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   338
            scopes.peek().add(site);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   339
        } else if (qname.equals("regalloc")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   340
            compile.setAttempts(Integer.parseInt(search(atts, "attempts")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   341
        } else if (qname.equals("inline_fail")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   342
            scopes.peek().last().setReason(search(atts, "reason"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   343
        } else if (qname.equals("failure")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   344
            failureReason = search(atts, "reason");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   345
        } else if (qname.equals("task_done")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   346
            compile.setEnd(Double.parseDouble(search(atts, "stamp")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   347
            if (Integer.parseInt(search(atts, "success")) == 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   348
                compile.setFailureReason(failureReason);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   349
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   350
        } else if (qname.equals("make_not_entrant")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   351
            String id = makeId(atts);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   352
            NMethod nm = nmethods.get(id);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   353
            if (nm == null) throw new InternalError();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   354
            LogEvent e = new MakeNotEntrantEvent(Double.parseDouble(search(atts, "stamp")), id,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   355
                                                 atts.getValue("zombie") != null, nm);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   356
            events.add(e);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   357
        } else if (qname.equals("uncommon_trap")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   358
            String id = atts.getValue("compile_id");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   359
            if (id != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   360
                id = makeId(atts);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   361
                currentTrap = new UncommonTrapEvent(Double.parseDouble(search(atts, "stamp")),
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   362
                        id,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   363
                        atts.getValue("reason"),
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   364
                        atts.getValue("action"),
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   365
                        Integer.parseInt(search(atts, "count", "0")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   366
                events.add(currentTrap);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   367
            } else {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   368
                // uncommon trap inserted during parsing.
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   369
                // ignore for now
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   370
            }
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   371
        } else if (qname.equals("late_inline")) {
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   372
            late_inline_scope = new Stack<CallSite>();
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   373
            site = new CallSite(-999, method(search(atts, "method")));
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   374
            late_inline_scope.push(site);
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   375
        } else if (qname.equals("jvms")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   376
            // <jvms bci='4' method='java/io/DataInputStream readChar ()C' bytes='40' count='5815' iicount='20815'/>
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   377
            if (currentTrap != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   378
                currentTrap.addJVMS(atts.getValue("method"), Integer.parseInt(atts.getValue("bci")));
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   379
            } else if (late_inline_scope != null) {
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   380
                bci = Integer.parseInt(search(atts, "bci"));
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   381
                site = new CallSite(bci, method(search(atts, "method")));
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   382
                late_inline_scope.push(site);
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   383
            } else {
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   384
                // Ignore <eliminate_allocation type='667'>,
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   385
                //        <eliminate_lock lock='1'>,
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   386
                //        <replace_string_concat arguments='2' string_alloc='0' multiple='0'>
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   387
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   388
        } else if (qname.equals("nmethod")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   389
            String id = makeId(atts);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   390
            NMethod nm = new NMethod(Double.parseDouble(search(atts, "stamp")),
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   391
                    id,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   392
                    parseLong(atts.getValue("address")),
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   393
                    parseLong(atts.getValue("size")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   394
            nmethods.put(id, nm);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   395
            events.add(nm);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   396
        } else if (qname.equals("parse")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   397
            Method m = method(search(atts, "method"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   398
            if (scopes.size() == 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   399
                compile.setMethod(m);
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   400
                scopes.push(site);
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   401
            } else {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   402
                if (site.getMethod() == m) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   403
                    scopes.push(site);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   404
                } else if (scopes.peek().getCalls().size() > 2 && m == scopes.peek().last(-2).getMethod()) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   405
                    scopes.push(scopes.peek().last(-2));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   406
                } else {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   407
                    System.out.println(site.getMethod());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   408
                    System.out.println(m);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   409
                    throw new InternalError("call site and parse don't match");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   410
                }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   411
            }
10563
b9b82ff9f0e9 7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents: 5547
diff changeset
   412
        } else if (qname.equals("parse_done")) {
b9b82ff9f0e9 7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents: 5547
diff changeset
   413
            CallSite call = scopes.pop();
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   414
            call.setEndNodes(Integer.parseInt(search(atts, "nodes", "1")));
14623
70c4c1be0a14 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 11960
diff changeset
   415
            call.setEndLiveNodes(Integer.parseInt(search(atts, "live", "1")));
10563
b9b82ff9f0e9 7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents: 5547
diff changeset
   416
            call.setTimeStamp(Double.parseDouble(search(atts, "stamp")));
b9b82ff9f0e9 7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents: 5547
diff changeset
   417
            scopes.push(call);
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   418
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   419
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   420
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   421
    @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   422
    public void endElement(String uri,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   423
            String localName,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   424
            String qname) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   425
        if (qname.equals("parse")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   426
            indent -= 2;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   427
            scopes.pop();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   428
        } else if (qname.equals("uncommon_trap")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   429
            currentTrap = null;
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   430
        } else if (qname.equals("late_inline")) {
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   431
            // Populate late inlining info.
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   432
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   433
            // late_inline scopes are specified in reverse order:
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   434
            // compiled method should be on top of stack.
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   435
            CallSite caller = late_inline_scope.pop();
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   436
            Method m = compile.getMethod();
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   437
            if (m != caller.getMethod()) {
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   438
                System.out.println(m);
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   439
                System.out.println(caller.getMethod() + " bci: " + bci);
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   440
                throw new InternalError("call site and late_inline info don't match");
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   441
            }
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   442
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   443
            // late_inline contains caller+bci info, convert it
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   444
            // to bci+callee info used by LogCompilation.
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   445
            site = compile.getLateInlineCall();
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   446
            do {
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   447
                bci = caller.getBci();
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   448
                // Next inlined call.
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   449
                caller = late_inline_scope.pop();
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   450
                CallSite callee =  new CallSite(bci, caller.getMethod());
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   451
                site.add(callee);
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   452
                site = callee;
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   453
            } while (!late_inline_scope.empty());
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   454
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   455
            if (caller.getBci() != -999) {
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   456
                System.out.println(caller.getMethod());
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   457
                throw new InternalError("broken late_inline info");
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   458
            }
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   459
            if (site.getMethod() != caller.getMethod()) {
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   460
                System.out.println(site.getMethod());
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   461
                System.out.println(caller.getMethod());
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   462
                throw new InternalError("call site and late_inline info don't match");
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   463
            }
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   464
            // late_inline is followed by parse with scopes.size() == 0,
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   465
            // 'site' will be pushed to scopes.
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   466
            late_inline_scope = null;
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   467
        } else if (qname.equals("task")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   468
            types.clear();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   469
            methods.clear();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   470
            site = null;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   471
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   472
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   473
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   474
    @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   475
    public void warning(org.xml.sax.SAXParseException e) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   476
        System.err.println(e.getMessage() + " at line " + e.getLineNumber() + ", column " + e.getColumnNumber());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   477
        e.printStackTrace();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   478
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   479
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   480
    @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   481
    public void error(org.xml.sax.SAXParseException e) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   482
        System.err.println(e.getMessage() + " at line " + e.getLineNumber() + ", column " + e.getColumnNumber());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   483
        e.printStackTrace();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   484
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   485
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   486
    @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   487
    public void fatalError(org.xml.sax.SAXParseException e) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   488
        System.err.println(e.getMessage() + " at line " + e.getLineNumber() + ", column " + e.getColumnNumber());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   489
        e.printStackTrace();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   490
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   491
}