annotate graal/com.oracle.graal.printer/src/com/oracle/graal/printer/BinaryGraphPrinter.java @ 18941:c943ba97b2a7

Remove class ScheduledNode from the node class hierarchy.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 24 Jan 2015 00:45:12 +0100
parents 9eb112c9337d
children 61d3cb8e1280
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;
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
33 import java.util.function.*;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
34
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
35 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
36 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
37 import com.oracle.graal.debug.*;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
38 import com.oracle.graal.graph.*;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
39 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
40 import com.oracle.graal.nodes.cfg.*;
10808
4278ab23c66f new Option PrintGraphProbabilities to output probabilities during binary graph dumping
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
41 import com.oracle.graal.phases.graph.*;
6525
2c913b643422 rename packages in graal.phases to match project name
Doug Simon <doug.simon@oracle.com>
parents: 6391
diff changeset
42 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
43
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
44 public class BinaryGraphPrinter implements GraphPrinter {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
45
12483
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12482
diff changeset
46 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
47
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
48 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
49 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
50 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
51
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
62 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
63 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
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
72 private static final int KLASS = 0x00;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
73 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
74
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
75 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
76
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
77 private final LinkedList<Character> availableIds;
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
78 private char nextId;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
79 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
80
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
81 public ConstantPool() {
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
82 super(50, 0.65f);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
83 availableIds = new LinkedList<>();
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
84 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
85
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
86 @Override
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
87 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
88 if (size() > CONSTANT_POOL_MAX_SIZE) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
89 availableIds.addFirst(eldest.getValue());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
90 return true;
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 return false;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
93 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
94
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
95 private Character nextAvailableId() {
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
96 if (!availableIds.isEmpty()) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
97 return availableIds.removeFirst();
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 return nextId++;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
100 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
101
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
102 public char add(Object obj) {
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
103 Character id = nextAvailableId();
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
104 put(obj, id);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
105 return id;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
106 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
107 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
108
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
109 private final ConstantPool constantPool;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
110 private final ByteBuffer buffer;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
111 private final WritableByteChannel channel;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
112
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
113 public BinaryGraphPrinter(WritableByteChannel channel) {
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
114 constantPool = new ConstantPool();
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
115 buffer = ByteBuffer.allocateDirect(256 * 1024);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
116 this.channel = channel;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
117 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
118
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
119 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
120 writeByte(BEGIN_GRAPH);
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
121 writePoolObject(title);
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
122 writeGraph(graph, predefinedSchedule);
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
123 flush();
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
124 }
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
125
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
126 private void writeGraph(Graph graph) throws IOException {
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
127 writeGraph(graph, null);
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
128 }
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
129
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
130 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
131 SchedulePhase schedule = predefinedSchedule;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
132 if (schedule == null) {
17071
1b7b4eb6e0ef Enable scheduling when dumping for DumpOnError
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16897
diff changeset
133 // 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
134 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
135 try {
07de1d5d53ef make scheduling before dumping optional to speed up dumping
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16590
diff changeset
136 schedule = new SchedulePhase();
07de1d5d53ef make scheduling before dumping optional to speed up dumping
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16590
diff changeset
137 schedule.apply((StructuredGraph) graph);
07de1d5d53ef make scheduling before dumping optional to speed up dumping
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16590
diff changeset
138 } catch (Throwable t) {
07de1d5d53ef make scheduling before dumping optional to speed up dumping
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16590
diff changeset
139 }
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
140 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
141 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
142 ControlFlowGraph cfg = schedule == null ? null : schedule.getCFG();
18941
c943ba97b2a7 Remove class ScheduledNode from the node class hierarchy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17272
diff changeset
143 BlockMap<List<ValueNode>> blockToNodes = schedule == null ? null : schedule.getBlockToNodesMap();
15537
8117e9cadb48 Use List instead of an array in AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15470
diff changeset
144 List<Block> blocks = cfg == null ? null : cfg.getBlocks();
12760
aeb651f3c5d9 made external node ids stable across graph dumps to the IGV
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
145 writeNodes(graph);
aeb651f3c5d9 made external node ids stable across graph dumps to the IGV
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
146 writeBlocks(blocks, blockToNodes);
5810
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
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
149 private void flush() throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
150 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
151 channel.write(buffer);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
152 buffer.compact();
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
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
155 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
156 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
157 while (buffer.remaining() < i) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
158 flush();
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
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
162 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
163 ensureAvailable(1);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
164 buffer.put((byte) b);
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
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
167 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
168 ensureAvailable(4);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
169 buffer.putInt(b);
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
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
172 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
173 ensureAvailable(8);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
174 buffer.putLong(b);
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
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
177 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
178 ensureAvailable(8);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
179 buffer.putDouble(b);
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
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
182 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
183 ensureAvailable(4);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
184 buffer.putFloat(b);
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
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
187 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
188 ensureAvailable(2);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
189 buffer.putChar(b);
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
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
192 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
193 writeInt(str.length());
12480
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
194 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
195 ensureAvailable(sizeInBytes);
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
196 buffer.asCharBuffer().put(str);
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
197 buffer.position(buffer.position() + sizeInBytes);
5810
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
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
200 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
201 if (b == null) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
202 writeInt(-1);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
203 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
204 writeInt(b.length);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
205 ensureAvailable(b.length);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
206 buffer.put(b);
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
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
210 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
211 if (b == null) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
212 writeInt(-1);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
213 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
214 writeInt(b.length);
12480
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
215 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
216 ensureAvailable(sizeInBytes);
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
217 buffer.asIntBuffer().put(b);
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
218 buffer.position(buffer.position() + sizeInBytes);
5810
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
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
222 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
223 if (b == null) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
224 writeInt(-1);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
225 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
226 writeInt(b.length);
12480
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
227 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
228 ensureAvailable(sizeInBytes);
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
229 buffer.asDoubleBuffer().put(b);
47200418768d Small optimizations to Binary Printer and IGV's BinaryParser
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11678
diff changeset
230 buffer.position(buffer.position() + sizeInBytes);
5810
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
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
234 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
235 if (object == null) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
236 writeByte(POOL_NULL);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
237 return;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
238 }
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
239 Character id = constantPool.get(object);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
240 if (id == null) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
241 addPoolEntry(object);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
242 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
243 if (object instanceof Enum<?>) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
244 writeByte(POOL_ENUM);
7052
47c120841ceb removed a usage of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
245 } 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
246 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
247 } 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
248 writeByte(POOL_NODE_CLASS);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
249 } else if (object instanceof ResolvedJavaMethod) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
250 writeByte(POOL_METHOD);
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
251 } else if (object instanceof ResolvedJavaField) {
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
252 writeByte(POOL_FIELD);
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
253 } else if (object instanceof Signature) {
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
254 writeByte(POOL_SIGNATURE);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
255 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
256 writeByte(POOL_STRING);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
257 }
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
258 writeShort(id.charValue());
5810
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 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
261
6391
07cd99f9dafb use more sensible string representation for classes in the binary graph protocol
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5819
diff changeset
262 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
263 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
264 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
265 }
07cd99f9dafb use more sensible string representation for classes in the binary graph protocol
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5819
diff changeset
266 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
267 }
07cd99f9dafb use more sensible string representation for classes in the binary graph protocol
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5819
diff changeset
268
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
269 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
270 char index = constantPool.add(object);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
271 writeByte(POOL_NEW);
12482
f8c99c2bbb37 Binary Graphs: use 16bits for pool indices
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12480
diff changeset
272 writeShort(index);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
273 if (object instanceof Class<?>) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7123
diff changeset
274 Class<?> klass = (Class<?>) object;
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
275 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
276 writeString(getClassName(klass));
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
277 if (klass.isEnum()) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
278 writeByte(ENUM_KLASS);
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
279 Object[] enumConstants = klass.getEnumConstants();
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
280 writeInt(enumConstants.length);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
281 for (Object o : enumConstants) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
282 writePoolObject(((Enum<?>) o).name());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
283 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
284 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
285 writeByte(KLASS);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
286 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
287 } else if (object instanceof Enum<?>) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
288 writeByte(POOL_ENUM);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
289 writePoolObject(object.getClass());
15040
288c23143d47 Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents: 13327
diff changeset
290 writeInt(((Enum<?>) object).ordinal());
7052
47c120841ceb removed a usage of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
291 } else if (object instanceof JavaType) {
47c120841ceb removed a usage of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
292 JavaType type = (JavaType) object;
47c120841ceb removed a usage of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
293 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
294 writeString(type.toJavaName());
7052
47c120841ceb removed a usage of ResolvedJavaType.toJava()
Doug Simon <doug.simon@oracle.com>
parents: 7032
diff changeset
295 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
296 } 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
297 NodeClass nodeClass = (NodeClass) object;
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17261
diff changeset
298 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
299 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
300 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
301 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
302 writeEdgesInfo(nodeClass, Successors);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
303 } else if (object instanceof ResolvedJavaMethod) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
304 writeByte(POOL_METHOD);
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
305 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
306 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
307 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
308 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
309 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
310 writeBytes(method.getCode());
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
311 } else if (object instanceof ResolvedJavaField) {
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
312 writeByte(POOL_FIELD);
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
313 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
314 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
315 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
316 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
317 writeInt(field.getModifiers());
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
318 } else if (object instanceof Signature) {
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
319 writeByte(POOL_SIGNATURE);
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
320 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
321 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
322 writeShort((char) args);
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
323 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
324 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
325 }
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
326 writePoolObject(signature.getReturnType(null).getName());
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
327 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
328 writeByte(POOL_STRING);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
329 writeString(object.toString());
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 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
332
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 private void writeEdgesInfo(NodeClass nodeClass, Edges.Type type) throws IOException {
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 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
335 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
336 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
337 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
338 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
339 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
340 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
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 }
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
344
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
345 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
346 if (obj instanceof Integer) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
347 writeByte(PROPERTY_INT);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
348 writeInt(((Integer) obj).intValue());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
349 } else if (obj instanceof Long) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
350 writeByte(PROPERTY_LONG);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
351 writeLong(((Long) obj).longValue());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
352 } else if (obj instanceof Double) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
353 writeByte(PROPERTY_DOUBLE);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
354 writeDouble(((Double) obj).doubleValue());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
355 } else if (obj instanceof Float) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
356 writeByte(PROPERTY_FLOAT);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
357 writeFloat(((Float) obj).floatValue());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
358 } else if (obj instanceof Boolean) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
359 if (((Boolean) obj).booleanValue()) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
360 writeByte(PROPERTY_TRUE);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
361 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
362 writeByte(PROPERTY_FALSE);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
363 }
11678
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
364 } else if (obj instanceof Graph) {
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
365 writeByte(PROPERTY_SUBGRAPH);
89e9476040de Support for sub-graphs in IGV.
Roland Schatz <roland.schatz@oracle.com>
parents: 10808
diff changeset
366 writeGraph((Graph) obj);
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
367 } 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
368 Class<?> componentType = obj.getClass().getComponentType();
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
369 if (componentType.isPrimitive()) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
370 if (componentType == Double.TYPE) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
371 writeByte(PROPERTY_ARRAY);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
372 writeByte(PROPERTY_DOUBLE);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
373 writeDoubles((double[]) obj);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
374 } else if (componentType == Integer.TYPE) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
375 writeByte(PROPERTY_ARRAY);
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
376 writeByte(PROPERTY_INT);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
377 writeInts((int[]) obj);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
378 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
379 writeByte(PROPERTY_POOL);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
380 writePoolObject(obj);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
381 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
382 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
383 writeByte(PROPERTY_ARRAY);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
384 writeByte(PROPERTY_POOL);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
385 Object[] array = (Object[]) obj;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
386 writeInt(array.length);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
387 for (Object o : array) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
388 writePoolObject(o);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
389 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
390 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
391 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
392 writeByte(PROPERTY_POOL);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
393 writePoolObject(obj);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
394 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
395 }
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 @SuppressWarnings("deprecation")
13327
c258331fdde6 removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12760
diff changeset
398 private static int getNodeId(Node node) {
c258331fdde6 removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12760
diff changeset
399 return node.getId();
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12511
diff changeset
400 }
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12511
diff changeset
401
12760
aeb651f3c5d9 made external node ids stable across graph dumps to the IGV
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
402 private void writeNodes(Graph graph) throws IOException {
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
403 ToDoubleFunction<FixedNode> probabilities = null;
10808
4278ab23c66f new Option PrintGraphProbabilities to output probabilities during binary graph dumping
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
404 if (PrintGraphProbabilities.getValue()) {
4278ab23c66f new Option PrintGraphProbabilities to output probabilities during binary graph dumping
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
405 try {
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
406 probabilities = new FixedNodeProbabilityCache();
10808
4278ab23c66f new Option PrintGraphProbabilities to output probabilities during binary graph dumping
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
407 } catch (Throwable t) {
4278ab23c66f new Option PrintGraphProbabilities to output probabilities during binary graph dumping
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
408 }
4278ab23c66f new Option PrintGraphProbabilities to output probabilities during binary graph dumping
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
409 }
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
410 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
411
13327
c258331fdde6 removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12760
diff changeset
412 writeInt(graph.getNodeCount());
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12511
diff changeset
413
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
414 for (Node node : graph.getNodes()) {
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
415 NodeClass nodeClass = node.getNodeClass();
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
416 node.getDebugProperties(props);
15470
c55f44b3c5e5 remove NodesToDoubles, refactoring of node probability and inlining relevance computation
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15259
diff changeset
417 if (probabilities != null && node instanceof FixedNode) {
16590
c62c1e0060cc Don't allow infinite loops to explode loop frequencies
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16479
diff changeset
418 try {
c62c1e0060cc Don't allow infinite loops to explode loop frequencies
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16479
diff changeset
419 props.put("probability", probabilities.applyAsDouble((FixedNode) node));
c62c1e0060cc Don't allow infinite loops to explode loop frequencies
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16479
diff changeset
420 } catch (Throwable t) {
c62c1e0060cc Don't allow infinite loops to explode loop frequencies
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16479
diff changeset
421 props.put("probability", t);
c62c1e0060cc Don't allow infinite loops to explode loop frequencies
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16479
diff changeset
422 }
10808
4278ab23c66f new Option PrintGraphProbabilities to output probabilities during binary graph dumping
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
423 }
12760
aeb651f3c5d9 made external node ids stable across graph dumps to the IGV
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
424 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
425 writePoolObject(nodeClass);
5814
d241f8b2e6f9 Adapt the coloring filter for binary dumped graphs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5813
diff changeset
426 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
427 // properties
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
428 writeShort((char) props.size());
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
429 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
430 String key = entry.getKey().toString();
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
431 writePoolObject(key);
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
432 writePropertyObject(entry.getValue());
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
433 }
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
434 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
435 writeEdges(node, Successors);
12511
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
436
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
437 props.clear();
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
438 }
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
439 }
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
440
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
441 private void writeEdges(Node node, Edges.Type type) throws IOException {
12511
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
442 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
443 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
444 for (int i = 0; i < edges.getDirectCount(); 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
445 writeNodeRef(edges.getNode(node, 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
446 }
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
447 for (int i = edges.getDirectCount(); 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
448 NodeList<Node> list = edges.getNodeList(node, 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
449 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
450 writeShort((char) 0);
12511
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
451 } 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
452 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
453 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
454 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
455 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
456 writeNodeRef(edge);
12483
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12482
diff changeset
457 }
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
458 }
12511
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
459 }
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
460 }
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
461
12760
aeb651f3c5d9 made external node ids stable across graph dumps to the IGV
Doug Simon <doug.simon@oracle.com>
parents: 12687
diff changeset
462 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
463 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
464 writeInt(getNodeId(edge));
12511
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
465 } else {
9e33b386281e Small refactoring of edge dumping in BinaryGraphPrinter
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
466 writeInt(-1);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
467 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
468 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
469
18941
c943ba97b2a7 Remove class ScheduledNode from the node class hierarchy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17272
diff changeset
470 private void writeBlocks(List<Block> blocks, BlockMap<List<ValueNode>> blockToNodes) throws IOException {
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
471 if (blocks != null) {
15537
8117e9cadb48 Use List instead of an array in AbstractControlFlowGraph.
Josef Eisl <josef.eisl@jku.at>
parents: 15470
diff changeset
472 writeInt(blocks.size());
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
473 for (Block block : blocks) {
18941
c943ba97b2a7 Remove class ScheduledNode from the node class hierarchy.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 17272
diff changeset
474 List<ValueNode> nodes = blockToNodes.get(block);
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
475 writeInt(block.getId());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
476 writeInt(nodes.size());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
477 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
478 writeInt(getNodeId(node));
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
479 }
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5812
diff changeset
480 writeInt(block.getSuccessors().size());
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
481 for (Block sux : block.getSuccessors()) {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
482 writeInt(sux.getId());
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
483 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
484 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
485 } else {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
486 writeInt(0);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
487 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
488 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
489
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
490 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
491 writeByte(BEGIN_GROUP);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
492 writePoolObject(name);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
493 writePoolObject(shortName);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
494 writePoolObject(method);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
495 writeInt(bci);
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 public void endGroup() throws IOException {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
499 writeByte(CLOSE_GROUP);
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
500 }
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5815
diff changeset
501
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5815
diff changeset
502 @Override
7032
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
503 public void close() {
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
504 try {
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
505 flush();
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
506 channel.close();
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
507 } catch (IOException ex) {
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
508 throw new Error(ex);
5a1f6e96e163 close() method for dump handlers should not throw IOException
Christian Wimmer <christian.wimmer@oracle.com>
parents: 6539
diff changeset
509 }
5819
8fd81d0e3acf Make DebugDumpHandler closable, close them on compiler thread when compiler threads finish
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5815
diff changeset
510 }
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff changeset
511 }