annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java @ 18383:1518c3296cc8

use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
author Doug Simon <doug.simon@oracle.com>
date Sun, 16 Nov 2014 09:44:04 +0100
parents 3aaf2747961c
children 86269e451920
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
17214
a552dd335bde generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents: 17210
diff changeset
33 import com.oracle.graal.compiler.common.*;
18378
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
34 import com.oracle.graal.compiler.common.remote.*;
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
35 import com.oracle.graal.graph.Graph.NodeEventListener;
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6458
diff changeset
36 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
37 import com.oracle.graal.graph.spi.*;
16841
cbd42807a31f moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents: 16811
diff changeset
38 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
39
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 /**
18378
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
41 * 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
42 * {@link Graph}.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
43 * <p>
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
44 * 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
45 * 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
46 * {@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
47 * {@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
48 * this field points to.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
49 * <p>
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 * 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
51 *
18378
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
52 * <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
53 *
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
54 * To enable deterministic replay compilation, node sets and node maps should be instantiated with
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
55 * the following methods:
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
56 * <ul>
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
57 * <li>{@link #newSet()}</li>
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
58 * <li>{@link #newSet(Collection)}</li>
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
59 * <li>{@link #newMap()}</li>
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
60 * <li>{@link #newMap(int)}</li>
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
61 * <li>{@link #newMap(Map)}</li>
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
62 * <li>{@link #newIdentityMap()}</li>
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
63 * <li>{@link #newIdentityMap(int)}</li>
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
64 * <li>{@link #newIdentityMap(Map)}</li>
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
65 * </ul>
18378
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
66 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 * <h1>Assertions and Verification</h1>
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
68 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 * 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
70 * {@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
71 * 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
72 * 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
73 * only performed if assertions are enabled.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 */
16811
5d468add216f added @NodeInfo annotations to all Node classes
Doug Simon <doug.simon@oracle.com>
parents: 16606
diff changeset
75 @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
76 public abstract class Node implements Cloneable, Formattable {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77
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
78 public static final boolean USE_UNSAFE_TO_CLONE = Boolean.parseBoolean(System.getProperty("graal.node.useUnsafeToClone", "true"));
17352
3457f147a24f made selectability of using generated node functionality more fine grained
Doug Simon <doug.simon@oracle.com>
parents: 17347
diff changeset
79
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 static final int DELETED_ID_START = -1000000000;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81 static final int INITIAL_ID = -1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 static final int ALIVE_ID_START = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83
16901
451468f7340b workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents: 16897
diff changeset
84 // 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
85 // 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
86
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
87 /**
16336
c88a9e432faf small fix and doc for @OptionalInput
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16332
diff changeset
88 * 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
89 * 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
90 * 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
91 * {@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
92 */
16901
451468f7340b workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents: 16897
diff changeset
93 @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
94 @java.lang.annotation.Target(ElementType.FIELD)
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95 public static @interface Input {
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
96 InputType value() default InputType.Value;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98
16332
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16241
diff changeset
99 /**
16336
c88a9e432faf small fix and doc for @OptionalInput
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16332
diff changeset
100 * 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
101 * 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
102 * {@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
103 * 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
104 */
16901
451468f7340b workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents: 16897
diff changeset
105 @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
106 @java.lang.annotation.Target(ElementType.FIELD)
16332
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16241
diff changeset
107 public static @interface OptionalInput {
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16241
diff changeset
108 InputType value() default InputType.Value;
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16241
diff changeset
109 }
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16241
diff changeset
110
16901
451468f7340b workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents: 16897
diff changeset
111 @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
112 @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
113 public static @interface Successor {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
114 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
117 * 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
118 * 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
119 */
16901
451468f7340b workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents: 16897
diff changeset
120 @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
121 @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
122 public static @interface ConstantNodeParameter {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
123 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125 /**
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
126 * 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
127 * 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
128 * 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
129 * 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
130 */
16901
451468f7340b workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents: 16897
diff changeset
131 @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
132 @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
133 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
134 }
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
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 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
137 * 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
138 * 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
139 * {@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
140 * 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
141 * 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
142 */
16901
451468f7340b workaround for a problem javac has resolving symbols in Node.java
Doug Simon <doug.simon@oracle.com>
parents: 16897
diff changeset
143 @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
144 @java.lang.annotation.Target(ElementType.METHOD)
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 public static @interface NodeIntrinsic {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
146
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
148 * 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
149 * 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
150 * 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
151 */
15040
288c23143d47 Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents: 15036
diff changeset
152 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
153
b74402a7079b fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents: 5823
diff changeset
154 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
155 * 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
156 * 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
157 * <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
158 * 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
159 * 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
160 */
b74402a7079b fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents: 5823
diff changeset
161 boolean setStampFromReturnType() default false;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
162 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17305
diff changeset
164 /**
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17305
diff changeset
165 * Marker for a node that can be replaced by another node via global value numbering. A
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17305
diff changeset
166 * {@linkplain NodeClass#isLeafNode() leaf} node can be replaced by another node of the same
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17305
diff changeset
167 * type that has exactly the same {@linkplain NodeClass#getData() data} values. A non-leaf node
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17305
diff changeset
168 * can be replaced by another node of the same type that has exactly the same data values as
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17305
diff changeset
169 * well as the same {@linkplain Node#inputs() inputs} and {@linkplain Node#successors()
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17305
diff changeset
170 * successors}.
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17305
diff changeset
171 */
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
172 public interface ValueNumberable {
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
173 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 private Graph graph;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 int id;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
178 // 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
179 // 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
180 Node typeCacheNext;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181
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
182 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
183 private static final Node[] NO_NODES = {};
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
184
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
185 /**
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
186 * 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
187 * {@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
188 */
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
189 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
190 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
191 Node[] extraUsages;
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
192
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 private Node predecessor;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194
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
195 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
196 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
197
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
198 public Node() {
15827
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15381
diff changeset
199 init();
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15381
diff changeset
200 }
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15381
diff changeset
201
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15381
diff changeset
202 final void init() {
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15381
diff changeset
203 id = INITIAL_ID;
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15381
diff changeset
204 extraUsages = NO_NODES;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
205 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206
12686
ca8ab182026f abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents: 12655
diff changeset
207 int id() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
208 return id;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
209 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
211 /**
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
212 * Creates a {@link Node} set. If the current thread has a non-null
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
213 * {@linkplain Context#getCurrent() compilation replay scope}, the returned set will have a
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
214 * deterministic iteration order determined by the order in which elements are inserted in the
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
215 * map.
18378
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
216 */
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
217 public static <E extends Node> Set<E> newSet() {
18378
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
218 return Context.getCurrent() == null ? new HashSet<>() : new LinkedHashSet<>();
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
219 }
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
220
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
221 /**
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
222 * @see #newSet()
18378
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
223 */
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
224 public static <E extends Node> Set<E> newSet(Collection<? extends E> c) {
18378
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
225 return Context.getCurrent() == null ? new HashSet<>(c) : new LinkedHashSet<>(c);
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
226 }
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
227
18383
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
228 public static <K extends Node, V> Map<K, V> newMap() {
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
229 // Node.equals() and Node.hashCode() are final and are implemented
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
230 // purely in terms of identity so HashMap and IdentityHashMap with
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
231 // Node's as keys will behave the same. We choose to use the latter
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
232 // due to its lighter memory footprint.
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
233 return newIdentityMap();
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
234 }
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
235
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
236 public static <K extends Node, V> Map<K, V> newMap(Map<K, V> m) {
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
237 // Node.equals() and Node.hashCode() are final and are implemented
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
238 // purely in terms of identity so HashMap and IdentityHashMap with
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
239 // Node's as keys will behave the same. We choose to use the latter
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
240 // due to its lighter memory footprint.
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
241 return newIdentityMap(m);
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
242 }
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
243
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
244 public static <K extends Node, V> Map<K, V> newMap(int expectedMaxSize) {
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
245 // Node.equals() and Node.hashCode() are final and are implemented
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
246 // purely in terms of identity so HashMap and IdentityHashMap with
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
247 // Node's as keys will behave the same. We choose to use the latter
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
248 // due to its lighter memory footprint.
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
249 return newIdentityMap(expectedMaxSize);
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
250 }
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
251
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
252 public static <K extends Node, V> Map<K, V> newIdentityMap() {
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
253 return Context.newIdentityMap();
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
254 }
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
255
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
256 public static <K extends Node, V> Map<K, V> newIdentityMap(Map<K, V> m) {
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
257 return Context.newIdentityMap(m);
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
258 }
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
259
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
260 public static <K extends Node, V> Map<K, V> newIdentityMap(int expectedMaxSize) {
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
261 return Context.newIdentityMap(expectedMaxSize);
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
262 }
1518c3296cc8 use deterministic iteration order Set and Map data structures when in the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18378
diff changeset
263
18378
3aaf2747961c use LinkedHashSets for node sets when created within the scope of a replay compilation context
Doug Simon <doug.simon@oracle.com>
parents: 18163
diff changeset
264 /**
13320
c258331fdde6 removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13140
diff changeset
265 * 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
266 */
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267 public Graph graph() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
268 return graph;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
269 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
271 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
272 * 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
273 * input edges of this node.
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
274 *
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6458
diff changeset
275 * @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
276 */
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6458
diff changeset
277 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
278 return getNodeClass().getEdges(Inputs).getIterable(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279 }
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 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
282 * 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
283 * successor edges of this node.
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
284 *
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6458
diff changeset
285 * @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
286 */
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6458
diff changeset
287 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
288 return getNodeClass().getEdges(Successors).getIterable(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
289 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
290
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
291 /**
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
292 * 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
293 */
11654
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
294 int getUsageCountUpperBound() {
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
295 if (usage0 == null) {
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
296 return 0;
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
297 }
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
298 if (usage1 == null) {
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
299 return 1;
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
300 }
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
301 return 2 + extraUsages.length;
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
302 }
317036da1f29 Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
303
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
304 /**
12570
af39ea2dc39d made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12437
diff changeset
305 * 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
306 */
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6458
diff changeset
307 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
308 return new NodeUsageIterable(this);
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
309 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
310
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
311 /**
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
312 * Finds the index of the last non-null entry in a node array. The search assumes that all
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
313 * non-null entries precede the first null entry in the array.
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
314 *
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
315 * @param nodes the array to search
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
316 * @return the index of the last non-null entry in {@code nodes} if it exists, else -1
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
317 */
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
318 private static int indexOfLastNonNull(Node[] nodes) {
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
319 if (nodes.length == 0 || nodes[0] == null) {
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
320 return -1;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
321 }
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
322 if (nodes[nodes.length - 1] != null) {
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
323 return nodes.length - 1;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
324 }
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
325
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
326 // binary search
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
327 int low = 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
328 int high = nodes.length - 1;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
329 while (true) {
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
330 int mid = (low + high) >>> 1;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
331 if (nodes[mid] == null) {
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
332 if (nodes[mid - 1] != null) {
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
333 return mid - 1;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
334 }
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
335 high = mid - 1;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
336 } else {
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
337 if (mid == nodes.length - 1 || nodes[mid + 1] == null) {
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
338 return mid;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
339 }
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
340 low = mid + 1;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
341 }
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 }
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 }
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
344
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
345 /**
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
346 * 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
347 *
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
348 * @param node the node to add
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
349 */
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
350 private void addUsage(Node node) {
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
351 incUsageModCount();
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
352 if (usage0 == null) {
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
353 usage0 = node;
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
354 } else if (usage1 == null) {
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
355 usage1 = node;
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
356 } else {
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
357 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
358 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
359 extraUsages = new Node[4];
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
360 extraUsages[0] = node;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
361 } else {
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
362 int lastNonNull = indexOfLastNonNull(extraUsages);
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
363 if (lastNonNull == length - 1) {
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
364 extraUsages = Arrays.copyOf(extraUsages, length * 2 + 1);
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
365 extraUsages[length] = node;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
366 } else if (lastNonNull == -1) {
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
367 extraUsages[0] = node;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
368 } else {
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
369 extraUsages[lastNonNull + 1] = node;
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
370 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
371 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
372 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
373 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
374
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
375 int usageCount() {
15153
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
376 if (usage0 == null) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
377 return 0;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
378 }
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
379 if (usage1 == null) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
380 return 1;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
381 }
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
382 return 2 + indexOfLastNonNull(extraUsages) + 1;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
383 }
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
384
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
385 /**
15153
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
386 * Remove all usages between {@code fromIndex} and {@code toIndex} (exclusive), also, if
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
387 * {@code toIndex} is a valid usage, it is moved to {@code fromIndex}.
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
388 *
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
389 * <p>
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
390 * Visually,
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
391 *
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
392 * <pre>
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
393 * {@code
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
394 * [1, 2, 3, 4, 5, 6, 7].removeUsagesAndShiftFirst(1, 2) == [1, 4, 6, 7, 5, null, null]}
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
395 * </pre>
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
396 *
15150
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
397 *
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
398 * @param fromIndex the index of the first element to be removed
15153
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
399 * @param toIndex the index after the last element to be removed
15150
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
400 */
15153
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
401 private void removeUsagesAndShiftFirst(int fromIndex, int toIndex) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
402 assert fromIndex < toIndex;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
403 int firstNullIndex = usageCount();
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
404 assert toIndex <= firstNullIndex;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
405 int i = fromIndex;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
406 int limit = toIndex;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
407 if (toIndex < firstNullIndex) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
408 // move usage at toIndex to fromIndex(!)
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
409 movUsageTo(toIndex, fromIndex);
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
410 limit++;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
411 i++;
15150
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
412 }
15153
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
413 while (i < limit && firstNullIndex > limit) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
414 movUsageTo(firstNullIndex - 1, i);
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
415 firstNullIndex--;
15150
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
416 i++;
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
417 }
15153
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
418 while (i < limit) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
419 if (i == 0) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
420 usage0 = null;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
421 } else if (i == 1) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
422 usage1 = null;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
423 } else {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
424 extraUsages[i - INLINE_USAGE_COUNT] = null;
15150
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
425 }
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
426 i++;
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
427 }
15153
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
428
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
429 }
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
430
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
431 private void movUsageTo(int usageIndex, int toIndex) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
432 assert usageIndex > toIndex;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
433 if (toIndex == 0) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
434 if (usageIndex == 1) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
435 usage0 = usage1;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
436 usage1 = null;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
437 } else {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
438 usage0 = extraUsages[usageIndex - INLINE_USAGE_COUNT];
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
439 extraUsages[usageIndex - INLINE_USAGE_COUNT] = null;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
440 }
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
441 } else if (toIndex == 1) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
442 usage1 = extraUsages[usageIndex - INLINE_USAGE_COUNT];
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
443 extraUsages[usageIndex - INLINE_USAGE_COUNT] = null;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
444 } else {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
445 extraUsages[toIndex - INLINE_USAGE_COUNT] = extraUsages[usageIndex - INLINE_USAGE_COUNT];
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
446 extraUsages[usageIndex - INLINE_USAGE_COUNT] = null;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
447 }
15150
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
448 }
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
449
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
450 /**
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
451 * 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
452 *
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
453 * @param node the node to remove
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
454 * @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
455 */
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
456 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
457 assert node != null;
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
458 // 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
459 // 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
460 incUsageModCount();
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
461 if (usage0 == node) {
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
462 if (usage1 != null) {
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
463 int lastNonNull = indexOfLastNonNull(extraUsages);
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
464 if (lastNonNull >= 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
465 usage0 = extraUsages[lastNonNull];
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
466 extraUsages[lastNonNull] = null;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
467 } else {
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
468 // usage1 is the last element
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
469 usage0 = usage1;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
470 usage1 = null;
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
471 }
11531
331f7590b741 modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11528
diff changeset
472 } else {
331f7590b741 modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11528
diff changeset
473 // usage0 is the last element
331f7590b741 modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11528
diff changeset
474 usage0 = null;
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
475 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
476 return true;
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
477 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
478 if (usage1 == node) {
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
479 int lastNonNull = indexOfLastNonNull(extraUsages);
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
480 if (lastNonNull >= 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
481 usage1 = extraUsages[lastNonNull];
edf875b3c091 use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11531
diff changeset
482 extraUsages[lastNonNull] = null;
11531
331f7590b741 modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11528
diff changeset
483 } else {
331f7590b741 modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11528
diff changeset
484 // usage1 is the last element
331f7590b741 modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11528
diff changeset
485 usage1 = null;
331f7590b741 modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11528
diff changeset
486 }
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
487 return true;
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
488 }
15153
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
489 int matchIndex = -1;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
490 int i = 0;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
491 Node n;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
492 while (i < extraUsages.length && (n = extraUsages[i]) != null) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
493 if (n == node) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
494 matchIndex = i;
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
495 }
15153
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
496 i++;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
497 }
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
498 if (matchIndex >= 0) {
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
499 extraUsages[matchIndex] = extraUsages[i - 1];
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
500 extraUsages[i - 1] = null;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
501 return true;
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
502 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
503 return false;
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
504 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
505
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
506 private void clearUsages() {
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
507 incUsageModCount();
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
508 usage0 = null;
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
509 usage1 = null;
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
510 extraUsages = NO_NODES;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
511 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
512
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
513 public final Node predecessor() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
514 return predecessor;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
515 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
516
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
517 public final int modCount() {
11524
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11492
diff changeset
518 if (MODIFICATION_COUNTS_ENABLED && graph != null) {
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11492
diff changeset
519 return graph.modCount(this);
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11492
diff changeset
520 }
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11492
diff changeset
521 return 0;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
522 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
523
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
524 final void incModCount() {
11524
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11492
diff changeset
525 if (MODIFICATION_COUNTS_ENABLED && graph != null) {
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11492
diff changeset
526 graph.incModCount(this);
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11492
diff changeset
527 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
528 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
529
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
530 final int usageModCount() {
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
531 if (MODIFICATION_COUNTS_ENABLED && graph != null) {
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
532 return graph.usageModCount(this);
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
533 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
534 return 0;
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
535 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
536
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
537 final void incUsageModCount() {
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
538 if (MODIFICATION_COUNTS_ENABLED && graph != null) {
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
539 graph.incUsageModCount(this);
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
540 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
541 }
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
542
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
543 public boolean isDeleted() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
544 return id <= DELETED_ID_START;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
545 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
546
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
547 public boolean isAlive() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
548 return id >= ALIVE_ID_START;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
549 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
550
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
551 /**
17214
a552dd335bde generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents: 17210
diff changeset
552 * 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
553 * {@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
554 * 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
555 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
556 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
557 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
558 if (oldInput != newInput) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
559 if (oldInput != null) {
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
560 boolean result = removeThisFromUsages(oldInput);
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
561 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
562 }
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
563 maybeNotifyInputChanged(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
564 if (newInput != null) {
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
565 newInput.addUsage(this);
16175
3ee8c2cb629c notify changed when setting input to null
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16101
diff changeset
566 }
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
567 if (oldInput != null && oldInput.usages().isEmpty()) {
16606
7036c4594919 correct name of zero usages method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16554
diff changeset
568 maybeNotifyZeroUsages(oldInput);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
569 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
570 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
571 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
572
15007
9a73164832a9 add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15002
diff changeset
573 protected void updateUsagesInterface(NodeInterface oldInput, NodeInterface newInput) {
9a73164832a9 add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15002
diff changeset
574 updateUsages(oldInput == null ? null : oldInput.asNode(), newInput == null ? null : newInput.asNode());
9a73164832a9 add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15002
diff changeset
575 }
9a73164832a9 add NodeInterface
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15002
diff changeset
576
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
577 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
578 * 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
579 * 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
580 * this node to newSuccessor's predecessors.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
581 */
5487
9743ae819f73 Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5485
diff changeset
582 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
583 assert isAlive() && (newSuccessor == null || newSuccessor.isAlive()) : "adding " + newSuccessor + " to " + this + " instead of " + oldSuccessor;
13744
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13320
diff changeset
584 assert graph == null || !graph.isFrozen();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
585 if (oldSuccessor != newSuccessor) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
586 if (oldSuccessor != null) {
17338
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
587 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
588 oldSuccessor.predecessor = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
589 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
590 if (newSuccessor != null) {
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11674
diff changeset
591 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
592 newSuccessor.predecessor = this;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
593 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
594 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
595 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
596
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
597 void initialize(Graph newGraph) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
598 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
599 this.graph = newGraph;
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
600 newGraph.register(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
601 for (Node input : inputs()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
602 updateUsages(null, input);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
603 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
604 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
605 updatePredecessor(null, successor);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
606 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
607 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
608
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
609 public final NodeClass getNodeClass() {
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 9495
diff changeset
610 return NodeClass.get(getClass());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
611 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
612
15002
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
613 public boolean isAllowedUsageType(InputType type) {
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
614 return getNodeClass().getAllowedUsageTypes().contains(type);
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
615 }
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
616
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
617 private boolean checkReplaceWith(Node other) {
13744
d96dbd96bb45 Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13320
diff changeset
618 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
619 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
620 assert assertFalse(isDeleted(), "cannot replace deleted node");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
621 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
622 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
623 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
624
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
625 public void replaceAtUsages(Node other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
626 assert checkReplaceWith(other);
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
627 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
628 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
629 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
630 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
631 maybeNotifyInputChanged(usage);
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
632 other.addUsage(usage);
3733
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 }
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
635 clearUsages();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
636 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
637
15150
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
638 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
639 assert checkReplaceWith(other);
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
640 NodeUsageIterator it = (NodeUsageIterator) usages().iterator();
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
641 int removeStart = -1;
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
642 while (it.hasNext()) {
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
643 Node usage = it.next();
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
644 if (usagePredicate.apply(usage)) {
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
645 if (removeStart < 0) {
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
646 removeStart = it.index - 1;
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
647 }
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
648 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
649 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
650 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
651 maybeNotifyInputChanged(usage);
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
652 other.addUsage(usage);
15150
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
653 }
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
654 } else {
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
655 if (removeStart >= 0) {
15153
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
656 int removeEndIndex = it.index - 1;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
657 removeUsagesAndShiftFirst(removeStart, removeEndIndex);
15150
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
658 it.index = removeStart;
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
659 it.advance();
15153
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
660 removeStart = -1;
15150
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
661 }
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
662 }
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
663 }
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
664 if (removeStart >= 0) {
15153
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
665 int removeEndIndex = it.index;
d224a3a0e6a9 Various optimizations of Node.replaceAtMatchingUsages and Node.replaceAtUsages
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15150
diff changeset
666 removeUsagesAndShiftFirst(removeStart, removeEndIndex);
15150
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
667 }
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
668 }
101a31da0dd0 Add Node.replaceAtMatchingUsages(Node, NodePredicate) and some tests.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15146
diff changeset
669
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
670 public void replaceAtUsages(InputType type, Node other) {
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
671 assert checkReplaceWith(other);
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
672 for (Node usage : usages().snapshot()) {
17008
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16982
diff changeset
673 NodePosIterator iter = usage.inputs().iterator();
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
674 while (iter.hasNext()) {
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
675 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
676 if (pos.getInputType() == type && pos.get(usage) == this) {
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
677 pos.set(usage, other);
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
678 }
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
679 }
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
680 }
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
681 }
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
682
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
683 private void maybeNotifyInputChanged(Node node) {
14157
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
684 if (graph != null) {
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
685 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
686 NodeEventListener listener = graph.nodeEventListener;
14157
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
687 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
688 listener.inputChanged(node);
14157
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
689 }
13979
5568586d32a6 factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13744
diff changeset
690 }
5568586d32a6 factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13744
diff changeset
691 }
5568586d32a6 factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13744
diff changeset
692
16606
7036c4594919 correct name of zero usages method
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 16554
diff changeset
693 private void maybeNotifyZeroUsages(Node node) {
14157
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
694 if (graph != null) {
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
695 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
696 NodeEventListener listener = graph.nodeEventListener;
14157
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
697 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
698 listener.usagesDroppedToZero(node);
14157
8c4a3d9308a7 fixed FindBugs bugs
twisti
parents: 13979
diff changeset
699 }
13979
5568586d32a6 factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13744
diff changeset
700 }
5568586d32a6 factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13744
diff changeset
701 }
5568586d32a6 factor out listener notify. fix typo
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13744
diff changeset
702
5487
9743ae819f73 Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5485
diff changeset
703 public void replaceAtPredecessor(Node other) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
704 assert checkReplaceWith(other);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
705 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
706 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
707 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
708 predecessor.updatePredecessor(this, other);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
709 }
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
712 public void replaceAndDelete(Node other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
713 assert checkReplaceWith(other);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
714 if (other != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
715 clearSuccessors();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
716 replaceAtUsages(other);
5487
9743ae819f73 Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5485
diff changeset
717 replaceAtPredecessor(other);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
718 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
719 safeDelete();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
720 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
721
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
722 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
723 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
724 updatePredecessor(oldSuccessor, newSuccessor);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
725 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
726 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
727
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
728 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
729 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
730 updateUsages(oldInput, newInput);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
731 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
732 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
733
16101
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
734 private void unregisterInputs() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
735 for (Node input : inputs()) {
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
736 removeThisFromUsages(input);
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
737 if (input.usages().isEmpty()) {
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
738 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
739 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
740 }
16101
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
741 }
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
742
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
743 public void clearInputs() {
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
744 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
745
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
746 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
747 getNodeClass().getEdges(Inputs).clear(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
748 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
749
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
750 private boolean removeThisFromUsages(Node n) {
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
751 return n.removeUsage(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
752 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
753
16101
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
754 private void unregisterSuccessors() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
755 for (Node successor : successors()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
756 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
757 successor.predecessor = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
758 }
16101
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
759 }
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
760
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
761 public void clearSuccessors() {
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
762 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
763
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
764 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
765 getNodeClass().getEdges(Successors).clear(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
766 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
767
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
768 private boolean checkDeletion() {
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
769 assertTrue(usages().isEmpty(), "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
770 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
771 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
772 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
773
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
774 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
775 * 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
776 * 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
777 */
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
778 public void safeDelete() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
779 assert checkDeletion();
16101
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
780 unregisterInputs();
99e2e006ade2 do not zap inputs and successors in Node.safeDelete
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15827
diff changeset
781 unregisterSuccessors();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
782 graph.unregister(this);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
783 id = DELETED_ID_START - id;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
784 assert isDeleted();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
785 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
786
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
787 public final Node copyWithInputs() {
17353
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
788 return copyWithInputs(true);
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
789 }
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
790
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
791 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
792 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
793 if (insertIntoGraph) {
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
794 for (Node input : inputs()) {
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
795 input.addUsage(newNode);
90dc742e8cc7 Re-add insertIntoGraph argument to Node.copyWithInputs method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17347
diff changeset
796 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
797 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
798 return newNode;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
799 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
800
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
801 /**
11940
87402d9a67ca spelling fix
Doug Simon <doug.simon@oracle.com>
parents: 11891
diff changeset
802 * 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
803 * {@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
804 * {@link Simplifiable#simplify(SimplifierTool)}.
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
805 *
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
806 * @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
807 */
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
808 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
809 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
810 }
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
811
17338
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
812 /**
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
813 * @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
814 * 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
815 * @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
816 * @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
817 * cleared
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
818 */
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
819 private void copyOrClearEdgesForClone(NodeClass nodeClass, Node newNode, Edges.Type type, EnumSet<Edges.Type> edgesToCopy) {
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
820 if (edgesToCopy.contains(type)) {
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
821 nodeClass.getEdges(type).copy(this, newNode);
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
822 } else {
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
823 if (USE_UNSAFE_TO_CLONE) {
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
824 // The direct edges are already null
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
825 nodeClass.getEdges(type).initializeLists(newNode, this);
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
826 } else {
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
827 nodeClass.getEdges(type).clear(newNode);
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
828 }
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
829 }
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
830 }
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
831
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
832 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
833 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
834 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
835 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
836
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
837 /**
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
838 * 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
839 *
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
840 * @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
841 * 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
842 * @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
843 * 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
844 * list for an edge list)
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
845 * @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
846 */
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
847 final Node clone(Graph into, EnumSet<Edges.Type> edgesToCopy) {
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
848 NodeClass nodeClass = 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
849 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
850 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
851 if (nodeClass.valueNumberable() && nodeClass.isLeafNode()) {
63780e37b7b9 re-added support for cloning a node without adding it to a graph
Doug Simon <doug.simon@oracle.com>
parents: 17346
diff changeset
852 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
853 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
854 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
855 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
856 }
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
857 }
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
858 }
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
859
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
860 Node newNode = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
861 try {
17338
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
862 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
863 newNode = (Node) UnsafeAccess.unsafe.allocateInstance(getClass());
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
864 nodeClass.getData().copy(this, newNode);
17338
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
865 copyOrClearEdgesForClone(nodeClass, newNode, Inputs, edgesToCopy);
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
866 copyOrClearEdgesForClone(nodeClass, 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
867 } 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
868 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
869 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
870 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
871 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
872 newNode.predecessor = null;
17338
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
873 copyOrClearEdgesForClone(nodeClass, newNode, Inputs, edgesToCopy);
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17329
diff changeset
874 copyOrClearEdgesForClone(nodeClass, 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
875 }
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
876 } catch (Exception e) {
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15153
diff changeset
877 throw new GraalGraphInternalError(e).addContext(this);
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 newNode.graph = into;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
880 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
881 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
882 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
883 }
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
884 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
885
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
886 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
887 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
888 }
11677
9d341b6e47e5 Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11676
diff changeset
889 newNode.afterClone(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
890 return newNode;
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
11677
9d341b6e47e5 Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11676
diff changeset
893 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
894 }
9d341b6e47e5 Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11676
diff changeset
895
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
896 public boolean verify() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
897 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
898 assertTrue(graph() != null, "null graph");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
899 for (Node input : inputs()) {
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
900 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
901 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
902 for (Node successor : successors()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
903 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
904 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
905 }
17064
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
906 for (Node usage : usages()) {
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
907 assertFalse(usage.isDeleted(), "usage %s must never be deleted", usage);
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
908 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
909 NodePosIterator iterator = usage.inputs().iterator();
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
910 while (iterator.hasNext()) {
3c54a098455f removed Node.recordsUsages()
Doug Simon <doug.simon@oracle.com>
parents: 17061
diff changeset
911 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
912 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
913 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
914 }
12570
af39ea2dc39d made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12437
diff changeset
915 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
916 }
17008
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16982
diff changeset
917 NodePosIterator iterator = inputs().withNullIterator();
16332
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16241
diff changeset
918 while (iterator.hasNext()) {
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16241
diff changeset
919 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
920 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
921 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
922 if (predecessor != null) {
12723
bbf6407458ee Node: print node in assert
Bernhard Urban <bernhard.urban@jku.at>
parents: 12686
diff changeset
923 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
924 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
925 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
926 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
927 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
928
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
929 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
930 if (condition) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
931 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
932 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
933 throw new VerificationError(message, args).addContext(this);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
934 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
935 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
936
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
937 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
938 if (condition) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
939 throw new VerificationError(message, args).addContext(this);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
940 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
941 return true;
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
944
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
945 public Iterable<? extends Node> cfgPredecessors() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
946 if (predecessor == null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
947 return Collections.emptySet();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
948 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
949 return Collections.singleton(predecessor);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
950 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
951 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
952
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
953 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
954 * 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
955 * 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
956 * 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
957 * fields contain them.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
958 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
959 public Iterable<? extends Node> cfgSuccessors() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
960 return successors();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
961 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
962
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
963 /**
13320
c258331fdde6 removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13140
diff changeset
964 * 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
965 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
966 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
967 public final int hashCode() {
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12570
diff changeset
968 return System.identityHashCode(this);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
969 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
970
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
971 /**
13320
c258331fdde6 removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 13140
diff changeset
972 * Equality tests must rely solely on identity.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
973 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
974 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
975 public final boolean equals(Object obj) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
976 return super.equals(obj);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
977 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
978
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
979 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
980 * 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
981 * ideal graph visualizer).
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
982 */
9495
6ad0bdcd76aa make Node.getDebugProperties() final
Lukas Stadler <lukas.stadler@jku.at>
parents: 9332
diff changeset
983 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
984 return getDebugProperties(new HashMap<>());
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
985 }
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
986
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
987 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7521
diff changeset
988 * 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
989 * 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
990 * their superclass.
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14577
diff changeset
991 *
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
992 * @param map
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
993 */
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
994 public Map<Object, Object> getDebugProperties(Map<Object, Object> map) {
15827
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15381
diff changeset
995 NodeClass nodeClass = getNodeClass();
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17214
diff changeset
996 Fields properties = nodeClass.getData();
17214
a552dd335bde generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents: 17210
diff changeset
997 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
998 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
999 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1000 return map;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1001 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1002
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1003 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1004 * 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
1005 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1006 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1007 public final String toString() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1008 return toString(Verbosity.Short);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1009 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1010
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1011 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1012 * 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
1013 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1014 public String toString(Verbosity verbosity) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1015 switch (verbosity) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1016 case Id:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1017 return Integer.toString(id);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1018 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
1019 return getNodeClass().shortName();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1020 case Short:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1021 return toString(Verbosity.Id) + "|" + toString(Verbosity.Name);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1022 case Long:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1023 return toString(Verbosity.Short);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1024 case Debugger:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1025 case All: {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1026 StringBuilder str = new StringBuilder();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1027 str.append(toString(Verbosity.Short)).append(" { ");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1028 for (Map.Entry<Object, Object> entry : getDebugProperties().entrySet()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1029 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
1030 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1031 str.append(" }");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1032 return str.toString();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1033 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1034 default:
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1035 throw new RuntimeException("unknown verbosity: " + verbosity);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1036 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1037 }
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
1038
5810
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
1039 @Deprecated
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
1040 public int getId() {
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
1041 return id;
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
1042 }
bc237d8b6f99 Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5806
diff changeset
1043
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
1044 @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
1045 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
1046 if ((flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE) {
4418
46e9068c09b4 small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents: 4397
diff changeset
1047 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
1048 } 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
1049 // 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
1050 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
1051 } else {
4418
46e9068c09b4 small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents: 4397
diff changeset
1052 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
1053 }
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
1054
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
1055 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
1056 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
1057 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
1058 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
1059 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
1060 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
1061 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
1062 }
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
1063
17008
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16982
diff changeset
1064 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
1065 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
1066 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
1067 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
1068 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
1069 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
1070 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
1071 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
1072 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
1073 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
1074 }
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
1075 }
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
1076 }
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
1077
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
1078 if (precision > 0) {
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
1079 if (!usages().isEmpty()) {
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
1080 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
1081 int z = 0;
11528
8f500c7a510a inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11524
diff changeset
1082 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
1083 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
1084 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
1085 }
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
1086 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
1087 ++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
1088 }
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
1089 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
1090 }
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
1091
17008
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16982
diff changeset
1092 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
1093 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
1094 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
1095 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
1096 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
1097 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
1098 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
1099 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
1100 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
1101 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
1102 }
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
1103 }
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
1104 }
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
1105 }
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
1106
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
1107 /**
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
1108 * 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
1109 * 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
1110 * 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
1111 *
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17305
diff changeset
1112 * 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
1113 *
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
1114 * @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
1115 * @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
1116 */
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
1117 public boolean valueEquals(Node other) {
17450
45b45f902bed removed Node generation (GRAAL-857)
Doug Simon <doug.simon@oracle.com>
parents: 17355
diff changeset
1118 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
1119 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1120 }