hotspot/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java
author vlivanov
Mon, 14 Jul 2014 03:28:13 -0700
changeset 25644 5319fc0701c7
parent 24673 2ec56802b829
child 29086 74100114a95a
permissions -rw-r--r--
8049532: LogCompilation: C1: inlining tree is flat (no depth is stored) Reviewed-by: roland, iveresov
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
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 19712
diff changeset
     2
 * Copyright (c) 2009, 2013, 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;
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
    34
import java.util.ArrayDeque;
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    35
import java.util.ArrayList;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    36
import java.util.Collections;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    37
import java.util.Comparator;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    38
import java.util.HashMap;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    39
import java.util.LinkedHashMap;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    40
import java.util.Stack;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    41
import javax.xml.parsers.SAXParser;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    42
import javax.xml.parsers.SAXParserFactory;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    43
import org.xml.sax.Attributes;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    44
import org.xml.sax.ErrorHandler;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    45
import org.xml.sax.InputSource;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    46
import org.xml.sax.helpers.DefaultHandler;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    47
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    48
public class LogParser extends DefaultHandler implements ErrorHandler, Constants {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    49
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    50
    static final HashMap<String, String> typeMap;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    51
    static {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    52
        typeMap = new HashMap<String, String>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    53
        typeMap.put("[I", "int[]");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    54
        typeMap.put("[C", "char[]");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    55
        typeMap.put("[Z", "boolean[]");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    56
        typeMap.put("[L", "Object[]");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    57
        typeMap.put("[B", "byte[]");
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
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    60
    static Comparator<LogEvent> sortByStart = new Comparator<LogEvent>() {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    61
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    62
        public int compare(LogEvent a, LogEvent b) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    63
            double difference = (a.getStart() - b.getStart());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    64
            if (difference < 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    65
                return -1;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    66
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    67
            if (difference > 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    68
                return 1;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    69
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    70
            return 0;
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
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    73
        @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    74
        public boolean equals(Object other) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    75
            return false;
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
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    78
        @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    79
        public int hashCode() {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    80
            return 7;
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
    };
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    83
    static Comparator<LogEvent> sortByNameAndStart = new Comparator<LogEvent>() {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    84
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    85
        public int compare(LogEvent a, LogEvent b) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    86
            Compilation c1 = a.getCompilation();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    87
            Compilation c2 = b.getCompilation();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    88
            if (c1 != null && c2 != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    89
                int result = c1.getMethod().toString().compareTo(c2.getMethod().toString());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    90
                if (result != 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    91
                    return result;
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
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    94
            double difference = (a.getStart() - b.getStart());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    95
            if (difference < 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    96
                return -1;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    97
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    98
            if (difference > 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
    99
                return 1;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   100
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   101
            return 0;
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
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   104
        public boolean equals(Object other) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   105
            return false;
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
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   108
        @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   109
        public int hashCode() {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   110
            return 7;
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
    };
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   113
    static Comparator<LogEvent> sortByElapsed = new Comparator<LogEvent>() {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   114
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   115
        public int compare(LogEvent a, LogEvent b) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   116
            double difference = (a.getElapsedTime() - b.getElapsedTime());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   117
            if (difference < 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   118
                return -1;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   119
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   120
            if (difference > 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   121
                return 1;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   122
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   123
            return 0;
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
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   126
        @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   127
        public boolean equals(Object other) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   128
            return false;
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
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   131
        @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   132
        public int hashCode() {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   133
            return 7;
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
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   137
    private ArrayList<LogEvent> events = new ArrayList<LogEvent>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   138
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   139
    private HashMap<String, String> types = new HashMap<String, String>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   140
    private HashMap<String, Method> methods = new HashMap<String, Method>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   141
    private LinkedHashMap<String, NMethod> nmethods = new LinkedHashMap<String, NMethod>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   142
    private HashMap<String, Compilation> compiles = new HashMap<String, Compilation>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   143
    private String failureReason;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   144
    private int bci;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   145
    private Stack<CallSite> scopes = new Stack<CallSite>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   146
    private Compilation compile;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   147
    private CallSite site;
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   148
    private CallSite methodHandleSite;
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   149
    private Stack<Phase> phaseStack = new Stack<Phase>();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   150
    private UncommonTrapEvent currentTrap;
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   151
    private Stack<CallSite> lateInlineScope;
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   152
    private boolean lateInlining;
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   153
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   154
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   155
    long parseLong(String l) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   156
        try {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   157
            return Long.decode(l).longValue();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   158
        } catch (NumberFormatException nfe) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   159
            int split = l.length() - 8;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   160
            String s1 = "0x" + l.substring(split);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   161
            String s2 = l.substring(0, split);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   162
            long v1 = Long.decode(s1).longValue() & 0xffffffffL;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   163
            long v2 = (Long.decode(s2).longValue() & 0xffffffffL) << 32;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   164
            if (!l.equals("0x" + Long.toHexString(v1 + v2))) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   165
                System.out.println(l);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   166
                System.out.println(s1);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   167
                System.out.println(s2);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   168
                System.out.println(v1);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   169
                System.out.println(v2);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   170
                System.out.println(Long.toHexString(v1 + v2));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   171
                throw new InternalError("bad conversion");
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
            return v1 + v2;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   174
        }
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(String file, boolean cleanup) throws Exception {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   178
        return parse(new FileReader(file), cleanup);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   179
    }
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
    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
   182
        // Create the XML input factory
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   183
        SAXParserFactory factory = SAXParserFactory.newInstance();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   184
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   185
        // Create the XML LogEvent reader
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   186
        SAXParser p = factory.newSAXParser();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   187
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   188
        if (cleanup) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   189
            // 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
   190
            // up before passing it to SAX
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   191
            reader = new LogCleanupReader(reader);
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
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   194
        LogParser log = new LogParser();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   195
        p.parse(new InputSource(reader), log);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   196
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   197
        // Associate compilations with their NMethods
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   198
        for (NMethod nm : log.nmethods.values()) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   199
            Compilation c = log.compiles.get(nm.getId());
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   200
            nm.setCompilation(c);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   201
            // Native wrappers for methods don't have a compilation
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   202
            if (c != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   203
                c.setNMethod(nm);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   204
            }
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
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   207
        // Initially we want the LogEvent log sorted by timestamp
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   208
        Collections.sort(log.events, sortByStart);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   209
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   210
        return log.events;
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) {
19712
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 14628
diff changeset
   214
        String result = attr.getValue(name);
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 14628
diff changeset
   215
        if (result != null) {
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 14628
diff changeset
   216
            return result;
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 14628
diff changeset
   217
        } else {
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 14628
diff changeset
   218
            throw new InternalError("can't find " + name);
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 14628
diff changeset
   219
        }
2126
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
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   222
    String search(Attributes attr, String name, String defaultValue) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   223
        String result = attr.getValue(name);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   224
        if (result != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   225
            return result;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   226
        }
19712
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 14628
diff changeset
   227
        return defaultValue;
2126
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
    int indent = 0;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   230
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   231
    String type(String id) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   232
        String result = types.get(id);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   233
        if (result == null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   234
            throw new InternalError(id);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   235
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   236
        String remapped = typeMap.get(result);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   237
        if (remapped != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   238
            return remapped;
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
        return result;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   241
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   242
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   243
    void type(String id, String name) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   244
        assert type(id) == null;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   245
        types.put(id, name);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   246
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   247
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   248
    Method method(String id) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   249
        Method result = methods.get(id);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   250
        if (result == null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   251
            throw new InternalError(id);
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
        return result;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   254
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   255
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   256
    public String makeId(Attributes atts) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   257
        String id = atts.getValue("compile_id");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   258
        String kind = atts.getValue("kind");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   259
        if (kind != null && kind.equals("osr")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   260
            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
        return id;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   263
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   264
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   265
    @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   266
    public void startElement(String uri,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   267
            String localName,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   268
            String qname,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   269
            Attributes atts) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   270
        if (qname.equals("phase")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   271
            Phase p = new Phase(search(atts, "name"),
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   272
                    Double.parseDouble(search(atts, "stamp")),
14628
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 14623
diff changeset
   273
                    Integer.parseInt(search(atts, "nodes", "0")),
19712
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 14628
diff changeset
   274
                    Integer.parseInt(search(atts, "live", "0")));
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   275
            phaseStack.push(p);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   276
        } else if (qname.equals("phase_done")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   277
            Phase p = phaseStack.pop();
19712
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 14628
diff changeset
   278
            String phaseName = search(atts, "name", null);
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 14628
diff changeset
   279
            if (phaseName != null && !p.getId().equals(phaseName)) {
14623
70c4c1be0a14 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 11960
diff changeset
   280
                System.out.println("phase: " + p.getId());
70c4c1be0a14 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 11960
diff changeset
   281
                throw new InternalError("phase name mismatch");
70c4c1be0a14 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 11960
diff changeset
   282
            }
70c4c1be0a14 7092905: C2: Keep track of the number of dead nodes
bharadwaj
parents: 11960
diff changeset
   283
            p.setEnd(Double.parseDouble(search(atts, "stamp")));
14628
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 14623
diff changeset
   284
            p.setEndNodes(Integer.parseInt(search(atts, "nodes", "0")));
19712
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 14628
diff changeset
   285
            p.setEndLiveNodes(Integer.parseInt(search(atts, "live", "0")));
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   286
            compile.getPhases().add(p);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   287
        } else if (qname.equals("task")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   288
            compile = new Compilation(Integer.parseInt(search(atts, "compile_id", "-1")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   289
            compile.setStart(Double.parseDouble(search(atts, "stamp")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   290
            compile.setICount(search(atts, "count", "0"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   291
            compile.setBCount(search(atts, "backedge_count", "0"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   292
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   293
            String method = atts.getValue("method");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   294
            int space = method.indexOf(' ');
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   295
            method = method.substring(0, space) + "::" +
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   296
                    method.substring(space + 1, method.indexOf(' ', space + 1) + 1);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   297
            String compiler = atts.getValue("compiler");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   298
            if (compiler == null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   299
                compiler = "";
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   300
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   301
            String kind = atts.getValue("compile_kind");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   302
            if (kind == null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   303
                kind = "normal";
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   304
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   305
            if (kind.equals("osr")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   306
                compile.setOsr(true);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   307
                compile.setOsr_bci(Integer.parseInt(search(atts, "osr_bci")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   308
            } else if (kind.equals("c2i")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   309
                compile.setSpecial("--- adapter " + method);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   310
            } else {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   311
                compile.setSpecial(compile.getId() + " " + method + " (0 bytes)");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   312
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   313
            events.add(compile);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   314
            compiles.put(makeId(atts), compile);
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   315
            site = compile.getCall();
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   316
        } else if (qname.equals("type")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   317
            type(search(atts, "id"), search(atts, "name"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   318
        } else if (qname.equals("bc")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   319
            bci = Integer.parseInt(search(atts, "bci"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   320
        } else if (qname.equals("klass")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   321
            type(search(atts, "id"), search(atts, "name"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   322
        } else if (qname.equals("method")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   323
            String id = search(atts, "id");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   324
            Method m = new Method();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   325
            m.setHolder(type(search(atts, "holder")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   326
            m.setName(search(atts, "name"));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   327
            m.setReturnType(type(search(atts, "return")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   328
            m.setArguments(search(atts, "arguments", "void"));
14628
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 14623
diff changeset
   329
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 14623
diff changeset
   330
            if (search(atts, "unloaded", "0").equals("0")) {
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 14623
diff changeset
   331
               m.setBytes(search(atts, "bytes"));
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 14623
diff changeset
   332
               m.setIICount(search(atts, "iicount"));
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 14623
diff changeset
   333
               m.setFlags(search(atts, "flags"));
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 14623
diff changeset
   334
            }
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   335
            methods.put(id, m);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   336
        } else if (qname.equals("call")) {
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   337
            if (methodHandleSite != null) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   338
                methodHandleSite = null;
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   339
            }
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   340
            Method m = method(search(atts, "method"));
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   341
            if (lateInlining && scopes.size() == 0) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   342
                // re-attempting already seen call site (late inlining for MH invokes)
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   343
                if (m != site.getMethod()) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   344
                    if (bci != site.getBci()) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   345
                        System.out.println(m + " bci: " + bci);
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   346
                        System.out.println(site.getMethod() +  " bci: " + site.getBci());
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   347
                        throw new InternalError("bci mismatch after late inlining");
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   348
                    }
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   349
                    site.setMethod(m);
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   350
                }
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   351
            } else {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   352
                site = new CallSite(bci, m);
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   353
            }
14628
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 14623
diff changeset
   354
            site.setCount(Integer.parseInt(search(atts, "count", "0")));
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   355
            String receiver = atts.getValue("receiver");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   356
            if (receiver != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   357
                site.setReceiver(type(receiver));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   358
                site.setReceiver_count(Integer.parseInt(search(atts, "receiver_count")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   359
            }
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   360
            int methodHandle = Integer.parseInt(search(atts, "method_handle_intrinsic", "0"));
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   361
            if (lateInlining && scopes.size() == 0) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   362
                // The call was added before this round of late inlining
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   363
            } else if (methodHandle == 0) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   364
                scopes.peek().add(site);
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   365
            } else {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   366
                // method handle call site can be followed by another
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   367
                // call (in case it is inlined). If that happens we
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   368
                // discard the method handle call site. So we keep
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   369
                // track of it but don't add it to the list yet.
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   370
                methodHandleSite = site;
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   371
            }
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   372
        } else if (qname.equals("regalloc")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   373
            compile.setAttempts(Integer.parseInt(search(atts, "attempts")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   374
        } else if (qname.equals("inline_fail")) {
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   375
            if (methodHandleSite != null) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   376
                scopes.peek().add(methodHandleSite);
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   377
                methodHandleSite = null;
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   378
            }
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   379
            if (lateInlining && scopes.size() == 0) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   380
                site.setReason(search(atts, "reason"));
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   381
                lateInlining = false;
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   382
            } else {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   383
                scopes.peek().last().setReason(search(atts, "reason"));
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   384
            }
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   385
        } else if (qname.equals("inline_success")) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   386
            if (methodHandleSite != null) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   387
                throw new InternalError("method handle site should have been replaced");
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   388
            }
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   389
            if (lateInlining && scopes.size() == 0) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   390
                site.setReason(null);
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   391
            }
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   392
        } else if (qname.equals("failure")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   393
            failureReason = search(atts, "reason");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   394
        } else if (qname.equals("task_done")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   395
            compile.setEnd(Double.parseDouble(search(atts, "stamp")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   396
            if (Integer.parseInt(search(atts, "success")) == 0) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   397
                compile.setFailureReason(failureReason);
24673
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   398
                failureReason = null;
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   399
            }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   400
        } else if (qname.equals("make_not_entrant")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   401
            String id = makeId(atts);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   402
            NMethod nm = nmethods.get(id);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   403
            if (nm == null) throw new InternalError();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   404
            LogEvent e = new MakeNotEntrantEvent(Double.parseDouble(search(atts, "stamp")), id,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   405
                                                 atts.getValue("zombie") != null, nm);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   406
            events.add(e);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   407
        } else if (qname.equals("uncommon_trap")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   408
            String id = atts.getValue("compile_id");
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   409
            if (id != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   410
                id = makeId(atts);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   411
                currentTrap = new UncommonTrapEvent(Double.parseDouble(search(atts, "stamp")),
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   412
                        id,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   413
                        atts.getValue("reason"),
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   414
                        atts.getValue("action"),
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   415
                        Integer.parseInt(search(atts, "count", "0")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   416
                events.add(currentTrap);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   417
            } else {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   418
                // uncommon trap inserted during parsing.
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   419
                // ignore for now
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   420
            }
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   421
        } else if (qname.equals("late_inline")) {
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   422
            long inlineId = Long.parseLong(search(atts, "inline_id"));
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   423
            lateInlineScope = new Stack<CallSite>();
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   424
            site = new CallSite(-999, method(search(atts, "method")));
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   425
            site.setInlineId(inlineId);
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   426
            lateInlineScope.push(site);
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   427
        } else if (qname.equals("jvms")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   428
            // <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
   429
            if (currentTrap != null) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   430
                currentTrap.addJVMS(atts.getValue("method"), Integer.parseInt(atts.getValue("bci")));
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   431
            } else if (lateInlineScope != null) {
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   432
                bci = Integer.parseInt(search(atts, "bci"));
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   433
                site = new CallSite(bci, method(search(atts, "method")));
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   434
                lateInlineScope.push(site);
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   435
            } else {
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   436
                // Ignore <eliminate_allocation type='667'>,
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   437
                //        <eliminate_lock lock='1'>,
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   438
                //        <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
   439
            }
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   440
        } else if (qname.equals("inline_id")) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   441
            if (methodHandleSite != null) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   442
                throw new InternalError("method handle site should have been replaced");
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   443
            }
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   444
            long id = Long.parseLong(search(atts, "id"));
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   445
            site.setInlineId(id);
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   446
        } else if (qname.equals("nmethod")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   447
            String id = makeId(atts);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   448
            NMethod nm = new NMethod(Double.parseDouble(search(atts, "stamp")),
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   449
                    id,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   450
                    parseLong(atts.getValue("address")),
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   451
                    parseLong(atts.getValue("size")));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   452
            nmethods.put(id, nm);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   453
            events.add(nm);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   454
        } else if (qname.equals("parse")) {
24673
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   455
            if (failureReason != null && scopes.size() == 0 && !lateInlining) {
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   456
                failureReason = null;
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   457
                compile.reset();
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   458
                site = compile.getCall();
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   459
            }
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   460
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   461
            if (methodHandleSite != null) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   462
                throw new InternalError("method handle site should have been replaced");
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   463
            }
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   464
            Method m = method(search(atts, "method"));
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   465
            if (lateInlining && scopes.size() == 0) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   466
                if (site.getMethod() != m) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   467
                    System.out.println(site.getMethod());
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   468
                    System.out.println(m);
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   469
                    throw new InternalError("Unexpected method mismatch during late inlining");
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   470
                }
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   471
            }
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   472
            if (scopes.size() == 0 && !lateInlining) {
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   473
                compile.setMethod(m);
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   474
                scopes.push(site);
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   475
            } else {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   476
                if (site.getMethod() == m) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   477
                    scopes.push(site);
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   478
                } 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
   479
                    scopes.push(scopes.peek().last(-2));
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   480
                } else {
25644
5319fc0701c7 8049532: LogCompilation: C1: inlining tree is flat (no depth is stored)
vlivanov
parents: 24673
diff changeset
   481
                    // C1 prints multiple method tags during inlining when it narrows method being inlinied.
5319fc0701c7 8049532: LogCompilation: C1: inlining tree is flat (no depth is stored)
vlivanov
parents: 24673
diff changeset
   482
                    // Example:
5319fc0701c7 8049532: LogCompilation: C1: inlining tree is flat (no depth is stored)
vlivanov
parents: 24673
diff changeset
   483
                    //   ...
5319fc0701c7 8049532: LogCompilation: C1: inlining tree is flat (no depth is stored)
vlivanov
parents: 24673
diff changeset
   484
                    //   <method id="813" holder="694" name="toString" return="695" flags="1" bytes="36" iicount="1"/>
5319fc0701c7 8049532: LogCompilation: C1: inlining tree is flat (no depth is stored)
vlivanov
parents: 24673
diff changeset
   485
                    //   <call method="813" instr="invokevirtual"/>
5319fc0701c7 8049532: LogCompilation: C1: inlining tree is flat (no depth is stored)
vlivanov
parents: 24673
diff changeset
   486
                    //   <inline_success reason="receiver is statically known"/>
5319fc0701c7 8049532: LogCompilation: C1: inlining tree is flat (no depth is stored)
vlivanov
parents: 24673
diff changeset
   487
                    //   <method id="814" holder="792" name="toString" return="695" flags="1" bytes="5" iicount="3"/>
5319fc0701c7 8049532: LogCompilation: C1: inlining tree is flat (no depth is stored)
vlivanov
parents: 24673
diff changeset
   488
                    //   <parse method="814">
5319fc0701c7 8049532: LogCompilation: C1: inlining tree is flat (no depth is stored)
vlivanov
parents: 24673
diff changeset
   489
                    //   ...
5319fc0701c7 8049532: LogCompilation: C1: inlining tree is flat (no depth is stored)
vlivanov
parents: 24673
diff changeset
   490
                    site.setMethod(m);
5319fc0701c7 8049532: LogCompilation: C1: inlining tree is flat (no depth is stored)
vlivanov
parents: 24673
diff changeset
   491
                    scopes.push(site);
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   492
                }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   493
            }
10563
b9b82ff9f0e9 7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents: 5547
diff changeset
   494
        } else if (qname.equals("parse_done")) {
b9b82ff9f0e9 7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents: 5547
diff changeset
   495
            CallSite call = scopes.pop();
19712
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 14628
diff changeset
   496
            call.setEndNodes(Integer.parseInt(search(atts, "nodes", "0")));
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 14628
diff changeset
   497
            call.setEndLiveNodes(Integer.parseInt(search(atts, "live", "0")));
10563
b9b82ff9f0e9 7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents: 5547
diff changeset
   498
            call.setTimeStamp(Double.parseDouble(search(atts, "stamp")));
b9b82ff9f0e9 7081842: assert(Compile::current()->unique() < (uint)MaxNodeLimit) failed: Node limit exceeded
kvn
parents: 5547
diff changeset
   499
            scopes.push(call);
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   500
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   501
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   502
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   503
    @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   504
    public void endElement(String uri,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   505
            String localName,
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   506
            String qname) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   507
        if (qname.equals("parse")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   508
            indent -= 2;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   509
            scopes.pop();
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   510
            if (scopes.size() == 0) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   511
                lateInlining = false;
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   512
            }
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   513
        } else if (qname.equals("uncommon_trap")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   514
            currentTrap = null;
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   515
        } else if (qname.equals("late_inline")) {
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   516
            // Populate late inlining info.
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   517
            if (scopes.size() != 0) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   518
                throw new InternalError("scopes should be empty for late inline");
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   519
            }
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   520
            // late inline scopes are specified in reverse order:
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   521
            // compiled method should be on top of stack.
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   522
            CallSite caller = lateInlineScope.pop();
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   523
            Method m = compile.getMethod();
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   524
            if (m != caller.getMethod()) {
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   525
                System.out.println(m);
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   526
                System.out.println(caller.getMethod() + " bci: " + bci);
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   527
                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
   528
            }
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   529
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   530
            // late_inline contains caller+bci info, convert it
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   531
            // to bci+callee info used by LogCompilation.
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   532
            CallSite lateInlineSite = compile.getLateInlineCall();
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   533
            ArrayDeque<CallSite> thisCallScopes = new ArrayDeque<CallSite>();
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   534
            do {
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   535
                bci = caller.getBci();
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   536
                // Next inlined call.
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   537
                caller = lateInlineScope.pop();
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   538
                CallSite callee =  new CallSite(bci, caller.getMethod());
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   539
                callee.setInlineId(caller.getInlineId());
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   540
                thisCallScopes.addLast(callee);
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   541
                lateInlineSite.add(callee);
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   542
                lateInlineSite = callee;
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   543
            } while (!lateInlineScope.empty());
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   544
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   545
            site = compile.getCall().findCallSite(thisCallScopes);
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   546
            if (site == null) {
24673
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   547
                System.out.println("call scopes:");
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   548
                for (CallSite c : thisCallScopes) {
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   549
                    System.out.println(c.getMethod() + " " + c.getBci() + " " + c.getInlineId());
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   550
                }
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   551
                CallSite c = thisCallScopes.getLast();
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   552
                if (c.getInlineId() != 0) {
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   553
                    System.out.println("Looking for call site in entire tree:");
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   554
                    ArrayDeque<CallSite> stack = compile.getCall().findCallSite2(c);
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   555
                    for (CallSite c2 : stack) {
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   556
                        System.out.println(c2.getMethod() + " " + c2.getBci() + " " + c2.getInlineId());
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   557
                    }
2ec56802b829 8043638: Multiple compilation attempts break LogCompulation, lead to confusing PrintInlining output
roland
parents: 24002
diff changeset
   558
                }
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   559
                System.out.println(caller.getMethod() + " bci: " + bci);
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   560
                throw new InternalError("couldn't find call site");
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   561
            }
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   562
            lateInlining = true;
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   563
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   564
            if (caller.getBci() != -999) {
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   565
                System.out.println(caller.getMethod());
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   566
                throw new InternalError("broken late_inline info");
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   567
            }
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   568
            if (site.getMethod() != caller.getMethod()) {
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   569
                if (site.getInlineId() == caller.getInlineId()) {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   570
                    site.setMethod(caller.getMethod());
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   571
                } else {
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   572
                    System.out.println(site.getMethod());
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   573
                    System.out.println(caller.getMethod());
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   574
                    throw new InternalError("call site and late_inline info don't match");
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   575
                }
11960
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   576
            }
57898a1b4b44 7147416: LogCompilation tool does not work with post parse inlining
kvn
parents: 10563
diff changeset
   577
            // 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
   578
            // 'site' will be pushed to scopes.
24002
4e6a72032a99 8005079: fix LogCompilation for incremental inlining
roland
parents: 22234
diff changeset
   579
            lateInlineScope = null;
2126
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   580
        } else if (qname.equals("task")) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   581
            types.clear();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   582
            methods.clear();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   583
            site = null;
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   584
        }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   585
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   586
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   587
    @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   588
    public void warning(org.xml.sax.SAXParseException e) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   589
        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
   590
        e.printStackTrace();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   591
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   592
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   593
    @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   594
    public void error(org.xml.sax.SAXParseException e) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   595
        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
   596
        e.printStackTrace();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   597
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   598
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   599
    @Override
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   600
    public void fatalError(org.xml.sax.SAXParseException e) {
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   601
        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
   602
        e.printStackTrace();
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   603
    }
f6f30d1677a8 6807963: need tool to make sense of LogCompilaton output
never
parents:
diff changeset
   604
}