Mercurial > hg > truffle
annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java @ 12361:ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 11 Oct 2013 21:58:41 +0200 |
parents | 87402d9a67ca |
children | c991f8291f1b |
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 |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
25 import static com.oracle.graal.graph.Graph.*; |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
26 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
27 import java.lang.annotation.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
28 import java.util.*; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
29 |
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
|
30 import com.oracle.graal.graph.Graph.NodeChangedListener; |
11486
5d5bfb75dae0
added metrics for total number of Nodes, LIRInstructions and CompositeValues created (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents:
11431
diff
changeset
|
31 import com.oracle.graal.graph.NodeClass.NodeClassIterator; |
5d5bfb75dae0
added metrics for total number of Nodes, LIRInstructions and CompositeValues created (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents:
11431
diff
changeset
|
32 import com.oracle.graal.graph.NodeClass.Position; |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
33 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
|
34 import com.oracle.graal.graph.spi.*; |
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
|
35 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
36 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
37 * This class is the base class for all nodes, it represent a node which can be inserted in a |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
38 * {@link Graph}. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
39 * <p> |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
40 * 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
|
41 * 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
|
42 * {@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
|
43 * {@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
|
44 * this field points to. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
45 * <p> |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
46 * Nodes which are be value numberable should implement the {@link ValueNumberable} interface. |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
47 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
48 * <h1>Assertions and Verification</h1> |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
49 * |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
50 * 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
|
51 * {@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
|
52 * 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
|
53 * 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
|
54 * only performed if assertions are enabled. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
55 */ |
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
|
56 public abstract class Node implements Cloneable, Formattable { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
57 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
58 static final int DELETED_ID_START = -1000000000; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
59 static final int INITIAL_ID = -1; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
60 static final int ALIVE_ID_START = 0; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
61 |
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
|
62 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
63 * Denotes a node input. This should be applied to exactly the fields of a node that are of type |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
64 * {@link Node}. Nodes that update their inputs outside of their constructor should call |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
65 * {@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
|
66 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
67 @Retention(RetentionPolicy.RUNTIME) |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
68 @Target(ElementType.FIELD) |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
69 public static @interface Input { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
70 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
71 boolean notDataflow() default false; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
72 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
73 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
74 @Retention(RetentionPolicy.RUNTIME) |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
75 @Target(ElementType.FIELD) |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
76 public static @interface Successor { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
77 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
78 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
79 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
80 * 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
|
81 * 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
|
82 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
83 @Retention(RetentionPolicy.RUNTIME) |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
84 @Target(ElementType.PARAMETER) |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
85 public static @interface ConstantNodeParameter { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
86 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
87 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
88 /** |
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
|
89 * 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
|
90 * 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
|
91 * 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
|
92 * 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
|
93 */ |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
94 @Retention(RetentionPolicy.RUNTIME) |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
95 @Target(ElementType.PARAMETER) |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
96 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
|
97 } |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
98 |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
99 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
100 * 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
|
101 * 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
|
102 * {@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
|
103 * signature (excluding a prefix of {@linkplain InjectedNodeParameter injected} parameters) of a |
ec57cc36371e
introduced @InjectedNodeParameter annotation to make injection of arguments during node intrinsification more extensible
Doug Simon <doug.simon@oracle.com>
parents:
11940
diff
changeset
|
104 * constructor in the node class. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
105 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
106 @Retention(RetentionPolicy.RUNTIME) |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
107 @Target(ElementType.METHOD) |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
108 public static @interface NodeIntrinsic { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
109 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
110 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
111 * 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
|
112 * 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
|
113 * 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
|
114 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
115 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
|
116 |
b74402a7079b
fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents:
5823
diff
changeset
|
117 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
118 * 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
|
119 * 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
|
120 * <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
|
121 * 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
|
122 * 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
|
123 */ |
b74402a7079b
fixed oopmap bug caused by unsafe mixing of word and object values
Doug Simon <doug.simon@oracle.com>
parents:
5823
diff
changeset
|
124 boolean setStampFromReturnType() default false; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
125 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
126 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
127 public interface ValueNumberable { |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
128 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
129 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
130 private Graph graph; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
131 int id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
132 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
133 // 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
|
134 // 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
|
135 Node typeCacheNext; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
136 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
137 private static final int INLINE_USAGE_COUNT = 2; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
138 private static final Node[] NO_NODES = {}; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
139 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
140 /** |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
141 * 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
|
142 * {@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
|
143 */ |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
144 private Node usage0; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
145 private Node usage1; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
146 private Node[] extraUsages = NO_NODES; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
147 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
148 private Node predecessor; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
149 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
150 public Node() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
151 this.graph = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
152 this.id = INITIAL_ID; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
153 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
154 |
4589
c148bec9398a
Fixed computation of exact type information in PhiStampPhase.
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4418
diff
changeset
|
155 protected int id() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
156 return id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
157 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
158 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
159 public Graph graph() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
160 return graph; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
161 } |
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 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
164 * 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
|
165 * input edges of this node. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
166 * |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
167 * @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
|
168 */ |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
169 public NodeClassIterable inputs() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
170 return getNodeClass().getInputIterable(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
171 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
172 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
174 * 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
|
175 * successor edges of this node. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
176 * |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
177 * @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
|
178 */ |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
179 public NodeClassIterable successors() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
180 return getNodeClass().getSuccessorIterable(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
181 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
182 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
183 class NodeUsageIterator implements Iterator<Node> { |
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 private final int expectedModCount = usageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
186 int index = -1; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
187 Node current; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
188 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
189 private void advance() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
190 assert index == -1 || current != null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
191 current = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
192 index++; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
193 if (index == 0) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
194 current = usage0; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
195 } else if (index == 1) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
196 current = usage1; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
197 } else { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
198 if (index - INLINE_USAGE_COUNT < extraUsages.length) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
199 current = extraUsages[index - INLINE_USAGE_COUNT]; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
200 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
201 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
202 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
203 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
204 public NodeUsageIterator() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
205 advance(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
206 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
207 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
208 public boolean hasNext() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
209 assert expectedModCount == usageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
210 return current != null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
211 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
212 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
213 public Node next() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
214 assert expectedModCount == usageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
215 Node result = current; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
216 if (result == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
217 throw new NoSuchElementException(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
218 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
219 advance(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
220 return result; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
221 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
222 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
223 public void remove() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
224 throw new UnsupportedOperationException(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
225 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
226 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
227 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
228 class NodeUsageIterable extends AbstractNodeIterable<Node> { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
229 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
230 public NodeUsageIterator iterator() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
231 return new NodeUsageIterator(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
232 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
233 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
234 @Override |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
235 public boolean isEmpty() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
236 return usage0 == null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
237 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
238 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
239 @Override |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
240 public boolean isNotEmpty() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
241 return usage0 != null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
242 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
243 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
244 @Override |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
245 public int count() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
246 if (usage0 == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
247 return 0; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
248 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
249 if (usage1 == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
250 return 1; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
251 } |
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
|
252 return 2 + indexOfLastNonNull(extraUsages) + 1; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
253 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
254 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
255 |
11654
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
256 int getUsageCountUpperBound() { |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
257 if (usage0 == null) { |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
258 return 0; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
259 } |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
260 if (usage1 == null) { |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
261 return 1; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
262 } |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
263 return 2 + extraUsages.length; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
264 } |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
265 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
266 /** |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
267 * Gets the list of nodes that use this node (e.g., as an input). |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
268 */ |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
269 public final NodeIterable<Node> usages() { |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
270 return new NodeUsageIterable(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
271 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
272 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
273 /** |
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
|
274 * 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
|
275 * non-null entries precede the first null entry in the array. |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
276 * |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
277 * @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
|
278 * @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
|
279 */ |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
280 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
|
281 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
|
282 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
|
283 } |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
284 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
|
285 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
|
286 } |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
287 |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
288 // 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
|
289 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
|
290 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
|
291 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
|
292 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
|
293 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
|
294 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
|
295 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
|
296 } |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
297 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
|
298 } 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
|
299 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
|
300 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
|
301 } |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
302 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
|
303 } |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
304 } |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
305 } |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
306 |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
307 /** |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
308 * Adds a given node to this node's {@linkplain #usages() usages}. |
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 * @param node the node to add |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
311 */ |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
312 private void addUsage(Node node) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
313 incUsageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
314 if (usage0 == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
315 usage0 = node; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
316 } else if (usage1 == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
317 usage1 = node; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
318 } else { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
319 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
|
320 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
|
321 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
|
322 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
|
323 } 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
|
324 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
|
325 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
|
326 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
|
327 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
|
328 } 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
|
329 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
|
330 } 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
|
331 extraUsages[lastNonNull + 1] = node; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
332 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
333 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
334 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
335 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
336 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
337 /** |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
338 * Removes a given node from this node's {@linkplain #usages() usages}. |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
339 * |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
340 * @param node the node to remove |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
341 * @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
|
342 */ |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
343 private boolean removeUsage(Node node) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
344 // 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
|
345 // 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
|
346 incUsageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
347 if (usage0 == node) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
348 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
|
349 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
|
350 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
|
351 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
|
352 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
|
353 } 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
|
354 // 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
|
355 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
|
356 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
|
357 } |
11531
331f7590b741
modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11528
diff
changeset
|
358 } else { |
331f7590b741
modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11528
diff
changeset
|
359 // 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
|
360 usage0 = null; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
361 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
362 return true; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
363 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
364 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
|
365 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
|
366 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
|
367 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
|
368 extraUsages[lastNonNull] = null; |
11531
331f7590b741
modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11528
diff
changeset
|
369 } else { |
331f7590b741
modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11528
diff
changeset
|
370 // 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
|
371 usage1 = null; |
331f7590b741
modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11528
diff
changeset
|
372 } |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
373 return true; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
374 } |
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
|
375 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
|
376 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
|
377 for (int i = 0; i <= lastNonNull; ++i) { |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
378 Node n = extraUsages[i]; |
11531
331f7590b741
modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11528
diff
changeset
|
379 if (n == 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
|
380 if (i < 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
|
381 extraUsages[i] = 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
|
382 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
|
383 } 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
|
384 extraUsages[i] = 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
|
385 } |
11531
331f7590b741
modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11528
diff
changeset
|
386 return true; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
387 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
388 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
389 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
390 return false; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
391 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
392 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
393 private void clearUsages() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
394 incUsageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
395 usage0 = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
396 usage1 = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
397 extraUsages = NO_NODES; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
398 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
399 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
400 public final Node predecessor() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
401 return predecessor; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
402 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
403 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
404 final int modCount() { |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
405 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
406 return graph.modCount(this); |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
407 } |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
408 return 0; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
409 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
410 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
411 final void incModCount() { |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
412 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
413 graph.incModCount(this); |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
414 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
415 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
416 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
417 final int usageModCount() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
418 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
419 return graph.usageModCount(this); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
420 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
421 return 0; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
422 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
423 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
424 final void incUsageModCount() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
425 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
426 graph.incUsageModCount(this); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
427 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
428 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
429 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
430 public boolean isDeleted() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
431 return id <= DELETED_ID_START; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
432 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
433 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
434 public boolean isAlive() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
435 return id >= ALIVE_ID_START; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
436 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
437 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
438 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
439 * Updates the usages sets of the given nodes after an input slot is changed from oldInput to |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
440 * newInput: removes this node from oldInput's usages and adds this node to newInput's usages. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
441 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
442 protected void updateUsages(Node oldInput, Node newInput) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
443 if (oldInput != newInput) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
444 if (oldInput != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
445 boolean result = removeThisFromUsages(oldInput); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
446 assert assertTrue(result, "not found in usages, old input: %s", oldInput); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
447 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
448 if (newInput != null) { |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
449 NodeChangedListener listener = graph.inputChangedListener; |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
450 if (listener != null) { |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
451 listener.nodeChanged(this); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4418
diff
changeset
|
452 } |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
453 newInput.addUsage(this); |
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
|
454 } else if (oldInput != null && oldInput.usages().isEmpty()) { |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
455 NodeChangedListener listener = graph.usagesDroppedToZeroListener; |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
456 if (listener != null) { |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
457 listener.nodeChanged(oldInput); |
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
|
458 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
459 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
460 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
461 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
462 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
463 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
464 * 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
|
465 * 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
|
466 * this node to newSuccessor's predecessors. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
467 */ |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
468 protected void updatePredecessor(Node oldSuccessor, Node newSuccessor) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
469 if (oldSuccessor != newSuccessor) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
470 if (oldSuccessor != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
471 assert assertTrue(oldSuccessor.predecessor == this, "wrong predecessor in old successor (%s): %s", oldSuccessor, oldSuccessor.predecessor); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
472 oldSuccessor.predecessor = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
473 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
474 if (newSuccessor != null) { |
11676
435c8b984680
Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11674
diff
changeset
|
475 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
|
476 newSuccessor.predecessor = this; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
477 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
478 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
479 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
480 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
481 void initialize(Graph newGraph) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
482 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
|
483 this.graph = newGraph; |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
484 newGraph.register(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
485 for (Node input : inputs()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
486 updateUsages(null, input); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
487 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
488 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
|
489 updatePredecessor(null, successor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
490 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
491 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
492 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
493 public final NodeClass getNodeClass() { |
11431
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9495
diff
changeset
|
494 return NodeClass.get(getClass()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
495 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
496 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
497 private boolean checkReplaceWith(Node other) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
498 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
|
499 assert assertFalse(isDeleted(), "cannot replace deleted node"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
500 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
|
501 assert assertTrue(other == null || other.graph() == graph, "cannot replace with node in different graph: %s", other == null ? null : other.graph()); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
502 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
503 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
504 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
505 public void replaceAtUsages(Node other) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
506 assert checkReplaceWith(other); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
507 for (Node usage : usages()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
508 boolean result = usage.getNodeClass().replaceFirstInput(usage, this, other); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
509 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
|
510 if (other != null) { |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
511 NodeChangedListener listener = graph.inputChangedListener; |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
512 if (listener != null) { |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
513 listener.nodeChanged(usage); |
5162
3ac351ed7270
Fix for canonicalizer : some input changes were not tracked leading to canonicalization misses
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5061
diff
changeset
|
514 } |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
515 other.addUsage(usage); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
516 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
517 } |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
518 clearUsages(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
519 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
520 |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
521 public void replaceAtPredecessor(Node other) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
522 assert checkReplaceWith(other); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
523 if (predecessor != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
524 boolean result = predecessor.getNodeClass().replaceFirstSuccessor(predecessor, this, other); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
525 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
|
526 predecessor.updatePredecessor(this, other); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
527 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
528 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
529 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
530 public void replaceAndDelete(Node other) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
531 assert checkReplaceWith(other); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
532 if (other != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
533 clearSuccessors(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
534 replaceAtUsages(other); |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
535 replaceAtPredecessor(other); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
536 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
537 safeDelete(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
538 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
539 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
540 public void replaceFirstSuccessor(Node oldSuccessor, Node newSuccessor) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
541 if (getNodeClass().replaceFirstSuccessor(this, oldSuccessor, newSuccessor)) { |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
542 updatePredecessor(oldSuccessor, newSuccessor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
543 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
544 } |
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 public void replaceFirstInput(Node oldInput, Node newInput) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
547 if (getNodeClass().replaceFirstInput(this, oldInput, newInput)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
548 updateUsages(oldInput, newInput); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
552 public void clearInputs() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
553 assert assertFalse(isDeleted(), "cannot clear inputs of deleted node"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
554 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
555 for (Node input : inputs()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
556 removeThisFromUsages(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
|
557 if (input.usages().isEmpty()) { |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
558 NodeChangedListener listener = graph.usagesDroppedToZeroListener; |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
559 if (listener != null) { |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
560 listener.nodeChanged(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
|
561 } |
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
|
562 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
563 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
564 getNodeClass().clearInputs(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
565 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
566 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
567 private boolean removeThisFromUsages(Node n) { |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
568 return n.removeUsage(this); |
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 public void clearSuccessors() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
572 assert assertFalse(isDeleted(), "cannot clear successors of deleted node"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
573 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
574 for (Node successor : successors()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
575 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
|
576 successor.predecessor = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
577 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
578 getNodeClass().clearSuccessors(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
579 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
580 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
581 private boolean checkDeletion() { |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
582 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
|
583 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
|
584 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
585 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
586 |
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
|
587 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
588 * 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
|
589 * 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
|
590 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
591 public void safeDelete() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
592 assert checkDeletion(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
593 clearInputs(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
594 clearSuccessors(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
595 graph.unregister(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
596 id = DELETED_ID_START - id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
597 assert isDeleted(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
598 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
599 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
600 public final Node copyWithInputs() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
601 Node newNode = clone(graph); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
602 NodeClass clazz = getNodeClass(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
603 clazz.copyInputs(this, newNode); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
604 for (Node input : inputs()) { |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
605 input.addUsage(newNode); |
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 return newNode; |
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 |
11677
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
610 public final Node clone(Graph into) { |
11674
8505bcff4bdc
New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11666
diff
changeset
|
611 return clone(into, true); |
8505bcff4bdc
New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11666
diff
changeset
|
612 } |
8505bcff4bdc
New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11666
diff
changeset
|
613 |
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
|
614 /** |
11940 | 615 * Must be overridden by subclasses that implement {@link Canonicalizable}. The implementation |
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
|
616 * in {@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
|
617 * {@link Canonicalizable#canonical(CanonicalizerTool)}. |
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
|
618 * |
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
|
619 * @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
|
620 */ |
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
|
621 public Node canonical(CanonicalizerTool 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
|
622 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
|
623 } |
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
|
624 |
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
|
625 /** |
11940 | 626 * 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
|
627 * {@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
|
628 * {@link Simplifiable#simplify(SimplifierTool)}. |
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
|
629 * |
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
|
630 * @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
|
631 */ |
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
|
632 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
|
633 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
|
634 } |
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
|
635 |
11677
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
636 final Node clone(Graph into, boolean clearInputsAndSuccessors) { |
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
|
637 NodeClass nodeClass = getNodeClass(); |
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
|
638 if (nodeClass.valueNumberable() && nodeClass.isLeafNode()) { |
64a9ed9f1e8d
Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
639 Node otherNode = into.findNodeInCache(this); |
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
|
640 if (otherNode != null) { |
64a9ed9f1e8d
Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
641 return otherNode; |
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
|
642 } |
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
|
643 } |
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
|
644 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
645 Node newNode = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
646 try { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
647 newNode = (Node) this.clone(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
648 } catch (CloneNotSupportedException e) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
649 throw new GraalInternalError(e).addContext(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
650 } |
11674
8505bcff4bdc
New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11666
diff
changeset
|
651 if (clearInputsAndSuccessors) { |
8505bcff4bdc
New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11666
diff
changeset
|
652 nodeClass.clearInputs(newNode); |
8505bcff4bdc
New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11666
diff
changeset
|
653 nodeClass.clearSuccessors(newNode); |
8505bcff4bdc
New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11666
diff
changeset
|
654 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
655 newNode.graph = into; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
656 newNode.typeCacheNext = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
657 newNode.id = INITIAL_ID; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
658 into.register(newNode); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
659 newNode.usage0 = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
660 newNode.usage1 = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
661 newNode.extraUsages = NO_NODES; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
662 newNode.predecessor = null; |
11653
64a9ed9f1e8d
Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
663 |
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
|
664 if (nodeClass.valueNumberable() && nodeClass.isLeafNode()) { |
64a9ed9f1e8d
Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11631
diff
changeset
|
665 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
|
666 } |
11677
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
667 newNode.afterClone(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
668 return newNode; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
669 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
670 |
11677
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
671 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
|
672 } |
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
673 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
674 public boolean verify() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
675 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
|
676 assertTrue(graph() != null, "null graph"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
677 for (Node input : inputs()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
678 assertTrue(input.usages().contains(this), "missing usage in input %s", input); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
679 assertTrue(input.graph() == graph(), "mismatching graph in input %s", input); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
680 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
681 for (Node successor : successors()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
682 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
|
683 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
|
684 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
685 for (Node usage : usages()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
686 assertFalse(usage.isDeleted(), "usage must never be deleted"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
687 assertTrue(usage.inputs().contains(this), "missing input in usage %s", usage); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
688 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
689 if (predecessor != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
690 assertFalse(predecessor.isDeleted(), "predecessor must never be deleted"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
691 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
|
692 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
693 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
694 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
695 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
696 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
|
697 if (condition) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
698 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
699 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
700 throw new VerificationError(message, args).addContext(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
701 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
702 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
703 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
704 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
|
705 if (condition) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
706 throw new VerificationError(message, args).addContext(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
707 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
708 return true; |
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 Iterable<? extends Node> cfgPredecessors() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
713 if (predecessor == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
714 return Collections.emptySet(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
715 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
716 return Collections.singleton(predecessor); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
717 } |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
720 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
721 * 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
|
722 * 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
|
723 * 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
|
724 * fields contain them. |
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 public Iterable<? extends Node> cfgSuccessors() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
727 return successors(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
728 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
729 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
730 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
731 * hashCode and equals should always rely on object identity alone, thus hashCode and equals are |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
732 * final. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
733 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
734 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
735 public final int hashCode() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
736 return super.hashCode(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
737 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
738 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
739 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
740 * hashCode and equals should always rely on object identity alone, thus hashCode and equals are |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
741 * final. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
742 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
743 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
744 public final boolean equals(Object obj) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
745 return super.equals(obj); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
746 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
747 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
748 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
749 * 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
|
750 * ideal graph visualizer). |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
751 */ |
9495
6ad0bdcd76aa
make Node.getDebugProperties() final
Lukas Stadler <lukas.stadler@jku.at>
parents:
9332
diff
changeset
|
752 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
|
753 return getDebugProperties(new HashMap<>()); |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
754 } |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
755 |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
756 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
757 * 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
|
758 * 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
|
759 * their superclass. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
760 * |
5813
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
761 * @param map |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
762 */ |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
763 public Map<Object, Object> getDebugProperties(Map<Object, Object> map) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
764 getNodeClass().getDebugProperties(this, map); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
765 return map; |
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 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
769 * 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
|
770 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
771 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
772 public final String toString() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
773 return toString(Verbosity.Short); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
774 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
775 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
776 public enum Verbosity { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
777 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
778 * Only the id of the node. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
779 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
780 Id, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
781 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
782 * Only the name of the node, which may contain some more information for certain node types |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
783 * (constants, ...). |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
784 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
785 Name, |
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 * {@link #Id} + {@link #Name}. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
788 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
789 Short, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
790 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
791 * Defaults to {@link #Short} and may be enhanced by subclasses. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
792 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
793 Long, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
794 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
795 * For use by a custom formatting facility in an IDE. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
796 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
797 Debugger, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
798 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
799 * All the other information plus all debug properties of the node. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
800 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
801 All |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
802 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
803 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
804 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
805 * 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
|
806 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
807 public String toString(Verbosity verbosity) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
808 switch (verbosity) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
809 case Id: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
810 return Integer.toString(id); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
811 case Name: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
812 return getNodeClass().shortName(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
813 case Short: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
814 return toString(Verbosity.Id) + "|" + toString(Verbosity.Name); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
815 case Long: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
816 return toString(Verbosity.Short); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
817 case Debugger: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
818 case All: { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
819 StringBuilder str = new StringBuilder(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
820 str.append(toString(Verbosity.Short)).append(" { "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
821 for (Map.Entry<Object, Object> entry : getDebugProperties().entrySet()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
822 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
|
823 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
824 str.append(" }"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
825 return str.toString(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
826 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
827 default: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
828 throw new RuntimeException("unknown verbosity: " + verbosity); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
829 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
830 } |
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
|
831 |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
832 @Deprecated |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
833 public int getId() { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
834 return id; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
835 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
836 |
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
|
837 @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
|
838 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
|
839 if ((flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE) { |
4418
46e9068c09b4
small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents:
4397
diff
changeset
|
840 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
|
841 } else if ((flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE) { |
4418
46e9068c09b4
small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents:
4397
diff
changeset
|
842 formatter.format("%s", toString(Verbosity.Long)); |
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
|
843 } else { |
4418
46e9068c09b4
small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents:
4397
diff
changeset
|
844 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
|
845 } |
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
|
846 |
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
|
847 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
|
848 int neighborsFlags = (neighborsAlternate ? FormattableFlags.ALTERNATE | FormattableFlags.LEFT_JUSTIFY : 0); |
11666
3967f9f306f8
Factor usages of getNodeClass().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11654
diff
changeset
|
849 NodeClass nodeClass = getNodeClass(); |
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
|
850 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
|
851 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
|
852 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
|
853 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
|
854 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
|
855 } |
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
|
856 |
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
|
857 NodeClassIterator inputIter = inputs().iterator(); |
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
|
858 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
|
859 Position position = inputIter.nextPosition(); |
11666
3967f9f306f8
Factor usages of getNodeClass().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11654
diff
changeset
|
860 Node input = nodeClass.get(this, position); |
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
|
861 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
|
862 formatter.format(" "); |
11666
3967f9f306f8
Factor usages of getNodeClass().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11654
diff
changeset
|
863 formatter.format(nodeClass.getName(position)); |
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
|
864 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
|
865 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
|
866 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
|
867 } |
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
|
868 } |
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
|
869 } |
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
|
870 |
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
|
871 if (precision > 0) { |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
872 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
|
873 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
|
874 int z = 0; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
875 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
|
876 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
|
877 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
|
878 } |
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
|
879 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
|
880 ++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
|
881 } |
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
|
882 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
|
883 } |
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
|
884 |
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
|
885 NodeClassIterator succIter = successors().iterator(); |
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
|
886 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
|
887 Position position = succIter.nextPosition(); |
11666
3967f9f306f8
Factor usages of getNodeClass().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11654
diff
changeset
|
888 Node successor = nodeClass.get(this, position); |
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
|
889 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
|
890 formatter.format(" "); |
11666
3967f9f306f8
Factor usages of getNodeClass().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11654
diff
changeset
|
891 formatter.format(nodeClass.getName(position)); |
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
|
892 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
|
893 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
|
894 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
|
895 } |
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
|
896 } |
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
|
897 } |
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
|
898 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
899 } |