Mercurial > hg > truffle
annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java @ 13744:d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Thu, 23 Jan 2014 16:15:04 -0800 |
parents | c258331fdde6 |
children | 5568586d32a6 |
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 |
12686
ca8ab182026f
abstracted a graph mark as a Mark object (hiding the node index)
Doug Simon <doug.simon@oracle.com>
parents:
12655
diff
changeset
|
155 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 |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
159 /** |
13327
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13140
diff
changeset
|
160 * Gets the graph context of this node. |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
161 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
162 public Graph graph() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
163 return graph; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
164 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
165 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
166 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
167 * 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
|
168 * input edges of this node. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
169 * |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
170 * @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
|
171 */ |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
172 public NodeClassIterable inputs() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
173 return getNodeClass().getInputIterable(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
174 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
175 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
176 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
177 * 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
|
178 * successor edges of this node. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
179 * |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
180 * @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
|
181 */ |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
182 public NodeClassIterable successors() { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
183 return getNodeClass().getSuccessorIterable(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
184 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
185 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
186 class NodeUsageIterator implements Iterator<Node> { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
187 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
188 private final int expectedModCount = usageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
189 int index = -1; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
190 Node current; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
191 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
192 private void advance() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
193 assert index == -1 || current != null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
194 current = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
195 index++; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
196 if (index == 0) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
197 current = usage0; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
198 } else if (index == 1) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
199 current = usage1; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
200 } else { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
201 if (index - INLINE_USAGE_COUNT < extraUsages.length) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
202 current = extraUsages[index - INLINE_USAGE_COUNT]; |
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 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
205 } |
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 public NodeUsageIterator() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
208 advance(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
209 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
210 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
211 public boolean hasNext() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
212 assert expectedModCount == usageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
213 return current != null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
214 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
215 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
216 public Node next() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
217 assert expectedModCount == usageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
218 Node result = current; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
219 if (result == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
220 throw new NoSuchElementException(); |
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 advance(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
223 return result; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
224 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
225 |
12437
c991f8291f1b
add missing @Override to Iterator.remove overrides
twisti
parents:
12361
diff
changeset
|
226 @Override |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
227 public void remove() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
228 throw new UnsupportedOperationException(); |
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 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
231 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
232 class NodeUsageIterable extends AbstractNodeIterable<Node> { |
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 public NodeUsageIterator iterator() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
235 return new NodeUsageIterator(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
236 } |
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 @Override |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
239 public boolean isEmpty() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
240 return usage0 == null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
241 } |
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 @Override |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
244 public boolean isNotEmpty() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
245 return usage0 != null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
246 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
247 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
248 @Override |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
249 public int count() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
250 if (usage0 == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
251 return 0; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
252 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
253 if (usage1 == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
254 return 1; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
255 } |
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
|
256 return 2 + indexOfLastNonNull(extraUsages) + 1; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
257 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
258 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
259 |
11654
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
260 int getUsageCountUpperBound() { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
261 assert recordsUsages(); |
11654
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
262 if (usage0 == null) { |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
263 return 0; |
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 if (usage1 == null) { |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
266 return 1; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
267 } |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
268 return 2 + extraUsages.length; |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
269 } |
317036da1f29
Improve global value numbering algorithm.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11653
diff
changeset
|
270 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
271 /** |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
272 * Gets the list of nodes that use this node (i.e., as an input). |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
273 */ |
7123
b914b9b4c578
graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
6458
diff
changeset
|
274 public final NodeIterable<Node> usages() { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
275 assert recordsUsages() : this; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
276 return new NodeUsageIterable(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
277 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
278 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
279 /** |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
280 * Determines if this node records its usages (i.e. the nodes for which it is an input). All |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
281 * methods in {@link Node} that pertain to querying or updating usage information must not be |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
282 * called for a {@link Node} instance that returns false for this method. |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
283 */ |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
284 public boolean recordsUsages() { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
285 return true; |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
286 } |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
287 |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
288 /** |
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
|
289 * 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
|
290 * 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
|
291 * |
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 * @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
|
293 * @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
|
294 */ |
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 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
|
296 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
|
297 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
|
298 } |
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 (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
|
300 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
|
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 |
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 // 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
|
304 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
|
305 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
|
306 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
|
307 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
|
308 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
|
309 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
|
310 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
|
311 } |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
312 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
|
313 } 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
|
314 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
|
315 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
|
316 } |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
317 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
|
318 } |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
319 } |
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 } |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
321 |
edf875b3c091
use binary search when looking for the end of Node.extraUsages (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11531
diff
changeset
|
322 /** |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
323 * 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
|
324 * |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
325 * @param node the node to add |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
326 */ |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
327 private void addUsage(Node node) { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
328 assert recordsUsages(); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
329 incUsageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
330 if (usage0 == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
331 usage0 = node; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
332 } else if (usage1 == null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
333 usage1 = node; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
334 } else { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
335 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
|
336 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
|
337 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
|
338 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
|
339 } 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
|
340 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
|
341 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
|
342 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
|
343 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
|
344 } 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
|
345 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
|
346 } 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
|
347 extraUsages[lastNonNull + 1] = node; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
348 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
349 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
350 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
351 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
352 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
353 /** |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
354 * 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
|
355 * |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
356 * @param node the node to remove |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
357 * @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
|
358 */ |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
359 private boolean removeUsage(Node node) { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
360 assert recordsUsages(); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
361 // 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
|
362 // 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
|
363 incUsageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
364 if (usage0 == node) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
365 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
|
366 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
|
367 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
|
368 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
|
369 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
|
370 } 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
|
371 // 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
|
372 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
|
373 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
|
374 } |
11531
331f7590b741
modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11528
diff
changeset
|
375 } else { |
331f7590b741
modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11528
diff
changeset
|
376 // 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
|
377 usage0 = null; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
378 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
379 return true; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
380 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
381 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
|
382 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
|
383 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
|
384 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
|
385 extraUsages[lastNonNull] = null; |
11531
331f7590b741
modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11528
diff
changeset
|
386 } else { |
331f7590b741
modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11528
diff
changeset
|
387 // 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
|
388 usage1 = null; |
331f7590b741
modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11528
diff
changeset
|
389 } |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
390 return true; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
391 } |
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
|
392 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
|
393 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
|
394 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
|
395 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
|
396 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
|
397 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
|
398 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
|
399 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
|
400 } 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
|
401 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
|
402 } |
11531
331f7590b741
modified Node.removeUsage to do less copying (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11528
diff
changeset
|
403 return true; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
404 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
405 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
406 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
407 return false; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
408 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
409 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
410 private void clearUsages() { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
411 assert recordsUsages(); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
412 incUsageModCount(); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
413 usage0 = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
414 usage1 = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
415 extraUsages = NO_NODES; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
416 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
417 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
418 public final Node predecessor() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
419 return predecessor; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
420 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
421 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
422 final int modCount() { |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
423 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
424 return graph.modCount(this); |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
425 } |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
426 return 0; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
427 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
428 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
429 final void incModCount() { |
11524
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
430 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
431 graph.incModCount(this); |
dede53632f3e
removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11492
diff
changeset
|
432 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
433 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
434 |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
435 final int usageModCount() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
436 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
437 return graph.usageModCount(this); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
438 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
439 return 0; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
440 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
441 |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
442 final void incUsageModCount() { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
443 if (MODIFICATION_COUNTS_ENABLED && graph != null) { |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
444 graph.incUsageModCount(this); |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
445 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
446 } |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
447 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
448 public boolean isDeleted() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
449 return id <= DELETED_ID_START; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
450 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
451 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
452 public boolean isAlive() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
453 return id >= ALIVE_ID_START; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
454 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
455 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
456 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
457 * 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
|
458 * 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
|
459 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
460 protected void updateUsages(Node oldInput, Node newInput) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
461 if (oldInput != newInput) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
462 if (oldInput != null) { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
463 if (oldInput.recordsUsages()) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
464 boolean result = removeThisFromUsages(oldInput); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
465 assert assertTrue(result, "not found in usages, old input: %s", oldInput); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
466 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
467 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
468 if (newInput != null) { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
469 if (newInput.recordsUsages()) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
470 NodeChangedListener listener = graph.inputChangedListener; |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
471 if (listener != null) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
472 listener.nodeChanged(this); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
473 } |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
474 newInput.addUsage(this); |
4614
a3882fd1ae61
Make it possible to have multiple LoopEnds per LoopBegin
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
4418
diff
changeset
|
475 } |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
476 } else if (oldInput != null && oldInput.recordsUsages() && oldInput.usages().isEmpty()) { |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
477 NodeChangedListener listener = graph.usagesDroppedToZeroListener; |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
478 if (listener != null) { |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
479 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
|
480 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
481 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
482 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
483 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
484 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
485 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
486 * 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
|
487 * 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
|
488 * this node to newSuccessor's predecessors. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
489 */ |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
490 protected void updatePredecessor(Node oldSuccessor, Node newSuccessor) { |
13744
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13327
diff
changeset
|
491 assert graph == null || !graph.isFrozen(); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
492 if (oldSuccessor != newSuccessor) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
493 if (oldSuccessor != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
494 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
|
495 oldSuccessor.predecessor = null; |
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 if (newSuccessor != null) { |
11676
435c8b984680
Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11674
diff
changeset
|
498 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
|
499 newSuccessor.predecessor = this; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
500 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
501 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
502 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
503 |
4142
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
504 void initialize(Graph newGraph) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
505 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
|
506 this.graph = newGraph; |
bc8527f3071c
Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3733
diff
changeset
|
507 newGraph.register(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
508 for (Node input : inputs()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
509 updateUsages(null, input); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
510 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
511 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
|
512 updatePredecessor(null, successor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
513 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
514 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
515 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
516 public final NodeClass getNodeClass() { |
11431
ca53d08b8ef9
removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents:
9495
diff
changeset
|
517 return NodeClass.get(getClass()); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
518 } |
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 private boolean checkReplaceWith(Node other) { |
13744
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13327
diff
changeset
|
521 assert assertTrue(graph == null || !graph.isFrozen(), "cannot modify frozen graph"); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
522 assert assertFalse(other == this, "cannot replace a node with itself"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
523 assert assertFalse(isDeleted(), "cannot replace deleted node"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
524 assert assertTrue(other == null || !other.isDeleted(), "cannot replace with deleted node %s", other); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
525 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
526 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
527 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
528 public void replaceAtUsages(Node other) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
529 assert checkReplaceWith(other); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
530 for (Node usage : usages()) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
531 boolean result = usage.getNodeClass().replaceFirstInput(usage, this, other); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
532 assert assertTrue(result, "not found in inputs, usage: %s", usage); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
533 if (other != null) { |
11755
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
534 NodeChangedListener listener = graph.inputChangedListener; |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
535 if (listener != null) { |
bbcb72443066
renames: Graph.inputChanged -> inputChangedListener, Graph.usagesDroppedZero -> usagesDroppedToZeroListener
Doug Simon <doug.simon@oracle.com>
parents:
11698
diff
changeset
|
536 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
|
537 } |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
538 if (other.recordsUsages()) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
539 other.addUsage(usage); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
540 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
541 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
542 } |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
543 clearUsages(); |
3733
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 |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
546 public void replaceAtPredecessor(Node other) { |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
547 assert checkReplaceWith(other); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
548 if (predecessor != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
549 boolean result = predecessor.getNodeClass().replaceFirstSuccessor(predecessor, this, other); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
550 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
|
551 predecessor.updatePredecessor(this, other); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
552 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
553 } |
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 public void replaceAndDelete(Node other) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
556 assert checkReplaceWith(other); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
557 if (other != null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
558 clearSuccessors(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
559 replaceAtUsages(other); |
5487
9743ae819f73
Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5485
diff
changeset
|
560 replaceAtPredecessor(other); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
561 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
562 safeDelete(); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
565 public void replaceFirstSuccessor(Node oldSuccessor, Node newSuccessor) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
566 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
|
567 updatePredecessor(oldSuccessor, newSuccessor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
568 } |
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 replaceFirstInput(Node oldInput, Node newInput) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
572 if (getNodeClass().replaceFirstInput(this, oldInput, newInput)) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
573 updateUsages(oldInput, newInput); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
574 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
575 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
576 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
577 public void clearInputs() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
578 assert assertFalse(isDeleted(), "cannot clear inputs of deleted node"); |
13744
d96dbd96bb45
Always copy method substitutions. Add some assertion checking for it.
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13327
diff
changeset
|
579 assert graph == null || !graph.isFrozen(); |
3733
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 for (Node input : inputs()) { |
13327
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13140
diff
changeset
|
582 if (input.recordsUsages()) { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
583 removeThisFromUsages(input); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
584 if (input.usages().isEmpty()) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
585 NodeChangedListener listener = graph.usagesDroppedToZeroListener; |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
586 if (listener != null) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
587 listener.nodeChanged(input); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
588 } |
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
|
589 } |
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
|
590 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
591 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
592 getNodeClass().clearInputs(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
593 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
594 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
595 private boolean removeThisFromUsages(Node n) { |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
596 return n.removeUsage(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
597 } |
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 public void clearSuccessors() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
600 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
|
601 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
602 for (Node successor : successors()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
603 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
|
604 successor.predecessor = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
605 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
606 getNodeClass().clearSuccessors(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
607 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
608 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
609 private boolean checkDeletion() { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
610 if (recordsUsages()) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
611 assertTrue(usages().isEmpty(), "cannot delete node %s because of usages: %s", this, usages()); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
612 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
613 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
|
614 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
615 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
616 |
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
|
617 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
618 * 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
|
619 * 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
|
620 */ |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
621 public void safeDelete() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
622 assert checkDeletion(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
623 clearInputs(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
624 clearSuccessors(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
625 graph.unregister(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
626 id = DELETED_ID_START - id; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
627 assert isDeleted(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
628 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
629 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
630 public final Node copyWithInputs() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
631 Node newNode = clone(graph); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
632 NodeClass clazz = getNodeClass(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
633 clazz.copyInputs(this, newNode); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
634 for (Node input : inputs()) { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
635 if (input.recordsUsages()) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
636 input.addUsage(newNode); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
637 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
638 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
639 return newNode; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
640 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
641 |
11677
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
642 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
|
643 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
|
644 } |
8505bcff4bdc
New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11666
diff
changeset
|
645 |
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
|
646 /** |
11940 | 647 * 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
|
648 * 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
|
649 * {@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
|
650 * |
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
|
651 * @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
|
652 */ |
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
|
653 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
|
654 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
|
655 } |
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
|
656 |
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
|
657 /** |
11940 | 658 * 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
|
659 * {@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
|
660 * {@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
|
661 * |
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
|
662 * @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
|
663 */ |
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
|
664 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
|
665 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
|
666 } |
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
|
667 |
11677
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
668 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
|
669 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
|
670 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
|
671 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
|
672 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
|
673 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
|
674 } |
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
|
675 } |
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
|
676 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
677 Node newNode = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
678 try { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
679 newNode = (Node) this.clone(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
680 } catch (CloneNotSupportedException e) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
681 throw new GraalInternalError(e).addContext(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
682 } |
11674
8505bcff4bdc
New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11666
diff
changeset
|
683 if (clearInputsAndSuccessors) { |
8505bcff4bdc
New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11666
diff
changeset
|
684 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
|
685 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
|
686 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
687 newNode.graph = into; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
688 newNode.typeCacheNext = null; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
689 newNode.id = INITIAL_ID; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
690 into.register(newNode); |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
691 newNode.usage0 = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
692 newNode.usage1 = null; |
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
693 newNode.extraUsages = NO_NODES; |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
694 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
|
695 |
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
|
696 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
|
697 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
|
698 } |
11677
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
699 newNode.afterClone(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
700 return newNode; |
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 |
11677
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
703 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
|
704 } |
9d341b6e47e5
Correct custom clone implementations after change of Node base class clone method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11676
diff
changeset
|
705 |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
706 public boolean verify() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
707 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
|
708 assertTrue(graph() != null, "null graph"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
709 for (Node input : inputs()) { |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
710 assertTrue(!input.recordsUsages() || input.usages().contains(this), "missing usage in input %s", input); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
711 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
712 for (Node successor : successors()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
713 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
|
714 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
|
715 } |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
716 if (recordsUsages()) { |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
717 for (Node usage : usages()) { |
12723
bbf6407458ee
Node: print node in assert
Bernhard Urban <bernhard.urban@jku.at>
parents:
12686
diff
changeset
|
718 assertFalse(usage.isDeleted(), "usage %s must never be deleted", usage); |
12570
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
719 assertTrue(usage.inputs().contains(this), "missing input in usage %s", usage); |
af39ea2dc39d
made ConstantNodes (optionally) not record their usages (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12437
diff
changeset
|
720 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
721 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
722 if (predecessor != null) { |
12723
bbf6407458ee
Node: print node in assert
Bernhard Urban <bernhard.urban@jku.at>
parents:
12686
diff
changeset
|
723 assertFalse(predecessor.isDeleted(), "predecessor %s must never be deleted", predecessor); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
724 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
|
725 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
726 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
727 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
728 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
729 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
|
730 if (condition) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
731 return true; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
732 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
733 throw new VerificationError(message, args).addContext(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
734 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
735 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
736 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
737 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
|
738 if (condition) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
739 throw new VerificationError(message, args).addContext(this); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
740 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
741 return true; |
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 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
744 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
745 public Iterable<? extends Node> cfgPredecessors() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
746 if (predecessor == null) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
747 return Collections.emptySet(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
748 } else { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
749 return Collections.singleton(predecessor); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
750 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
751 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
752 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
753 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
754 * 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
|
755 * 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
|
756 * 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
|
757 * fields contain them. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
758 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
759 public Iterable<? extends Node> cfgSuccessors() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
760 return successors(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
761 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
762 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
763 /** |
13327
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13140
diff
changeset
|
764 * Nodes always use an {@linkplain System#identityHashCode(Object) identity} hash code. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
765 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
766 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
767 public final int hashCode() { |
12655
2c4aa758ee18
made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
12570
diff
changeset
|
768 return System.identityHashCode(this); |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
769 } |
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 /** |
13327
c258331fdde6
removed support for external nodes (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents:
13140
diff
changeset
|
772 * Equality tests must rely solely on identity. |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
773 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
774 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
775 public final boolean equals(Object obj) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
776 return super.equals(obj); |
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 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
779 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
780 * 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
|
781 * ideal graph visualizer). |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
782 */ |
9495
6ad0bdcd76aa
make Node.getDebugProperties() final
Lukas Stadler <lukas.stadler@jku.at>
parents:
9332
diff
changeset
|
783 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
|
784 return getDebugProperties(new HashMap<>()); |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
785 } |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
786 |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
787 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
788 * 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
|
789 * 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
|
790 * their superclass. |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
791 * |
5813
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
792 * @param map |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
793 */ |
3b8bc07f8d17
Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5810
diff
changeset
|
794 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
|
795 getNodeClass().getDebugProperties(this, map); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
796 return map; |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
797 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
798 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
799 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
800 * 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
|
801 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
802 @Override |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
803 public final String toString() { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
804 return toString(Verbosity.Short); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
805 } |
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 enum Verbosity { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
808 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
809 * Only the id of the node. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
810 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
811 Id, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
812 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7521
diff
changeset
|
813 * 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
|
814 * (constants, ...). |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
815 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
816 Name, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
817 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
818 * {@link #Id} + {@link #Name}. |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
819 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
820 Short, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
821 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
822 * 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
|
823 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
824 Long, |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
825 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
826 * 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
|
827 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
828 Debugger, |
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 * 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
|
831 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
832 All |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
833 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
834 |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
835 /** |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
836 * 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
|
837 */ |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
838 public String toString(Verbosity verbosity) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
839 switch (verbosity) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
840 case Id: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
841 return Integer.toString(id); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
842 case Name: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
843 return getNodeClass().shortName(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
844 case Short: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
845 return toString(Verbosity.Id) + "|" + toString(Verbosity.Name); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
846 case Long: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
847 return toString(Verbosity.Short); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
848 case Debugger: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
849 case All: { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
850 StringBuilder str = new StringBuilder(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
851 str.append(toString(Verbosity.Short)).append(" { "); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
852 for (Map.Entry<Object, Object> entry : getDebugProperties().entrySet()) { |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
853 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
|
854 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
855 str.append(" }"); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
856 return str.toString(); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
857 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
858 default: |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
859 throw new RuntimeException("unknown verbosity: " + verbosity); |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
860 } |
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
861 } |
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
|
862 |
5810
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
863 @Deprecated |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
864 public int getId() { |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
865 return id; |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
866 } |
bc237d8b6f99
Add binary graph dumping to compiler (-G:+PrintBinaryGraphs)
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
5806
diff
changeset
|
867 |
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
|
868 @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
|
869 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
|
870 if ((flags & FormattableFlags.ALTERNATE) == FormattableFlags.ALTERNATE) { |
4418
46e9068c09b4
small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents:
4397
diff
changeset
|
871 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
|
872 } else if ((flags & FormattableFlags.UPPERCASE) == FormattableFlags.UPPERCASE) { |
4418
46e9068c09b4
small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents:
4397
diff
changeset
|
873 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
|
874 } else { |
4418
46e9068c09b4
small fixed to log output
Lukas Stadler <lukas.stadler@jku.at>
parents:
4397
diff
changeset
|
875 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
|
876 } |
403330cfd3da
Added Formattable interface to node base 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 |
403330cfd3da
Added Formattable interface to node base 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 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
|
879 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
|
880 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
|
881 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
|
882 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
|
883 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
|
884 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
|
885 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
|
886 } |
403330cfd3da
Added Formattable interface to node base 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 |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
888 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
|
889 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
|
890 Position position = inputIter.nextPosition(); |
11666
3967f9f306f8
Factor usages of getNodeClass().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11654
diff
changeset
|
891 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
|
892 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
|
893 formatter.format(" "); |
11666
3967f9f306f8
Factor usages of getNodeClass().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11654
diff
changeset
|
894 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
|
895 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
|
896 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
|
897 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
|
898 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
899 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
900 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
901 |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
902 if (precision > 0) { |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
903 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
|
904 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
|
905 int z = 0; |
11528
8f500c7a510a
inlined NodeUsageList into Node (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents:
11524
diff
changeset
|
906 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
|
907 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
|
908 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
|
909 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
910 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
|
911 ++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
|
912 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
913 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
|
914 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
915 |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
916 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
|
917 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
|
918 Position position = succIter.nextPosition(); |
11666
3967f9f306f8
Factor usages of getNodeClass().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11654
diff
changeset
|
919 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
|
920 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
|
921 formatter.format(" "); |
11666
3967f9f306f8
Factor usages of getNodeClass().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11654
diff
changeset
|
922 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
|
923 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
|
924 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
|
925 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
|
926 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
927 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
928 } |
403330cfd3da
Added Formattable interface to node base class in order to allow custom handling of formatter specifiers for the node class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
4311
diff
changeset
|
929 } |
3733
e233f5660da4
Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff
changeset
|
930 } |