annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java @ 19529:8fc336a04d77

Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 20 Feb 2015 22:22:55 +0100
parents 55d0b9ec7587
children 353669a84287
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
12686
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
2 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
23 package com.oracle.graal.graph;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
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: 17127
diff changeset
25 import static com.oracle.graal.graph.Edges.Type.*;
16919
0fe4732e5181 made use of generated Node classes predicated on value of graal.useGeneratedNodes system property (default is false)
Doug Simon <doug.simon@oracle.com>
parents: 16897
diff changeset
26
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15146
diff changeset
29 import com.oracle.graal.compiler.common.*;
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
30 import com.oracle.graal.debug.*;
17338
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17328
diff changeset
31 import com.oracle.graal.debug.internal.*;
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14904
diff changeset
32 import com.oracle.graal.graph.Node.ValueNumberable;
5060
4ed4295ce15f Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5059
diff changeset
33 import com.oracle.graal.graph.iterators.*;
17127
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
34 import com.oracle.graal.options.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 * This class is a graph container, it contains the set of nodes that belong to this graph.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 public class Graph {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40
17127
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
41 static class Options {
18674
ecb9d0cedbab First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18651
diff changeset
42 @Option(help = "Verify graphs often during compilation when assertions are turned on", type = OptionType.Debug)//
17127
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
43 public static final OptionValue<Boolean> VerifyGraalGraphs = new OptionValue<>(true);
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
44 }
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
45
5361
dec5a35ddbe2 lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
46 public final String name;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
48 /**
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
49 * The set of nodes in the graph, ordered by {@linkplain #register(Node) registration} time.
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
50 */
16948
d569f2fafb6a more refactorings to workaround javac symbol issue (JDK-7101822)
Doug Simon <doug.simon@oracle.com>
parents: 16925
diff changeset
51 Node[] nodes;
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
52
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
53 /**
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
54 * The number of valid entries in {@link #nodes}.
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
55 */
16948
d569f2fafb6a more refactorings to workaround javac symbol issue (JDK-7101822)
Doug Simon <doug.simon@oracle.com>
parents: 16925
diff changeset
56 int nodesSize;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57
11524
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
58 /**
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
59 * Records the modification count for nodes. This is only used in assertions.
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
60 */
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
61 private int[] nodeModCounts;
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
62
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
63 /**
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
64 * Records the modification count for nodes' usage lists. This is only used in assertions.
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
65 */
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
66 private int[] nodeUsageModCounts;
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
67
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 // these two arrays contain one entry for each NodeClass, indexed by NodeClass.iterableId.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 // they contain the first and last pointer to a linked list of all nodes with this type.
18651
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
70 private final ArrayList<Node> iterableNodesFirst;
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
71 private final ArrayList<Node> iterableNodesLast;
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
72
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
73 private int nodesDeletedSinceLastCompression;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
74 private int nodesDeletedBeforeLastCompression;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
76 /**
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
77 * The number of times this graph has been compressed.
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
78 */
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
79 int compressions;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
80
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
81 NodeEventListener nodeEventListener;
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
82
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
83 /**
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
84 * Used to global value number {@link ValueNumberable} {@linkplain NodeClass#isLeafNode() leaf}
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
85 * nodes.
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
86 */
18743
220d7f242e57 use deterministic iteration-order data structures
Doug Simon <doug.simon@oracle.com>
parents: 18674
diff changeset
87 private final HashMap<CacheEntry, Node> cachedLeafNodes = CollectionsFactory.newMap();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88
13744
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
89 /*
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
90 * Indicates that the graph should no longer be modified. Frozen graphs can be used my multiple
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
91 * threads so it's only safe to read them.
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
92 */
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
93 private boolean isFrozen = false;
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
94
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
95 /**
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
96 * Entry in {@link Graph#cachedLeafNodes}.
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
97 */
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98 private static final class CacheEntry {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
99
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100 private final Node node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
101
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102 public CacheEntry(Node node) {
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
103 assert node.getNodeClass().valueNumberable();
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
104 assert node.getNodeClass().isLeafNode();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 this.node = node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109 public int hashCode() {
17450
45b45f902bed removed Node generation (GRAAL-857)
Doug Simon <doug.simon@oracle.com>
parents: 17366
diff changeset
110 return node.getNodeClass().valueNumber(node);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 public boolean equals(Object obj) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115 if (obj == this) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118 if (obj instanceof CacheEntry) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119 CacheEntry other = (CacheEntry) obj;
11666
3967f9f306f8 Factor usages of getNodeClass().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11654
diff changeset
120 if (other.node.getClass() == node.getClass()) {
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17210
diff changeset
121 return node.valueEquals(other.node);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125 }
18884
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18878
diff changeset
126
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18878
diff changeset
127 @Override
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18878
diff changeset
128 public String toString() {
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18878
diff changeset
129 return node.toString();
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18878
diff changeset
130 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134 * Creates an empty Graph with no name.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 public Graph() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 this(null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139
16897
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16895
diff changeset
140 public static final boolean MODIFICATION_COUNTS_ENABLED = assertionsEnabled();
11524
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
141
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
142 /**
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
143 * Determines if assertions are enabled for the {@link Graph} class.
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
144 */
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
145 @SuppressWarnings("all")
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
146 private static boolean assertionsEnabled() {
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
147 boolean enabled = false;
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
148 assert enabled = true;
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
149 return enabled;
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
150 }
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
151
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
152 private static final int INITIAL_NODES_SIZE = 32;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
153
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155 * Creates an empty Graph with a given name.
14904
162d8fe89017 Revert 3e9a8ef2e0e1.
Josef Eisl <josef.eisl@jku.at>
parents: 14898
diff changeset
156 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157 * @param name the name of the graph, used for debugging purposes
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159 public Graph(String name) {
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
160 nodes = new Node[INITIAL_NODES_SIZE];
18651
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
161 iterableNodesFirst = new ArrayList<>(NodeClass.allocatedNodeIterabledIds());
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
162 iterableNodesLast = new ArrayList<>(NodeClass.allocatedNodeIterabledIds());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163 this.name = name;
11524
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
164 if (MODIFICATION_COUNTS_ENABLED) {
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
165 nodeModCounts = new int[INITIAL_NODES_SIZE];
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
166 nodeUsageModCounts = new int[INITIAL_NODES_SIZE];
11524
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
167 }
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
168 }
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
169
11540
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
170 int extractOriginalNodeId(Node node) {
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
171 int id = node.id;
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
172 if (id <= Node.DELETED_ID_START) {
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
173 id = Node.DELETED_ID_START - id;
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
174 }
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
175 return id;
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
176 }
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
177
11524
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
178 int modCount(Node node) {
11540
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
179 int id = extractOriginalNodeId(node);
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
180 if (id >= 0 && id < nodeModCounts.length) {
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
181 return nodeModCounts[id];
11524
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
182 }
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
183 return 0;
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
184 }
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
185
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
186 void incModCount(Node node) {
11540
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
187 int id = extractOriginalNodeId(node);
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
188 if (id >= 0) {
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
189 if (id >= nodeModCounts.length) {
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
190 nodeModCounts = Arrays.copyOf(nodeModCounts, id + 30);
11524
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
191 }
11540
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
192 nodeModCounts[id]++;
11524
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
193 } else {
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
194 assert false;
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11437
diff changeset
195 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
197
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
198 int usageModCount(Node node) {
11540
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
199 int id = extractOriginalNodeId(node);
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
200 if (id >= 0 && id < nodeUsageModCounts.length) {
11555
8d52ef9ab876 Graph: fix index of array access in usageModCount()
Bernhard Urban <bernhard.urban@jku.at>
parents: 11540
diff changeset
201 return nodeUsageModCounts[id];
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
202 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
203 return 0;
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
204 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
205
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
206 void incUsageModCount(Node node) {
11540
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
207 int id = extractOriginalNodeId(node);
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
208 if (id >= 0) {
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
209 if (id >= nodeUsageModCounts.length) {
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
210 nodeUsageModCounts = Arrays.copyOf(nodeUsageModCounts, id + 30);
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
211 }
11540
601755e6848b Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 11528
diff changeset
212 nodeUsageModCounts[id]++;
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
213 } else {
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
214 assert false;
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
215 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
216 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
217
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
218 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
219 * Creates a copy of this graph.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
220 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221 public Graph copy() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
222 return copy(name);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
224
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
225 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
226 * Creates a copy of this graph.
14904
162d8fe89017 Revert 3e9a8ef2e0e1.
Josef Eisl <josef.eisl@jku.at>
parents: 14898
diff changeset
227 *
5711
4d7175cf3526 enabled Eclipse/JDT javadoc checking and fixed resulting warnings
Doug Simon <doug.simon@oracle.com>
parents: 5608
diff changeset
228 * @param newName the name of the copy, used for debugging purposes (can be null)
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229 */
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
230 public Graph copy(String newName) {
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
231 Graph copy = new Graph(newName);
11675
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11671
diff changeset
232 copy.addDuplicates(getNodes(), this, this.getNodeCount(), (Map<Node, Node>) null);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
233 return copy;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
234 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
235
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
236 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237 public String toString() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238 return name == null ? super.toString() : "Graph " + name;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
239 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
240
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
242 * Gets the number of live nodes in this graph. That is the number of nodes which have been
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
243 * added to the graph minus the number of deleted nodes.
14904
162d8fe89017 Revert 3e9a8ef2e0e1.
Josef Eisl <josef.eisl@jku.at>
parents: 14898
diff changeset
244 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 * @return the number of live nodes in this graph
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
247 public int getNodeCount() {
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
248 return nodesSize - getNodesDeletedSinceLastCompression();
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
249 }
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
250
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
251 /**
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
252 * Gets the number of times this graph has been {@linkplain #maybeCompress() compressed}. Node
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
253 * identifiers are only stable between compressions. To ensure this constraint is observed, any
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
254 * entity relying upon stable node identifiers should use {@link NodeIdAccessor}.
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
255 */
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
256 public int getCompressions() {
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
257 return compressions;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
258 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
259
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260 /**
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
261 * Gets the number of nodes which have been deleted from this graph since it was last
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
262 * {@linkplain #maybeCompress() compressed}.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263 */
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
264 public int getNodesDeletedSinceLastCompression() {
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
265 return nodesDeletedSinceLastCompression;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
266 }
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
267
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
268 /**
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
269 * Gets the total number of nodes which have been deleted from this graph.
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
270 */
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
271 public int getTotalNodesDeleted() {
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
272 return nodesDeletedSinceLastCompression + nodesDeletedBeforeLastCompression;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
273 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
274
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
275 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
276 * Adds a new node to the graph.
14904
162d8fe89017 Revert 3e9a8ef2e0e1.
Josef Eisl <josef.eisl@jku.at>
parents: 14898
diff changeset
277 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
278 * @param node the node to be added
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279 * @return the node which was added to the graph
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
280 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 public <T extends Node> T add(T node) {
11652
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
282 if (node.getNodeClass().valueNumberable()) {
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
283 throw new IllegalStateException("Using add for value numberable node. Consider using either unique or addWithoutUnique.");
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
284 }
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
285 return addHelper(node);
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
286 }
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
287
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
288 public <T extends Node> T addWithoutUnique(T node) {
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
289 return addHelper(node);
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
290 }
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
291
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
292 public <T extends Node> T addOrUnique(T node) {
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
293 if (node.getNodeClass().valueNumberable()) {
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
294 return uniqueHelper(node, true);
11652
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
295 }
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
296 return add(node);
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
297 }
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
298
16206
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
299 public <T extends Node> T addOrUniqueWithInputs(T node) {
17008
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16970
diff changeset
300 NodePosIterator iterator = node.inputs().iterator();
16206
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
301 while (iterator.hasNext()) {
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
302 Position pos = iterator.nextPosition();
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
303 Node input = pos.get(node);
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
304 if (input != null && !input.isAlive()) {
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
305 assert !input.isDeleted();
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
306 pos.initialize(node, addOrUniqueWithInputs(input));
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
307 }
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
308 }
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
309 if (node.getNodeClass().valueNumberable()) {
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
310 return uniqueHelper(node, true);
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
311 }
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
312 return add(node);
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
313 }
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16135
diff changeset
314
11652
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
315 private <T extends Node> T addHelper(T node) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
316 node.initialize(this);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
317 return node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
318 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
320 /**
16295
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
321 * The type of events sent to a {@link NodeEventListener}.
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
322 */
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
323 public enum NodeEvent {
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
324 /**
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
325 * A node's input is changed.
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
326 */
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
327 INPUT_CHANGED,
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
328
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
329 /**
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
330 * A node's {@linkplain Node#usages() usages} count dropped to zero.
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
331 */
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
332 ZERO_USAGES,
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
333
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
334 /**
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
335 * A node was added to a graph.
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
336 */
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
337 NODE_ADDED;
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
338 }
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
339
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
340 /**
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
341 * Client interested in one or more node related events.
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
342 */
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
343 public interface NodeEventListener {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
344
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
345 /**
16295
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
346 * Default handler for events.
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
347 *
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
348 * @param e an event
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
349 * @param node the node related to {@code e}
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
350 */
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
351 default void event(NodeEvent e, Node node) {
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
352 }
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
353
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
354 /**
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
355 * Notifies this listener of a change in a node's inputs.
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
356 *
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
357 * @param node a node who has had one of its inputs changed
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
358 */
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
359 default void inputChanged(Node node) {
16295
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
360 event(NodeEvent.INPUT_CHANGED, node);
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
361 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
362
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
363 /**
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
364 * Notifies this listener of a node becoming unused.
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
365 *
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
366 * @param node a node whose {@link Node#usages()} just became empty
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
367 */
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
368 default void usagesDroppedToZero(Node node) {
16295
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
369 event(NodeEvent.ZERO_USAGES, node);
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
370 }
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
371
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
372 /**
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
373 * Notifies this listener of an added node.
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
374 *
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
375 * @param node a node that was just added to the graph
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
376 */
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
377 default void nodeAdded(Node node) {
16295
d9de8f5197e1 simplified NodeEventListener implementations by having all events routed to a single method by default
Doug Simon <doug.simon@oracle.com>
parents: 16293
diff changeset
378 event(NodeEvent.NODE_ADDED, node);
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
379 }
5419
3c16d338888e Merge Canonicalizer and GVN Phases
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5380
diff changeset
380 }
3c16d338888e Merge Canonicalizer and GVN Phases
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5380
diff changeset
381
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
382 /**
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
383 * Registers a given {@link NodeEventListener} with the enclosing graph until this object is
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
384 * {@linkplain #close() closed}.
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
385 */
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
386 public final class NodeEventScope implements AutoCloseable {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
387 NodeEventScope(NodeEventListener listener) {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
388 if (nodeEventListener == null) {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
389 nodeEventListener = listener;
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
390 } else {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
391 nodeEventListener = new ChainedNodeEventListener(listener, nodeEventListener);
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
392 }
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
393 }
11735
9c9683970656 Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents: 11728
diff changeset
394
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
395 public void close() {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
396 assert nodeEventListener != null;
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
397 if (nodeEventListener instanceof ChainedNodeEventListener) {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
398 nodeEventListener = ((ChainedNodeEventListener) nodeEventListener).next;
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
399 } else {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
400 nodeEventListener = null;
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
401 }
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
402 }
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
403 }
11735
9c9683970656 Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents: 11728
diff changeset
404
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
405 private static class ChainedNodeEventListener implements NodeEventListener {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
406
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
407 NodeEventListener head;
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
408 NodeEventListener next;
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
409
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
410 ChainedNodeEventListener(NodeEventListener head, NodeEventListener next) {
11735
9c9683970656 Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents: 11728
diff changeset
411 this.head = head;
9c9683970656 Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents: 11728
diff changeset
412 this.next = next;
9c9683970656 Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents: 11728
diff changeset
413 }
9c9683970656 Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents: 11728
diff changeset
414
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
415 public void nodeAdded(Node node) {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
416 head.nodeAdded(node);
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
417 next.nodeAdded(node);
11735
9c9683970656 Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents: 11728
diff changeset
418 }
9c9683970656 Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents: 11728
diff changeset
419
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
420 public void inputChanged(Node node) {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
421 head.inputChanged(node);
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
422 next.inputChanged(node);
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
423 }
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
424
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
425 public void usagesDroppedToZero(Node node) {
16296
f2d75b3b3963 fixed incorrect forwarding of ZERO_USAGEs event in ChainedNodeEventListener
Doug Simon <doug.simon@oracle.com>
parents: 16295
diff changeset
426 head.usagesDroppedToZero(node);
f2d75b3b3963 fixed incorrect forwarding of ZERO_USAGEs event in ChainedNodeEventListener
Doug Simon <doug.simon@oracle.com>
parents: 16295
diff changeset
427 next.usagesDroppedToZero(node);
11735
9c9683970656 Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents: 11728
diff changeset
428 }
4614
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4411
diff changeset
429 }
a3882fd1ae61 Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4411
diff changeset
430
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
431 /**
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
432 * Registers a given {@link NodeEventListener} with this graph. This should be used in
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
433 * conjunction with try-with-resources statement as follows:
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
434 *
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
435 * <pre>
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
436 * try (NodeEventScope nes = graph.trackNodeEvents(listener)) {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
437 * // make changes to the graph
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
438 * }
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
439 * </pre>
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
440 */
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
441 public NodeEventScope trackNodeEvents(NodeEventListener listener) {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
442 return new NodeEventScope(listener);
9331
199c77760850 Rename InputChangedListener => NodeChangedListener. Add event for usage count of a node dropping to 0.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8327
diff changeset
443 }
199c77760850 Rename InputChangedListener => NodeChangedListener. Add event for usage count of a node dropping to 0.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8327
diff changeset
444
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445 /**
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
446 * Looks for a node <i>similar</i> to {@code node} and returns it if found. Otherwise
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
447 * {@code node} is added to this graph and returned.
14904
162d8fe89017 Revert 3e9a8ef2e0e1.
Josef Eisl <josef.eisl@jku.at>
parents: 14898
diff changeset
448 *
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
449 * @return a node similar to {@code node} if one exists, otherwise {@code node}
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
450 */
14904
162d8fe89017 Revert 3e9a8ef2e0e1.
Josef Eisl <josef.eisl@jku.at>
parents: 14898
diff changeset
451 public <T extends Node & ValueNumberable> T unique(T node) {
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
452 return uniqueHelper(node, true);
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
453 }
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
454
11652
f091e0d6f4f3 Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11631
diff changeset
455 @SuppressWarnings("unchecked")
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
456 <T extends Node> T uniqueHelper(T node, boolean addIfMissing) {
11653
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
457 assert node.getNodeClass().valueNumberable();
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
458 Node other = this.findDuplicate(node);
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
459 if (other != null) {
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
460 return (T) other;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
461 } else {
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
462 Node result = addIfMissing ? addHelper(node) : node;
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
463 if (node.getNodeClass().isLeafNode()) {
11653
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
464 putNodeIntoCache(result);
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
465 }
4646
75dcf829cfdc experimental: "next" successor on all nodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 4614
diff changeset
466 return (T) result;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
467 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
469
11653
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
470 void putNodeIntoCache(Node node) {
13320
c258331fdde6 removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13140
diff changeset
471 assert node.graph() == this || node.graph() == null;
11653
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
472 assert node.getNodeClass().valueNumberable();
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
473 assert node.getNodeClass().isLeafNode() : node.getClass();
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
474 cachedLeafNodes.put(new CacheEntry(node), node);
11653
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
475 }
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
476
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
477 Node findNodeInCache(Node node) {
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
478 CacheEntry key = new CacheEntry(node);
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
479 Node result = cachedLeafNodes.get(key);
11653
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
480 if (result != null && result.isDeleted()) {
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
481 cachedLeafNodes.remove(key);
11653
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
482 return null;
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
483 }
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
484 return result;
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
485 }
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
486
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487 public Node findDuplicate(Node node) {
19410
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
488 NodeClass<?> nodeClass = node.getNodeClass();
11654
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
489 assert nodeClass.valueNumberable();
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
490 if (nodeClass.isLeafNode()) {
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
491 // Leaf node: look up in cache
11653
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
492 Node cachedNode = findNodeInCache(node);
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
493 if (cachedNode != null) {
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
494 return cachedNode;
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
495 } else {
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
496 return null;
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
497 }
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11652
diff changeset
498 } else {
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
499 // Non-leaf node: look for another usage of the node's inputs that
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
500 // has the same data, inputs and successors as the node. To reduce
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
501 // the cost of this computation, only the input with estimated highest
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17306
diff changeset
502 // usage count is considered.
11654
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
503
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
504 int minCount = Integer.MAX_VALUE;
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
505 Node minCountNode = null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
506 for (Node input : node.inputs()) {
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17008
diff changeset
507 if (input != null) {
18938
ef1494ece1a8 Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18890
diff changeset
508 int estimate = input.getUsageCount();
11654
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
509 if (estimate == 0) {
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
510 return null;
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
511 } else if (estimate < minCount) {
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
512 minCount = estimate;
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
513 minCountNode = input;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
514 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
515 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
516 }
11654
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
517 if (minCountNode != null) {
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
518 for (Node usage : minCountNode.usages()) {
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17210
diff changeset
519 if (usage != node && nodeClass == usage.getNodeClass() && node.valueEquals(usage) && nodeClass.getEdges(Inputs).areEqualIn(node, usage) &&
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: 17127
diff changeset
520 nodeClass.getEdges(Successors).areEqualIn(node, usage)) {
11654
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
521 return usage;
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
522 }
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
523 }
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
524 return null;
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
525 }
5446
fafab5f0507d Fix findDuplicate for nodes with no inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5427
diff changeset
526 return null;
fafab5f0507d Fix findDuplicate for nodes with no inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5427
diff changeset
527 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
528 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
529
12686
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
530 public boolean isNew(Mark mark, Node node) {
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
531 return node.id >= mark.getValue();
11728
7778a0f2999a Run partial escape analysis on Truffle cache methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
532 }
7778a0f2999a Run partial escape analysis on Truffle cache methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
533
5361
dec5a35ddbe2 lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
534 /**
12686
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
535 * A snapshot of the {@linkplain Graph#getNodeCount() live node count} in a graph.
5361
dec5a35ddbe2 lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents: 5061
diff changeset
536 */
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
537 public static class Mark extends NodeIdAccessor {
12686
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
538 private final int value;
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
539
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
540 Mark(Graph graph) {
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
541 super(graph);
12686
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
542 this.value = graph.nodeIdCount();
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
543 }
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
544
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
545 @Override
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
546 public boolean equals(Object obj) {
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
547 if (obj instanceof Mark) {
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
548 Mark other = (Mark) obj;
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
549 return other.getValue() == getValue() && other.getGraph() == getGraph();
12686
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
550 }
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
551 return false;
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
552 }
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
553
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
554 @Override
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
555 public int hashCode() {
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
556 return value ^ (epoch + 11);
12686
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
557 }
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
558
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
559 /**
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
560 * Determines if this mark is positioned at the first live node in the graph.
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
561 */
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
562 public boolean isStart() {
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
563 return value == 0;
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
564 }
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
565
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
566 /**
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
567 * Gets the {@linkplain Graph#getNodeCount() live node count} of the associated graph when
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
568 * this object was created.
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
569 */
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
570 int getValue() {
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
571 return value;
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
572 }
16133
d568574e6448 reduce allocations of NodeIterables by Graph.getNewNodes()
Doug Simon <doug.simon@oracle.com>
parents: 15956
diff changeset
573
d568574e6448 reduce allocations of NodeIterables by Graph.getNewNodes()
Doug Simon <doug.simon@oracle.com>
parents: 15956
diff changeset
574 /**
d568574e6448 reduce allocations of NodeIterables by Graph.getNewNodes()
Doug Simon <doug.simon@oracle.com>
parents: 15956
diff changeset
575 * Determines if this mark still represents the {@linkplain Graph#getNodeCount() live node
d568574e6448 reduce allocations of NodeIterables by Graph.getNewNodes()
Doug Simon <doug.simon@oracle.com>
parents: 15956
diff changeset
576 * count} of the graph.
d568574e6448 reduce allocations of NodeIterables by Graph.getNewNodes()
Doug Simon <doug.simon@oracle.com>
parents: 15956
diff changeset
577 */
d568574e6448 reduce allocations of NodeIterables by Graph.getNewNodes()
Doug Simon <doug.simon@oracle.com>
parents: 15956
diff changeset
578 public boolean isCurrent() {
d568574e6448 reduce allocations of NodeIterables by Graph.getNewNodes()
Doug Simon <doug.simon@oracle.com>
parents: 15956
diff changeset
579 return value == graph.nodeIdCount();
d568574e6448 reduce allocations of NodeIterables by Graph.getNewNodes()
Doug Simon <doug.simon@oracle.com>
parents: 15956
diff changeset
580 }
12686
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
581 }
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
582
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
583 /**
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
584 * Gets a mark that can be used with {@link #getNewNodes}.
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
585 */
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
586 public Mark getMark() {
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
587 return new Mark(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
588 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
589
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
590 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
591 * Returns an {@link Iterable} providing all nodes added since the last {@link Graph#getMark()
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
592 * mark}.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
593 */
12686
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
594 public NodeIterable<Node> getNewNodes(Mark mark) {
17127
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
595 final int index = mark == null ? 0 : mark.getValue();
15146
65efd2eeea1b Remove AbstractNodeIterable, move its methods to default methods on NodeIterable.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14991
diff changeset
596 return new NodeIterable<Node>() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
597
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
598 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
599 public Iterator<Node> iterator() {
16948
d569f2fafb6a more refactorings to workaround javac symbol issue (JDK-7101822)
Doug Simon <doug.simon@oracle.com>
parents: 16925
diff changeset
600 return new GraphNodeIterator(Graph.this, index);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
601 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
602 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
603 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
604
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
605 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
606 * Returns an {@link Iterable} providing all the live nodes.
14904
162d8fe89017 Revert 3e9a8ef2e0e1.
Josef Eisl <josef.eisl@jku.at>
parents: 14898
diff changeset
607 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
608 * @return an {@link Iterable} providing all the live nodes.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
609 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
610 public NodeIterable<Node> getNodes() {
15146
65efd2eeea1b Remove AbstractNodeIterable, move its methods to default methods on NodeIterable.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14991
diff changeset
611 return new NodeIterable<Node>() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
612
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
613 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
614 public Iterator<Node> iterator() {
16948
d569f2fafb6a more refactorings to workaround javac symbol issue (JDK-7101822)
Doug Simon <doug.simon@oracle.com>
parents: 16925
diff changeset
615 return new GraphNodeIterator(Graph.this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
616 }
5488
21cab9000931 .filter() on Graph.getNode now tries to use the fast node iterator if possible
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5478
diff changeset
617
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
618 @Override
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
619 public int count() {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
620 return getNodeCount();
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
621 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
622 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
623 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
624
16843
52aa237f233d workaround for javac issue
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
625 // Fully qualified annotation name is required to satisfy javac
52aa237f233d workaround for javac issue
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
626 @com.oracle.graal.nodeinfo.NodeInfo
18998
ec0733b5a90a Allow final modifier on node subclasses and start adding the modifier to leaf classes.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18938
diff changeset
627 static final class PlaceHolderNode extends Node {
19403
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
628
19529
8fc336a04d77 Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19517
diff changeset
629 public static final NodeClass<PlaceHolderNode> TYPE = NodeClass.create(PlaceHolderNode.class);
19403
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
630
18845
f57d86eb036f removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents: 18743
diff changeset
631 public PlaceHolderNode() {
19403
7e2c87dae93e Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18998
diff changeset
632 super(TYPE);
16895
06c15e88d383 added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents: 16843
diff changeset
633 }
16811
5d468add216f added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents: 16296
diff changeset
634
5d468add216f added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents: 16296
diff changeset
635 }
5d468add216f added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents: 16296
diff changeset
636
17450
45b45f902bed removed Node generation (GRAAL-857)
Doug Simon <doug.simon@oracle.com>
parents: 17366
diff changeset
637 static final Node PLACE_HOLDER = new PlaceHolderNode();
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7124
diff changeset
638
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
639 /**
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
640 * When the percent of live nodes in {@link #nodes} fall below this number, a call to
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
641 * {@link #maybeCompress()} will actually do compression.
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
642 */
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
643 public static final int COMPRESSION_THRESHOLD = Integer.getInteger("graal.graphCompressionThreshold", 70);
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
644
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
645 private static final DebugMetric GraphCompressions = Debug.metric("GraphCompressions");
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
646
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
647 /**
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
648 * If the {@linkplain #COMPRESSION_THRESHOLD compression threshold} is met, the list of nodes is
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
649 * compressed such that all non-null entries precede all null entries while preserving the
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
650 * ordering between the nodes within the list.
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
651 */
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
652 public boolean maybeCompress() {
13326
48e821e409eb Add Debug.isDumpEnabledForMethod() and Debug.isLogEnabledForMethod() use it to diable graph compression and enable guard-id-as-debug-id
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 13140
diff changeset
653 if (Debug.isDumpEnabledForMethod() || Debug.isLogEnabledForMethod()) {
12700
4b053442b9d1 Do not compress graph when debug is enabled
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12687
diff changeset
654 return false;
4b053442b9d1 Do not compress graph when debug is enabled
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12687
diff changeset
655 }
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
656 int liveNodeCount = getNodeCount();
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
657 int liveNodePercent = liveNodeCount * 100 / nodesSize;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
658 if (COMPRESSION_THRESHOLD == 0 || liveNodePercent >= COMPRESSION_THRESHOLD) {
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
659 return false;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
660 }
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
661 GraphCompressions.increment();
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
662 int nextId = 0;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
663 for (int i = 0; nextId < liveNodeCount; i++) {
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
664 Node n = nodes[i];
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
665 if (n != null) {
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
666 assert n.id == i;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
667 if (i != nextId) {
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
668 assert n.id > nextId;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
669 n.id = nextId;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
670 nodes[nextId] = n;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
671 nodes[i] = null;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
672 }
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
673 nextId++;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
674 }
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
675 }
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
676 if (MODIFICATION_COUNTS_ENABLED) {
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
677 // This will cause any current iteration to fail with an assertion
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
678 Arrays.fill(nodeModCounts, 0);
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
679 Arrays.fill(nodeUsageModCounts, 0);
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
680 }
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
681 nodesSize = nextId;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
682 compressions++;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
683 nodesDeletedBeforeLastCompression += nodesDeletedSinceLastCompression;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
684 nodesDeletedSinceLastCompression = 0;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
685 return true;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
686 }
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
687
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
688 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
689 * Returns an {@link Iterable} providing all the live nodes whose type is compatible with
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
690 * {@code type}.
14904
162d8fe89017 Revert 3e9a8ef2e0e1.
Josef Eisl <josef.eisl@jku.at>
parents: 14898
diff changeset
691 *
19410
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
692 * @param nodeClass the type of node to return
11631
1aed684853f6 refactored IterableNodeType into a top level type to avoid problems it was causing for javac and JDT (CR-1408)
Doug Simon <doug.simon@oracle.com>
parents: 11556
diff changeset
693 * @return an {@link Iterable} providing all the matching nodes
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
694 */
19410
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
695 public <T extends Node & IterableNodeType> NodeIterable<T> getNodes(final NodeClass<T> nodeClass) {
15146
65efd2eeea1b Remove AbstractNodeIterable, move its methods to default methods on NodeIterable.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14991
diff changeset
696 return new NodeIterable<T>() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
697
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
698 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
699 public Iterator<T> iterator() {
16970
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents: 16948
diff changeset
700 return new TypedGraphNodeIterator<>(nodeClass, Graph.this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
701 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
702 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
703 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
704
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
705 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
706 * Returns whether the graph contains at least one node of the given type.
14904
162d8fe89017 Revert 3e9a8ef2e0e1.
Josef Eisl <josef.eisl@jku.at>
parents: 14898
diff changeset
707 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
708 * @param type the type of node that is checked for occurrence
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
709 * @return whether there is at least one such node
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
710 */
19410
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
711 public <T extends Node & IterableNodeType> boolean hasNode(final NodeClass<T> type) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
712 return getNodes(type).iterator().hasNext();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
713 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
714
16970
818844f7224d extract TypedNodeIterator to separate file and rename (workaround for javac bug)
Michael Haupt <michael.haupt@oracle.com>
parents: 16948
diff changeset
715 Node getStartNode(int iterableId) {
18651
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
716 Node start = iterableNodesFirst.size() <= iterableId ? null : iterableNodesFirst.get(iterableId);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
717 return start;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
718 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
719
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
720 public NodeBitMap createNodeBitMap() {
15955
3f48e9a1016c NodeBitMap refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15890
diff changeset
721 return new NodeBitMap(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
722 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
723
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
724 public <T> NodeMap<T> createNodeMap() {
15890
f4510fd9e8b3 Removed unused grow functionality on NodeMap.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15196
diff changeset
725 return new NodeMap<>(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
726 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
727
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
728 public NodeFlood createNodeFlood() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
729 return new NodeFlood(this);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
730 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
731
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
732 public NodeWorkList createNodeWorkList() {
15956
edc33e8715d5 NodeWorkList refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15955
diff changeset
733 return new NodeWorkList.SingletonNodeWorkList(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
734 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
735
15956
edc33e8715d5 NodeWorkList refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15955
diff changeset
736 public NodeWorkList createIterativeNodeWorkList(boolean fill, int iterationLimitPerNode) {
edc33e8715d5 NodeWorkList refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15955
diff changeset
737 return new NodeWorkList.IterativeNodeWorkList(this, fill, iterationLimitPerNode);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
738 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
739
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
740 void register(Node node) {
13744
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
741 assert !isFrozen();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
742 assert node.id() == Node.INITIAL_ID;
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
743 if (nodes.length == nodesSize) {
19517
55d0b9ec7587 Replace Array.copyOf usages with System.arraycopy usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19410
diff changeset
744 Node[] newNodes = new Node[(nodesSize * 2) + 1];
55d0b9ec7587 Replace Array.copyOf usages with System.arraycopy usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19410
diff changeset
745 System.arraycopy(nodes, 0, newNodes, 0, nodesSize);
55d0b9ec7587 Replace Array.copyOf usages with System.arraycopy usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19410
diff changeset
746 nodes = newNodes;
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
747 }
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
748 int id = nodesSize;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
749 nodes[id] = node;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
750 nodesSize++;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
751
18651
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
752 updateNodeCaches(node);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
753
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
754 node.id = id;
16241
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
755 if (nodeEventListener != null) {
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
756 nodeEventListener.nodeAdded(node);
c6ebc1997a55 added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents: 16206
diff changeset
757 }
18884
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18878
diff changeset
758 if (Fingerprint.ENABLED) {
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18878
diff changeset
759 Fingerprint.submit("%s: %s", NodeEvent.NODE_ADDED, node);
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18878
diff changeset
760 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
761 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
762
18651
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
763 @SuppressWarnings("unused")
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
764 private void postDeserialization() {
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
765 recomputeIterableNodeLists();
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
766 }
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
767
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
768 /**
19410
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
769 * Rebuilds the lists used to support {@link #getNodes(NodeClass)}. This is useful for
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
770 * serialization where the underlying {@linkplain NodeClass#iterableId() iterable ids} may have
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
771 * changed.
18651
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
772 */
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
773 private void recomputeIterableNodeLists() {
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
774 iterableNodesFirst.clear();
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
775 iterableNodesLast.clear();
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
776 for (Node node : nodes) {
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
777 if (node != null && node.isAlive()) {
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
778 updateNodeCaches(node);
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
779 }
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
780 }
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
781 }
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
782
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
783 private void updateNodeCaches(Node node) {
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
784 int nodeClassId = node.getNodeClass().iterableId();
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
785 if (nodeClassId != Node.NOT_ITERABLE) {
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
786 while (iterableNodesFirst.size() <= nodeClassId) {
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
787 iterableNodesFirst.add(null);
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
788 iterableNodesLast.add(null);
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
789 }
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
790 Node prev = iterableNodesLast.get(nodeClassId);
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
791 if (prev != null) {
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
792 prev.typeCacheNext = node;
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
793 } else {
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
794 iterableNodesFirst.set(nodeClassId, node);
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
795 }
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
796 iterableNodesLast.set(nodeClassId, node);
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
797 }
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
798 }
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
799
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
800 void unregister(Node node) {
13744
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
801 assert !isFrozen();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
802 assert !node.isDeleted() : "cannot delete a node twice! node=" + node;
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
803 nodes[node.id] = null;
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
804 nodesDeletedSinceLastCompression++;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
805
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
806 // nodes aren't removed from the type cache here - they will be removed during iteration
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
807 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
808
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
809 public boolean verify() {
17127
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
810 if (Options.VerifyGraalGraphs.getValue()) {
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
811 for (Node node : getNodes()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
812 try {
17127
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
813 try {
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
814 assert node.verify();
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
815 } catch (AssertionError t) {
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
816 throw new GraalInternalError(t);
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
817 } catch (RuntimeException t) {
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
818 throw new GraalInternalError(t);
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
819 }
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
820 } catch (GraalInternalError e) {
3db919d1c8d5 Add option to disable Graal graph verification (which takes very long for big graphs)
Christian Wimmer <christian.wimmer@oracle.com>
parents: 17064
diff changeset
821 throw GraalGraphInternalError.transformAndAddContext(e, node).addContext(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
822 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
823 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
824 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
825 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
826 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
827
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
828 Node getNode(int i) {
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
829 return nodes[i];
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
830 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
831
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
832 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
833 * Returns the number of node ids generated so far.
14904
162d8fe89017 Revert 3e9a8ef2e0e1.
Josef Eisl <josef.eisl@jku.at>
parents: 14898
diff changeset
834 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
835 * @return the number of node ids generated so far
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
836 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
837 int nodeIdCount() {
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12686
diff changeset
838 return nodesSize;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
839 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
840
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
841 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
842 * Adds duplicates of the nodes in {@code nodes} to this graph. This will recreate any edges
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
843 * between the duplicate nodes. The {@code replacement} map can be used to replace a node from
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
844 * the source graph by a given node (which must already be in this graph). Edges between
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
845 * duplicate and replacement nodes will also be recreated so care should be taken regarding the
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
846 * matching of node types in the replacement map.
14904
162d8fe89017 Revert 3e9a8ef2e0e1.
Josef Eisl <josef.eisl@jku.at>
parents: 14898
diff changeset
847 *
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
848 * @param newNodes the nodes to be duplicated
5711
4d7175cf3526 enabled Eclipse/JDT javadoc checking and fixed resulting warnings
Doug Simon <doug.simon@oracle.com>
parents: 5608
diff changeset
849 * @param replacementsMap the replacement map (can be null if no replacement is to be performed)
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
850 * @return a map which associates the original nodes from {@code nodes} to their duplicates
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
851 */
17366
84f9c2baab1d Relax type signature in Graph.addDuplicates method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17352
diff changeset
852 public Map<Node, Node> addDuplicates(Iterable<? extends Node> newNodes, final Graph oldGraph, int estimatedNodeCount, Map<Node, Node> replacementsMap) {
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
853 DuplicationReplacement replacements;
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
854 if (replacementsMap == null) {
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
855 replacements = null;
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
856 } else {
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
857 replacements = new MapReplacement(replacementsMap);
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
858 }
11675
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11671
diff changeset
859 return addDuplicates(newNodes, oldGraph, estimatedNodeCount, replacements);
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
860 }
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
861
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
862 public interface DuplicationReplacement {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
863
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
864 Node replacement(Node original);
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
865 }
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
866
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
867 private static final class MapReplacement implements DuplicationReplacement {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
868
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
869 private final Map<Node, Node> map;
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
870
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
871 public MapReplacement(Map<Node, Node> map) {
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
872 this.map = map;
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
873 }
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
874
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
875 @Override
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
876 public Node replacement(Node original) {
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
877 Node replacement = map.get(original);
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
878 return replacement != null ? replacement : original;
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
879 }
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
880
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
881 }
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5446
diff changeset
882
17338
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17328
diff changeset
883 private static final DebugTimer DuplicateGraph = Debug.timer("DuplicateGraph");
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17328
diff changeset
884
5427
441cf24df453 correctly handle null for replacements parameter in Graph.addDuplicates()
Doug Simon <doug.simon@oracle.com>
parents: 5419
diff changeset
885 @SuppressWarnings("all")
17366
84f9c2baab1d Relax type signature in Graph.addDuplicates method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17352
diff changeset
886 public Map<Node, Node> addDuplicates(Iterable<? extends Node> newNodes, final Graph oldGraph, int estimatedNodeCount, DuplicationReplacement replacements) {
17338
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17328
diff changeset
887 try (TimerCloseable s = DuplicateGraph.start()) {
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17328
diff changeset
888 return NodeClass.addGraphDuplicate(this, oldGraph, estimatedNodeCount, newNodes, replacements);
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17328
diff changeset
889 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
890 }
13744
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
891
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
892 public boolean isFrozen() {
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
893 return isFrozen;
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
894 }
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
895
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
896 public void freeze() {
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
897 this.isFrozen = true;
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13329
diff changeset
898 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
899 }