Mercurial > hg > truffle
annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Graph.java @ 15955:3f48e9a1016c
NodeBitMap refactoring
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Wed, 28 May 2014 17:19:41 +0200 |
parents | f4510fd9e8b3 |
children | edc33e8715d5 |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
25 import java.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
26 |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15146
diff
changeset
|
27 import com.oracle.graal.compiler.common.*; |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
28 import com.oracle.graal.debug.*; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
29 import com.oracle.graal.graph.GraphEvent.NodeEvent; |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14904
diff
changeset
|
30 import com.oracle.graal.graph.Node.ValueNumberable; |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
31 import com.oracle.graal.graph.iterators.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
32 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
33 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
34 * 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
|
35 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 public class Graph { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
37 |
5361
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
38 public final String name; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
39 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
40 private static final boolean TIME_TRAVEL = false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
42 /** |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
43 * 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
|
44 */ |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
45 private Node[] nodes; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
46 |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
47 /** |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
48 * The number of valid entries in {@link #nodes}. |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
49 */ |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
50 private int nodesSize; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
52 /** |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
53 * 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
|
54 */ |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
55 private int[] nodeModCounts; |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
56 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
57 /** |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
58 * 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
|
59 */ |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
60 private int[] nodeUsageModCounts; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
61 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
62 // 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
|
63 // they contain the first and last pointer to a linked list of all nodes with this type. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
64 private final ArrayList<Node> nodeCacheFirst; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
65 private final ArrayList<Node> nodeCacheLast; |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
66 private int nodesDeletedSinceLastCompression; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
67 private int nodesDeletedBeforeLastCompression; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 private GraphEventLog eventLog; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
70 /** |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
71 * 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
|
72 */ |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
73 int compressions; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
74 |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
75 NodeChangedListener inputChangedListener; |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
76 NodeChangedListener usagesDroppedToZeroListener; |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
77 private final HashMap<CacheEntry, Node> cachedNodes = new HashMap<>(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 |
13744
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13329
diff
changeset
|
79 /* |
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13329
diff
changeset
|
80 * 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
|
81 * 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
|
82 */ |
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13329
diff
changeset
|
83 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
|
84 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 private static final class CacheEntry { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 private final Node node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
89 public 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
|
90 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
|
91 assert node.getNodeClass().isLeafNode(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
92 this.node = node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
93 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
94 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
95 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
96 public int hashCode() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 return node.getNodeClass().valueNumber(node); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 } |
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 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 public boolean equals(Object obj) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
102 if (obj == this) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
103 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
104 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 if (obj instanceof CacheEntry) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 CacheEntry other = (CacheEntry) obj; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 NodeClass nodeClass = node.getNodeClass(); |
11666
3967f9f306f8
Factor usages of getNodeClass().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11654
diff
changeset
|
108 if (other.node.getClass() == node.getClass()) { |
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
|
109 return nodeClass.valueEqual(node, other.node); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 } |
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 return false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
113 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
114 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
116 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 * Creates an empty Graph with no name. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
119 public Graph() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
120 this(null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
121 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
123 static final boolean MODIFICATION_COUNTS_ENABLED = assertionsEnabled(); |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
124 |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
125 /** |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
126 * 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
|
127 */ |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
128 @SuppressWarnings("all") |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
129 private static boolean assertionsEnabled() { |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
130 boolean enabled = false; |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
131 assert enabled = true; |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
132 return enabled; |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
133 } |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
134 |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
135 private static final int INITIAL_NODES_SIZE = 32; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
136 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
137 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
138 * Creates an empty Graph with a given name. |
14904 | 139 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
140 * @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
|
141 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
142 public Graph(String name) { |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
143 nodes = new Node[INITIAL_NODES_SIZE]; |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
144 nodeCacheFirst = new ArrayList<>(NodeClass.cacheSize()); |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
145 nodeCacheLast = new ArrayList<>(NodeClass.cacheSize()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
146 this.name = name; |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
147 if (MODIFICATION_COUNTS_ENABLED) { |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
148 nodeModCounts = new int[INITIAL_NODES_SIZE]; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
149 nodeUsageModCounts = new int[INITIAL_NODES_SIZE]; |
11524
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 } |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
152 |
11540
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
153 int extractOriginalNodeId(Node node) { |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
154 int id = node.id; |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
155 if (id <= Node.DELETED_ID_START) { |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
156 id = Node.DELETED_ID_START - id; |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
157 } |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
158 return id; |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
159 } |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
160 |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
161 int modCount(Node node) { |
11540
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
162 int id = extractOriginalNodeId(node); |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
163 if (id >= 0 && id < nodeModCounts.length) { |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
164 return nodeModCounts[id]; |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
165 } |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
166 return 0; |
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 void incModCount(Node node) { |
11540
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
170 int id = extractOriginalNodeId(node); |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
171 if (id >= 0) { |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
172 if (id >= nodeModCounts.length) { |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
173 nodeModCounts = Arrays.copyOf(nodeModCounts, id + 30); |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
174 } |
11540
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
175 nodeModCounts[id]++; |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
176 } else { |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
177 assert false; |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11437
diff
changeset
|
178 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
179 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
181 int usageModCount(Node node) { |
11540
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
182 int id = extractOriginalNodeId(node); |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
183 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
|
184 return nodeUsageModCounts[id]; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
185 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
186 return 0; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
187 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
188 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
189 void incUsageModCount(Node node) { |
11540
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
190 int id = extractOriginalNodeId(node); |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
191 if (id >= 0) { |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
192 if (id >= nodeUsageModCounts.length) { |
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
193 nodeUsageModCounts = Arrays.copyOf(nodeUsageModCounts, id + 30); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
194 } |
11540
601755e6848b
Allow getting modCount fo deleted nodes
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
11528
diff
changeset
|
195 nodeUsageModCounts[id]++; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
196 } else { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
197 assert false; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
198 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
199 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
200 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
201 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
202 * Creates a copy of this graph. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
203 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
204 public Graph copy() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 return copy(name); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
206 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
208 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
209 * Creates a copy of this graph. |
14904 | 210 * |
5711
4d7175cf3526
enabled Eclipse/JDT javadoc checking and fixed resulting warnings
Doug Simon <doug.simon@oracle.com>
parents:
5608
diff
changeset
|
211 * @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
|
212 */ |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
213 public Graph copy(String newName) { |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
214 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
|
215 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
|
216 return copy; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
217 } |
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 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 public String toString() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
221 return name == null ? super.toString() : "Graph " + name; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
222 } |
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 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7332
diff
changeset
|
225 * 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
|
226 * added to the graph minus the number of deleted nodes. |
14904 | 227 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
228 * @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
|
229 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
230 public int getNodeCount() { |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
231 return nodesSize - getNodesDeletedSinceLastCompression(); |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
232 } |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
233 |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
234 /** |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
235 * 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
|
236 * 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
|
237 * 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
|
238 */ |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
239 public int getCompressions() { |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
240 return compressions; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
241 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
242 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
243 /** |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
244 * 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
|
245 * {@linkplain #maybeCompress() compressed}. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
246 */ |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
247 public int getNodesDeletedSinceLastCompression() { |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
248 return nodesDeletedSinceLastCompression; |
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 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
|
253 */ |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
254 public int getTotalNodesDeleted() { |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
255 return nodesDeletedSinceLastCompression + nodesDeletedBeforeLastCompression; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
256 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
257 |
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 * Adds a new node to the graph. |
14904 | 260 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
261 * @param node the node to be added |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
262 * @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
|
263 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
264 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
|
265 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
|
266 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
|
267 } |
f091e0d6f4f3
Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
268 return addHelper(node); |
f091e0d6f4f3
Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
269 } |
f091e0d6f4f3
Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
270 |
f091e0d6f4f3
Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
271 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
|
272 return addHelper(node); |
f091e0d6f4f3
Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
273 } |
f091e0d6f4f3
Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
274 |
f091e0d6f4f3
Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
275 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
|
276 if (node.getNodeClass().valueNumberable()) { |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
277 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
|
278 } |
f091e0d6f4f3
Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
279 return add(node); |
f091e0d6f4f3
Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
280 } |
f091e0d6f4f3
Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
281 |
f091e0d6f4f3
Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
282 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
|
283 node.initialize(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
284 return node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
285 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
286 |
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
|
287 public interface NodeChangedListener { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7332
diff
changeset
|
288 |
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
|
289 void nodeChanged(Node node); |
5419
3c16d338888e
Merge Canonicalizer and GVN Phases
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5380
diff
changeset
|
290 } |
3c16d338888e
Merge Canonicalizer and GVN Phases
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5380
diff
changeset
|
291 |
11735
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
292 private static class ChainedNodeChangedListener implements NodeChangedListener { |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
293 |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
294 NodeChangedListener head; |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
295 NodeChangedListener next; |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
296 |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
297 ChainedNodeChangedListener(NodeChangedListener head, NodeChangedListener next) { |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
298 this.head = head; |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
299 this.next = next; |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
300 } |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
301 |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
302 public void nodeChanged(Node node) { |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
303 head.nodeChanged(node); |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
304 next.nodeChanged(node); |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
305 } |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
306 } |
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
307 |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
308 public void trackInputChange(NodeChangedListener listener) { |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
309 if (inputChangedListener == null) { |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
310 inputChangedListener = listener; |
11735
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
311 } else { |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
312 inputChangedListener = new ChainedNodeChangedListener(listener, inputChangedListener); |
11735
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
313 } |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
314 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
315 |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
316 public void stopTrackingInputChange() { |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
317 assert inputChangedListener != null; |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
318 if (inputChangedListener instanceof ChainedNodeChangedListener) { |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
319 inputChangedListener = ((ChainedNodeChangedListener) inputChangedListener).next; |
11735
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
320 } else { |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
321 inputChangedListener = null; |
11735
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
322 } |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
323 } |
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4411
diff
changeset
|
324 |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
325 public void trackUsagesDroppedZero(NodeChangedListener listener) { |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
326 if (usagesDroppedToZeroListener == null) { |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
327 usagesDroppedToZeroListener = listener; |
11735
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
328 } else { |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
329 usagesDroppedToZeroListener = new ChainedNodeChangedListener(listener, usagesDroppedToZeroListener); |
11735
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
330 } |
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
|
331 } |
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
|
332 |
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
|
333 public void stopTrackingUsagesDroppedZero() { |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
334 assert usagesDroppedToZeroListener != null; |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
335 if (usagesDroppedToZeroListener instanceof ChainedNodeChangedListener) { |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
336 usagesDroppedToZeroListener = ((ChainedNodeChangedListener) usagesDroppedToZeroListener).next; |
11735
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
337 } else { |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11735
diff
changeset
|
338 usagesDroppedToZeroListener = null; |
11735
9c9683970656
Allow multiple NodeChangedListeners.
Roland Schatz <roland.schatz@oracle.com>
parents:
11728
diff
changeset
|
339 } |
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
|
340 } |
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
|
341 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
342 /** |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
343 * 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
|
344 * {@code node} is added to this graph and returned. |
14904 | 345 * |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
346 * @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
|
347 */ |
14904 | 348 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
|
349 return uniqueHelper(node, true); |
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
350 } |
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
351 |
11652
f091e0d6f4f3
Disallow add for global value numberable node types. Introduce addWithoutUnique.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
352 @SuppressWarnings("unchecked") |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
353 <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
|
354 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
|
355 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
|
356 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
|
357 return (T) other; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
358 } else { |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
359 Node result = addIfMissing ? addHelper(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
|
360 if (node.getNodeClass().isLeafNode()) { |
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
|
361 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
|
362 } |
4646
75dcf829cfdc
experimental: "next" successor on all nodes
Lukas Stadler <lukas.stadler@jku.at>
parents:
4614
diff
changeset
|
363 return (T) result; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
364 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
365 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
366 |
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
|
367 void putNodeIntoCache(Node node) { |
13327
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13140
diff
changeset
|
368 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
|
369 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
|
370 assert node.getNodeClass().isLeafNode() : node.getClass(); |
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
|
371 cachedNodes.put(new CacheEntry(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
|
372 } |
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
|
373 |
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
|
374 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
|
375 CacheEntry key = new CacheEntry(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
|
376 Node result = cachedNodes.get(key); |
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
|
377 if (result != null && result.isDeleted()) { |
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
|
378 cachedNodes.remove(key); |
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
|
379 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
|
380 } |
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
|
381 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
|
382 } |
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
|
383 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
384 public Node findDuplicate(Node node) { |
11654
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
385 NodeClass nodeClass = node.getNodeClass(); |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
386 assert nodeClass.valueNumberable(); |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
387 if (nodeClass.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
|
388 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
|
389 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
|
390 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
|
391 } 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
|
392 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
|
393 } |
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
|
394 } else { |
11654
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
395 |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
396 int minCount = Integer.MAX_VALUE; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
397 Node minCountNode = null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
398 for (Node input : node.inputs()) { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
11755
diff
changeset
|
399 if (input != null && input.recordsUsages()) { |
11654
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
400 int estimate = input.getUsageCountUpperBound(); |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
401 if (estimate == 0) { |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
402 return null; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
403 } else if (estimate < minCount) { |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
404 minCount = estimate; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
405 minCountNode = input; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
406 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
407 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
408 } |
11654
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
409 if (minCountNode != null) { |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
410 for (Node usage : minCountNode.usages()) { |
11666
3967f9f306f8
Factor usages of getNodeClass().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11654
diff
changeset
|
411 if (usage != node && nodeClass == usage.getNodeClass() && nodeClass.valueEqual(node, usage) && nodeClass.edgesEqual(node, usage)) { |
11654
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
412 return usage; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
413 } |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
414 } |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
415 return null; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
416 } |
5446
fafab5f0507d
Fix findDuplicate for nodes with no inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5427
diff
changeset
|
417 return null; |
fafab5f0507d
Fix findDuplicate for nodes with no inputs
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5427
diff
changeset
|
418 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
419 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
420 |
12686
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
421 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
|
422 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
|
423 } |
7778a0f2999a
Run partial escape analysis on Truffle cache methods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11675
diff
changeset
|
424 |
5361
dec5a35ddbe2
lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents:
5061
diff
changeset
|
425 /** |
12686
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
426 * 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
|
427 */ |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
428 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
|
429 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
|
430 |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
431 Mark(Graph graph) { |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
432 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
|
433 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
|
434 } |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
435 |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
436 @Override |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
437 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
|
438 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
|
439 Mark other = (Mark) obj; |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
440 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
|
441 } |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
442 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
|
443 } |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
444 |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
445 @Override |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
446 public int hashCode() { |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
447 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
|
448 } |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
449 |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
450 /** |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
451 * 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
|
452 */ |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
453 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
|
454 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
|
455 } |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
456 |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
457 /** |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
458 * 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
|
459 * 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
|
460 */ |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
461 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
|
462 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
|
463 } |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
464 } |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
465 |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
466 /** |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
467 * 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
|
468 */ |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
469 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
|
470 return new Mark(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
471 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
472 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
473 private class NodeIterator implements Iterator<Node> { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7332
diff
changeset
|
474 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
475 private int index; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
476 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
477 public NodeIterator() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
478 this(0); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
479 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
480 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
481 public NodeIterator(int index) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
482 this.index = index - 1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
483 forward(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
484 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
485 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
486 private void forward() { |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
487 if (index < nodesSize) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
488 do { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
489 index++; |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
490 } while (index < nodesSize && nodes[index] == null); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
491 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
492 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
493 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
494 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
495 public boolean hasNext() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
496 checkForDeletedNode(); |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
497 return index < nodesSize; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
498 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
499 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
500 private void checkForDeletedNode() { |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
501 if (index < nodesSize) { |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
502 while (index < nodesSize && nodes[index] == null) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
503 index++; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
504 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
505 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
506 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
507 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
508 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
509 public Node next() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
510 try { |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
511 return nodes[index]; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
512 } finally { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
513 forward(); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
517 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
518 public void remove() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
519 throw new UnsupportedOperationException(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
521 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
522 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
523 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7332
diff
changeset
|
524 * 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
|
525 * mark}. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
526 */ |
12686
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
527 public NodeIterable<Node> getNewNodes(Mark mark) { |
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
528 final int index = mark.getValue(); |
15146
65efd2eeea1b
Remove AbstractNodeIterable, move its methods to default methods on NodeIterable.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14991
diff
changeset
|
529 return new NodeIterable<Node>() { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7332
diff
changeset
|
530 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
531 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
532 public Iterator<Node> iterator() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
533 return new NodeIterator(index); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
534 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
535 }; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
536 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
537 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
538 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
539 * Returns an {@link Iterable} providing all the live nodes. |
14904 | 540 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
541 * @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
|
542 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
543 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
|
544 return new NodeIterable<Node>() { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7332
diff
changeset
|
545 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
546 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
547 public Iterator<Node> iterator() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
548 return new NodeIterator(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
549 } |
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
|
550 |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
551 @Override |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
552 public int count() { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
553 return getNodeCount(); |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
554 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
555 }; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
556 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
557 |
8327
e24fb475bdec
Remove PlaceHolderNode class definition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
558 private static final Node PLACE_HOLDER = new Node() { |
e24fb475bdec
Remove PlaceHolderNode class definition.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
559 }; |
7332
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
560 |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
561 /** |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
562 * 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
|
563 * {@link #maybeCompress()} will actually do compression. |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
564 */ |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
565 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
|
566 |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
567 private static final DebugMetric GraphCompressions = Debug.metric("GraphCompressions"); |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
568 |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
569 /** |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
570 * 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
|
571 * 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
|
572 * ordering between the nodes within the list. |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
573 */ |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
574 public boolean maybeCompress() { |
13323
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
|
575 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
|
576 return false; |
4b053442b9d1
Do not compress graph when debug is enabled
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12687
diff
changeset
|
577 } |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
578 int liveNodeCount = getNodeCount(); |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
579 int liveNodePercent = liveNodeCount * 100 / nodesSize; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
580 if (COMPRESSION_THRESHOLD == 0 || liveNodePercent >= COMPRESSION_THRESHOLD) { |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
581 return false; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
582 } |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
583 GraphCompressions.increment(); |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
584 int nextId = 0; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
585 for (int i = 0; nextId < liveNodeCount; i++) { |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
586 Node n = nodes[i]; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
587 if (n != null) { |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
588 assert n.id == i; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
589 if (i != nextId) { |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
590 assert n.id > nextId; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
591 n.id = nextId; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
592 nodes[nextId] = n; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
593 nodes[i] = null; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
594 } |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
595 nextId++; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
596 } |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
597 } |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
598 if (MODIFICATION_COUNTS_ENABLED) { |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
599 // 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
|
600 Arrays.fill(nodeModCounts, 0); |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
601 Arrays.fill(nodeUsageModCounts, 0); |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
602 } |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
603 nodesSize = nextId; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
604 compressions++; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
605 nodesDeletedBeforeLastCompression += nodesDeletedSinceLastCompression; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
606 nodesDeletedSinceLastCompression = 0; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
607 return true; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
608 } |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
609 |
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
|
610 private class TypedNodeIterator<T extends IterableNodeType> implements Iterator<T> { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7332
diff
changeset
|
611 |
7332
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
612 private final int[] ids; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
613 private final Node[] current; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
614 |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
615 private int currentIdIndex; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
616 private boolean needsForward; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
617 |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
618 public TypedNodeIterator(NodeClass clazz) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
619 ids = clazz.iterableIds(); |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
620 currentIdIndex = 0; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
621 current = new Node[ids.length]; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
622 Arrays.fill(current, PLACE_HOLDER); |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
623 needsForward = true; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
624 } |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
625 |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
626 private Node findNext() { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
627 if (needsForward) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
628 forward(); |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
629 } else { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
630 Node c = current(); |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
631 Node afterDeleted = skipDeleted(c); |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
632 if (afterDeleted == null) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
633 needsForward = true; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
634 } else if (c != afterDeleted) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
635 setCurrent(afterDeleted); |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
636 } |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
637 } |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
638 if (needsForward) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
639 return null; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
640 } |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
641 return current(); |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
642 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
643 |
7332
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
644 private Node skipDeleted(Node node) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
645 Node n = node; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
646 while (n != null && n.isDeleted()) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
647 n = n.typeCacheNext; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
648 } |
7332
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
649 return n; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
650 } |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
651 |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
652 private void forward() { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
653 needsForward = false; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
654 int startIdx = currentIdIndex; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
655 while (true) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
656 Node next; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
657 if (current() == PLACE_HOLDER) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
658 next = getStartNode(ids[currentIdIndex]); |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
659 } else { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
660 next = current().typeCacheNext; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
661 } |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
662 next = skipDeleted(next); |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
663 if (next == null) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
664 currentIdIndex++; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
665 if (currentIdIndex >= ids.length) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
666 currentIdIndex = 0; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
667 } |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
668 if (currentIdIndex == startIdx) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
669 needsForward = true; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
670 return; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
671 } |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
672 } else { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
673 setCurrent(next); |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
674 break; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
675 } |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
676 } |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
677 } |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
678 |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
679 private Node current() { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
680 return current[currentIdIndex]; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
681 } |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
682 |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
683 private void setCurrent(Node n) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
684 current[currentIdIndex] = n; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
685 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
686 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
687 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
688 public boolean hasNext() { |
7332
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
689 return findNext() != null; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
690 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
691 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
692 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
693 @SuppressWarnings("unchecked") |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
694 public T next() { |
7332
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
695 Node result = findNext(); |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
696 if (result == null) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
697 throw new NoSuchElementException(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
698 } |
7332
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
699 needsForward = true; |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
700 return (T) result; |
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 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
704 public void remove() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
705 throw new UnsupportedOperationException(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
706 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
707 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
708 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
709 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7332
diff
changeset
|
710 * 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
|
711 * {@code type}. |
14904 | 712 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
713 * @param type 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
|
714 * @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
|
715 */ |
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
|
716 public <T extends Node & IterableNodeType> NodeIterable<T> getNodes(final Class<T> type) { |
7332
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
717 final NodeClass nodeClass = NodeClass.get(type); |
15146
65efd2eeea1b
Remove AbstractNodeIterable, move its methods to default methods on NodeIterable.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
14991
diff
changeset
|
718 return new NodeIterable<T>() { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7332
diff
changeset
|
719 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
720 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
721 public Iterator<T> iterator() { |
7332
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
722 return new TypedNodeIterator<>(nodeClass); |
3733
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 }; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
725 } |
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 * Returns whether the graph contains at least one node of the given type. |
14904 | 729 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
730 * @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
|
731 * @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
|
732 */ |
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
|
733 public <T extends Node & IterableNodeType> boolean hasNode(final Class<T> type) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
734 return getNodes(type).iterator().hasNext(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
735 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
736 |
7332
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
737 private Node getStartNode(int iterableId) { |
c5a9bcd9493d
Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
7124
diff
changeset
|
738 Node start = nodeCacheFirst.size() <= iterableId ? null : nodeCacheFirst.get(iterableId); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
739 return start; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
740 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
741 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
742 public NodeBitMap createNodeBitMap() { |
15955
3f48e9a1016c
NodeBitMap refactoring
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15890
diff
changeset
|
743 return new NodeBitMap(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
744 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
745 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
746 public <T> NodeMap<T> createNodeMap() { |
15890
f4510fd9e8b3
Removed unused grow functionality on NodeMap.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15196
diff
changeset
|
747 return new NodeMap<>(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
748 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
749 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
750 public NodeFlood createNodeFlood() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
751 return new NodeFlood(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
752 } |
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 public NodeWorkList createNodeWorkList() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
755 return new NodeWorkList(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
756 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
757 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
758 public NodeWorkList createNodeWorkList(boolean fill, int iterationLimitPerNode) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
759 return new NodeWorkList(this, fill, iterationLimitPerNode); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
760 } |
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 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
|
763 assert !isFrozen(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
764 assert node.id() == Node.INITIAL_ID; |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
765 if (nodes.length == nodesSize) { |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
766 nodes = Arrays.copyOf(nodes, (nodesSize * 2) + 1); |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
767 } |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
768 int id = nodesSize; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
769 nodes[id] = node; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
770 nodesSize++; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
771 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
772 int nodeClassId = node.getNodeClass().iterableId(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
773 if (nodeClassId != NodeClass.NOT_ITERABLE) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
774 while (nodeCacheFirst.size() <= nodeClassId) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
775 nodeCacheFirst.add(null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
776 nodeCacheLast.add(null); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
777 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
778 Node prev = nodeCacheLast.get(nodeClassId); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
779 if (prev != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
780 prev.typeCacheNext = node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
781 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
782 nodeCacheFirst.set(nodeClassId, node); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
783 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
784 nodeCacheLast.set(nodeClassId, node); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
785 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
786 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
787 node.id = id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
788 logNodeAdded(node); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
789 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
790 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
791 void logNodeAdded(Node node) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
792 if (TIME_TRAVEL) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
793 log(new GraphEvent.NodeEvent(node, GraphEvent.NodeEvent.Type.ADDED)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
794 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
795 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
796 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
797 void logNodeDeleted(Node node) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
798 if (TIME_TRAVEL) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
799 log(new GraphEvent.NodeEvent(node, GraphEvent.NodeEvent.Type.DELETED)); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
800 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
801 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
802 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
803 private void log(NodeEvent nodeEvent) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
804 if (eventLog == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
805 eventLog = new GraphEventLog(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
806 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
807 eventLog.add(nodeEvent); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
810 public GraphEventLog getEventLog() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
811 return eventLog; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
812 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
813 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
814 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
|
815 assert !isFrozen(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
816 assert !node.isDeleted() : "cannot delete a node twice! node=" + node; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
817 logNodeDeleted(node); |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
818 nodes[node.id] = null; |
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
819 nodesDeletedSinceLastCompression++; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
820 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
821 // 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
|
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 public boolean verify() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
825 for (Node node : getNodes()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
826 try { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
827 try { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
828 assert node.verify(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
829 } catch (AssertionError t) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
830 throw new GraalInternalError(t); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
831 } catch (RuntimeException t) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
832 throw new GraalInternalError(t); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
833 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
834 } catch (GraalInternalError e) { |
15196
593f7d0a6f50
GraalGraphInternalError: improve method names and documentation.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
835 throw GraalGraphInternalError.transformAndAddContext(e, node).addContext(this); |
3733
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
838 return true; |
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 Node getNode(int i) { |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
842 return nodes[i]; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
843 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
844 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
845 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
846 * Returns the number of node ids generated so far. |
14904 | 847 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
848 * @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
|
849 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
850 int nodeIdCount() { |
12687
43301f080126
added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents:
12686
diff
changeset
|
851 return nodesSize; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
852 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
853 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
854 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7332
diff
changeset
|
855 * 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
|
856 * 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
|
857 * 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
|
858 * 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
|
859 * matching of node types in the replacement map. |
14904 | 860 * |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
861 * @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
|
862 * @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
|
863 * @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
|
864 */ |
11675
77d9f12797c5
Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11671
diff
changeset
|
865 public Map<Node, Node> addDuplicates(Iterable<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
|
866 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
|
867 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
|
868 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
|
869 } else { |
4a99bfc329f0
Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5446
diff
changeset
|
870 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
|
871 } |
11675
77d9f12797c5
Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11671
diff
changeset
|
872 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
|
873 } |
4a99bfc329f0
Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5446
diff
changeset
|
874 |
4a99bfc329f0
Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5446
diff
changeset
|
875 public interface DuplicationReplacement { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7332
diff
changeset
|
876 |
5478
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(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
|
878 } |
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 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
|
881 |
5478
4a99bfc329f0
Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5446
diff
changeset
|
882 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
|
883 |
5478
4a99bfc329f0
Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5446
diff
changeset
|
884 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
|
885 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
|
886 } |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7332
diff
changeset
|
887 |
5478
4a99bfc329f0
Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5446
diff
changeset
|
888 @Override |
4a99bfc329f0
Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5446
diff
changeset
|
889 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
|
890 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
|
891 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
|
892 } |
4a99bfc329f0
Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5446
diff
changeset
|
893 |
4a99bfc329f0
Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5446
diff
changeset
|
894 } |
4a99bfc329f0
Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5446
diff
changeset
|
895 |
5427
441cf24df453
correctly handle null for replacements parameter in Graph.addDuplicates()
Doug Simon <doug.simon@oracle.com>
parents:
5419
diff
changeset
|
896 @SuppressWarnings("all") |
11675
77d9f12797c5
Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11671
diff
changeset
|
897 public Map<Node, Node> addDuplicates(Iterable<Node> newNodes, final Graph oldGraph, int estimatedNodeCount, DuplicationReplacement replacements) { |
77d9f12797c5
Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11671
diff
changeset
|
898 return NodeClass.addGraphDuplicate(this, oldGraph, estimatedNodeCount, newNodes, replacements); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
899 } |
13744
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13329
diff
changeset
|
900 |
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13329
diff
changeset
|
901 public boolean isFrozen() { |
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13329
diff
changeset
|
902 return isFrozen; |
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13329
diff
changeset
|
903 } |
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13329
diff
changeset
|
904 |
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13329
diff
changeset
|
905 public void freeze() { |
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13329
diff
changeset
|
906 this.isFrozen = true; |
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13329
diff
changeset
|
907 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
908 } |