annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java @ 19542:f98e2f0c35d8

Make GraphUtil#propagateKill more efficient.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 22 Feb 2015 23:12:31 +0100
parents c66037cb9cd1
children 353669a84287
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
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
17226
a552dd335bde generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents: 17210
diff changeset
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: 16822
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 /**
18379
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
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
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
52 *
18379
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
diff changeset
66 * </ul>
18379
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
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
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
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 */
16822
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
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19396
diff changeset
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"));
17353
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
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
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: 17308
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: 17308
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: 17308
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: 17308
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: 17308
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: 17308
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: 17308
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: 17308
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();
19396
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()
18379
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
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: 18379
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();
18379
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
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: 18379
diff changeset
233 * @see #newSet()
18379
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
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: 18379
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);
18379
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
diff changeset
246
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18379
diff changeset
247 public static <K extends Node, V> Map<K, V> newMap(Map<K, V> m) {
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18379
diff changeset
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
diff changeset
254
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18379
diff changeset
255 public static <K extends Node, V> Map<K, V> newMap(int expectedMaxSize) {
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18379
diff changeset
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
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: 18379
diff changeset
262
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18379
diff changeset
263 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: 18379
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: 18379
diff changeset
266
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18379
diff changeset
267 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: 18379
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: 18379
diff changeset
270
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18379
diff changeset
271 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: 18379
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: 18379
diff changeset
274
18379
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
275 /**
13327
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
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
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
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
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
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
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) {
19514
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
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
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 /**
17226
a552dd335bde generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents: 17210
diff changeset
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: 13327
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: 13327
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
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
570 public void replaceAtUsages(InputType type, Node other) {
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
571 assert checkReplaceWith(other);
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
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: 16984
diff changeset
573 NodePosIterator iter = usage.inputs().iterator();
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
574 while (iter.hasNext()) {
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
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
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
577 pos.set(usage, other);
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
578 }
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
579 }
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
580 }
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
581 }
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
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
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
584 if (graph != null) {
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
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
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
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
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
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
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
597 if (graph != null) {
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
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
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
600 if (listener != null) {
19542
f98e2f0c35d8 Make GraphUtil#propagateKill more efficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19541
diff changeset
601 // System.out.println("usage dropped to zero: " + node);
f98e2f0c35d8 Make GraphUtil#propagateKill more efficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19541
diff changeset
602 // listener.usagesDroppedToZero(node);
14157
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
603 }
18884
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18815
diff changeset
604 if (Fingerprint.ENABLED) {
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18815
diff changeset
605 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
606 }
13979
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 }
5568586d32a6 factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13744
diff changeset
609
5487
9743ae819f73 Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5485
diff changeset
610 public void replaceAtPredecessor(Node other) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
611 assert checkReplaceWith(other);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
612 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
613 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
614 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
615 predecessor.updatePredecessor(this, other);
3733
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
619 public void replaceAndDelete(Node other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
620 assert checkReplaceWith(other);
19541
c66037cb9cd1 Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19514
diff changeset
621 assert other != null;
c66037cb9cd1 Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19514
diff changeset
622 clearInputs();
c66037cb9cd1 Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19514
diff changeset
623 clearSuccessors();
c66037cb9cd1 Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19514
diff changeset
624 replaceAtUsages(other);
c66037cb9cd1 Make Node#replaceAndDelete not accept null as an argument.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19514
diff changeset
625 replaceAtPredecessor(other);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
626 safeDelete();
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
629 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
630 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
631 updatePredecessor(oldSuccessor, newSuccessor);
3733
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
635 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
636 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
637 updateUsages(oldInput, newInput);
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
640
16101
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
641 private void unregisterInputs() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
642 for (Node input : inputs()) {
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
643 removeThisFromUsages(input);
18937
ff232ff8d028 Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18884
diff changeset
644 if (input.hasNoUsages()) {
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
645 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
646 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
647 }
16101
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
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
650 public void clearInputs() {
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
651 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
652
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
653 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
654 getNodeClass().getEdges(Inputs).clear(this);
3733
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
657 private boolean removeThisFromUsages(Node n) {
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
658 return n.removeUsage(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
659 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
660
16101
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
661 private void unregisterSuccessors() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
662 for (Node successor : successors()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
663 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
664 successor.predecessor = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
665 }
16101
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
666 }
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
667
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
668 public void clearSuccessors() {
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
669 assert assertFalse(isDeleted(), "cannot clear successors of deleted node");
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
670
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
671 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
672 getNodeClass().getEdges(Successors).clear(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
673 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
674
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
675 private boolean checkDeletion() {
18937
ff232ff8d028 Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18884
diff changeset
676 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
677 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
678 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
679 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
680
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
681 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
682 * 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
683 * 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
684 */
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
685 public void safeDelete() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
686 assert checkDeletion();
19542
f98e2f0c35d8 Make GraphUtil#propagateKill more efficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19541
diff changeset
687 unsafeDelete();
f98e2f0c35d8 Make GraphUtil#propagateKill more efficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19541
diff changeset
688 }
f98e2f0c35d8 Make GraphUtil#propagateKill more efficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19541
diff changeset
689
f98e2f0c35d8 Make GraphUtil#propagateKill more efficient.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19541
diff changeset
690 public void unsafeDelete() {
16101
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
691 unregisterInputs();
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
692 unregisterSuccessors();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
693 graph.unregister(this);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
694 id = DELETED_ID_START - id;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
695 assert isDeleted();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
696 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
697
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
698 public final Node copyWithInputs() {
17351
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
699 return copyWithInputs(true);
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
700 }
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
701
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
702 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
703 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
704 if (insertIntoGraph) {
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
705 for (Node input : inputs()) {
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
706 input.addUsage(newNode);
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
707 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
708 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
709 return newNode;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
710 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
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 /**
11940
87402d9a67ca spelling fix
Doug Simon <doug.simon@oracle.com>
parents: 11891
diff changeset
713 * 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
714 * {@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
715 * {@link Simplifiable#simplify(SimplifierTool)}.
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
716 *
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
717 * @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
718 */
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
719 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
720 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
721 }
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
722
17338
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
723 /**
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
724 * @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
725 * 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
726 * @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
727 * @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
728 * cleared
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
729 */
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
730 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
731 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
732 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
733 } else {
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
734 if (USE_UNSAFE_TO_CLONE) {
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
735 // 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
736 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
737 } 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
738 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
739 }
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
740 }
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
741 }
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 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
744 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
745 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
746 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
747
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
748 /**
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
749 * 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
750 *
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
751 * @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
752 * 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
753 * @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
754 * 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
755 * list for an edge list)
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
756 * @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
757 */
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
758 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
759 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
760 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
761 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
762 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
763 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
764 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
765 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
766 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
767 }
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
768 }
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
769 }
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
770
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
771 Node newNode = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
772 try {
17338
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
773 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
774 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
775 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
776 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
777 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
778 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
779 } 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
780 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
781 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
782 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
783 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
784 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
785 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
786 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
787 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
788 }
1e7e354e407f use Unsafe.allocateInstance in Node.clone(Graph into, boolean clearInputsAndSuccessors) to avoid initializing fields twice
Doug Simon <doug.simon@oracle.com>
parents: 17328
diff changeset
789 } catch (Exception e) {
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15153
diff changeset
790 throw new GraalGraphInternalError(e).addContext(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
791 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
792 newNode.graph = into;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
793 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
794 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
795 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
796 }
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
797 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
798
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
799 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
800 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
801 }
11677
9d341b6e47e5 Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11676
diff changeset
802 newNode.afterClone(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
803 return newNode;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
804 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
805
11677
9d341b6e47e5 Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11676
diff changeset
806 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
807 }
9d341b6e47e5 Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11676
diff changeset
808
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
809 public boolean verify() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
810 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
811 assertTrue(graph() != null, "null graph");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
812 for (Node input : inputs()) {
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
813 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
814 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
815 for (Node successor : successors()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
816 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
817 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
818 }
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
819 for (Node usage : usages()) {
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
820 assertFalse(usage.isDeleted(), "usage %s must never be deleted", usage);
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
821 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
822 NodePosIterator iterator = usage.inputs().iterator();
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
823 while (iterator.hasNext()) {
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
824 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
825 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
826 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
827 }
12570
af39ea2dc39d made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12437
diff changeset
828 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
829 }
17008
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16984
diff changeset
830 NodePosIterator iterator = inputs().withNullIterator();
16332
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16241
diff changeset
831 while (iterator.hasNext()) {
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16241
diff changeset
832 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
833 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
834 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
835 if (predecessor != null) {
12723
bbf6407458ee Node: print node in assert
Bernhard Urban <bernhard.urban@jku.at>
parents: 12686
diff changeset
836 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
837 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
838 }
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
841
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
842 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
843 if (condition) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
844 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
845 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
846 throw new VerificationError(message, args).addContext(this);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
847 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
848 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
849
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
850 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
851 if (condition) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
852 throw new VerificationError(message, args).addContext(this);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
853 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
854 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
855 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
856 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
857
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
858 public Iterable<? extends Node> cfgPredecessors() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
859 if (predecessor == null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
860 return Collections.emptySet();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
861 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
862 return Collections.singleton(predecessor);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
863 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
864 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
865
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
866 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
867 * 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
868 * 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
869 * 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
870 * fields contain them.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
871 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
872 public Iterable<? extends Node> cfgSuccessors() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
873 return successors();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
874 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
875
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
876 /**
13327
c258331fdde6 removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13140
diff changeset
877 * 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
878 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
879 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
880 public final int hashCode() {
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
881 return System.identityHashCode(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
882 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
883
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
884 /**
13327
c258331fdde6 removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13140
diff changeset
885 * Equality tests must rely solely on identity.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
886 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
887 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
888 public final boolean equals(Object obj) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
889 return super.equals(obj);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
890 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
891
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
892 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
893 * 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
894 * ideal graph visualizer).
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
895 */
9495
6ad0bdcd76aa make Node.getDebugProperties() final
Lukas Stadler <lukas.stadler@jku.at>
parents: 9332
diff changeset
896 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
897 return getDebugProperties(new HashMap<>());
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
898 }
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
899
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
900 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
901 * 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
902 * 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
903 * their superclass.
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
904 *
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
905 * @param map
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
906 */
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
907 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
908 Fields properties = getNodeClass().getData();
17226
a552dd335bde generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents: 17210
diff changeset
909 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
910 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
911 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
912 return map;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
913 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
914
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
915 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
916 * 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
917 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
918 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
919 public final String toString() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
920 return toString(Verbosity.Short);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
921 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
922
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
923 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
924 * 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
925 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
926 public String toString(Verbosity verbosity) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
927 switch (verbosity) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
928 case Id:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
929 return Integer.toString(id);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
930 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
931 return getNodeClass().shortName();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
932 case Short:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
933 return toString(Verbosity.Id) + "|" + toString(Verbosity.Name);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
934 case Long:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
935 return toString(Verbosity.Short);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
936 case Debugger:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
937 case All: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
938 StringBuilder str = new StringBuilder();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
939 str.append(toString(Verbosity.Short)).append(" { ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
940 for (Map.Entry<Object, Object> entry : getDebugProperties().entrySet()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
941 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
942 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
943 str.append(" }");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
944 return str.toString();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
945 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
946 default:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
947 throw new RuntimeException("unknown verbosity: " + verbosity);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
948 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
949 }
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
950
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
951 @Deprecated
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
952 public int getId() {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
953 return id;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
954 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
955
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
956 @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
957 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
958 if ((flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE) {
4418
46e9068c09b4 small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents: 4397
diff changeset
959 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
960 } 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
961 // 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
962 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
963 } else {
4418
46e9068c09b4 small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents: 4397
diff changeset
964 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
965 }
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
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 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
968 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
969 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
970 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
971 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
972 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
973 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
974 }
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
17008
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16984
diff changeset
976 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
977 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
978 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
979 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
980 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
981 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
982 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
983 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
984 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
985 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
986 }
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 }
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 }
403330cfd3da Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4311
diff changeset
989
403330cfd3da Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4311
diff changeset
990 if (precision > 0) {
18937
ff232ff8d028 Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18884
diff changeset
991 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
992 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
993 int z = 0;
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
994 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
995 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
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 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
999 ++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
1000 }
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 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
1002 }
403330cfd3da Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4311
diff changeset
1003
17008
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16984
diff changeset
1004 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
1005 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
1006 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
1007 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
1008 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
1009 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
1010 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
1011 formatter.format("={");
403330cfd3da Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4311
diff changeset
1012 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
1013 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
1014 }
403330cfd3da Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4311
diff changeset
1015 }
403330cfd3da Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4311
diff changeset
1016 }
403330cfd3da Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4311
diff changeset
1017 }
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
1018
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
1019 /**
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
1020 * 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
1021 * 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
1022 * 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
1023 *
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17308
diff changeset
1024 * 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
1025 *
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
1026 * @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
1027 * @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
1028 */
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
1029 public boolean valueEquals(Node other) {
17450
45b45f902bed removed Node generation (GRAAL-857)
Doug Simon <doug.simon@oracle.com>
parents: 17355
diff changeset
1030 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
1031 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1032 }