annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java @ 19470:d216de21bfe8

Fix unchecked warnings in NodeClass.
author Roland Schatz <roland.schatz@oracle.com>
date Wed, 18 Feb 2015 12:10:04 +0100
parents f13ce59e4150
children 8fc336a04d77
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
16154
f9f7bd1a6b2c IGV: Support for InputType.
Roland Schatz <roland.schatz@oracle.com>
parents: 15827
diff changeset
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3733
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;
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
24
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
25 import static com.oracle.graal.compiler.common.Fields.*;
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
26 import static com.oracle.graal.graph.Edges.*;
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
27 import static com.oracle.graal.graph.InputEdges.*;
16897
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
28 import static com.oracle.graal.graph.Node.*;
11524
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11434
diff changeset
29
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
30 import java.lang.annotation.*;
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
31 import java.lang.reflect.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 import java.util.*;
19454
f13ce59e4150 Use atomic integer for iterable IDs to prevent races.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19434
diff changeset
33 import java.util.concurrent.atomic.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15186
diff changeset
35 import com.oracle.graal.compiler.common.*;
11642
5507e2824bc6 added metric to count IterableNodeTypes (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11631
diff changeset
36 import com.oracle.graal.debug.*;
17147
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
37 import com.oracle.graal.debug.internal.*;
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
38 import com.oracle.graal.graph.Edges.Type;
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
39 import com.oracle.graal.graph.Graph.DuplicationReplacement;
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14616
diff changeset
40 import com.oracle.graal.graph.Node.Input;
17450
45b45f902bed removed Node generation (GRAAL-857)
Doug Simon <doug.simon@oracle.com>
parents: 17366
diff changeset
41 import com.oracle.graal.graph.Node.OptionalInput;
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14616
diff changeset
42 import com.oracle.graal.graph.Node.Successor;
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: 11676
diff changeset
43 import com.oracle.graal.graph.spi.*;
16841
cbd42807a31f moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents: 16554
diff changeset
44 import com.oracle.graal.nodeinfo.*;
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
45
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
46 /**
15106
6876a4599b7e create NodeClass for each Node subclass during class initialization of the latter
Doug Simon <doug.simon@oracle.com>
parents: 15040
diff changeset
47 * Metadata for every {@link Node} type. The metadata includes:
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
48 * <ul>
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
49 * <li>The offsets of fields annotated with {@link Input} and {@link Successor} as well as methods
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
50 * for iterating over such fields.</li>
11631
1aed684853f6 refactored IterableNodeType into a top level type to avoid problems it was causing for javac and JDT (CR-1408)
Doug Simon <doug.simon@oracle.com>
parents: 11556
diff changeset
51 * <li>The identifier for an {@link IterableNodeType} class.</li>
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
52 * </ul>
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
53 */
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 19454
diff changeset
54 public final class NodeClass<T> extends FieldIntrospection<T> {
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
55
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
56 // Timers for creation of a NodeClass instance
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
57 private static final DebugTimer Init_FieldScanning = Debug.timer("NodeClass.Init.FieldScanning");
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
58 private static final DebugTimer Init_FieldScanningInner = Debug.timer("NodeClass.Init.FieldScanning.Inner");
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
59 private static final DebugTimer Init_AnnotationParsing = Debug.timer("NodeClass.Init.AnnotationParsing");
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
60 private static final DebugTimer Init_Edges = Debug.timer("NodeClass.Init.Edges");
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
61 private static final DebugTimer Init_Data = Debug.timer("NodeClass.Init.Data");
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
62 private static final DebugTimer Init_AllowedUsages = Debug.timer("NodeClass.Init.AllowedUsages");
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
63 private static final DebugTimer Init_IterableIds = Debug.timer("NodeClass.Init.IterableIds");
17147
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
64
17274
5c55441b4c62 fixed reported annotation parsing time in NodeClass
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
65 private static <T extends Annotation> T getAnnotationTimed(AnnotatedElement e, Class<T> annotationClass) {
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
66 try (TimerCloseable s = Init_AnnotationParsing.start()) {
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
67 return e.getAnnotation(annotationClass);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
68 }
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
69 }
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
70
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
71 /**
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
72 * Gets the {@link NodeClass} associated with a given {@link Class}.
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
73 */
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19105
diff changeset
74 public static <T> NodeClass<T> get(Class<T> c) {
19405
e6637891a870 Simplify NodeClass management.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
75 assert getNodeClassViaReflection(c) == null;
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 19454
diff changeset
76 Class<? super T> superclass = c.getSuperclass();
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 19454
diff changeset
77 NodeClass<? super T> nodeSuperclass = null;
19405
e6637891a870 Simplify NodeClass management.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
78 if (superclass != NODE_CLASS) {
e6637891a870 Simplify NodeClass management.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
79 nodeSuperclass = getNodeClassViaReflection(superclass);
e6637891a870 Simplify NodeClass management.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
80 }
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 19454
diff changeset
81 return new NodeClass<>(c, nodeSuperclass);
19405
e6637891a870 Simplify NodeClass management.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
82 }
16903
3ca8ba1bfc21 bind a generated Node class to the NodeClass instance of the generated-from Node class
Doug Simon <doug.simon@oracle.com>
parents: 16897
diff changeset
83
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 19454
diff changeset
84 @SuppressWarnings("unchecked")
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 19454
diff changeset
85 public static <T> NodeClass<T> getNodeClassViaReflection(Class<T> superclass) {
19405
e6637891a870 Simplify NodeClass management.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
86 try {
e6637891a870 Simplify NodeClass management.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
87 Field field = superclass.getDeclaredField("TYPE");
e6637891a870 Simplify NodeClass management.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
88 field.setAccessible(true);
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 19454
diff changeset
89 return (NodeClass<T>) field.get(null);
19405
e6637891a870 Simplify NodeClass management.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
90 } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
e6637891a870 Simplify NodeClass management.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19403
diff changeset
91 throw new RuntimeException(e);
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
92 }
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
93 }
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
94
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
95 private static final Class<?> NODE_CLASS = Node.class;
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
96 private static final Class<?> INPUT_LIST_CLASS = NodeInputList.class;
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
97 private static final Class<?> SUCCESSOR_LIST_CLASS = NodeSuccessorList.class;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98
19454
f13ce59e4150 Use atomic integer for iterable IDs to prevent races.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19434
diff changeset
99 private static AtomicInteger nextIterableId = new AtomicInteger();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
101 private final InputEdges inputs;
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
102 private final SuccessorEdges successors;
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 19454
diff changeset
103 private final NodeClass<? super T> superNodeClass;
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
104
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 private final boolean canGVN;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106 private final int startGVNNumber;
17272
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
107 private final String nameTemplate;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108 private final int iterableId;
15002
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
109 private final EnumSet<InputType> allowedUsageTypes;
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
110 private int[] iterableIds;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111
11642
5507e2824bc6 added metric to count IterableNodeTypes (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11631
diff changeset
112 private static final DebugMetric ITERABLE_NODE_TYPES = Debug.metric("IterableNodeTypes");
11663
d213be26ffb4 added metric to count number of times a typed node iterator is used per IterableNodeType (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11653
diff changeset
113 private final DebugMetric nodeIterableCount;
11642
5507e2824bc6 added metric to count IterableNodeTypes (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11631
diff changeset
114
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: 11676
diff changeset
115 /**
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
116 * Determines if this node type implements {@link Canonicalizable}.
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
117 */
16239
de84713267fa use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16206
diff changeset
118 private final boolean isCanonicalizable;
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: 11676
diff changeset
119
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
120 /**
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
121 * Determines if this node type implements {@link Simplifiable}.
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
122 */
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
123 private final boolean isSimplifiable;
16919
0fe4732e5181 made use of generated Node classes predicated on value of graal.useGeneratedNodes system property (default is false)
Doug Simon <doug.simon@oracle.com>
parents: 16903
diff changeset
124 private final boolean isLeafNode;
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: 11676
diff changeset
125
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 19454
diff changeset
126 public NodeClass(Class<T> clazz, NodeClass<? super T> superNodeClass) {
18261
d66c79acfeac refactored Fields class to make it usable for implementing custom serialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
127 this(clazz, superNodeClass, new FieldsScanner.DefaultCalcOffset(), null, 0);
13127
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
128 }
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
129
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 19454
diff changeset
130 public NodeClass(Class<T> clazz, NodeClass<? super T> superNodeClass, FieldsScanner.CalcOffset calcOffset, int[] presetIterableIds, int presetIterableId) {
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
131 super(clazz);
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
132 this.superNodeClass = superNodeClass;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 assert NODE_CLASS.isAssignableFrom(clazz);
16239
de84713267fa use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16206
diff changeset
134
de84713267fa use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16206
diff changeset
135 this.isCanonicalizable = Canonicalizable.class.isAssignableFrom(clazz);
de84713267fa use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16206
diff changeset
136 if (Canonicalizable.Unary.class.isAssignableFrom(clazz) || Canonicalizable.Binary.class.isAssignableFrom(clazz)) {
de84713267fa use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16206
diff changeset
137 assert Canonicalizable.Unary.class.isAssignableFrom(clazz) ^ Canonicalizable.Binary.class.isAssignableFrom(clazz) : clazz + " should implement either Unary or Binary, not both";
16206
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16154
diff changeset
138 }
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16154
diff changeset
139
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: 11676
diff changeset
140 this.isSimplifiable = Simplifiable.class.isAssignableFrom(clazz);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141
18261
d66c79acfeac refactored Fields class to make it usable for implementing custom serialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
142 NodeFieldsScanner fs = new NodeFieldsScanner(calcOffset, superNodeClass);
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
143 try (TimerCloseable t = Init_FieldScanning.start()) {
18261
d66c79acfeac refactored Fields class to make it usable for implementing custom serialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
144 fs.scan(clazz, clazz.getSuperclass(), false);
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
145 }
17008
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16991
diff changeset
146
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
147 try (TimerCloseable t1 = Init_Edges.start()) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
148 successors = new SuccessorEdges(fs.directSuccessors, fs.successors);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
149 inputs = new InputEdges(fs.directInputs, fs.inputs);
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
150 }
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
151 try (TimerCloseable t1 = Init_Data.start()) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
152 data = new Fields(fs.data);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
154
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
155 isLeafNode = inputs.getCount() + successors.getCount() == 0;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157 canGVN = Node.ValueNumberable.class.isAssignableFrom(clazz);
19105
b4441fd15166 Backed out c8b2315651d3 as it breaks replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 19074
diff changeset
158 startGVNNumber = clazz.getName().hashCode();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159
17274
5c55441b4c62 fixed reported annotation parsing time in NodeClass
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
160 NodeInfo info = getAnnotationTimed(clazz, NodeInfo.class);
18340
a0381103324b More folding of constant classes and NodeClass references
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18261
diff changeset
161 assert info != null : "Missing NodeInfo annotation on " + clazz;
17272
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
162 this.nameTemplate = info.nameTemplate();
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
163
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
164 try (TimerCloseable t1 = Init_AllowedUsages.start()) {
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
165 allowedUsageTypes = superNodeClass == null ? EnumSet.noneOf(InputType.class) : superNodeClass.allowedUsageTypes.clone();
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
166 allowedUsageTypes.addAll(Arrays.asList(info.allowedUsageTypes()));
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
167 }
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
168
13127
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
169 if (presetIterableIds != null) {
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
170 this.iterableIds = presetIterableIds;
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
171 this.iterableId = presetIterableId;
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
172 } else if (IterableNodeType.class.isAssignableFrom(clazz)) {
11642
5507e2824bc6 added metric to count IterableNodeTypes (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11631
diff changeset
173 ITERABLE_NODE_TYPES.increment();
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
174 try (TimerCloseable t1 = Init_IterableIds.start()) {
19454
f13ce59e4150 Use atomic integer for iterable IDs to prevent races.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19434
diff changeset
175 this.iterableId = nextIterableId.getAndIncrement();
17148
3837c6aa9fd0 ensure NodeClass initialization follows class hierarchy order
Doug Simon <doug.simon@oracle.com>
parents: 17147
diff changeset
176
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19105
diff changeset
177 NodeClass<?> snc = superNodeClass;
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
178 while (snc != null && IterableNodeType.class.isAssignableFrom(snc.getClazz())) {
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
179 assert !containsId(this.iterableId, snc.iterableIds);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
180 snc.iterableIds = Arrays.copyOf(snc.iterableIds, snc.iterableIds.length + 1);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
181 snc.iterableIds[snc.iterableIds.length - 1] = this.iterableId;
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
182 snc = snc.superNodeClass;
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
183 }
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
184
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
185 this.iterableIds = new int[]{iterableId};
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
186 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187 } else {
16897
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
188 this.iterableId = Node.NOT_ITERABLE;
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
189 this.iterableIds = null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 }
17258
f1f7b796874f moved Node naming logic to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17247
diff changeset
191 nodeIterableCount = Debug.metric("NodeIterable_%s", clazz);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193
16987
39d979dae809 need extra logic when computing Node iterable ids and USE_GENERATED_NODES == true
Doug Simon <doug.simon@oracle.com>
parents: 16986
diff changeset
194 private static boolean containsId(int iterableId, int[] iterableIds) {
39d979dae809 need extra logic when computing Node iterable ids and USE_GENERATED_NODES == true
Doug Simon <doug.simon@oracle.com>
parents: 16986
diff changeset
195 for (int i : iterableIds) {
39d979dae809 need extra logic when computing Node iterable ids and USE_GENERATED_NODES == true
Doug Simon <doug.simon@oracle.com>
parents: 16986
diff changeset
196 if (i == iterableId) {
39d979dae809 need extra logic when computing Node iterable ids and USE_GENERATED_NODES == true
Doug Simon <doug.simon@oracle.com>
parents: 16986
diff changeset
197 return true;
39d979dae809 need extra logic when computing Node iterable ids and USE_GENERATED_NODES == true
Doug Simon <doug.simon@oracle.com>
parents: 16986
diff changeset
198 }
39d979dae809 need extra logic when computing Node iterable ids and USE_GENERATED_NODES == true
Doug Simon <doug.simon@oracle.com>
parents: 16986
diff changeset
199 }
39d979dae809 need extra logic when computing Node iterable ids and USE_GENERATED_NODES == true
Doug Simon <doug.simon@oracle.com>
parents: 16986
diff changeset
200 return false;
39d979dae809 need extra logic when computing Node iterable ids and USE_GENERATED_NODES == true
Doug Simon <doug.simon@oracle.com>
parents: 16986
diff changeset
201 }
39d979dae809 need extra logic when computing Node iterable ids and USE_GENERATED_NODES == true
Doug Simon <doug.simon@oracle.com>
parents: 16986
diff changeset
202
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17274
diff changeset
203 private String shortName;
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17274
diff changeset
204
17272
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
205 public String shortName() {
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17274
diff changeset
206 if (shortName == null) {
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17274
diff changeset
207 NodeInfo info = getClazz().getAnnotation(NodeInfo.class);
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17274
diff changeset
208 if (!info.shortName().isEmpty()) {
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17274
diff changeset
209 shortName = info.shortName();
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17274
diff changeset
210 } else {
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17274
diff changeset
211 shortName = getClazz().getSimpleName();
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17274
diff changeset
212 if (shortName.endsWith("Node") && !shortName.equals("StartNode") && !shortName.equals("EndNode")) {
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17274
diff changeset
213 shortName = shortName.substring(0, shortName.length() - 4);
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17274
diff changeset
214 }
17272
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
215 }
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
216 }
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
217 return shortName;
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
218 }
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
219
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
220 public int[] iterableIds() {
11663
d213be26ffb4 added metric to count number of times a typed node iterator is used per IterableNodeType (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11653
diff changeset
221 nodeIterableCount.increment();
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
222 return iterableIds;
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
223 }
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
224
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
225 public int iterableId() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
226 return iterableId;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
227 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229 public boolean valueNumberable() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230 return canGVN;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
231 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232
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: 11676
diff changeset
233 /**
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
234 * Determines if this node type implements {@link Canonicalizable}.
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
235 */
16239
de84713267fa use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16206
diff changeset
236 public boolean isCanonicalizable() {
de84713267fa use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16206
diff changeset
237 return isCanonicalizable;
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: 11676
diff changeset
238 }
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
239
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
240 /**
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
241 * Determines if this node type implements {@link Simplifiable}.
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
242 */
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
243 public boolean isSimplifiable() {
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
244 return isSimplifiable;
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
245 }
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
246
18651
8c753e6fab96 added mechanism for recomputing IterableNodeType lists in a Graph after deserialization
Doug Simon <doug.simon@oracle.com>
parents: 18383
diff changeset
247 static int allocatedNodeIterabledIds() {
19454
f13ce59e4150 Use atomic integer for iterable IDs to prevent races.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19434
diff changeset
248 return nextIterableId.get();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
249 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250
15002
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
251 public EnumSet<InputType> getAllowedUsageTypes() {
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
252 return allowedUsageTypes;
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
253 }
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
254
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
255 /**
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
256 * Describes a field representing an input or successor edge in a node.
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
257 */
18261
d66c79acfeac refactored Fields class to make it usable for implementing custom serialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
258 protected static class EdgeInfo extends FieldsScanner.FieldInfo {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
259
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
260 public EdgeInfo(long offset, String name, Class<?> type) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
261 super(offset, name, type);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
262 }
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
263
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
264 /**
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
265 * Sorts non-list edges before list edges.
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
266 */
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
267 @Override
18261
d66c79acfeac refactored Fields class to make it usable for implementing custom serialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
268 public int compareTo(FieldsScanner.FieldInfo o) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
269 if (NodeList.class.isAssignableFrom(o.type)) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
270 if (!NodeList.class.isAssignableFrom(type)) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
271 return -1;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
272 }
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
273 } else {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
274 if (NodeList.class.isAssignableFrom(type)) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
275 return 1;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
276 }
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
277 }
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
278 return super.compareTo(o);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
279 }
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
280 }
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
281
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
282 /**
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
283 * Describes a field representing an {@linkplain Type#Inputs input} edge in a node.
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
284 */
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
285 protected static class InputInfo extends EdgeInfo {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
286 final InputType inputType;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
287 final boolean optional;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
288
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
289 public InputInfo(long offset, String name, Class<?> type, InputType inputType, boolean optional) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
290 super(offset, name, type);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
291 this.inputType = inputType;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
292 this.optional = optional;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
293 }
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
294
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
295 @Override
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
296 public String toString() {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
297 return super.toString() + "{inputType=" + inputType + ", optional=" + optional + "}";
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
298 }
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
299 }
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
300
18261
d66c79acfeac refactored Fields class to make it usable for implementing custom serialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
301 protected static class NodeFieldsScanner extends FieldsScanner {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
302
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
303 public final ArrayList<InputInfo> inputs = new ArrayList<>();
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
304 public final ArrayList<EdgeInfo> successors = new ArrayList<>();
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
305 int directInputs;
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
306 int directSuccessors;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
307
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19105
diff changeset
308 protected NodeFieldsScanner(FieldsScanner.CalcOffset calc, NodeClass<?> superNodeClass) {
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
309 super(calc);
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
310 if (superNodeClass != null) {
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
311 translateInto(superNodeClass.inputs, inputs);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
312 translateInto(superNodeClass.successors, successors);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
313 translateInto(superNodeClass.data, data);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
314 directInputs = superNodeClass.inputs.getDirectCount();
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
315 directSuccessors = superNodeClass.successors.getDirectCount();
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
316 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
317 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
318
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
319 @Override
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
320 protected void scanField(Field field, long offset) {
17274
5c55441b4c62 fixed reported annotation parsing time in NodeClass
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
321 Input inputAnnotation = getAnnotationTimed(field, Node.Input.class);
5c55441b4c62 fixed reported annotation parsing time in NodeClass
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
322 OptionalInput optionalInputAnnotation = getAnnotationTimed(field, Node.OptionalInput.class);
5c55441b4c62 fixed reported annotation parsing time in NodeClass
Doug Simon <doug.simon@oracle.com>
parents: 17272
diff changeset
323 Successor successorAnnotation = getAnnotationTimed(field, Successor.class);
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
324 try (TimerCloseable s = Init_FieldScanningInner.start()) {
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
325 Class<?> type = field.getType();
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
326 int modifiers = field.getModifiers();
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
327
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
328 if (inputAnnotation != null || optionalInputAnnotation != null) {
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
329 assert successorAnnotation == null : "field cannot be both input and successor";
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
330 if (INPUT_LIST_CLASS.isAssignableFrom(type)) {
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
331 // NodeInputList fields should not be final since they are
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
332 // written (via Unsafe) in clearInputs()
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
333 GraalInternalError.guarantee(!Modifier.isFinal(modifiers), "NodeInputList input field %s should not be final", field);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
334 GraalInternalError.guarantee(!Modifier.isPublic(modifiers), "NodeInputList input field %s should not be public", field);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
335 } else {
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
336 GraalInternalError.guarantee(NODE_CLASS.isAssignableFrom(type) || type.isInterface(), "invalid input type: %s", type);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
337 GraalInternalError.guarantee(!Modifier.isFinal(modifiers), "Node input field %s should not be final", field);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
338 directInputs++;
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
339 }
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
340 InputType inputType;
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
341 if (inputAnnotation != null) {
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
342 assert optionalInputAnnotation == null : "inputs can either be optional or non-optional";
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
343 inputType = inputAnnotation.value();
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
344 } else {
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
345 inputType = optionalInputAnnotation.value();
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
346 }
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
347 inputs.add(new InputInfo(offset, field.getName(), type, inputType, field.isAnnotationPresent(Node.OptionalInput.class)));
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
348 } else if (successorAnnotation != null) {
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
349 if (SUCCESSOR_LIST_CLASS.isAssignableFrom(type)) {
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
350 // NodeSuccessorList fields should not be final since they are
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
351 // written (via Unsafe) in clearSuccessors()
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
352 GraalInternalError.guarantee(!Modifier.isFinal(modifiers), "NodeSuccessorList successor field % should not be final", field);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
353 GraalInternalError.guarantee(!Modifier.isPublic(modifiers), "NodeSuccessorList successor field %s should not be public", field);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
354 } else {
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
355 GraalInternalError.guarantee(NODE_CLASS.isAssignableFrom(type), "invalid successor type: %s", type);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
356 GraalInternalError.guarantee(!Modifier.isFinal(modifiers), "Node successor field %s should not be final", field);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
357 directSuccessors++;
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
358 }
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
359 successors.add(new EdgeInfo(offset, field.getName(), type));
16332
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16239
diff changeset
360 } else {
17247
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
361 GraalInternalError.guarantee(!NODE_CLASS.isAssignableFrom(type) || field.getName().equals("Null"), "suspicious node field: %s", field);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
362 GraalInternalError.guarantee(!INPUT_LIST_CLASS.isAssignableFrom(type), "suspicious node input list field: %s", field);
eed077c367d3 improved performance of NodeClass initialization by improving the way information is derived from super NodeClasses
Doug Simon <doug.simon@oracle.com>
parents: 17244
diff changeset
363 GraalInternalError.guarantee(!SUCCESSOR_LIST_CLASS.isAssignableFrom(type), "suspicious node successor list field: %s", field);
18261
d66c79acfeac refactored Fields class to make it usable for implementing custom serialization
Doug Simon <doug.simon@oracle.com>
parents: 17450
diff changeset
364 super.scanField(field, offset);
16332
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16239
diff changeset
365 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
366 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
367 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
369
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
370 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
371 public String toString() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
372 StringBuilder str = new StringBuilder();
15295
21663230ba88 Move FieldIntrospection to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15241
diff changeset
373 str.append("NodeClass ").append(getClazz().getSimpleName()).append(" [");
17226
a552dd335bde generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents: 17225
diff changeset
374 inputs.appendFields(str);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
375 str.append("] [");
17226
a552dd335bde generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents: 17225
diff changeset
376 successors.appendFields(str);
a552dd335bde generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents: 17225
diff changeset
377 str.append("] [");
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
378 data.appendFields(str);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
379 str.append("]");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
380 return str.toString();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
381 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
382
12696
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
383 private static int deepHashCode0(Object o) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
384 if (o instanceof Object[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
385 return Arrays.deepHashCode((Object[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
386 } else if (o instanceof byte[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
387 return Arrays.hashCode((byte[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
388 } else if (o instanceof short[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
389 return Arrays.hashCode((short[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
390 } else if (o instanceof int[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
391 return Arrays.hashCode((int[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
392 } else if (o instanceof long[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
393 return Arrays.hashCode((long[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
394 } else if (o instanceof char[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
395 return Arrays.hashCode((char[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
396 } else if (o instanceof float[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
397 return Arrays.hashCode((float[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
398 } else if (o instanceof double[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
399 return Arrays.hashCode((double[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
400 } else if (o instanceof boolean[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
401 return Arrays.hashCode((boolean[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
402 } else if (o != null) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
403 return o.hashCode();
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
404 } else {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
405 return 0;
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
406 }
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
407 }
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
408
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409 public int valueNumber(Node n) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
410 int number = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
411 if (canGVN) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
412 number = startGVNNumber;
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
413 for (int i = 0; i < data.getCount(); ++i) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
414 Class<?> type = data.getType(i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
415 if (type.isPrimitive()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
416 if (type == Integer.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
417 int intValue = data.getInt(n, i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
418 number += intValue;
6657
768793150bcd more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents: 6414
diff changeset
419 } else if (type == Long.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
420 long longValue = data.getLong(n, i);
6657
768793150bcd more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents: 6414
diff changeset
421 number += longValue ^ (longValue >>> 32);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
422 } else if (type == Boolean.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
423 boolean booleanValue = data.getBoolean(n, i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
424 if (booleanValue) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
425 number += 7;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
426 }
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
427 } else if (type == Float.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
428 float floatValue = data.getFloat(n, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
429 number += Float.floatToRawIntBits(floatValue);
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
430 } else if (type == Double.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
431 double doubleValue = data.getDouble(n, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
432 long longValue = Double.doubleToRawLongBits(doubleValue);
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
433 number += longValue ^ (longValue >>> 32);
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
434 } else if (type == Short.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
435 short shortValue = data.getShort(n, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
436 number += shortValue;
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
437 } else if (type == Character.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
438 char charValue = data.getChar(n, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
439 number += charValue;
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
440 } else if (type == Byte.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
441 byte byteValue = data.getByte(n, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
442 number += byteValue;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
443 } else {
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
444 assert false : "unhandled property type: " + type;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
446 } else {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
447 Object o = data.getObject(n, i);
12696
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
448 number += deepHashCode0(o);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
449 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
450 number *= 13;
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
453 return number;
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
12696
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
456 private static boolean deepEquals0(Object e1, Object e2) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
457 assert e1 != null;
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
458 boolean eq;
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
459 if (e1 instanceof Object[] && e2 instanceof Object[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
460 eq = Arrays.deepEquals((Object[]) e1, (Object[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
461 } else if (e1 instanceof byte[] && e2 instanceof byte[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
462 eq = Arrays.equals((byte[]) e1, (byte[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
463 } else if (e1 instanceof short[] && e2 instanceof short[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
464 eq = Arrays.equals((short[]) e1, (short[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
465 } else if (e1 instanceof int[] && e2 instanceof int[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
466 eq = Arrays.equals((int[]) e1, (int[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
467 } else if (e1 instanceof long[] && e2 instanceof long[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
468 eq = Arrays.equals((long[]) e1, (long[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
469 } else if (e1 instanceof char[] && e2 instanceof char[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
470 eq = Arrays.equals((char[]) e1, (char[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
471 } else if (e1 instanceof float[] && e2 instanceof float[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
472 eq = Arrays.equals((float[]) e1, (float[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
473 } else if (e1 instanceof double[] && e2 instanceof double[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
474 eq = Arrays.equals((double[]) e1, (double[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
475 } else if (e1 instanceof boolean[] && e2 instanceof boolean[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
476 eq = Arrays.equals((boolean[]) e1, (boolean[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
477 } else {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
478 eq = e1.equals(e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
479 }
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
480 return eq;
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
481 }
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
482
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17308
diff changeset
483 public boolean dataEquals(Node a, Node b) {
17276
ffb974bef674 moved Node valueNumber and valueEquals logic (optionally) to generated nodes
Doug Simon <doug.simon@oracle.com>
parents: 17274
diff changeset
484 assert a.getClass() == b.getClass();
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
485 for (int i = 0; i < data.getCount(); ++i) {
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
486 Class<?> type = data.getType(i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487 if (type.isPrimitive()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
488 if (type == Integer.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
489 int aInt = data.getInt(a, i);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
490 int bInt = data.getInt(b, i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
491 if (aInt != bInt) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
492 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
493 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
494 } else if (type == Boolean.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
495 boolean aBoolean = data.getBoolean(a, i);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
496 boolean bBoolean = data.getBoolean(b, i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
497 if (aBoolean != bBoolean) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
498 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
499 }
5301
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
500 } else if (type == Long.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
501 long aLong = data.getLong(a, i);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
502 long bLong = data.getLong(b, i);
5301
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
503 if (aLong != bLong) {
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
504 return false;
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
505 }
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
506 } else if (type == Float.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
507 float aFloat = data.getFloat(a, i);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
508 float bFloat = data.getFloat(b, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
509 if (aFloat != bFloat) {
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
510 return false;
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
511 }
10785
debb9d8e0282 allow double fields in value number computation and thus, in floating nodes
Doug Simon <doug.simon@oracle.com>
parents: 10424
diff changeset
512 } else if (type == Double.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
513 double aDouble = data.getDouble(a, i);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
514 double bDouble = data.getDouble(b, i);
10785
debb9d8e0282 allow double fields in value number computation and thus, in floating nodes
Doug Simon <doug.simon@oracle.com>
parents: 10424
diff changeset
515 if (aDouble != bDouble) {
debb9d8e0282 allow double fields in value number computation and thus, in floating nodes
Doug Simon <doug.simon@oracle.com>
parents: 10424
diff changeset
516 return false;
debb9d8e0282 allow double fields in value number computation and thus, in floating nodes
Doug Simon <doug.simon@oracle.com>
parents: 10424
diff changeset
517 }
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
518 } else if (type == Short.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
519 short aShort = data.getShort(a, i);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
520 short bShort = data.getShort(b, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
521 if (aShort != bShort) {
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
522 return false;
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
523 }
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
524 } else if (type == Character.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
525 char aChar = data.getChar(a, i);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
526 char bChar = data.getChar(b, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
527 if (aChar != bChar) {
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
528 return false;
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
529 }
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
530 } else if (type == Byte.TYPE) {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
531 byte aByte = data.getByte(a, i);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
532 byte bByte = data.getByte(b, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
533 if (aByte != bByte) {
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
534 return false;
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
535 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
536 } else {
5301
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
537 assert false : "unhandled type: " + type;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
538 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
539 } else {
17244
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
540 Object objectA = data.getObject(a, i);
aef31f60e970 converted all FieldIntrospection subclass to use Fields
Doug Simon <doug.simon@oracle.com>
parents: 17231
diff changeset
541 Object objectB = data.getObject(b, i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
542 if (objectA != objectB) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
543 if (objectA != null && objectB != null) {
12696
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
544 if (!deepEquals0(objectA, objectB)) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
545 return false;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
546 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
547 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
548 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
549 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
550 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
551 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
552 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
553 return true;
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
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19105
diff changeset
556 public boolean isValid(Position pos, NodeClass<?> from, Edges fromEdges) {
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5487
diff changeset
557 if (this == from) {
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5487
diff changeset
558 return true;
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5487
diff changeset
559 }
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
560 Edges toEdges = getEdges(fromEdges.type());
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
561 if (pos.getIndex() >= toEdges.getCount()) {
5214
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
562 return false;
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
563 }
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
564 if (pos.getIndex() >= fromEdges.getCount()) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
565 return false;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
566 }
17226
a552dd335bde generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents: 17225
diff changeset
567 return toEdges.isSame(fromEdges, pos.getIndex());
15827
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
568 }
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
569
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
570 static void updateEdgesInPlace(Node node, InplaceUpdateClosure duplicationReplacement, Edges edges) {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
571 int index = 0;
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
572 while (index < edges.getDirectCount()) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
573 Node edge = edges.getNode(node, index);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
574 if (edge != null) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
575 Node newEdge = duplicationReplacement.replacement(edge, edges.type());
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
576 if (edges.type() == Edges.Type.Inputs) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
577 node.updateUsages(null, newEdge);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
578 } else {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
579 node.updatePredecessor(null, newEdge);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
580 }
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
581 assert newEdge == null || edges.getType(index).isAssignableFrom(newEdge.getClass()) : "Can not assign " + newEdge.getClass() + " to " + edges.getType(index) + " in " + node;
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
582 edges.initializeNode(node, index, newEdge);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
583 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
584 index++;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
585 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
586
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
587 while (index < edges.getCount()) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
588 NodeList<Node> list = edges.getNodeList(node, index);
18925
14599c77560a Do not always allocate monitorId NodeInputList. Allow null NodeInputList.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18884
diff changeset
589 if (list != null) {
14599c77560a Do not always allocate monitorId NodeInputList. Allow null NodeInputList.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18884
diff changeset
590 edges.initializeList(node, index, updateEdgeListCopy(node, list, duplicationReplacement, edges.type()));
14599c77560a Do not always allocate monitorId NodeInputList. Allow null NodeInputList.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18884
diff changeset
591 }
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
592 index++;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
593 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
594 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
595
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
596 void updateInputSuccInPlace(Node node, InplaceUpdateClosure duplicationReplacement) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
597 updateEdgesInPlace(node, duplicationReplacement, inputs);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
598 updateEdgesInPlace(node, duplicationReplacement, successors);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
599 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
600
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
601 private static NodeList<Node> updateEdgeListCopy(Node node, NodeList<Node> list, InplaceUpdateClosure duplicationReplacement, Edges.Type type) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
602 NodeList<Node> result = type == Edges.Type.Inputs ? new NodeInputList<>(node, list.size()) : new NodeSuccessorList<>(node, list.size());
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
603
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
604 for (int i = 0; i < list.count(); ++i) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
605 Node oldNode = list.get(i);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
606 if (oldNode != null) {
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
607 Node newNode = duplicationReplacement.replacement(oldNode, type);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
608 result.set(i, newNode);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
609 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
610 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
611 return result;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
612 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
613
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
614 /**
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
615 * Gets the input or successor edges defined by this node class.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
616 */
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
617 public Edges getEdges(Edges.Type type) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
618 return type == Edges.Type.Inputs ? inputs : successors;
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
619 }
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
620
15827
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
621 /**
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
622 * Initializes a fresh allocated node for which no constructor is called yet. Needed to
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
623 * implement node factories in svm.
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
624 */
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
625 public void initRawNode(Node node) {
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
626 node.init();
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
627 initNullEdgeLists(node, Edges.Type.Inputs);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
628 initNullEdgeLists(node, Edges.Type.Successors);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
629 }
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
630
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
631 private void initNullEdgeLists(Node node, Edges.Type type) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
632 Edges edges = getEdges(type);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
633 for (int inputPos = edges.getDirectCount(); inputPos < edges.getCount(); inputPos++) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
634 if (edges.getNodeList(node, inputPos) == null) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
635 edges.initializeList(node, inputPos, type == Edges.Type.Inputs ? new NodeInputList<>(node) : new NodeSuccessorList<>(node));
15827
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
636 }
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
637 }
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
638 }
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
639
19470
d216de21bfe8 Fix unchecked warnings in NodeClass.
Roland Schatz <roland.schatz@oracle.com>
parents: 19454
diff changeset
640 public Class<T> getJavaClass() {
15295
21663230ba88 Move FieldIntrospection to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15241
diff changeset
641 return getClazz();
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
642 }
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
643
17272
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
644 /**
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
645 * The template used to build the {@link Verbosity#Name} version. Variable parts are specified
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
646 * using &#123;i#inputName&#125; or &#123;p#propertyName&#125;.
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
647 */
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
648 public String getNameTemplate() {
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
649 return nameTemplate.isEmpty() ? shortName() : nameTemplate;
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
650 }
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
651
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
652 interface InplaceUpdateClosure {
17272
9eb112c9337d moved Node naming logic back to NodeClass (without impacting NodeClass constructor performance)
Doug Simon <doug.simon@oracle.com>
parents: 17258
diff changeset
653
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
654 Node replacement(Node node, Edges.Type type);
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
655 }
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
656
17366
84f9c2baab1d Relax type signature in Graph.addDuplicates method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17338
diff changeset
657 static Map<Node, Node> addGraphDuplicate(final Graph graph, final Graph oldGraph, int estimatedNodeCount, Iterable<? extends Node> nodes, final DuplicationReplacement replacements) {
12685
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
658 final Map<Node, Node> newNodes;
15551
33cedbce5b23 added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents: 15295
diff changeset
659 int denseThreshold = oldGraph.getNodeCount() + oldGraph.getNodesDeletedSinceLastCompression() >> 4;
33cedbce5b23 added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents: 15295
diff changeset
660 if (estimatedNodeCount > denseThreshold) {
12685
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
661 // Use dense map
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
662 newNodes = new NodeNodeMap(oldGraph);
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
663 } else {
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
664 // Use sparse map
15551
33cedbce5b23 added CollectionsProvider and NodeCollectionsProvider and replaced (almost) all allocations of IdentityHashMaps to go through these providers
Doug Simon <doug.simon@oracle.com>
parents: 15295
diff changeset
665 newNodes = newIdentityMap();
12685
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
666 }
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
667 createNodeDuplicates(graph, nodes, replacements, newNodes);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
668
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
669 InplaceUpdateClosure replacementClosure = new InplaceUpdateClosure() {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
670
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
671 public Node replacement(Node node, Edges.Type type) {
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
672 Node target = newNodes.get(node);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
673 if (target == null) {
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
674 Node replacement = node;
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
675 if (replacements != null) {
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
676 replacement = replacements.replacement(node);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
677 }
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
678 if (replacement != node) {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
679 target = replacement;
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
680 } else if (node.graph() == graph && type == Edges.Type.Inputs) {
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
681 // patch to the outer world
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
682 target = node;
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
683 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
684
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
685 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
686 return target;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
687 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
688
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
689 };
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
690
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
691 // re-wire inputs
11675
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11674
diff changeset
692 for (Node oldNode : nodes) {
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11674
diff changeset
693 Node node = newNodes.get(oldNode);
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19105
diff changeset
694 NodeClass<?> nodeClass = node.getNodeClass();
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
695 if (replacements == null || replacements.replacement(oldNode) == oldNode) {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
696 nodeClass.updateInputSuccInPlace(node, replacementClosure);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
697 } else {
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
698 transferEdgesDifferentNodeClass(graph, replacements, newNodes, oldNode, node);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
699 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
700 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
701
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
702 return newNodes;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
703 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
704
17366
84f9c2baab1d Relax type signature in Graph.addDuplicates method.
Roland Schatz <roland.schatz@oracle.com>
parents: 17338
diff changeset
705 private static void createNodeDuplicates(final Graph graph, Iterable<? extends Node> nodes, final DuplicationReplacement replacements, final Map<Node, Node> newNodes) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
706 for (Node node : nodes) {
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
707 if (node != null) {
6302
5d7d9a6953bd added InstanceOfSnippets which passes InstanceOfTest but is not yet enabled for general lowering
Doug Simon <doug.simon@oracle.com>
parents: 5858
diff changeset
708 assert !node.isDeleted() : "trying to duplicate deleted node: " + node;
11671
3522f7c99c5f Allow null DuplicationReplacement in addDuplicates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
709 Node replacement = node;
3522f7c99c5f Allow null DuplicationReplacement in addDuplicates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
710 if (replacements != null) {
3522f7c99c5f Allow null DuplicationReplacement in addDuplicates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
711 replacement = replacements.replacement(node);
3522f7c99c5f Allow null DuplicationReplacement in addDuplicates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
712 }
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
713 if (replacement != node) {
18884
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18651
diff changeset
714 if (Fingerprint.ENABLED) {
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18651
diff changeset
715 Fingerprint.submit("replacing %s with %s", node, replacement);
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18651
diff changeset
716 }
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
717 assert replacement != null;
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5487
diff changeset
718 newNodes.put(node, replacement);
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
719 } else {
18884
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18651
diff changeset
720 if (Fingerprint.ENABLED) {
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18651
diff changeset
721 Fingerprint.submit("duplicating %s", node);
0857a4186ecd added Fingerprint points to assist debugging replay compilation
Doug Simon <doug.simon@oracle.com>
parents: 18651
diff changeset
722 }
17338
1778c3208bc5 reduce or eliminate redundant writes during Node cloning
Doug Simon <doug.simon@oracle.com>
parents: 17316
diff changeset
723 Node newNode = node.clone(graph, WithAllEdges);
18937
ff232ff8d028 Add utility Node#hasNoUsages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 18925
diff changeset
724 assert newNode.inputs().isEmpty() || newNode.hasNoUsages();
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
725 assert newNode.getClass() == node.getClass();
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
726 newNodes.put(node, newNode);
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
727 }
3733
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 }
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
730 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
731
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
732 private static void transferEdgesDifferentNodeClass(final Graph graph, final DuplicationReplacement replacements, final Map<Node, Node> newNodes, Node oldNode, Node node) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
733 transferEdges(graph, replacements, newNodes, oldNode, node, Edges.Type.Inputs);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
734 transferEdges(graph, replacements, newNodes, oldNode, node, Edges.Type.Successors);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
735 }
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
736
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
737 private static void transferEdges(final Graph graph, final DuplicationReplacement replacements, final Map<Node, Node> newNodes, Node oldNode, Node node, Edges.Type type) {
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19105
diff changeset
738 NodeClass<?> nodeClass = node.getNodeClass();
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 19105
diff changeset
739 NodeClass<?> oldNodeClass = oldNode.getNodeClass();
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
740 Edges oldEdges = oldNodeClass.getEdges(type);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
741 for (NodePosIterator oldIter = oldEdges.getIterable(oldNode).iterator(); oldIter.hasNext();) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
742 Position pos = oldIter.nextPosition();
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
743 if (!nodeClass.isValid(pos, oldNodeClass, oldEdges)) {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
744 continue;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
745 }
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
746 Node oldEdge = pos.get(oldNode);
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
747 Node target = newNodes.get(oldEdge);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
748 if (target == null) {
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
749 Node replacement = oldEdge;
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
750 if (replacements != null) {
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
751 replacement = replacements.replacement(oldEdge);
5489
5d0d72b37f88 Switch to new loop transformation framework, use it for peeling and full unrolling for snippets
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5487
diff changeset
752 }
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
753 if (replacement != oldEdge) {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
754 target = replacement;
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
755 } else if (type == Edges.Type.Inputs && oldEdge.graph() == graph) {
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
756 // patch to the outer world
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
757 target = oldEdge;
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 }
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
760 pos.set(node, target);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
761 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
762 }
16919
0fe4732e5181 made use of generated Node classes predicated on value of graal.useGeneratedNodes system property (default is false)
Doug Simon <doug.simon@oracle.com>
parents: 16903
diff changeset
763
17316
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17308
diff changeset
764 /**
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17308
diff changeset
765 * @returns true if the node has no inputs and no successors
e6e678c3818f only generate data fields equality method for leaf ValueNumberable nodes; no longer generate Node.isLeafNode()
Doug Simon <doug.simon@oracle.com>
parents: 17308
diff changeset
766 */
16919
0fe4732e5181 made use of generated Node classes predicated on value of graal.useGeneratedNodes system property (default is false)
Doug Simon <doug.simon@oracle.com>
parents: 16903
diff changeset
767 public boolean isLeafNode() {
0fe4732e5181 made use of generated Node classes predicated on value of graal.useGeneratedNodes system property (default is false)
Doug Simon <doug.simon@oracle.com>
parents: 16903
diff changeset
768 return isLeafNode;
0fe4732e5181 made use of generated Node classes predicated on value of graal.useGeneratedNodes system property (default is false)
Doug Simon <doug.simon@oracle.com>
parents: 16903
diff changeset
769 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
770 }