Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java @ 19548:c66037cb9cd1
Make Node#replaceAndDelete not accept null as an argument.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 22 Feb 2015 22:39:26 +0100 |
parents | 55d0b9ec7587 |
children | f98e2f0c35d8 |
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.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
30 |
17338
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
31 import sun.misc.*; |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
32 |
17214
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
|
33 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
|
34 import com.oracle.graal.debug.*; |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18815
diff
changeset
|
35 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
|
36 import com.oracle.graal.graph.Graph.NodeEventListener; |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
37 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
|
38 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:
16811
diff
changeset
|
39 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
|
40 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
41 /** |
18378
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
|
42 * 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
|
43 * {@link Graph}. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
44 * <p> |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
45 * 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
|
46 * 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
|
47 * {@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
|
48 * {@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
|
49 * this field points to. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
50 * <p> |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
51 * Nodes which are be value numberable should implement the {@link ValueNumberable} interface. |
15001 | 52 * |
18378
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
|
53 * <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
|
54 * |
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:
18378
diff
changeset
|
55 * 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:
18378
diff
changeset
|
56 * 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:
18378
diff
changeset
|
57 * <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:
18378
diff
changeset
|
58 * <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:
18378
diff
changeset
|
59 * <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:
18378
diff
changeset
|
60 * <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:
18378
diff
changeset
|
61 * <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:
18378
diff
changeset
|
62 * <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:
18378
diff
changeset
|
63 * <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:
18378
diff
changeset
|
64 * <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:
18378
diff
changeset
|
65 * <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:
18378
diff
changeset
|
66 * </ul> |
18378
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
|
67 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 * <h1>Assertions and Verification</h1> |
15001 | 69 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
70 * 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
|
71 * {@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
|
72 * 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
|
73 * 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
|
74 * only performed if assertions are enabled. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 */ |
16811
5d468add216f
added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents:
16606
diff
changeset
|
76 @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
|
77 public abstract class Node implements Cloneable, Formattable { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 |
19410
61d3cb8e1280
Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19403
diff
changeset
|
79 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
|
80 public static final boolean USE_UNSAFE_TO_CLONE = Boolean.parseBoolean(System.getProperty("graal.node.useUnsafeToClone", "true")); |
17352
3457f147a24f
made selectability of using generated node functionality more fine grained
Doug Simon <doug.simon@oracle.com>
parents:
17347
diff
changeset
|
81 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
82 static final int DELETED_ID_START = -1000000000; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 static final int INITIAL_ID = -1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 static final int ALIVE_ID_START = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
85 |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
86 // 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
|
87 // 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
|
88 |
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
|
89 /** |
16336
c88a9e432faf
small fix and doc for @OptionalInput
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16332
diff
changeset
|
90 * 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
|
91 * 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
|
92 * 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
|
93 * {@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
|
94 */ |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
95 @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
|
96 @java.lang.annotation.Target(ElementType.FIELD) |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
97 public static @interface Input { |
15001 | 98 InputType value() default InputType.Value; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
99 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
100 |
16332
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
101 /** |
16336
c88a9e432faf
small fix and doc for @OptionalInput
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16332
diff
changeset
|
102 * 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
|
103 * 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
|
104 * {@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
|
105 * 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
|
106 */ |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
107 @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
|
108 @java.lang.annotation.Target(ElementType.FIELD) |
16332
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
109 public static @interface OptionalInput { |
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
110 InputType value() default InputType.Value; |
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
111 } |
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
112 |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
113 @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
|
114 @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
|
115 public static @interface Successor { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
116 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
117 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
118 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
119 * 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
|
120 * 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
|
121 */ |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
122 @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
|
123 @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
|
124 public static @interface ConstantNodeParameter { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
125 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
127 /** |
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
|
128 * 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
|
129 * 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
|
130 * 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
|
131 * 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
|
132 */ |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
133 @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
|
134 @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
|
135 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
|
136 } |
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 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
139 * 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
|
140 * 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
|
141 * {@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
|
142 * 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
|
143 * 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
|
144 */ |
16901
451468f7340b
workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents:
16897
diff
changeset
|
145 @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
|
146 @java.lang.annotation.Target(ElementType.METHOD) |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
147 public static @interface NodeIntrinsic { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
148 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
150 * 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
|
151 * 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
|
152 * 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
|
153 */ |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
15036
diff
changeset
|
154 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
|
155 |
b74402a7079b
fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents:
5823
diff
changeset
|
156 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
157 * 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
|
158 * 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
|
159 * <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
|
160 * 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
|
161 * 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
|
162 */ |
b74402a7079b
fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents:
5823
diff
changeset
|
163 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
|
164 |
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 * 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
|
167 * (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
|
168 * 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
|
169 * 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
|
170 */ |
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 boolean foldable() default false; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 |
17316
e6e678c3818f
only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents:
17305
diff
changeset
|
174 /** |
e6e678c3818f
only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents:
17305
diff
changeset
|
175 * 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:
17305
diff
changeset
|
176 * {@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:
17305
diff
changeset
|
177 * 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:
17305
diff
changeset
|
178 * 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:
17305
diff
changeset
|
179 * 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:
17305
diff
changeset
|
180 * successors}. |
e6e678c3818f
only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents:
17305
diff
changeset
|
181 */ |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
182 public interface ValueNumberable { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
183 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
184 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 private Graph graph; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
186 int id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
187 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
188 // 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
|
189 // 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
|
190 Node typeCacheNext; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
191 |
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
|
192 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
|
193 private static final Node[] NO_NODES = {}; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
194 |
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 * 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
|
197 * {@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
|
198 */ |
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
|
199 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
|
200 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
|
201 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
|
202 int extraUsagesCount; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
203 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
204 private Node predecessor; |
19471
880717e44675
Use typed NodeClass in node constructors.
Roland Schatz <roland.schatz@oracle.com>
parents:
19420
diff
changeset
|
205 private NodeClass<? extends Node> nodeClass; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
206 |
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
|
207 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
|
208 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
|
209 |
19471
880717e44675
Use typed NodeClass in node constructors.
Roland Schatz <roland.schatz@oracle.com>
parents:
19420
diff
changeset
|
210 public Node(NodeClass<? extends Node> c) { |
15827
4e770fa50889
Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15381
diff
changeset
|
211 init(); |
19403
7e2c87dae93e
Create static final NodeClass field named TYPE in Node subclasses.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18938
diff
changeset
|
212 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
|
213 this.nodeClass = c; |
15827
4e770fa50889
Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15381
diff
changeset
|
214 } |
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 final void init() { |
4e770fa50889
Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15381
diff
changeset
|
217 id = INITIAL_ID; |
4e770fa50889
Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents:
15381
diff
changeset
|
218 extraUsages = NO_NODES; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
219 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
220 |
12686
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
221 int id() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
222 return id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
223 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
224 |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
225 /** |
18742
5df121664e08
added factory methods for creating sets
Doug Simon <doug.simon@oracle.com>
parents:
18655
diff
changeset
|
226 * @see CollectionsFactory#newSet() |
18378
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
|
227 */ |
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:
18378
diff
changeset
|
228 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
|
229 return CollectionsFactory.newSet(); |
18378
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
|
230 } |
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 /** |
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:
18378
diff
changeset
|
233 * @see #newSet() |
18378
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
|
234 */ |
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:
18378
diff
changeset
|
235 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
|
236 return CollectionsFactory.newSet(c); |
18378
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
|
237 } |
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 |
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:
18378
diff
changeset
|
239 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:
18378
diff
changeset
|
240 // 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:
18378
diff
changeset
|
241 // 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:
18378
diff
changeset
|
242 // 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:
18378
diff
changeset
|
243 // 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:
18378
diff
changeset
|
244 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:
18378
diff
changeset
|
245 } |
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:
18378
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:
18378
diff
changeset
|
247 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:
18378
diff
changeset
|
248 // 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:
18378
diff
changeset
|
249 // 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:
18378
diff
changeset
|
250 // 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:
18378
diff
changeset
|
251 // 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:
18378
diff
changeset
|
252 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:
18378
diff
changeset
|
253 } |
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:
18378
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:
18378
diff
changeset
|
255 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:
18378
diff
changeset
|
256 // 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:
18378
diff
changeset
|
257 // 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:
18378
diff
changeset
|
258 // 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:
18378
diff
changeset
|
259 // 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:
18378
diff
changeset
|
260 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:
18378
diff
changeset
|
261 } |
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:
18378
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:
18378
diff
changeset
|
263 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
|
264 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:
18378
diff
changeset
|
265 } |
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:
18378
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:
18378
diff
changeset
|
267 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
|
268 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:
18378
diff
changeset
|
269 } |
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:
18378
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:
18378
diff
changeset
|
271 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
|
272 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:
18378
diff
changeset
|
273 } |
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:
18378
diff
changeset
|
274 |
18378
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
|
275 /** |
13320
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13140
diff
changeset
|
276 * 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
|
277 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
278 public Graph graph() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
279 return graph; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
280 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
281 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
282 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
283 * 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
|
284 * input edges of this node. |
15001 | 285 * |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
286 * @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
|
287 */ |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
288 public NodeClassIterable inputs() { |
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
|
289 return getNodeClass().getEdges(Inputs).getIterable(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
290 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
291 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
292 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
293 * 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
|
294 * successor edges of this node. |
15001 | 295 * |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
296 * @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
|
297 */ |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
298 public NodeClassIterable successors() { |
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
|
299 return getNodeClass().getEdges(Successors).getIterable(this); |
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 |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
302 /** |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
303 * 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
|
304 */ |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
305 public int getUsageCount() { |
11654
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
306 if (usage0 == null) { |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
307 return 0; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
308 } |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
309 if (usage1 == null) { |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
310 return 1; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
311 } |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
312 return 2 + extraUsagesCount; |
11654
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
313 } |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
314 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
315 /** |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
316 * 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
|
317 */ |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
318 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
|
319 return new NodeUsageIterable(this); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
320 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
321 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
322 /** |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
323 * Checks whether this node has no usages. |
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
324 */ |
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
325 public final boolean hasNoUsages() { |
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
326 return this.usage0 == null; |
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
327 } |
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
328 |
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
329 /** |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
330 * Adds a given node to this node's {@linkplain #usages() usages}. |
15001 | 331 * |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
332 * @param node the node to add |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
333 */ |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
334 private void addUsage(Node node) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
335 incUsageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
336 if (usage0 == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
337 usage0 = node; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
338 } else if (usage1 == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
339 usage1 = node; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
340 } else { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
341 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
|
342 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
|
343 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
|
344 } else if (extraUsagesCount == length) { |
19517
55d0b9ec7587
Replace Array.copyOf usages with System.arraycopy usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19471
diff
changeset
|
345 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
|
346 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
|
347 extraUsages = newExtraUsages; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
348 } |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
349 extraUsages[extraUsagesCount++] = node; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
350 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
351 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
352 |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
353 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
|
354 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
|
355 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
|
356 if (lastIndex == 0) { |
15153
d224a3a0e6a9
Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15150
diff
changeset
|
357 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
|
358 return; |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
359 } else if (lastIndex == 1) { |
15153
d224a3a0e6a9
Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15150
diff
changeset
|
360 usage0 = usage1; |
d224a3a0e6a9
Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15150
diff
changeset
|
361 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
|
362 return; |
15153
d224a3a0e6a9
Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15150
diff
changeset
|
363 } 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
|
364 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
|
365 } |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
366 } 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
|
367 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
|
368 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
|
369 return; |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
370 } |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
371 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
|
372 } 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
|
373 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
|
374 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
|
375 } |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
376 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
|
377 this.extraUsagesCount--; |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
378 } |
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
379 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
380 /** |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
381 * Removes a given node from this node's {@linkplain #usages() usages}. |
15001 | 382 * |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
383 * @param node the node to remove |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
384 * @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
|
385 */ |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
386 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
|
387 assert node != null; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
388 // 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
|
389 // 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
|
390 incUsageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
391 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
|
392 this.movUsageFromEndTo(0); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
393 return true; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
394 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
395 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
|
396 this.movUsageFromEndTo(1); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
397 return true; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
398 } |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
399 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
|
400 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
|
401 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
|
402 return true; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
403 } |
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 return false; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
406 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
407 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
408 private void clearUsages() { |
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 usage0 = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
411 usage1 = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
412 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
|
413 extraUsagesCount = 0; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
414 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
415 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
416 public final Node predecessor() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
417 return predecessor; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
418 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
419 |
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
|
420 public final int modCount() { |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
421 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
422 return graph.modCount(this); |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
423 } |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
424 return 0; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
425 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
426 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
427 final void incModCount() { |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
428 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
429 graph.incModCount(this); |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
430 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
431 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
432 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
433 final int usageModCount() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
434 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
435 return graph.usageModCount(this); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
436 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
437 return 0; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
438 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
439 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
440 final void incUsageModCount() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
441 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
442 graph.incUsageModCount(this); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
443 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
444 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
445 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
446 public boolean isDeleted() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
447 return id <= DELETED_ID_START; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
448 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
449 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
450 public boolean isAlive() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
451 return id >= ALIVE_ID_START; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
452 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
453 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
454 /** |
17214
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
|
455 * 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
|
456 * {@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
|
457 * 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
|
458 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
459 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
|
460 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
|
461 if (oldInput != newInput) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
462 if (oldInput != null) { |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
463 boolean result = removeThisFromUsages(oldInput); |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
464 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
|
465 } |
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
|
466 maybeNotifyInputChanged(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
467 if (newInput != null) { |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
468 newInput.addUsage(this); |
16175
3ee8c2cb629c
notify changed when setting input to null
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16101
diff
changeset
|
469 } |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
470 if (oldInput != null && oldInput.hasNoUsages()) { |
16606
7036c4594919
correct name of zero usages method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16554
diff
changeset
|
471 maybeNotifyZeroUsages(oldInput); |
3733
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
474 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
475 |
15007
9a73164832a9
add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15002
diff
changeset
|
476 protected void updateUsagesInterface(NodeInterface oldInput, NodeInterface newInput) { |
9a73164832a9
add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15002
diff
changeset
|
477 updateUsages(oldInput == null ? null : oldInput.asNode(), newInput == null ? null : newInput.asNode()); |
9a73164832a9
add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15002
diff
changeset
|
478 } |
9a73164832a9
add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15002
diff
changeset
|
479 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
480 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
481 * 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
|
482 * 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
|
483 * this node to newSuccessor's predecessors. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
484 */ |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
485 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
|
486 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:
13320
diff
changeset
|
487 assert graph == null || !graph.isFrozen(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
488 if (oldSuccessor != newSuccessor) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
489 if (oldSuccessor != null) { |
17338
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
490 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
|
491 oldSuccessor.predecessor = null; |
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 if (newSuccessor != null) { |
11676
435c8b984680
Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11674
diff
changeset
|
494 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
|
495 newSuccessor.predecessor = this; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
496 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
497 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
498 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
499 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
500 void initialize(Graph newGraph) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
501 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
|
502 this.graph = newGraph; |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
503 newGraph.register(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
504 for (Node input : inputs()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
505 updateUsages(null, input); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
506 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
507 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
|
508 updatePredecessor(null, successor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
509 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
510 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
511 |
19471
880717e44675
Use typed NodeClass in node constructors.
Roland Schatz <roland.schatz@oracle.com>
parents:
19420
diff
changeset
|
512 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
|
513 return nodeClass; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
514 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
515 |
15002
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
516 public boolean isAllowedUsageType(InputType type) { |
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
517 return getNodeClass().getAllowedUsageTypes().contains(type); |
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
518 } |
06e50d290784
isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15001
diff
changeset
|
519 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 private boolean checkReplaceWith(Node other) { |
13744
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13320
diff
changeset
|
521 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
|
522 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
|
523 assert assertFalse(isDeleted(), "cannot replace deleted node"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
524 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
|
525 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
526 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
527 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
528 public void replaceAtUsages(Node other) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
529 assert checkReplaceWith(other); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
530 for (Node usage : usages()) { |
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
|
531 boolean result = usage.getNodeClass().getEdges(Inputs).replaceFirst(usage, this, other); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
532 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
|
533 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
|
534 maybeNotifyInputChanged(usage); |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
535 other.addUsage(usage); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
536 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
537 } |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
538 clearUsages(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
539 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
540 |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
541 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
|
542 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
|
543 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
|
544 } 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
|
545 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
|
546 } else { |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
547 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
|
548 } |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
549 } |
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
550 |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
551 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
|
552 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
|
553 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
|
554 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
|
555 Node usage = getUsageAt(index); |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
556 if (usagePredicate.apply(usage)) { |
17210
ef64e2682bb6
added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents:
17188
diff
changeset
|
557 boolean result = usage.getNodeClass().getEdges(Inputs).replaceFirst(usage, this, other); |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
558 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
|
559 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
|
560 maybeNotifyInputChanged(usage); |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
561 other.addUsage(usage); |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
562 } |
18938
ef1494ece1a8
Move to a system that has an extra counter for extra usages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18937
diff
changeset
|
563 this.movUsageFromEndTo(index); |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
564 } 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
|
565 index++; |
15150
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
566 } |
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
567 } |
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
568 } |
101a31da0dd0
Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
15146
diff
changeset
|
569 |
15001 | 570 public void replaceAtUsages(InputType type, Node other) { |
571 assert checkReplaceWith(other); | |
572 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:
16982
diff
changeset
|
573 NodePosIterator iter = usage.inputs().iterator(); |
15001 | 574 while (iter.hasNext()) { |
575 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
|
576 if (pos.getInputType() == type && pos.get(usage) == this) { |
15001 | 577 pos.set(usage, other); |
578 } | |
579 } | |
580 } | |
581 } | |
582 | |
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
|
583 private void maybeNotifyInputChanged(Node node) { |
14157 | 584 if (graph != null) { |
585 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
|
586 NodeEventListener listener = graph.nodeEventListener; |
14157 | 587 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
|
588 listener.inputChanged(node); |
14157 | 589 } |
18884
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18815
diff
changeset
|
590 if (Fingerprint.ENABLED) { |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18815
diff
changeset
|
591 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
|
592 } |
13979
5568586d32a6
factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13744
diff
changeset
|
593 } |
5568586d32a6
factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13744
diff
changeset
|
594 } |
5568586d32a6
factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13744
diff
changeset
|
595 |
16606
7036c4594919
correct name of zero usages method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
16554
diff
changeset
|
596 private void maybeNotifyZeroUsages(Node node) { |
14157 | 597 if (graph != null) { |
598 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
|
599 NodeEventListener listener = graph.nodeEventListener; |
14157 | 600 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
|
601 listener.usagesDroppedToZero(node); |
14157 | 602 } |
18884
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18815
diff
changeset
|
603 if (Fingerprint.ENABLED) { |
0857a4186ecd
added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents:
18815
diff
changeset
|
604 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
|
605 } |
13979
5568586d32a6
factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13744
diff
changeset
|
606 } |
5568586d32a6
factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13744
diff
changeset
|
607 } |
5568586d32a6
factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13744
diff
changeset
|
608 |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
609 public void replaceAtPredecessor(Node other) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
610 assert checkReplaceWith(other); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
611 if (predecessor != null) { |
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
|
612 boolean result = predecessor.getNodeClass().getEdges(Successors).replaceFirst(predecessor, this, other); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
613 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
|
614 predecessor.updatePredecessor(this, other); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
615 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
616 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
617 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
618 public void replaceAndDelete(Node other) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
619 assert checkReplaceWith(other); |
19548
c66037cb9cd1
Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19517
diff
changeset
|
620 assert other != null; |
c66037cb9cd1
Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19517
diff
changeset
|
621 clearInputs(); |
c66037cb9cd1
Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19517
diff
changeset
|
622 clearSuccessors(); |
c66037cb9cd1
Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19517
diff
changeset
|
623 replaceAtUsages(other); |
c66037cb9cd1
Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
19517
diff
changeset
|
624 replaceAtPredecessor(other); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
625 safeDelete(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
626 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
627 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
628 public void replaceFirstSuccessor(Node oldSuccessor, Node newSuccessor) { |
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
|
629 if (getNodeClass().getEdges(Successors).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
|
630 updatePredecessor(oldSuccessor, newSuccessor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
631 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
632 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
633 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
634 public void replaceFirstInput(Node oldInput, Node newInput) { |
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
|
635 if (getNodeClass().getEdges(Inputs).replaceFirst(this, oldInput, newInput)) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
636 updateUsages(oldInput, newInput); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
637 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
638 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
639 |
16101
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
640 private void unregisterInputs() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
641 for (Node input : inputs()) { |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
642 removeThisFromUsages(input); |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
643 if (input.hasNoUsages()) { |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
644 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
|
645 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
646 } |
16101
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
647 } |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
648 |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
649 public void clearInputs() { |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
650 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
|
651 |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
652 unregisterInputs(); |
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
|
653 getNodeClass().getEdges(Inputs).clear(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
654 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
655 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
656 private boolean removeThisFromUsages(Node n) { |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
657 return n.removeUsage(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
658 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
659 |
16101
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
660 private void unregisterSuccessors() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
661 for (Node successor : successors()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
662 assert assertTrue(successor.predecessor == this, "wrong predecessor in old successor (%s): %s", successor, successor.predecessor); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
663 successor.predecessor = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
664 } |
16101
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
665 } |
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 public void clearSuccessors() { |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
668 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
|
669 |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
670 unregisterSuccessors(); |
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
|
671 getNodeClass().getEdges(Successors).clear(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
672 } |
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 private boolean checkDeletion() { |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
675 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
|
676 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
|
677 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
678 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
679 |
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
|
680 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
681 * 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
|
682 * 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
|
683 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
684 public void safeDelete() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
685 assert checkDeletion(); |
16101
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
686 unregisterInputs(); |
99e2e006ade2
do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15827
diff
changeset
|
687 unregisterSuccessors(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
688 graph.unregister(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
689 id = DELETED_ID_START - id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
690 assert isDeleted(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
691 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
692 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
693 public final Node copyWithInputs() { |
17353
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
694 return copyWithInputs(true); |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
695 } |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
696 |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
697 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
|
698 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
|
699 if (insertIntoGraph) { |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
700 for (Node input : inputs()) { |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
701 input.addUsage(newNode); |
90dc742e8cc7
Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents:
17347
diff
changeset
|
702 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
703 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
704 return newNode; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
705 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
706 |
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
|
707 /** |
11940 | 708 * 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
|
709 * {@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
|
710 * {@link Simplifiable#simplify(SimplifierTool)}. |
15001 | 711 * |
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
|
712 * @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
|
713 */ |
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
|
714 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
|
715 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
|
716 } |
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
|
717 |
17338
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
718 /** |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
719 * @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
|
720 * 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
|
721 * @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
|
722 * @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
|
723 * cleared |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
724 */ |
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
|
725 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
|
726 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
|
727 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
|
728 } else { |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
729 if (USE_UNSAFE_TO_CLONE) { |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
730 // 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
|
731 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
|
732 } 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
|
733 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
|
734 } |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
735 } |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
736 } |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
737 |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
738 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
|
739 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
|
740 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
|
741 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
|
742 |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
743 /** |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
744 * 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
|
745 * |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
746 * @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
|
747 * 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
|
748 * @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
|
749 * 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
|
750 * list for an edge list) |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
751 * @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
|
752 */ |
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
753 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
|
754 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
|
755 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
|
756 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
|
757 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
|
758 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
|
759 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
|
760 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
|
761 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
|
762 } |
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
|
763 } |
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
|
764 } |
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
|
765 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
766 Node newNode = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
767 try { |
17338
1778c3208bc5
reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents:
17329
diff
changeset
|
768 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
|
769 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
|
770 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
|
771 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
|
772 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
|
773 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
|
774 } 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
|
775 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
|
776 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
|
777 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
|
778 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
|
779 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
|
780 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
|
781 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
|
782 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
|
783 } |
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
|
784 } catch (Exception e) { |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
15153
diff
changeset
|
785 throw new GraalGraphInternalError(e).addContext(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
786 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
787 newNode.graph = into; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
788 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
|
789 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
|
790 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
|
791 } |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
792 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
|
793 |
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
|
794 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
|
795 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
|
796 } |
11677
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
797 newNode.afterClone(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
798 return newNode; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
799 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
800 |
11677
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
801 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
|
802 } |
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
803 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
804 public boolean verify() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
805 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
|
806 assertTrue(graph() != null, "null graph"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
807 for (Node input : inputs()) { |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
808 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
|
809 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
810 for (Node successor : successors()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
811 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
|
812 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
|
813 } |
17064
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
814 for (Node usage : usages()) { |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
815 assertFalse(usage.isDeleted(), "usage %s must never be deleted", usage); |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
816 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
|
817 NodePosIterator iterator = usage.inputs().iterator(); |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
818 while (iterator.hasNext()) { |
3c54a098455f
removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents:
17061
diff
changeset
|
819 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
|
820 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
|
821 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
|
822 } |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
823 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
824 } |
17008
81c9a1fc9072
select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents:
16982
diff
changeset
|
825 NodePosIterator iterator = inputs().withNullIterator(); |
16332
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
826 while (iterator.hasNext()) { |
ddd68e267e34
explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16241
diff
changeset
|
827 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
|
828 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
|
829 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
830 if (predecessor != null) { |
12723
bbf6407458ee
Node: print node in assert
Bernhard Urban <bernhard.urban@jku.at>
parents:
12686
diff
changeset
|
831 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
|
832 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
|
833 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
834 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
835 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
836 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
837 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
|
838 if (condition) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
839 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
840 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
841 throw new VerificationError(message, args).addContext(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
842 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
843 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
844 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
845 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
|
846 if (condition) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
847 throw new VerificationError(message, args).addContext(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
848 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
849 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
850 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
851 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
852 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
853 public Iterable<? extends Node> cfgPredecessors() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
854 if (predecessor == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
855 return Collections.emptySet(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
856 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
857 return Collections.singleton(predecessor); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
858 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
859 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
860 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
861 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
862 * 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
|
863 * 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
|
864 * 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
|
865 * fields contain them. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
866 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
867 public Iterable<? extends Node> cfgSuccessors() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
868 return successors(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
869 } |
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 /** |
13320
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13140
diff
changeset
|
872 * 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
|
873 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
874 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
875 public final int hashCode() { |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
876 return System.identityHashCode(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
877 } |
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 /** |
13320
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13140
diff
changeset
|
880 * Equality tests must rely solely on identity. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
881 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
882 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
883 public final boolean equals(Object obj) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
884 return super.equals(obj); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
885 } |
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 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
888 * 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
|
889 * ideal graph visualizer). |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
890 */ |
9495
6ad0bdcd76aa
make Node.getDebugProperties() final
Lukas Stadler <lukas.stadler@jku.at>
parents:
9332
diff
changeset
|
891 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
|
892 return getDebugProperties(new HashMap<>()); |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
893 } |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
894 |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
895 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
896 * 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
|
897 * 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
|
898 * their superclass. |
15001 | 899 * |
5813
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
900 * @param map |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
901 */ |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
902 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
|
903 Fields properties = getNodeClass().getData(); |
17214
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
|
904 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
|
905 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
|
906 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
907 return map; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
908 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
909 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
910 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
911 * 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
|
912 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
913 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
914 public final String toString() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
915 return toString(Verbosity.Short); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
916 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
917 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
918 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
919 * 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
|
920 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
921 public String toString(Verbosity verbosity) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
922 switch (verbosity) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
923 case Id: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
924 return Integer.toString(id); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
925 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
|
926 return getNodeClass().shortName(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
927 case Short: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
928 return toString(Verbosity.Id) + "|" + toString(Verbosity.Name); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
929 case Long: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
930 return toString(Verbosity.Short); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
931 case Debugger: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
932 case All: { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
933 StringBuilder str = new StringBuilder(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
934 str.append(toString(Verbosity.Short)).append(" { "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
935 for (Map.Entry<Object, Object> entry : getDebugProperties().entrySet()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
936 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
|
937 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
938 str.append(" }"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
939 return str.toString(); |
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 default: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
942 throw new RuntimeException("unknown verbosity: " + verbosity); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
943 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
944 } |
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
|
945 |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
946 @Deprecated |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
947 public int getId() { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
948 return id; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
949 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
950 |
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
|
951 @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
|
952 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
|
953 if ((flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE) { |
4418
46e9068c09b4
small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents:
4397
diff
changeset
|
954 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
|
955 } 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
|
956 // 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
|
957 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
|
958 } else { |
4418
46e9068c09b4
small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents:
4397
diff
changeset
|
959 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
|
960 } |
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
|
961 |
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
|
962 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
|
963 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
|
964 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
|
965 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
|
966 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
|
967 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
|
968 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
|
969 } |
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
|
970 |
17008
81c9a1fc9072
select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents:
16982
diff
changeset
|
971 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
|
972 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
|
973 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
|
974 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
|
975 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
|
976 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
|
977 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
|
978 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
|
979 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
|
980 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
|
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 } |
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 } |
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 |
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 (precision > 0) { |
18937
ff232ff8d028
Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18884
diff
changeset
|
986 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
|
987 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
|
988 int z = 0; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
989 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
|
990 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
|
991 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
|
992 } |
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 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
|
994 ++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
|
995 } |
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("}"); |
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
|
997 } |
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 |
17008
81c9a1fc9072
select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents:
16982
diff
changeset
|
999 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
|
1000 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
|
1001 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
|
1002 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
|
1003 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
|
1004 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
|
1005 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
|
1006 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
|
1007 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
|
1008 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
|
1009 } |
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 } |
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 } |
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 } |
17276
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1013 |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1014 /** |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1015 * 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
|
1016 * 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
|
1017 * 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
|
1018 * |
17316
e6e678c3818f
only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents:
17305
diff
changeset
|
1019 * 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
|
1020 * |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1021 * @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
|
1022 * @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
|
1023 */ |
ffb974bef674
moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents:
17272
diff
changeset
|
1024 public boolean valueEquals(Node other) { |
17450
45b45f902bed
removed Node generation (GRAAL-857)
Doug Simon <doug.simon@oracle.com>
parents:
17355
diff
changeset
|
1025 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
|
1026 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
1027 } |