Mercurial > hg > truffle
annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java @ 19547:3be278f50e4b
Reenable usage dropped to zero listener.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Mon, 23 Feb 2015 00:29:23 +0100 |
parents | 353669a84287 |
children | 14a30a0f631c |
rev | line source |
---|---|
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1 /* |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
4 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
8 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
14 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
18 * |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
21 * questions. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
22 */ |
5060
4ed4295ce15f
Update import statements.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5059
diff
changeset
|
23 package com.oracle.graal.graph; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
24 |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17188
diff
changeset
|
25 import static com.oracle.graal.graph.Edges.Type.*; |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
26 import static com.oracle.graal.graph.Graph.*; |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
27 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 import java.lang.annotation.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 import java.util.*; |
19543
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
30 import java.util.function.*; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
31 |
17338
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
32 import sun.misc.*; |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
33 |
17226
a552dd335bde
generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents:
17210
diff
changeset
|
34 import com.oracle.graal.compiler.common.*; |
18884
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18815
diff
changeset
|
35 import com.oracle.graal.debug.*; |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18815
diff
changeset
|
36 import com.oracle.graal.graph.Graph.NodeEvent; |
16897
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
37 import com.oracle.graal.graph.Graph.NodeEventListener; |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
38 import com.oracle.graal.graph.iterators.*; |
11882
51059863da73
replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11755
diff
changeset
|
39 import com.oracle.graal.graph.spi.*; |
16841
cbd42807a31f
moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents:
16822
diff
changeset
|
40 import com.oracle.graal.nodeinfo.*; |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
41 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
42 /** |
18379
3aaf2747961c
use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18163
diff
changeset
|
43 * This class is the base class for all nodes. It represents a node that can be inserted in a |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
44 * {@link Graph}. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
45 * <p> |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
46 * Once a node has been added to a graph, it has a graph-unique {@link #id()}. Edges in the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
47 * subclasses are represented with annotated fields. There are two kind of edges : {@link Input} and |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
48 * {@link Successor}. If a field, of a type compatible with {@link Node}, annotated with either |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
49 * {@link Input} and {@link Successor} is not null, then there is an edge from this node to the node |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
50 * this field points to. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
51 * <p> |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
52 * Nodes which are be value numberable should implement the {@link ValueNumberable} interface. |
15001 | 53 * |
18379
3aaf2747961c
use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18163
diff
changeset
|
54 * <h1>Replay Compilation</h1> |
3aaf2747961c
use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18163
diff
changeset
|
55 * |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
56 * To enable deterministic replay compilation, node sets and node maps should be instantiated with |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
57 * the following methods: |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
58 * <ul> |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
59 * <li>{@link #newSet()}</li> |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
60 * <li>{@link #newSet(Collection)}</li> |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
61 * <li>{@link #newMap()}</li> |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
62 * <li>{@link #newMap(int)}</li> |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
63 * <li>{@link #newMap(Map)}</li> |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
64 * <li>{@link #newIdentityMap()}</li> |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
65 * <li>{@link #newIdentityMap(int)}</li> |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
66 * <li>{@link #newIdentityMap(Map)}</li> |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
67 * </ul> |
18379
3aaf2747961c
use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18163
diff
changeset
|
68 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 * <h1>Assertions and Verification</h1> |
15001 | 70 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 * The Node class supplies the {@link #assertTrue(boolean, String, Object...)} and |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
72 * {@link #assertFalse(boolean, String, Object...)} methods, which will check the supplied boolean |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
73 * and throw a VerificationError if it has the wrong value. Both methods will always either throw an |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
74 * exception or return true. They can thus be used within an assert statement, so that the check is |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
75 * only performed if assertions are enabled. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
76 */ |
16822
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16606
diff
changeset
|
77 @NodeInfo |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
78 public abstract class Node implements Cloneable, Formattable { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 |
19403
61d3cb8e1280
Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19396
diff
changeset
|
80 public static final NodeClass<?> TYPE = null; |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
17450
diff
changeset
|
81 public static final boolean USE_UNSAFE_TO_CLONE = Boolean.parseBoolean(System.getProperty("graal.node.useUnsafeToClone", "true")); |
17353
3457f147a24f
made selectability of using generated node functionality more fine grained
Doug Simon <doug.simon@oracle.com>
parents:
17347
diff
changeset
|
82 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 static final int DELETED_ID_START = -1000000000; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 static final int INITIAL_ID = -1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 static final int ALIVE_ID_START = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
86 |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
87 // The use of fully qualified class names here and in the rest |
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
88 // of this file works around a problem javac has resolving symbols |
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
89 |
5823
f238fe91dc7f
partial (non XIR) support for inlining virtual dispatch at call sites - still needs fixing
Doug Simon <doug.simon@oracle.com>
parents:
5814
diff
changeset
|
90 /** |
16336
c88a9e432faf
small fix and doc for @OptionalInput
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16332
diff
changeset
|
91 * Denotes a non-optional (non-null) node input. This should be applied to exactly the fields of |
c88a9e432faf
small fix and doc for @OptionalInput
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16332
diff
changeset
|
92 * a node that are of type {@link Node} or {@link NodeInputList}. Nodes that update fields of |
c88a9e432faf
small fix and doc for @OptionalInput
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16332
diff
changeset
|
93 * type {@link Node} outside of their constructor should call |
c88a9e432faf
small fix and doc for @OptionalInput
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16332
diff
changeset
|
94 * {@link Node#updateUsages(Node, Node)} just prior to doing the update of the input. |
5823
f238fe91dc7f
partial (non XIR) support for inlining virtual dispatch at call sites - still needs fixing
Doug Simon <doug.simon@oracle.com>
parents:
5814
diff
changeset
|
95 */ |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
96 @java.lang.annotation.Retention(RetentionPolicy.RUNTIME) |
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
97 @java.lang.annotation.Target(ElementType.FIELD) |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
98 public static @interface Input { |
15001 | 99 InputType value() default InputType.Value; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
101 |
16332
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
102 /** |
16336
c88a9e432faf
small fix and doc for @OptionalInput
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16332
diff
changeset
|
103 * Denotes an optional (nullable) node input. This should be applied to exactly the fields of a |
c88a9e432faf
small fix and doc for @OptionalInput
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16332
diff
changeset
|
104 * node that are of type {@link Node} or {@link NodeInputList}. Nodes that update fields of type |
16332
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
105 * {@link Node} outside of their constructor should call {@link Node#updateUsages(Node, Node)} |
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
106 * just prior to doing the update of the input. |
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
107 */ |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
108 @java.lang.annotation.Retention(RetentionPolicy.RUNTIME) |
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
109 @java.lang.annotation.Target(ElementType.FIELD) |
16332
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
110 public static @interface OptionalInput { |
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
111 InputType value() default InputType.Value; |
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
112 } |
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
113 |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
114 @java.lang.annotation.Retention(RetentionPolicy.RUNTIME) |
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
115 @java.lang.annotation.Target(ElementType.FIELD) |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
116 public static @interface Successor { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
117 } |
3733
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 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
120 * Denotes that a parameter of an {@linkplain NodeIntrinsic intrinsic} method must be a compile |
7759
9e68bd67b745
cleanups, javadoc, assertions
Lukas Stadler <lukas.stadler@jku.at>
parents:
7651
diff
changeset
|
121 * time constant at all call sites to the intrinsic method. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
122 */ |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
123 @java.lang.annotation.Retention(RetentionPolicy.RUNTIME) |
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
124 @java.lang.annotation.Target(ElementType.PARAMETER) |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
125 public static @interface ConstantNodeParameter { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
126 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
128 /** |
12361
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
129 * Denotes an injected parameter in a {@linkplain NodeIntrinsic node intrinsic} constructor. If |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
130 * the constructor is called as part of node intrinsification, the node intrinsifier will inject |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
131 * an argument for the annotated parameter. Injected parameters must precede all non-injected |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
132 * parameters in a constructor. |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
133 */ |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
134 @java.lang.annotation.Retention(RetentionPolicy.RUNTIME) |
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
135 @java.lang.annotation.Target(ElementType.PARAMETER) |
12361
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
136 public static @interface InjectedNodeParameter { |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
137 } |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
138 |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
139 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
140 * Annotates a method that can be replaced by a compiler intrinsic. A (resolved) call to the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
141 * annotated method can be replaced with an instance of the node class denoted by |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
142 * {@link #value()}. For this reason, the signature of the annotated method must match the |
12361
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
143 * signature (excluding a prefix of {@linkplain InjectedNodeParameter injected} parameters) of a |
16895
06c15e88d383
added factory method to all Node classes; replaced Node classes instantiation with calls to factory methods; replaced identity tests on Node classes with ' == <node class>.getGenClass()' idiom
Doug Simon <doug.simon@oracle.com>
parents:
16841
diff
changeset
|
144 * factory method named {@code "create"} in the node class. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
145 */ |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
146 @java.lang.annotation.Retention(RetentionPolicy.RUNTIME) |
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
147 @java.lang.annotation.Target(ElementType.METHOD) |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 public static @interface NodeIntrinsic { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
149 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
151 * Gets the {@link Node} subclass instantiated when intrinsifying a call to the annotated |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
152 * method. If not specified, then the class in which the annotated method is declared is |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
153 * used (and is assumed to be a {@link Node} subclass). |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
154 */ |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15036
diff
changeset
|
155 Class<?> value() default NodeIntrinsic.class; |
6419
b74402a7079b
fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents:
5823
diff
changeset
|
156 |
b74402a7079b
fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents:
5823
diff
changeset
|
157 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
158 * Determines if the stamp of the instantiated intrinsic node has its stamp set from the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
159 * return type of the annotated method. |
11698
4eec2ac671c2
Refactor the WordTypeVerificationPhase to use fewer graph iterations, and invoke it a fewer places
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11677
diff
changeset
|
160 * <p> |
4eec2ac671c2
Refactor the WordTypeVerificationPhase to use fewer graph iterations, and invoke it a fewer places
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11677
diff
changeset
|
161 * When it is set to true, the stamp that is passed in to the constructor of ValueNode is |
4eec2ac671c2
Refactor the WordTypeVerificationPhase to use fewer graph iterations, and invoke it a fewer places
Christian Wimmer <christian.wimmer@oracle.com>
parents:
11677
diff
changeset
|
162 * ignored and can therefore safely be {@code null}. |
6419
b74402a7079b
fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents:
5823
diff
changeset
|
163 */ |
b74402a7079b
fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents:
5823
diff
changeset
|
164 boolean setStampFromReturnType() default false; |
19419
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
18938
diff
changeset
|
165 |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
18938
diff
changeset
|
166 /** |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
18938
diff
changeset
|
167 * Determines if this intrinsic can be compile-time executed. An attempt to execute a call |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
18938
diff
changeset
|
168 * (via reflection) to this intrinsic at compile-time will be made if all of its arguments |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
18938
diff
changeset
|
169 * are compile-time constant. If the execution succeeds without an exception, the result is |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
18938
diff
changeset
|
170 * inserted as a constant node in the graph. |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
18938
diff
changeset
|
171 */ |
e2fd58839d38
exposed API for creating node intrinsic without first having an InvokeNode; added mechanism for NodeIntrinsics to be folded
Doug Simon <doug.simon@oracle.com>
parents:
18938
diff
changeset
|
172 boolean foldable() default false; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
174 |
17316
e6e678c3818f
only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents:
17308
diff
changeset
|
175 /** |
e6e678c3818f
only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents:
17308
diff
changeset
|
176 * Marker for a node that can be replaced by another node via global value numbering. A |
e6e678c3818f
only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents:
17308
diff
changeset
|
177 * {@linkplain NodeClass#isLeafNode() leaf} node can be replaced by another node of the same |
e6e678c3818f
only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents:
17308
diff
changeset
|
178 * type that has exactly the same {@linkplain NodeClass#getData() data} values. A non-leaf node |
e6e678c3818f
only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents:
17308
diff
changeset
|
179 * can be replaced by another node of the same type that has exactly the same data values as |
e6e678c3818f
only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents:
17308
diff
changeset
|
180 * well as the same {@linkplain Node#inputs() inputs} and {@linkplain Node#successors() |
e6e678c3818f
only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents:
17308
diff
changeset
|
181 * successors}. |
e6e678c3818f
only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents:
17308
diff
changeset
|
182 */ |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
183 public interface ValueNumberable { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
184 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 private Graph graph; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 int id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
188 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
189 // this next pointer is used in Graph to implement fast iteration over NodeClass types, it |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
190 // therefore points to the next Node of the same type. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 Node typeCacheNext; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
192 |
16925
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
193 static final int INLINE_USAGE_COUNT = 2; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
194 private static final Node[] NO_NODES = {}; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
195 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
196 /** |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
197 * Head of usage list. The elements of the usage list in order are {@link #usage0}, |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
198 * {@link #usage1} and {@link #extraUsages}. The first null entry terminates the list. |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
199 */ |
16925
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
200 Node usage0; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
201 Node usage1; |
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
202 Node[] extraUsages; |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
203 int extraUsagesCount; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
204 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
205 private Node predecessor; |
19471
880717e44675
Use typed NodeClass in node constructors.
Roland Schatz <roland.schatz@oracle.com>
parents:
19420
diff
changeset
|
206 private NodeClass<? extends Node> nodeClass; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
207 |
16897
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
208 public static final int NODE_LIST = -2; |
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
209 public static final int NOT_ITERABLE = -1; |
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
210 |
19471
880717e44675
Use typed NodeClass in node constructors.
Roland Schatz <roland.schatz@oracle.com>
parents:
19420
diff
changeset
|
211 public Node(NodeClass<? extends Node> c) { |
15827
4e770fa50889
Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15381
diff
changeset
|
212 init(); |
19396
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18938
diff
changeset
|
213 assert c.getJavaClass() == this.getClass(); |
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18938
diff
changeset
|
214 this.nodeClass = c; |
15827
4e770fa50889
Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15381
diff
changeset
|
215 } |
4e770fa50889
Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15381
diff
changeset
|
216 |
4e770fa50889
Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15381
diff
changeset
|
217 final void init() { |
4e770fa50889
Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15381
diff
changeset
|
218 id = INITIAL_ID; |
4e770fa50889
Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15381
diff
changeset
|
219 extraUsages = NO_NODES; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
221 |
12686
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
222 int id() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 return id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
225 |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
226 /** |
18742
5df121664e08
added factory methods for creating sets
Doug Simon <doug.simon@oracle.com>
parents:
18655
diff
changeset
|
227 * @see CollectionsFactory#newSet() |
18379
3aaf2747961c
use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18163
diff
changeset
|
228 */ |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
229 public static <E extends Node> Set<E> newSet() { |
18742
5df121664e08
added factory methods for creating sets
Doug Simon <doug.simon@oracle.com>
parents:
18655
diff
changeset
|
230 return CollectionsFactory.newSet(); |
18379
3aaf2747961c
use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18163
diff
changeset
|
231 } |
3aaf2747961c
use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18163
diff
changeset
|
232 |
3aaf2747961c
use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18163
diff
changeset
|
233 /** |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
234 * @see #newSet() |
18379
3aaf2747961c
use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18163
diff
changeset
|
235 */ |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
236 public static <E extends Node> Set<E> newSet(Collection<? extends E> c) { |
18742
5df121664e08
added factory methods for creating sets
Doug Simon <doug.simon@oracle.com>
parents:
18655
diff
changeset
|
237 return CollectionsFactory.newSet(c); |
18379
3aaf2747961c
use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18163
diff
changeset
|
238 } |
3aaf2747961c
use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18163
diff
changeset
|
239 |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
240 public static <K extends Node, V> Map<K, V> newMap() { |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
241 // Node.equals() and Node.hashCode() are final and are implemented |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
242 // purely in terms of identity so HashMap and IdentityHashMap with |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
243 // Node's as keys will behave the same. We choose to use the latter |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
244 // due to its lighter memory footprint. |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
245 return newIdentityMap(); |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
246 } |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
247 |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
248 public static <K extends Node, V> Map<K, V> newMap(Map<K, V> m) { |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
249 // Node.equals() and Node.hashCode() are final and are implemented |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
250 // purely in terms of identity so HashMap and IdentityHashMap with |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
251 // Node's as keys will behave the same. We choose to use the latter |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
252 // due to its lighter memory footprint. |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
253 return newIdentityMap(m); |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
254 } |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
255 |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
256 public static <K extends Node, V> Map<K, V> newMap(int expectedMaxSize) { |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
257 // Node.equals() and Node.hashCode() are final and are implemented |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
258 // purely in terms of identity so HashMap and IdentityHashMap with |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
259 // Node's as keys will behave the same. We choose to use the latter |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
260 // due to its lighter memory footprint. |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
261 return newIdentityMap(expectedMaxSize); |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
262 } |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
263 |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
264 public static <K extends Node, V> Map<K, V> newIdentityMap() { |
18655
86269e451920
removed (most) replay compilation support
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
265 return CollectionsFactory.newIdentityMap(); |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
266 } |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
267 |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
268 public static <K extends Node, V> Map<K, V> newIdentityMap(Map<K, V> m) { |
18655
86269e451920
removed (most) replay compilation support
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
269 return CollectionsFactory.newIdentityMap(m); |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
270 } |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
271 |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
272 public static <K extends Node, V> Map<K, V> newIdentityMap(int expectedMaxSize) { |
18655
86269e451920
removed (most) replay compilation support
Doug Simon <doug.simon@oracle.com>
parents:
18383
diff
changeset
|
273 return CollectionsFactory.newIdentityMap(expectedMaxSize); |
18383
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
274 } |
1518c3296cc8
use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18379
diff
changeset
|
275 |
18379
3aaf2747961c
use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents:
18163
diff
changeset
|
276 /** |
13327
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13140
diff
changeset
|
277 * Gets the graph context of this node. |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
278 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
279 public Graph graph() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
280 return graph; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
281 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
282 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
283 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
284 * Returns an {@link NodeClassIterable iterable} which can be used to traverse all non-null |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
285 * input edges of this node. |
15001 | 286 * |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
287 * @return an {@link NodeClassIterable iterable} for all non-null input edges. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
288 */ |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
289 public NodeClassIterable inputs() { |
19543
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
290 return nodeClass.getInputEdges().getIterable(this); |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
291 } |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
292 |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
293 /** |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
294 * Applies the given consumer to all inputs of this node. |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
295 * |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
296 * @param consumer the consumer to be applied to the inputs |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
297 */ |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
298 public void acceptInputs(Consumer<Node> consumer) { |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
299 nodeClass.getInputEdges().accept(this, consumer); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
300 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
301 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
302 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
303 * Returns an {@link NodeClassIterable iterable} which can be used to traverse all non-null |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
304 * successor edges of this node. |
15001 | 305 * |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
306 * @return an {@link NodeClassIterable iterable} for all non-null successor edges. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
307 */ |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
308 public NodeClassIterable successors() { |
19543
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
309 return nodeClass.getSuccessorEdges().getIterable(this); |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
310 } |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
311 |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
312 /** |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
313 * Applies the given consumer to all successors of this node. |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
314 * |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
315 * @param consumer the consumer to be applied to the inputs |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
316 */ |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
317 public void acceptSuccessors(Consumer<Node> consumer) { |
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
318 nodeClass.getSuccessorEdges().accept(this, consumer); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
319 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
320 |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
321 /** |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
322 * Gets the maximum number of usages this node has had at any point in time. |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
323 */ |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
324 public int getUsageCount() { |
11654
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
325 if (usage0 == null) { |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
326 return 0; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
327 } |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
328 if (usage1 == null) { |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
329 return 1; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
330 } |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
331 return 2 + extraUsagesCount; |
11654
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
332 } |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
333 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
334 /** |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
335 * Gets the list of nodes that use this node (i.e., as an input). |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
336 */ |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
337 public final NodeIterable<Node> usages() { |
16925
87a40fe1ba0c
refactored inner classes to be static top level classes to workaround javac "cannot find symbol" issue
Doug Simon <doug.simon@oracle.com>
parents:
16919
diff
changeset
|
338 return new NodeUsageIterable(this); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
339 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
340 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
341 /** |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
342 * Checks whether this node has no usages. |
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
343 */ |
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
344 public final boolean hasNoUsages() { |
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
345 return this.usage0 == null; |
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
346 } |
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
347 |
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
348 /** |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
349 * Adds a given node to this node's {@linkplain #usages() usages}. |
15001 | 350 * |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
351 * @param node the node to add |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
352 */ |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
353 private void addUsage(Node node) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
354 incUsageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
355 if (usage0 == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
356 usage0 = node; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
357 } else if (usage1 == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
358 usage1 = node; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
359 } else { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
360 int length = extraUsages.length; |
11539
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
361 if (length == 0) { |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
362 extraUsages = new Node[4]; |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
363 } else if (extraUsagesCount == length) { |
19514
55d0b9ec7587
Replace Array.copyOf usages with System.arraycopy usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19471
diff
changeset
|
364 Node[] newExtraUsages = new Node[length * 2 + 1]; |
55d0b9ec7587
Replace Array.copyOf usages with System.arraycopy usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19471
diff
changeset
|
365 System.arraycopy(extraUsages, 0, newExtraUsages, 0, length); |
55d0b9ec7587
Replace Array.copyOf usages with System.arraycopy usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19471
diff
changeset
|
366 extraUsages = newExtraUsages; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
367 } |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
368 extraUsages[extraUsagesCount++] = node; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
369 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
370 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
371 |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
372 private void movUsageFromEndTo(int destIndex) { |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
373 int lastIndex = this.getUsageCount() - 1; |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
374 if (destIndex == 0) { |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
375 if (lastIndex == 0) { |
15153
d224a3a0e6a9
Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15150
diff
changeset
|
376 usage0 = null; |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
377 return; |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
378 } else if (lastIndex == 1) { |
15153
d224a3a0e6a9
Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15150
diff
changeset
|
379 usage0 = usage1; |
d224a3a0e6a9
Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15150
diff
changeset
|
380 usage1 = null; |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
381 return; |
15153
d224a3a0e6a9
Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15150
diff
changeset
|
382 } else { |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
383 usage0 = extraUsages[lastIndex - INLINE_USAGE_COUNT]; |
15153
d224a3a0e6a9
Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15150
diff
changeset
|
384 } |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
385 } else if (destIndex == 1) { |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
386 if (lastIndex == 1) { |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
387 usage1 = null; |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
388 return; |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
389 } |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
390 usage1 = extraUsages[lastIndex - INLINE_USAGE_COUNT]; |
15153
d224a3a0e6a9
Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15150
diff
changeset
|
391 } else { |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
392 Node n = extraUsages[lastIndex - INLINE_USAGE_COUNT]; |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
393 extraUsages[destIndex - INLINE_USAGE_COUNT] = n; |
15153
d224a3a0e6a9
Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15150
diff
changeset
|
394 } |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
395 extraUsages[lastIndex - INLINE_USAGE_COUNT] = null; |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
396 this.extraUsagesCount--; |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
397 } |
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
398 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
399 /** |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
400 * Removes a given node from this node's {@linkplain #usages() usages}. |
15001 | 401 * |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
402 * @param node the node to remove |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
403 * @return whether or not {@code usage} was in the usage list |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
404 */ |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
405 private boolean removeUsage(Node node) { |
15153
d224a3a0e6a9
Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15150
diff
changeset
|
406 assert node != null; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
407 // It is critical that this method maintains the invariant that |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
408 // the usage list has no null element preceding a non-null element |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
409 incUsageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
410 if (usage0 == node) { |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
411 this.movUsageFromEndTo(0); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
412 return true; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
413 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
414 if (usage1 == node) { |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
415 this.movUsageFromEndTo(1); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
416 return true; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
417 } |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
418 for (int i = 0; i < this.extraUsagesCount; ++i) { |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
419 if (extraUsages[i] == node) { |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
420 this.movUsageFromEndTo(i + INLINE_USAGE_COUNT); |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
421 return true; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
422 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
423 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
424 return false; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
425 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
426 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
427 private void clearUsages() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
428 incUsageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
429 usage0 = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
430 usage1 = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
431 extraUsages = NO_NODES; |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
432 extraUsagesCount = 0; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
433 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
434 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
435 public final Node predecessor() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
436 return predecessor; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
437 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
438 |
16897
f90dcdbbb75e
switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents:
16895
diff
changeset
|
439 public final int modCount() { |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
440 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
441 return graph.modCount(this); |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
442 } |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
443 return 0; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
444 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
445 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
446 final void incModCount() { |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
447 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
448 graph.incModCount(this); |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
449 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
450 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
451 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
452 final int usageModCount() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
453 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
454 return graph.usageModCount(this); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
455 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
456 return 0; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
457 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
458 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
459 final void incUsageModCount() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
460 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
461 graph.incUsageModCount(this); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
462 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
463 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
464 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
465 public boolean isDeleted() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
466 return id <= DELETED_ID_START; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
467 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
468 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
469 public boolean isAlive() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
470 return id >= ALIVE_ID_START; |
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 /** |
17226
a552dd335bde
generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents:
17210
diff
changeset
|
474 * Updates the usages sets of the given nodes after an input slot is changed from |
a552dd335bde
generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents:
17210
diff
changeset
|
475 * {@code oldInput} to {@code newInput} by removing this node from {@code oldInput}'s usages and |
a552dd335bde
generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents:
17210
diff
changeset
|
476 * adds this node to {@code newInput}'s usages. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
477 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
478 protected void updateUsages(Node oldInput, Node newInput) { |
14577
532d9b78c7d4
assert that only live ValueNodes are added as inputs and successors
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14157
diff
changeset
|
479 assert isAlive() && (newInput == null || newInput.isAlive()) : "adding " + newInput + " to " + this + " instead of " + oldInput; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
480 if (oldInput != newInput) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
481 if (oldInput != null) { |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
482 boolean result = removeThisFromUsages(oldInput); |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
483 assert assertTrue(result, "not found in usages, old input: %s", oldInput); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
484 } |
16241
c6ebc1997a55
added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents:
16239
diff
changeset
|
485 maybeNotifyInputChanged(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
486 if (newInput != null) { |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
487 newInput.addUsage(this); |
16175
3ee8c2cb629c
notify changed when setting input to null
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16101
diff
changeset
|
488 } |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
489 if (oldInput != null && oldInput.hasNoUsages()) { |
16606
7036c4594919
correct name of zero usages method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16554
diff
changeset
|
490 maybeNotifyZeroUsages(oldInput); |
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 |
15007
9a73164832a9
add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15002
diff
changeset
|
495 protected void updateUsagesInterface(NodeInterface oldInput, NodeInterface newInput) { |
9a73164832a9
add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15002
diff
changeset
|
496 updateUsages(oldInput == null ? null : oldInput.asNode(), newInput == null ? null : newInput.asNode()); |
9a73164832a9
add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15002
diff
changeset
|
497 } |
9a73164832a9
add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15002
diff
changeset
|
498 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
499 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
500 * Updates the predecessor of the given nodes after a successor slot is changed from |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
501 * oldSuccessor to newSuccessor: removes this node from oldSuccessor's predecessors and adds |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
502 * this node to newSuccessor's predecessors. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
503 */ |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
504 protected void updatePredecessor(Node oldSuccessor, Node newSuccessor) { |
14577
532d9b78c7d4
assert that only live ValueNodes are added as inputs and successors
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14157
diff
changeset
|
505 assert isAlive() && (newSuccessor == null || newSuccessor.isAlive()) : "adding " + newSuccessor + " to " + this + " instead of " + oldSuccessor; |
13744
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13327
diff
changeset
|
506 assert graph == null || !graph.isFrozen(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
507 if (oldSuccessor != newSuccessor) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
508 if (oldSuccessor != null) { |
17338
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
509 assert assertTrue(oldSuccessor.predecessor == this, "wrong predecessor in old successor (%s): %s, should be %s", oldSuccessor, oldSuccessor.predecessor, this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
510 oldSuccessor.predecessor = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
511 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
512 if (newSuccessor != null) { |
11676
435c8b984680
Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11674
diff
changeset
|
513 assert assertTrue(newSuccessor.predecessor == null, "unexpected non-null predecessor in new successor (%s): %s, this=%s", newSuccessor, newSuccessor.predecessor, this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
514 newSuccessor.predecessor = this; |
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
518 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
519 void initialize(Graph newGraph) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 assert assertTrue(id == INITIAL_ID, "unexpected id: %d", id); |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
521 this.graph = newGraph; |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
522 newGraph.register(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
523 for (Node input : inputs()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
524 updateUsages(null, input); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
525 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
526 for (Node successor : successors()) { |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
527 updatePredecessor(null, successor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
528 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
529 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
530 |
19471
880717e44675
Use typed NodeClass in node constructors.
Roland Schatz <roland.schatz@oracle.com>
parents:
19420
diff
changeset
|
531 public final NodeClass<? extends Node> getNodeClass() { |
18815
c4469ca2a822
Move back to an approach where NodeClass is cached in each Node instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18742
diff
changeset
|
532 return nodeClass; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
533 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
534 |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
535 public boolean isAllowedUsageType(InputType type) { |
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
536 return getNodeClass().getAllowedUsageTypes().contains(type); |
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
537 } |
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
538 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
539 private boolean checkReplaceWith(Node other) { |
13744
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13327
diff
changeset
|
540 assert assertTrue(graph == null || !graph.isFrozen(), "cannot modify frozen graph"); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
541 assert assertFalse(other == this, "cannot replace a node with itself"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
542 assert assertFalse(isDeleted(), "cannot replace deleted node"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
543 assert assertTrue(other == null || !other.isDeleted(), "cannot replace with deleted node %s", other); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
544 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
545 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
546 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
547 public void replaceAtUsages(Node other) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
548 assert checkReplaceWith(other); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
549 for (Node usage : usages()) { |
19543
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
550 boolean result = usage.getNodeClass().getInputEdges().replaceFirst(usage, this, other); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
551 assert assertTrue(result, "not found in inputs, usage: %s", usage); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
552 if (other != null) { |
16241
c6ebc1997a55
added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents:
16239
diff
changeset
|
553 maybeNotifyInputChanged(usage); |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
554 other.addUsage(usage); |
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 } |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
557 clearUsages(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
558 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
559 |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
560 public Node getUsageAt(int index) { |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
561 if (index == 0) { |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
562 return this.usage0; |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
563 } else if (index == 1) { |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
564 return this.usage1; |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
565 } else { |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
566 return this.extraUsages[index - INLINE_USAGE_COUNT]; |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
567 } |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
568 } |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
569 |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
570 public void replaceAtMatchingUsages(Node other, NodePredicate usagePredicate) { |
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
571 assert checkReplaceWith(other); |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
572 int index = 0; |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
573 while (index < this.getUsageCount()) { |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
574 Node usage = getUsageAt(index); |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
575 if (usagePredicate.apply(usage)) { |
19543
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
576 boolean result = usage.getNodeClass().getInputEdges().replaceFirst(usage, this, other); |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
577 assert assertTrue(result, "not found in inputs, usage: %s", usage); |
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
578 if (other != null) { |
16241
c6ebc1997a55
added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents:
16239
diff
changeset
|
579 maybeNotifyInputChanged(usage); |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
580 other.addUsage(usage); |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
581 } |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
582 this.movUsageFromEndTo(index); |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
583 } else { |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
584 index++; |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
585 } |
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
586 } |
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
587 } |
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
588 |
15001 | 589 public void replaceAtUsages(InputType type, Node other) { |
590 assert checkReplaceWith(other); | |
591 for (Node usage : usages().snapshot()) { | |
17008
81c9a1fc9072
select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents:
16984
diff
changeset
|
592 NodePosIterator iter = usage.inputs().iterator(); |
15001 | 593 while (iter.hasNext()) { |
594 Position pos = iter.nextPosition(); | |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17188
diff
changeset
|
595 if (pos.getInputType() == type && pos.get(usage) == this) { |
15001 | 596 pos.set(usage, other); |
597 } | |
598 } | |
599 } | |
600 } | |
601 | |
16241
c6ebc1997a55
added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents:
16239
diff
changeset
|
602 private void maybeNotifyInputChanged(Node node) { |
14157 | 603 if (graph != null) { |
604 assert !graph.isFrozen(); | |
16241
c6ebc1997a55
added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents:
16239
diff
changeset
|
605 NodeEventListener listener = graph.nodeEventListener; |
14157 | 606 if (listener != null) { |
16241
c6ebc1997a55
added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents:
16239
diff
changeset
|
607 listener.inputChanged(node); |
14157 | 608 } |
18884
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18815
diff
changeset
|
609 if (Fingerprint.ENABLED) { |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18815
diff
changeset
|
610 Fingerprint.submit("%s: %s", NodeEvent.INPUT_CHANGED, node); |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18815
diff
changeset
|
611 } |
13979
5568586d32a6
factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13744
diff
changeset
|
612 } |
5568586d32a6
factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13744
diff
changeset
|
613 } |
5568586d32a6
factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13744
diff
changeset
|
614 |
16606
7036c4594919
correct name of zero usages method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16554
diff
changeset
|
615 private void maybeNotifyZeroUsages(Node node) { |
14157 | 616 if (graph != null) { |
617 assert !graph.isFrozen(); | |
16241
c6ebc1997a55
added listener for nodes being added to a graph; consolidated all node event listeners into new NodeEventListener interface and made registering such listeners work in a try-with-resources statement so that de-registration is automatic
Doug Simon <doug.simon@oracle.com>
parents:
16239
diff
changeset
|
618 NodeEventListener listener = graph.nodeEventListener; |
19547
3be278f50e4b
Reenable usage dropped to zero listener.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19543
diff
changeset
|
619 if (listener != null && node.isAlive()) { |
3be278f50e4b
Reenable usage dropped to zero listener.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19543
diff
changeset
|
620 listener.usagesDroppedToZero(node); |
14157 | 621 } |
18884
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18815
diff
changeset
|
622 if (Fingerprint.ENABLED) { |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18815
diff
changeset
|
623 Fingerprint.submit("%s: %s", NodeEvent.ZERO_USAGES, node); |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18815
diff
changeset
|
624 } |
13979
5568586d32a6
factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13744
diff
changeset
|
625 } |
5568586d32a6
factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13744
diff
changeset
|
626 } |
5568586d32a6
factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13744
diff
changeset
|
627 |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
628 public void replaceAtPredecessor(Node other) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
629 assert checkReplaceWith(other); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
630 if (predecessor != null) { |
19543
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
631 boolean result = predecessor.getNodeClass().getSuccessorEdges().replaceFirst(predecessor, this, other); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
632 assert assertTrue(result, "not found in successors, predecessor: %s", predecessor); |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
633 predecessor.updatePredecessor(this, other); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
634 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
635 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
636 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
637 public void replaceAndDelete(Node other) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
638 assert checkReplaceWith(other); |
19541
c66037cb9cd1
Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19514
diff
changeset
|
639 assert other != null; |
c66037cb9cd1
Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19514
diff
changeset
|
640 clearInputs(); |
c66037cb9cd1
Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19514
diff
changeset
|
641 clearSuccessors(); |
c66037cb9cd1
Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19514
diff
changeset
|
642 replaceAtUsages(other); |
c66037cb9cd1
Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19514
diff
changeset
|
643 replaceAtPredecessor(other); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
644 safeDelete(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
645 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
646 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
647 public void replaceFirstSuccessor(Node oldSuccessor, Node newSuccessor) { |
19543
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
648 if (nodeClass.getSuccessorEdges().replaceFirst(this, oldSuccessor, newSuccessor)) { |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
649 updatePredecessor(oldSuccessor, newSuccessor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
650 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
651 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
652 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
653 public void replaceFirstInput(Node oldInput, Node newInput) { |
19543
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
654 if (nodeClass.getInputEdges().replaceFirst(this, oldInput, newInput)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
655 updateUsages(oldInput, newInput); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
656 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
657 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
658 |
16101
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
659 private void unregisterInputs() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
660 for (Node input : inputs()) { |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
661 removeThisFromUsages(input); |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
662 if (input.hasNoUsages()) { |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
663 maybeNotifyZeroUsages(input); |
9331
199c77760850
Rename InputChangedListener => NodeChangedListener. Add event for usage count of a node dropping to 0.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8555
diff
changeset
|
664 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
665 } |
16101
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
666 } |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
667 |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
668 public void clearInputs() { |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
669 assert assertFalse(isDeleted(), "cannot clear inputs of deleted node"); |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
670 |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
671 unregisterInputs(); |
19543
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
672 getNodeClass().getInputEdges().clear(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
673 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
674 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
675 private boolean removeThisFromUsages(Node n) { |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
676 return n.removeUsage(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
677 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
678 |
16101
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
679 private void unregisterSuccessors() { |
19543
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
680 this.acceptSuccessors(successor -> successor.predecessor = null); |
16101
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
681 } |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
682 |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
683 public void clearSuccessors() { |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
684 assert assertFalse(isDeleted(), "cannot clear successors of deleted node"); |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
685 |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
686 unregisterSuccessors(); |
19543
353669a84287
Utilities Node#acceptInputs and Node#acceptSuccessors.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19542
diff
changeset
|
687 getNodeClass().getSuccessorEdges().clear(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
688 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
689 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
690 private boolean checkDeletion() { |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
691 assertTrue(hasNoUsages(), "cannot delete node %s because of usages: %s", this, usages()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
692 assertTrue(predecessor == null, "cannot delete node %s because of predecessor: %s", this, predecessor); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
693 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
694 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
695 |
5258
97b1e0ab7442
added javadoc to some of the API for removing nodes from a graph
Doug Simon <doug.simon@oracle.com>
parents:
5175
diff
changeset
|
696 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
697 * Removes this node from its graph. This node must have no {@linkplain Node#usages() usages} |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
698 * and no {@linkplain #predecessor() predecessor}. |
5258
97b1e0ab7442
added javadoc to some of the API for removing nodes from a graph
Doug Simon <doug.simon@oracle.com>
parents:
5175
diff
changeset
|
699 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
700 public void safeDelete() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
701 assert checkDeletion(); |
19542
f98e2f0c35d8
Make GraphUtil#propagateKill more efficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19541
diff
changeset
|
702 unsafeDelete(); |
f98e2f0c35d8
Make GraphUtil#propagateKill more efficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19541
diff
changeset
|
703 } |
f98e2f0c35d8
Make GraphUtil#propagateKill more efficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19541
diff
changeset
|
704 |
f98e2f0c35d8
Make GraphUtil#propagateKill more efficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19541
diff
changeset
|
705 public void unsafeDelete() { |
16101
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
706 unregisterInputs(); |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
707 unregisterSuccessors(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
708 graph.unregister(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
709 id = DELETED_ID_START - id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
710 assert isDeleted(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
711 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
712 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
713 public final Node copyWithInputs() { |
17351
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
714 return copyWithInputs(true); |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
715 } |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
716 |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
717 public final Node copyWithInputs(boolean insertIntoGraph) { |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
718 Node newNode = clone(insertIntoGraph ? graph : null, WithOnlyInputEdges); |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
719 if (insertIntoGraph) { |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
720 for (Node input : inputs()) { |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
721 input.addUsage(newNode); |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
722 } |
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 return newNode; |
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 |
11882
51059863da73
replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11755
diff
changeset
|
727 /** |
11940 | 728 * Must be overridden by subclasses that implement {@link Simplifiable}. The implementation in |
11882
51059863da73
replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11755
diff
changeset
|
729 * {@link Node} exists to obviate the need to cast a node before invoking |
51059863da73
replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11755
diff
changeset
|
730 * {@link Simplifiable#simplify(SimplifierTool)}. |
15001 | 731 * |
11882
51059863da73
replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11755
diff
changeset
|
732 * @param tool |
51059863da73
replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11755
diff
changeset
|
733 */ |
51059863da73
replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11755
diff
changeset
|
734 public void simplify(SimplifierTool tool) { |
51059863da73
replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11755
diff
changeset
|
735 throw new UnsupportedOperationException(); |
51059863da73
replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11755
diff
changeset
|
736 } |
51059863da73
replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents:
11755
diff
changeset
|
737 |
17338
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
738 /** |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
739 * @param newNode the result of cloning this node or {@link Unsafe#allocateInstance(Class) raw |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
740 * allocating} a copy of this node |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
741 * @param type the type of edges to process |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
742 * @param edgesToCopy if {@code type} is in this set, the edges are copied otherwise they are |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
743 * cleared |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
744 */ |
18815
c4469ca2a822
Move back to an approach where NodeClass is cached in each Node instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18742
diff
changeset
|
745 private void copyOrClearEdgesForClone(Node newNode, Edges.Type type, EnumSet<Edges.Type> edgesToCopy) { |
17338
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
746 if (edgesToCopy.contains(type)) { |
18815
c4469ca2a822
Move back to an approach where NodeClass is cached in each Node instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18742
diff
changeset
|
747 getNodeClass().getEdges(type).copy(this, newNode); |
17338
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
748 } else { |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
749 if (USE_UNSAFE_TO_CLONE) { |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
750 // The direct edges are already null |
18815
c4469ca2a822
Move back to an approach where NodeClass is cached in each Node instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18742
diff
changeset
|
751 getNodeClass().getEdges(type).initializeLists(newNode, this); |
17338
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
752 } else { |
18815
c4469ca2a822
Move back to an approach where NodeClass is cached in each Node instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18742
diff
changeset
|
753 getNodeClass().getEdges(type).clear(newNode); |
17338
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
754 } |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
755 } |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
756 } |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
757 |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
758 public static final EnumSet<Edges.Type> WithNoEdges = EnumSet.noneOf(Edges.Type.class); |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
759 public static final EnumSet<Edges.Type> WithAllEdges = EnumSet.allOf(Edges.Type.class); |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
760 public static final EnumSet<Edges.Type> WithOnlyInputEdges = EnumSet.of(Inputs); |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
761 public static final EnumSet<Edges.Type> WithOnlySucessorEdges = EnumSet.of(Successors); |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
762 |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
763 /** |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
764 * Makes a copy of this node in(to) a given graph. |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
765 * |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
766 * @param into the graph in which the copy will be registered (which may be this node's graph) |
17347
63780e37b7b9
re-added support for cloning a node without adding it to a graph
Doug Simon <doug.simon@oracle.com>
parents:
17346
diff
changeset
|
767 * or null if the copy should not be registered in a graph |
17338
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
768 * @param edgesToCopy specifies the edges to be copied. The edges not specified in this set are |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
769 * initialized to their default value (i.e., {@code null} for a direct edge, an empty |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
770 * list for an edge list) |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
771 * @return the copy of this node |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
772 */ |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
773 final Node clone(Graph into, EnumSet<Edges.Type> edgesToCopy) { |
19471
880717e44675
Use typed NodeClass in node constructors.
Roland Schatz <roland.schatz@oracle.com>
parents:
19420
diff
changeset
|
774 final NodeClass<? extends Node> nodeClassTmp = getNodeClass(); |
17347
63780e37b7b9
re-added support for cloning a node without adding it to a graph
Doug Simon <doug.simon@oracle.com>
parents:
17346
diff
changeset
|
775 boolean useIntoLeafNodeCache = false; |
63780e37b7b9
re-added support for cloning a node without adding it to a graph
Doug Simon <doug.simon@oracle.com>
parents:
17346
diff
changeset
|
776 if (into != null) { |
18815
c4469ca2a822
Move back to an approach where NodeClass is cached in each Node instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18742
diff
changeset
|
777 if (nodeClassTmp.valueNumberable() && nodeClassTmp.isLeafNode()) { |
17347
63780e37b7b9
re-added support for cloning a node without adding it to a graph
Doug Simon <doug.simon@oracle.com>
parents:
17346
diff
changeset
|
778 useIntoLeafNodeCache = true; |
63780e37b7b9
re-added support for cloning a node without adding it to a graph
Doug Simon <doug.simon@oracle.com>
parents:
17346
diff
changeset
|
779 Node otherNode = into.findNodeInCache(this); |
63780e37b7b9
re-added support for cloning a node without adding it to a graph
Doug Simon <doug.simon@oracle.com>
parents:
17346
diff
changeset
|
780 if (otherNode != null) { |
63780e37b7b9
re-added support for cloning a node without adding it to a graph
Doug Simon <doug.simon@oracle.com>
parents:
17346
diff
changeset
|
781 return otherNode; |
63780e37b7b9
re-added support for cloning a node without adding it to a graph
Doug Simon <doug.simon@oracle.com>
parents:
17346
diff
changeset
|
782 } |
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:
11631
diff
changeset
|
783 } |
64a9ed9f1e8d
Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
784 } |
64a9ed9f1e8d
Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
785 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
786 Node newNode = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
787 try { |
17338
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
788 if (USE_UNSAFE_TO_CLONE) { |
17329
1e7e354e407f
use Unsafe.allocateInstance in Node.clone(Graph into, boolean clearInputsAndSuccessors) to avoid initializing fields twice
Doug Simon <doug.simon@oracle.com>
parents:
17328
diff
changeset
|
789 newNode = (Node) UnsafeAccess.unsafe.allocateInstance(getClass()); |
18815
c4469ca2a822
Move back to an approach where NodeClass is cached in each Node instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18742
diff
changeset
|
790 newNode.nodeClass = nodeClassTmp; |
c4469ca2a822
Move back to an approach where NodeClass is cached in each Node instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18742
diff
changeset
|
791 nodeClassTmp.getData().copy(this, newNode); |
c4469ca2a822
Move back to an approach where NodeClass is cached in each Node instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18742
diff
changeset
|
792 copyOrClearEdgesForClone(newNode, Inputs, edgesToCopy); |
c4469ca2a822
Move back to an approach where NodeClass is cached in each Node instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18742
diff
changeset
|
793 copyOrClearEdgesForClone(newNode, Successors, edgesToCopy); |
17329
1e7e354e407f
use Unsafe.allocateInstance in Node.clone(Graph into, boolean clearInputsAndSuccessors) to avoid initializing fields twice
Doug Simon <doug.simon@oracle.com>
parents:
17328
diff
changeset
|
794 } else { |
1e7e354e407f
use Unsafe.allocateInstance in Node.clone(Graph into, boolean clearInputsAndSuccessors) to avoid initializing fields twice
Doug Simon <doug.simon@oracle.com>
parents:
17328
diff
changeset
|
795 newNode = (Node) this.clone(); |
1e7e354e407f
use Unsafe.allocateInstance in Node.clone(Graph into, boolean clearInputsAndSuccessors) to avoid initializing fields twice
Doug Simon <doug.simon@oracle.com>
parents:
17328
diff
changeset
|
796 newNode.typeCacheNext = null; |
1e7e354e407f
use Unsafe.allocateInstance in Node.clone(Graph into, boolean clearInputsAndSuccessors) to avoid initializing fields twice
Doug Simon <doug.simon@oracle.com>
parents:
17328
diff
changeset
|
797 newNode.usage0 = null; |
1e7e354e407f
use Unsafe.allocateInstance in Node.clone(Graph into, boolean clearInputsAndSuccessors) to avoid initializing fields twice
Doug Simon <doug.simon@oracle.com>
parents:
17328
diff
changeset
|
798 newNode.usage1 = null; |
1e7e354e407f
use Unsafe.allocateInstance in Node.clone(Graph into, boolean clearInputsAndSuccessors) to avoid initializing fields twice
Doug Simon <doug.simon@oracle.com>
parents:
17328
diff
changeset
|
799 newNode.predecessor = null; |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
800 newNode.extraUsagesCount = 0; |
18815
c4469ca2a822
Move back to an approach where NodeClass is cached in each Node instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18742
diff
changeset
|
801 copyOrClearEdgesForClone(newNode, Inputs, edgesToCopy); |
c4469ca2a822
Move back to an approach where NodeClass is cached in each Node instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18742
diff
changeset
|
802 copyOrClearEdgesForClone(newNode, Successors, edgesToCopy); |
17329
1e7e354e407f
use Unsafe.allocateInstance in Node.clone(Graph into, boolean clearInputsAndSuccessors) to avoid initializing fields twice
Doug Simon <doug.simon@oracle.com>
parents:
17328
diff
changeset
|
803 } |
1e7e354e407f
use Unsafe.allocateInstance in Node.clone(Graph into, boolean clearInputsAndSuccessors) to avoid initializing fields twice
Doug Simon <doug.simon@oracle.com>
parents:
17328
diff
changeset
|
804 } catch (Exception e) { |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15153
diff
changeset
|
805 throw new GraalGraphInternalError(e).addContext(this); |
3733
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 newNode.graph = into; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
808 newNode.id = INITIAL_ID; |
17347
63780e37b7b9
re-added support for cloning a node without adding it to a graph
Doug Simon <doug.simon@oracle.com>
parents:
17346
diff
changeset
|
809 if (into != null) { |
63780e37b7b9
re-added support for cloning a node without adding it to a graph
Doug Simon <doug.simon@oracle.com>
parents:
17346
diff
changeset
|
810 into.register(newNode); |
63780e37b7b9
re-added support for cloning a node without adding it to a graph
Doug Simon <doug.simon@oracle.com>
parents:
17346
diff
changeset
|
811 } |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
812 newNode.extraUsages = NO_NODES; |
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:
11631
diff
changeset
|
813 |
17347
63780e37b7b9
re-added support for cloning a node without adding it to a graph
Doug Simon <doug.simon@oracle.com>
parents:
17346
diff
changeset
|
814 if (into != null && useIntoLeafNodeCache) { |
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:
11631
diff
changeset
|
815 into.putNodeIntoCache(newNode); |
64a9ed9f1e8d
Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
816 } |
11677
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
817 newNode.afterClone(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
818 return newNode; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
819 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
820 |
11677
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
821 protected void afterClone(@SuppressWarnings("unused") Node other) { |
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
822 } |
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
823 |
3733
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 assertTrue(isAlive(), "cannot verify inactive nodes (id=%d)", id); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
826 assertTrue(graph() != null, "null graph"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
827 for (Node input : inputs()) { |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
828 assertTrue(input.usages().contains(this), "missing usage in input %s", input); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
829 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
830 for (Node successor : successors()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
831 assertTrue(successor.predecessor() == this, "missing predecessor in %s (actual: %s)", successor, successor.predecessor()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
832 assertTrue(successor.graph() == graph(), "mismatching graph in successor %s", successor); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
833 } |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
834 for (Node usage : usages()) { |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
835 assertFalse(usage.isDeleted(), "usage %s must never be deleted", usage); |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
836 assertTrue(usage.inputs().contains(this), "missing input in usage %s", usage); |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
837 NodePosIterator iterator = usage.inputs().iterator(); |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
838 while (iterator.hasNext()) { |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
839 Position pos = iterator.nextPosition(); |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17188
diff
changeset
|
840 if (pos.get(usage) == this && pos.getInputType() != InputType.Unchecked) { |
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17188
diff
changeset
|
841 assert isAllowedUsageType(pos.getInputType()) : "invalid input of type " + pos.getInputType() + " from " + usage + " to " + this + " (" + pos.getName() + ")"; |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
842 } |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
843 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
844 } |
17008
81c9a1fc9072
select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents:
16984
diff
changeset
|
845 NodePosIterator iterator = inputs().withNullIterator(); |
16332
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
846 while (iterator.hasNext()) { |
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
847 Position pos = iterator.nextPosition(); |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17188
diff
changeset
|
848 assert pos.isInputOptional() || pos.get(this) != null : "non-optional input " + pos.getName() + " cannot be null in " + this + " (fix nullness or use @OptionalInput)"; |
16332
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
849 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
850 if (predecessor != null) { |
12723
bbf6407458ee
Node: print node in assert
Bernhard Urban <bernhard.urban@jku.at>
parents:
12686
diff
changeset
|
851 assertFalse(predecessor.isDeleted(), "predecessor %s must never be deleted", predecessor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
852 assertTrue(predecessor.successors().contains(this), "missing successor in predecessor %s", predecessor); |
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 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
855 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
856 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
857 public boolean assertTrue(boolean condition, String message, Object... args) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
858 if (condition) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
859 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
860 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
861 throw new VerificationError(message, args).addContext(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
862 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
863 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
864 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
865 public boolean assertFalse(boolean condition, String message, Object... args) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
866 if (condition) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
867 throw new VerificationError(message, args).addContext(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
868 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
869 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
870 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
871 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
872 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
873 public Iterable<? extends Node> cfgPredecessors() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
874 if (predecessor == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
875 return Collections.emptySet(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
876 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
877 return Collections.singleton(predecessor); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
878 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
879 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
880 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
881 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
882 * Returns an iterator that will provide all control-flow successors of this node. Normally this |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
883 * will be the contents of all fields marked as NodeSuccessor, but some node classes (like |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
884 * EndNode) may return different nodes. Note that the iterator may generate null values if the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
885 * fields contain them. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
886 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
887 public Iterable<? extends Node> cfgSuccessors() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
888 return successors(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
889 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
890 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
891 /** |
13327
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13140
diff
changeset
|
892 * Nodes always use an {@linkplain System#identityHashCode(Object) identity} hash code. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
893 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
894 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
895 public final int hashCode() { |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
896 return System.identityHashCode(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
897 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
898 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
899 /** |
13327
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13140
diff
changeset
|
900 * Equality tests must rely solely on identity. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
901 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
902 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
903 public final boolean equals(Object obj) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
904 return super.equals(obj); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
905 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
906 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
907 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
908 * Provides a {@link Map} of properties of this node for use in debugging (e.g., to view in the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
909 * ideal graph visualizer). |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
910 */ |
9495
6ad0bdcd76aa
make Node.getDebugProperties() final
Lukas Stadler <lukas.stadler@jku.at>
parents:
9332
diff
changeset
|
911 public final Map<Object, Object> getDebugProperties() { |
5813
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
912 return getDebugProperties(new HashMap<>()); |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
913 } |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
914 |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
915 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
916 * Fills a {@link Map} with properties of this node for use in debugging (e.g., to view in the |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
917 * ideal graph visualizer). Subclasses overriding this method should also fill the map using |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
918 * their superclass. |
15001 | 919 * |
5813
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
920 * @param map |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
921 */ |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
922 public Map<Object, Object> getDebugProperties(Map<Object, Object> map) { |
18815
c4469ca2a822
Move back to an approach where NodeClass is cached in each Node instance.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18742
diff
changeset
|
923 Fields properties = getNodeClass().getData(); |
17226
a552dd335bde
generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents:
17210
diff
changeset
|
924 for (int i = 0; i < properties.getCount(); i++) { |
a552dd335bde
generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents:
17210
diff
changeset
|
925 map.put(properties.getName(i), properties.get(this, i)); |
15827
4e770fa50889
Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15381
diff
changeset
|
926 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
927 return map; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
928 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
929 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
930 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
931 * This method is a shortcut for {@link #toString(Verbosity)} with {@link Verbosity#Short}. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
932 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
933 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
934 public final String toString() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
935 return toString(Verbosity.Short); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
936 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
937 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
938 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
939 * Creates a String representation for this node with a given {@link Verbosity}. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
940 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
941 public String toString(Verbosity verbosity) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
942 switch (verbosity) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
943 case Id: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
944 return Integer.toString(id); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
945 case Name: |
17272
9eb112c9337d
moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents:
17258
diff
changeset
|
946 return getNodeClass().shortName(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
947 case Short: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
948 return toString(Verbosity.Id) + "|" + toString(Verbosity.Name); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
949 case Long: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
950 return toString(Verbosity.Short); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
951 case Debugger: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
952 case All: { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
953 StringBuilder str = new StringBuilder(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
954 str.append(toString(Verbosity.Short)).append(" { "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
955 for (Map.Entry<Object, Object> entry : getDebugProperties().entrySet()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
956 str.append(entry.getKey()).append("=").append(entry.getValue()).append(", "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
957 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
958 str.append(" }"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
959 return str.toString(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
960 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
961 default: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
962 throw new RuntimeException("unknown verbosity: " + verbosity); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
963 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
964 } |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
965 |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
966 @Deprecated |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
967 public int getId() { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
968 return id; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
969 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
970 |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
971 @Override |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
972 public void formatTo(Formatter formatter, int flags, int width, int precision) { |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
973 if ((flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE) { |
4418
46e9068c09b4
small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents:
4397
diff
changeset
|
974 formatter.format("%s", toString(Verbosity.Id)); |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
975 } else if ((flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE) { |
15036
9806a98bcf9a
make %S format for Node emit Verbosity.All
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15010
diff
changeset
|
976 // Use All here since Long is only slightly longer than Short. |
9806a98bcf9a
make %S format for Node emit Verbosity.All
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
15010
diff
changeset
|
977 formatter.format("%s", toString(Verbosity.All)); |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
978 } else { |
4418
46e9068c09b4
small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents:
4397
diff
changeset
|
979 formatter.format("%s", toString(Verbosity.Short)); |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
980 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
981 |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
982 boolean neighborsAlternate = ((flags & FormattableFlags.LEFT_JUSTIFY) == FormattableFlags.LEFT_JUSTIFY); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
983 int neighborsFlags = (neighborsAlternate ? FormattableFlags.ALTERNATE | FormattableFlags.LEFT_JUSTIFY : 0); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
984 if (width > 0) { |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
985 if (this.predecessor != null) { |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
986 formatter.format(" pred={"); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
987 this.predecessor.formatTo(formatter, neighborsFlags, width - 1, 0); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
988 formatter.format("}"); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
989 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
990 |
17008
81c9a1fc9072
select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents:
16984
diff
changeset
|
991 NodePosIterator inputIter = inputs().iterator(); |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
992 while (inputIter.hasNext()) { |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
993 Position position = inputIter.nextPosition(); |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17188
diff
changeset
|
994 Node input = position.get(this); |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
995 if (input != null) { |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
996 formatter.format(" "); |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17188
diff
changeset
|
997 formatter.format(position.getName()); |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
998 formatter.format("={"); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
999 input.formatTo(formatter, neighborsFlags, width - 1, 0); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1000 formatter.format("}"); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1001 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1002 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1003 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1004 |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1005 if (precision > 0) { |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
1006 if (!hasNoUsages()) { |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1007 formatter.format(" usages={"); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1008 int z = 0; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
1009 for (Node usage : usages()) { |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1010 if (z != 0) { |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1011 formatter.format(", "); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1012 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1013 usage.formatTo(formatter, neighborsFlags, 0, precision - 1); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1014 ++z; |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1015 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1016 formatter.format("}"); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1017 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1018 |
17008
81c9a1fc9072
select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents:
16984
diff
changeset
|
1019 NodePosIterator succIter = successors().iterator(); |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1020 while (succIter.hasNext()) { |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1021 Position position = succIter.nextPosition(); |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17188
diff
changeset
|
1022 Node successor = position.get(this); |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1023 if (successor != null) { |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1024 formatter.format(" "); |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17188
diff
changeset
|
1025 formatter.format(position.getName()); |
4397
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1026 formatter.format("={"); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1027 successor.formatTo(formatter, neighborsFlags, 0, precision - 1); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1028 formatter.format("}"); |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1029 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1030 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1031 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
1032 } |
17276
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1033 |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1034 /** |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1035 * Determines if this node's {@link NodeClass#getData() data} fields are equal to the data |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1036 * fields of another node of the same type. Primitive fields are compared by value and |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1037 * non-primitive fields are compared by {@link Objects#equals(Object, Object)}. |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1038 * |
17316
e6e678c3818f
only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents:
17308
diff
changeset
|
1039 * The result of this method undefined if {@code other.getClass() != this.getClass()}. |
17276
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1040 * |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1041 * @param other a node of exactly the same type as this node |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1042 * @return true if the data fields of this object and {@code other} are equal |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1043 */ |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1044 public boolean valueEquals(Node other) { |
17450
45b45f902bed
removed Node generation (GRAAL-857)
Doug Simon <doug.simon@oracle.com>
parents:
17355
diff
changeset
|
1045 return getNodeClass().dataEquals(this, other); |
17276
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1046 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1047 } |