annotate graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java @ 21543:93c50cefb9e8

moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Mon, 25 May 2015 23:30:34 +0200
parents 4de8827ca59b
children b1530a6cce8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
1 /*
16154
f9f7bd1a6b2c IGV: Support for InputType.
Roland Schatz <roland.schatz@oracle.com>
parents: 15537
diff changeset
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
4 *
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
8 *
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
13 * accompanied this code).
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
14 *
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
18 *
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
21 * questions.
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
22 */
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
23 package com.oracle.graal.printer;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
24
15259
d90e5c22ba55 Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15241
diff changeset
25 import static com.oracle.graal.compiler.common.GraalOptions.*;
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
26 import static com.oracle.graal.graph.Edges.Type.*;
10808
4278ab23c66f new Option PrintGraphProbabilities to output probabilities during binary graph dumping
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
27
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
28 import java.io.*;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
29 import java.nio.*;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
30 import java.nio.channels.*;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
31 import java.util.*;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
32 import java.util.Map.Entry;
21543
93c50cefb9e8 moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21427
diff changeset
33
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
34 import com.oracle.graal.api.meta.*;
15192
644dfe49c0f4 Move packages com.oracle.graal.cfg to com.oracle.graal.compiler.common.cfg.
Josef Eisl <josef.eisl@jku.at>
parents: 15157
diff changeset
35 import com.oracle.graal.compiler.common.cfg.*;
17071
1b7b4eb6e0ef Enable scheduling when dumping for DumpOnError
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16897
diff changeset
36 import com.oracle.graal.debug.*;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
37 import com.oracle.graal.graph.*;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
38 import com.oracle.graal.nodes.*;
6529
2e96dc4eb8e2 renamed package: com.oracle.graal.lir.cfg -> com.oracle.graal.nodes.cfg
Doug Simon <doug.simon@oracle.com>
parents: 6525
diff changeset
39 import com.oracle.graal.nodes.cfg.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6391
diff changeset
40 import com.oracle.graal.phases.schedule.*;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
41
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
42 public class BinaryGraphPrinter implements GraphPrinter {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
43
12483
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12482
diff changeset
44 private static final int CONSTANT_POOL_MAX_SIZE = 8000;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
45
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
46 private static final int BEGIN_GROUP = 0x00;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
47 private static final int BEGIN_GRAPH = 0x01;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
48 private static final int CLOSE_GROUP = 0x02;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
49
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
50 private static final int POOL_NEW = 0x00;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
51 private static final int POOL_STRING = 0x01;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
52 private static final int POOL_ENUM = 0x02;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
53 private static final int POOL_CLASS = 0x03;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
54 private static final int POOL_METHOD = 0x04;
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
55 private static final int POOL_NULL = 0x05;
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
56 private static final int POOL_NODE_CLASS = 0x06;
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
57 private static final int POOL_FIELD = 0x07;
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
58 private static final int POOL_SIGNATURE = 0x08;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
59
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
60 private static final int PROPERTY_POOL = 0x00;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
61 private static final int PROPERTY_INT = 0x01;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
62 private static final int PROPERTY_LONG = 0x02;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
63 private static final int PROPERTY_DOUBLE = 0x03;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
64 private static final int PROPERTY_FLOAT = 0x04;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
65 private static final int PROPERTY_TRUE = 0x05;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
66 private static final int PROPERTY_FALSE = 0x06;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
67 private static final int PROPERTY_ARRAY = 0x07;
11678
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
68 private static final int PROPERTY_SUBGRAPH = 0x08;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
69
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
70 private static final int KLASS = 0x00;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
71 private static final int ENUM_KLASS = 0x01;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
72
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
73 private static final class ConstantPool extends LinkedHashMap<Object, Character> {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
74
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
75 private final LinkedList<Character> availableIds;
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
76 private char nextId;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
77 private static final long serialVersionUID = -2676889957907285681L;
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
78
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
79 public ConstantPool() {
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
80 super(50, 0.65f);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
81 availableIds = new LinkedList<>();
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
82 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
83
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
84 @Override
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
85 protected boolean removeEldestEntry(java.util.Map.Entry<Object, Character> eldest) {
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
86 if (size() > CONSTANT_POOL_MAX_SIZE) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
87 availableIds.addFirst(eldest.getValue());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
88 return true;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
89 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
90 return false;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
91 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
92
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
93 private Character nextAvailableId() {
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
94 if (!availableIds.isEmpty()) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
95 return availableIds.removeFirst();
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
96 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
97 return nextId++;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
98 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
99
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
100 public char add(Object obj) {
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
101 Character id = nextAvailableId();
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
102 put(obj, id);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
103 return id;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
104 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
105 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
106
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
107 private final ConstantPool constantPool;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
108 private final ByteBuffer buffer;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
109 private final WritableByteChannel channel;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
110
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
111 public BinaryGraphPrinter(WritableByteChannel channel) {
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
112 constantPool = new ConstantPool();
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
113 buffer = ByteBuffer.allocateDirect(256 * 1024);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
114 this.channel = channel;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
115 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
116
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
117 public void print(Graph graph, String title, SchedulePhase predefinedSchedule) throws IOException {
11678
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
118 writeByte(BEGIN_GRAPH);
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
119 writePoolObject(title);
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
120 writeGraph(graph, predefinedSchedule);
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
121 flush();
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
122 }
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
123
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
124 private void writeGraph(Graph graph) throws IOException {
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
125 writeGraph(graph, null);
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
126 }
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
127
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
128 private void writeGraph(Graph graph, SchedulePhase predefinedSchedule) throws IOException {
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
129 SchedulePhase schedule = predefinedSchedule;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
130 if (schedule == null) {
17071
1b7b4eb6e0ef Enable scheduling when dumping for DumpOnError
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16897
diff changeset
131 // Also provide a schedule when an error occurs
1b7b4eb6e0ef Enable scheduling when dumping for DumpOnError
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16897
diff changeset
132 if (PrintIdealGraphSchedule.getValue() || Debug.contextLookup(Throwable.class) != null) {
16607
07de1d5d53ef make scheduling before dumping optional to speed up dumping
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16590
diff changeset
133 try {
07de1d5d53ef make scheduling before dumping optional to speed up dumping
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16590
diff changeset
134 schedule = new SchedulePhase();
07de1d5d53ef make scheduling before dumping optional to speed up dumping
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16590
diff changeset
135 schedule.apply((StructuredGraph) graph);
07de1d5d53ef make scheduling before dumping optional to speed up dumping
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16590
diff changeset
136 } catch (Throwable t) {
07de1d5d53ef make scheduling before dumping optional to speed up dumping
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16590
diff changeset
137 }
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
138 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
139 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
140 ControlFlowGraph cfg = schedule == null ? null : schedule.getCFG();
19824
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19609
diff changeset
141 BlockMap<List<Node>> blockToNodes = schedule == null ? null : schedule.getBlockToNodesMap();
20027
87419b0d9bfb BinaryGraphPrinter: if a schedule is available, also print he node-to-blocks mapping in addition to the block-to-nodes
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19859
diff changeset
142 NodeMap<Block> nodeToBlocks = schedule == null ? null : schedule.getNodeToBlockMap();
15537
8117e9cadb48 Use List instead of an array in AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15470
diff changeset
143 List<Block> blocks = cfg == null ? null : cfg.getBlocks();
20069
2dbfa1ed5efa Reduce usages of fixed node probability cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20058
diff changeset
144 writeNodes(graph, nodeToBlocks, cfg);
12760
aeb651f3c5d9 made external node ids stable across graph dumps to the IGV
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
145 writeBlocks(blocks, blockToNodes);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
146 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
147
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
148 private void flush() throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
149 buffer.flip();
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5815
diff changeset
150 channel.write(buffer);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
151 buffer.compact();
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
152 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
153
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
154 private void ensureAvailable(int i) throws IOException {
12480
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
155 assert buffer.capacity() >= i : "Can not make " + i + " bytes available, buffer is too small";
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
156 while (buffer.remaining() < i) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
157 flush();
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
158 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
159 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
160
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
161 private void writeByte(int b) throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
162 ensureAvailable(1);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
163 buffer.put((byte) b);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
164 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
165
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
166 private void writeInt(int b) throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
167 ensureAvailable(4);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
168 buffer.putInt(b);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
169 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
170
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
171 private void writeLong(long b) throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
172 ensureAvailable(8);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
173 buffer.putLong(b);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
174 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
175
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
176 private void writeDouble(double b) throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
177 ensureAvailable(8);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
178 buffer.putDouble(b);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
179 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
180
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
181 private void writeFloat(float b) throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
182 ensureAvailable(4);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
183 buffer.putFloat(b);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
184 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
185
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
186 private void writeShort(char b) throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
187 ensureAvailable(2);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
188 buffer.putChar(b);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
189 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
190
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
191 private void writeString(String str) throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
192 writeInt(str.length());
12480
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
193 int sizeInBytes = str.length() * 2;
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
194 ensureAvailable(sizeInBytes);
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
195 buffer.asCharBuffer().put(str);
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
196 buffer.position(buffer.position() + sizeInBytes);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
197 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
198
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
199 private void writeBytes(byte[] b) throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
200 if (b == null) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
201 writeInt(-1);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
202 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
203 writeInt(b.length);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
204 ensureAvailable(b.length);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
205 buffer.put(b);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
206 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
207 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
208
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
209 private void writeInts(int[] b) throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
210 if (b == null) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
211 writeInt(-1);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
212 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
213 writeInt(b.length);
12480
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
214 int sizeInBytes = b.length * 4;
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
215 ensureAvailable(sizeInBytes);
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
216 buffer.asIntBuffer().put(b);
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
217 buffer.position(buffer.position() + sizeInBytes);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
218 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
219 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
220
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
221 private void writeDoubles(double[] b) throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
222 if (b == null) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
223 writeInt(-1);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
224 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
225 writeInt(b.length);
12480
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
226 int sizeInBytes = b.length * 8;
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
227 ensureAvailable(sizeInBytes);
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
228 buffer.asDoubleBuffer().put(b);
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
229 buffer.position(buffer.position() + sizeInBytes);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
230 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
231 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
232
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
233 private void writePoolObject(Object object) throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
234 if (object == null) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
235 writeByte(POOL_NULL);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
236 return;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
237 }
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
238 Character id = constantPool.get(object);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
239 if (id == null) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
240 addPoolEntry(object);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
241 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
242 if (object instanceof Enum<?>) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
243 writeByte(POOL_ENUM);
7052
47c120841ceb removed a usage of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
244 } else if (object instanceof Class<?> || object instanceof JavaType) {
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
245 writeByte(POOL_CLASS);
17272
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17261
diff changeset
246 } else if (object instanceof NodeClass) {
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17261
diff changeset
247 writeByte(POOL_NODE_CLASS);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
248 } else if (object instanceof ResolvedJavaMethod) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
249 writeByte(POOL_METHOD);
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
250 } else if (object instanceof ResolvedJavaField) {
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
251 writeByte(POOL_FIELD);
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
252 } else if (object instanceof Signature) {
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
253 writeByte(POOL_SIGNATURE);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
254 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
255 writeByte(POOL_STRING);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
256 }
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
257 writeShort(id.charValue());
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
258 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
259 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
260
6391
07cd99f9dafb use more sensible string representation for classes in the binary graph protocol
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5819
diff changeset
261 private static String getClassName(Class<?> klass) {
07cd99f9dafb use more sensible string representation for classes in the binary graph protocol
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5819
diff changeset
262 if (!klass.isArray()) {
07cd99f9dafb use more sensible string representation for classes in the binary graph protocol
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5819
diff changeset
263 return klass.getName();
07cd99f9dafb use more sensible string representation for classes in the binary graph protocol
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5819
diff changeset
264 }
07cd99f9dafb use more sensible string representation for classes in the binary graph protocol
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5819
diff changeset
265 return getClassName(klass.getComponentType()) + "[]";
07cd99f9dafb use more sensible string representation for classes in the binary graph protocol
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5819
diff changeset
266 }
07cd99f9dafb use more sensible string representation for classes in the binary graph protocol
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5819
diff changeset
267
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
268 private void addPoolEntry(Object object) throws IOException {
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
269 char index = constantPool.add(object);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
270 writeByte(POOL_NEW);
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
271 writeShort(index);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
272 if (object instanceof Class<?>) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
273 Class<?> klass = (Class<?>) object;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
274 writeByte(POOL_CLASS);
6391
07cd99f9dafb use more sensible string representation for classes in the binary graph protocol
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5819
diff changeset
275 writeString(getClassName(klass));
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
276 if (klass.isEnum()) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
277 writeByte(ENUM_KLASS);
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
278 Object[] enumConstants = klass.getEnumConstants();
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
279 writeInt(enumConstants.length);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
280 for (Object o : enumConstants) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
281 writePoolObject(((Enum<?>) o).name());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
282 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
283 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
284 writeByte(KLASS);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
285 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
286 } else if (object instanceof Enum<?>) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
287 writeByte(POOL_ENUM);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
288 writePoolObject(object.getClass());
15040
288c23143d47 Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents: 13327
diff changeset
289 writeInt(((Enum<?>) object).ordinal());
7052
47c120841ceb removed a usage of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
290 } else if (object instanceof JavaType) {
47c120841ceb removed a usage of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
291 JavaType type = (JavaType) object;
47c120841ceb removed a usage of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
292 writeByte(POOL_CLASS);
16479
558cf39c646b moved toJavaName(JavaType type) from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents: 16154
diff changeset
293 writeString(type.toJavaName());
7052
47c120841ceb removed a usage of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
294 writeByte(KLASS);
17272
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17261
diff changeset
295 } else if (object instanceof NodeClass) {
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18941
diff changeset
296 NodeClass<?> nodeClass = (NodeClass<?>) object;
17272
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17261
diff changeset
297 writeByte(POOL_NODE_CLASS);
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17261
diff changeset
298 writeString(nodeClass.getJavaClass().getSimpleName());
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17261
diff changeset
299 writeString(nodeClass.getNameTemplate());
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17261
diff changeset
300 writeEdgesInfo(nodeClass, Inputs);
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17261
diff changeset
301 writeEdgesInfo(nodeClass, Successors);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
302 } else if (object instanceof ResolvedJavaMethod) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
303 writeByte(POOL_METHOD);
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
304 ResolvedJavaMethod method = ((ResolvedJavaMethod) object);
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
305 writePoolObject(method.getDeclaringClass());
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
306 writePoolObject(method.getName());
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
307 writePoolObject(method.getSignature());
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
308 writeInt(method.getModifiers());
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
309 writeBytes(method.getCode());
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
310 } else if (object instanceof ResolvedJavaField) {
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
311 writeByte(POOL_FIELD);
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
312 ResolvedJavaField field = ((ResolvedJavaField) object);
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
313 writePoolObject(field.getDeclaringClass());
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
314 writePoolObject(field.getName());
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
315 writePoolObject(field.getType().getName());
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
316 writeInt(field.getModifiers());
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
317 } else if (object instanceof Signature) {
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
318 writeByte(POOL_SIGNATURE);
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
319 Signature signature = ((Signature) object);
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
320 int args = signature.getParameterCount(false);
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
321 writeShort((char) args);
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
322 for (int i = 0; i < args; i++) {
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
323 writePoolObject(signature.getParameterType(i, null).getName());
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
324 }
6539
2463eb24b644 Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6529
diff changeset
325 writePoolObject(signature.getReturnType(null).getName());
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
326 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
327 writeByte(POOL_STRING);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
328 writeString(object.toString());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
329 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
330 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
331
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18941
diff changeset
332 private void writeEdgesInfo(NodeClass<?> nodeClass, Edges.Type type) throws IOException {
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
333 Edges edges = nodeClass.getEdges(type);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
334 writeShort((char) edges.getCount());
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
335 for (int i = 0; i < edges.getCount(); i++) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
336 writeByte(i < edges.getDirectCount() ? 0 : 1);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
337 writePoolObject(edges.getName(i));
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
338 if (type == Inputs) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
339 writePoolObject(((InputEdges) edges).getInputType(i));
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
340 }
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
341 }
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
342 }
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
343
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
344 private void writePropertyObject(Object obj) throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
345 if (obj instanceof Integer) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
346 writeByte(PROPERTY_INT);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
347 writeInt(((Integer) obj).intValue());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
348 } else if (obj instanceof Long) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
349 writeByte(PROPERTY_LONG);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
350 writeLong(((Long) obj).longValue());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
351 } else if (obj instanceof Double) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
352 writeByte(PROPERTY_DOUBLE);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
353 writeDouble(((Double) obj).doubleValue());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
354 } else if (obj instanceof Float) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
355 writeByte(PROPERTY_FLOAT);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
356 writeFloat(((Float) obj).floatValue());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
357 } else if (obj instanceof Boolean) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
358 if (((Boolean) obj).booleanValue()) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
359 writeByte(PROPERTY_TRUE);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
360 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
361 writeByte(PROPERTY_FALSE);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
362 }
11678
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
363 } else if (obj instanceof Graph) {
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
364 writeByte(PROPERTY_SUBGRAPH);
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
365 writeGraph((Graph) obj);
21427
4de8827ca59b Add support of CachedGraph to BinaryGraphPrinter.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20069
diff changeset
366 } else if (obj instanceof CachedGraph) {
4de8827ca59b Add support of CachedGraph to BinaryGraphPrinter.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20069
diff changeset
367 writeByte(PROPERTY_SUBGRAPH);
4de8827ca59b Add support of CachedGraph to BinaryGraphPrinter.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20069
diff changeset
368 writeGraph(((CachedGraph<?>) obj).getReadonlyCopy());
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
369 } else if (obj != null && obj.getClass().isArray()) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
370 Class<?> componentType = obj.getClass().getComponentType();
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
371 if (componentType.isPrimitive()) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
372 if (componentType == Double.TYPE) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
373 writeByte(PROPERTY_ARRAY);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
374 writeByte(PROPERTY_DOUBLE);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
375 writeDoubles((double[]) obj);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
376 } else if (componentType == Integer.TYPE) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
377 writeByte(PROPERTY_ARRAY);
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
378 writeByte(PROPERTY_INT);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
379 writeInts((int[]) obj);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
380 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
381 writeByte(PROPERTY_POOL);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
382 writePoolObject(obj);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
383 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
384 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
385 writeByte(PROPERTY_ARRAY);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
386 writeByte(PROPERTY_POOL);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
387 Object[] array = (Object[]) obj;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
388 writeInt(array.length);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
389 for (Object o : array) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
390 writePoolObject(o);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
391 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
392 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
393 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
394 writeByte(PROPERTY_POOL);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
395 writePoolObject(obj);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
396 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
397 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
398
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
399 @SuppressWarnings("deprecation")
13327
c258331fdde6 removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12760
diff changeset
400 private static int getNodeId(Node node) {
c258331fdde6 removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12760
diff changeset
401 return node.getId();
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12511
diff changeset
402 }
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12511
diff changeset
403
20069
2dbfa1ed5efa Reduce usages of fixed node probability cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20058
diff changeset
404 private void writeNodes(Graph graph, NodeMap<Block> nodeToBlocks, ControlFlowGraph cfg) throws IOException {
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
405 Map<Object, Object> props = new HashMap<>();
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12511
diff changeset
406
13327
c258331fdde6 removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12760
diff changeset
407 writeInt(graph.getNodeCount());
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12511
diff changeset
408
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
409 for (Node node : graph.getNodes()) {
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18941
diff changeset
410 NodeClass<?> nodeClass = node.getNodeClass();
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
411 node.getDebugProperties(props);
20069
2dbfa1ed5efa Reduce usages of fixed node probability cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20058
diff changeset
412 if (cfg != null && PrintGraphProbabilities.getValue() && node instanceof FixedNode) {
16590
c62c1e0060cc Don't allow infinite loops to explode loop frequencies
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16479
diff changeset
413 try {
20069
2dbfa1ed5efa Reduce usages of fixed node probability cache.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20058
diff changeset
414 props.put("probability", cfg.blockFor(node).probability());
16590
c62c1e0060cc Don't allow infinite loops to explode loop frequencies
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16479
diff changeset
415 } catch (Throwable t) {
c62c1e0060cc Don't allow infinite loops to explode loop frequencies
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16479
diff changeset
416 props.put("probability", t);
c62c1e0060cc Don't allow infinite loops to explode loop frequencies
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16479
diff changeset
417 }
10808
4278ab23c66f new Option PrintGraphProbabilities to output probabilities during binary graph dumping
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
418 }
20027
87419b0d9bfb BinaryGraphPrinter: if a schedule is available, also print he node-to-blocks mapping in addition to the block-to-nodes
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19859
diff changeset
419 if (nodeToBlocks != null) {
87419b0d9bfb BinaryGraphPrinter: if a schedule is available, also print he node-to-blocks mapping in addition to the block-to-nodes
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19859
diff changeset
420 if (nodeToBlocks.isNew(node)) {
87419b0d9bfb BinaryGraphPrinter: if a schedule is available, also print he node-to-blocks mapping in addition to the block-to-nodes
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19859
diff changeset
421 props.put("node-to-block", "NEW (not in schedule)");
87419b0d9bfb BinaryGraphPrinter: if a schedule is available, also print he node-to-blocks mapping in addition to the block-to-nodes
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19859
diff changeset
422 } else {
87419b0d9bfb BinaryGraphPrinter: if a schedule is available, also print he node-to-blocks mapping in addition to the block-to-nodes
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19859
diff changeset
423 Block block = nodeToBlocks.get(node);
87419b0d9bfb BinaryGraphPrinter: if a schedule is available, also print he node-to-blocks mapping in addition to the block-to-nodes
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19859
diff changeset
424 if (block != null) {
87419b0d9bfb BinaryGraphPrinter: if a schedule is available, also print he node-to-blocks mapping in addition to the block-to-nodes
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19859
diff changeset
425 props.put("node-to-block", block.getId());
87419b0d9bfb BinaryGraphPrinter: if a schedule is available, also print he node-to-blocks mapping in addition to the block-to-nodes
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19859
diff changeset
426 }
87419b0d9bfb BinaryGraphPrinter: if a schedule is available, also print he node-to-blocks mapping in addition to the block-to-nodes
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19859
diff changeset
427 }
87419b0d9bfb BinaryGraphPrinter: if a schedule is available, also print he node-to-blocks mapping in addition to the block-to-nodes
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 19859
diff changeset
428 }
20055
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
429
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
430 if (node instanceof ControlSinkNode) {
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
431 props.put("category", "controlSink");
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
432 } else if (node instanceof ControlSplitNode) {
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
433 props.put("category", "controlSplit");
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
434 } else if (node instanceof AbstractMergeNode) {
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
435 props.put("category", "merge");
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
436 } else if (node instanceof AbstractBeginNode) {
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
437 props.put("category", "begin");
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
438 } else if (node instanceof AbstractEndNode) {
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
439 props.put("category", "end");
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
440 } else if (node instanceof FixedNode) {
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
441 props.put("category", "fixed");
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
442 } else if (node instanceof VirtualState) {
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
443 props.put("category", "state");
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
444 } else if (node instanceof PhiNode) {
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
445 props.put("category", "phi");
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
446 } else if (node instanceof ProxyNode) {
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
447 props.put("category", "proxy");
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
448 } else {
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
449 props.put("category", "floating");
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
450 }
4042339df317 Improve coloring and filters in IGV.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 20027
diff changeset
451
12760
aeb651f3c5d9 made external node ids stable across graph dumps to the IGV
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
452 writeInt(getNodeId(node));
17272
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17261
diff changeset
453 writePoolObject(nodeClass);
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
454 writeByte(node.predecessor() == null ? 0 : 1);
12511
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
455 // properties
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
456 writeShort((char) props.size());
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
457 for (Entry<Object, Object> entry : props.entrySet()) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
458 String key = entry.getKey().toString();
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
459 writePoolObject(key);
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
460 writePropertyObject(entry.getValue());
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
461 }
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
462 writeEdges(node, Inputs);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
463 writeEdges(node, Successors);
12511
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
464
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
465 props.clear();
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
466 }
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
467 }
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
468
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
469 private void writeEdges(Node node, Edges.Type type) throws IOException {
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18941
diff changeset
470 NodeClass<?> nodeClass = node.getNodeClass();
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
471 Edges edges = nodeClass.getEdges(type);
19609
b964772c43bd Changes to the node list iterators to make more values loop invariant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
472 final long[] curOffsets = edges.getOffsets();
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
473 for (int i = 0; i < edges.getDirectCount(); i++) {
19609
b964772c43bd Changes to the node list iterators to make more values loop invariant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
474 writeNodeRef(Edges.getNode(node, curOffsets, i));
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
475 }
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
476 for (int i = edges.getDirectCount(); i < edges.getCount(); i++) {
19609
b964772c43bd Changes to the node list iterators to make more values loop invariant.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
477 NodeList<Node> list = Edges.getNodeList(node, curOffsets, i);
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
478 if (list == null) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
479 writeShort((char) 0);
12511
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
480 } else {
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
481 int listSize = list.count();
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
482 assert listSize == ((char) listSize);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
483 writeShort((char) listSize);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
484 for (Node edge : list) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17071
diff changeset
485 writeNodeRef(edge);
12483
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12482
diff changeset
486 }
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
487 }
12511
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
488 }
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
489 }
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
490
12760
aeb651f3c5d9 made external node ids stable across graph dumps to the IGV
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
491 private void writeNodeRef(Node edge) throws IOException {
12511
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
492 if (edge != null) {
12760
aeb651f3c5d9 made external node ids stable across graph dumps to the IGV
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
493 writeInt(getNodeId(edge));
12511
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
494 } else {
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
495 writeInt(-1);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
496 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
497 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
498
19824
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19609
diff changeset
499 private void writeBlocks(List<Block> blocks, BlockMap<List<Node>> blockToNodes) throws IOException {
19859
ba265a5410e0 Add utility Node#pushInputs(NodeStack).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19824
diff changeset
500 if (blocks != null && blockToNodes != null) {
19824
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19609
diff changeset
501 for (Block block : blocks) {
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19609
diff changeset
502 List<Node> nodes = blockToNodes.get(block);
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19609
diff changeset
503 if (nodes == null) {
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19609
diff changeset
504 writeInt(0);
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19609
diff changeset
505 return;
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19609
diff changeset
506 }
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19609
diff changeset
507 }
15537
8117e9cadb48 Use List instead of an array in AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15470
diff changeset
508 writeInt(blocks.size());
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
509 for (Block block : blocks) {
19824
6b73ce815fc2 Add a new algorithm for latest possible schedule. Fix earliest possible schedule for the case of floating reads. Add scheduling test cases.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19609
diff changeset
510 List<Node> nodes = blockToNodes.get(block);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
511 writeInt(block.getId());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
512 writeInt(nodes.size());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
513 for (Node node : nodes) {
12760
aeb651f3c5d9 made external node ids stable across graph dumps to the IGV
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
514 writeInt(getNodeId(node));
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
515 }
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
516 writeInt(block.getSuccessors().size());
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
517 for (Block sux : block.getSuccessors()) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
518 writeInt(sux.getId());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
519 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
520 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
521 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
522 writeInt(0);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
523 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
524 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
525
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
526 public void beginGroup(String name, String shortName, ResolvedJavaMethod method, int bci) throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
527 writeByte(BEGIN_GROUP);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
528 writePoolObject(name);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
529 writePoolObject(shortName);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
530 writePoolObject(method);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
531 writeInt(bci);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
532 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
533
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
534 public void endGroup() throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
535 writeByte(CLOSE_GROUP);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
536 }
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5815
diff changeset
537
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5815
diff changeset
538 @Override
7032
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
539 public void close() {
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
540 try {
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
541 flush();
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
542 channel.close();
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
543 } catch (IOException ex) {
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
544 throw new Error(ex);
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
545 }
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5815
diff changeset
546 }
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
547 }