annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java @ 17231:58f1d1335ef4

force inline Fields.getObject(Object, int, Class) so that a constant value bound to its last parameter is connected with the DeferredPiNode used in Fields.getObject(Object, long, Class)
author Doug Simon <doug.simon@oracle.com>
date Fri, 26 Sep 2014 14:53:23 +0200
parents a552dd335bde
children aef31f60e970
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
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
25 import static com.oracle.graal.graph.Node.*;
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
26 import static com.oracle.graal.graph.util.CollectionsAccess.*;
16991
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
27 import static java.lang.reflect.Modifier.*;
11524
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11434
diff changeset
28
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
29 import java.lang.reflect.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15186
diff changeset
32 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
33 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
34 import com.oracle.graal.debug.internal.*;
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
35 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
36 import com.oracle.graal.graph.Node.Input;
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14616
diff changeset
37 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
38 import com.oracle.graal.graph.spi.*;
16841
cbd42807a31f moved NodeInfo and friends into separate com.oracle.graal.nodeinfo project so that annotation processor can be applied to the base Node class
Doug Simon <doug.simon@oracle.com>
parents: 16554
diff changeset
39 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
40
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
41 /**
15106
6876a4599b7e create NodeClass for each Node subclass during class initialization of the latter
Doug Simon <doug.simon@oracle.com>
parents: 15040
diff changeset
42 * 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
43 * <ul>
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
44 * <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
45 * 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
46 * <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
47 * </ul>
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
48 */
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
49 public final class NodeClass extends FieldIntrospection {
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
50
15106
6876a4599b7e create NodeClass for each Node subclass during class initialization of the latter
Doug Simon <doug.simon@oracle.com>
parents: 15040
diff changeset
51 private static final Object GetNodeClassLock = new Object();
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
52
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
53 // Timers for creation of a NodeClass instance
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
54 private static final DebugTimer Init = Debug.timer("NodeClass.Init");
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
55 private static final DebugTimer Init_FieldScanning = Debug.timer("NodeClass.Init.FieldScanning");
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
56 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
57 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
58 private static final DebugTimer Init_Naming = Debug.timer("NodeClass.Init.Naming");
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
59 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
60 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
61
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
62 /**
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
63 * 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
64 */
11434
0d9fe4e80ab8 moved warning suppression annotation to placate JDT
Doug Simon <doug.simon@oracle.com>
parents: 11431
diff changeset
65 @SuppressWarnings("unchecked")
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
66 public static NodeClass get(Class<?> c) {
16982
5762848171e7 replaced 'node.getClass() == <literal>.getGenClass()' idiom with new 'NodeClass.is(Class<? extends Node.class> cls)' mechanism
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
67 Class<? extends Node> key = (Class<? extends Node>) c;
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
68
15106
6876a4599b7e create NodeClass for each Node subclass during class initialization of the latter
Doug Simon <doug.simon@oracle.com>
parents: 15040
diff changeset
69 NodeClass value = (NodeClass) allClasses.get(key);
6876a4599b7e create NodeClass for each Node subclass during class initialization of the latter
Doug Simon <doug.simon@oracle.com>
parents: 15040
diff changeset
70 // The fact that {@link ConcurrentHashMap#put} and {@link ConcurrentHashMap#get}
6876a4599b7e create NodeClass for each Node subclass during class initialization of the latter
Doug Simon <doug.simon@oracle.com>
parents: 15040
diff changeset
71 // are used makes the double-checked locking idiom work.
6876a4599b7e create NodeClass for each Node subclass during class initialization of the latter
Doug Simon <doug.simon@oracle.com>
parents: 15040
diff changeset
72 if (value == null) {
6876a4599b7e create NodeClass for each Node subclass during class initialization of the latter
Doug Simon <doug.simon@oracle.com>
parents: 15040
diff changeset
73 // The creation of a NodeClass must be serialized as the NodeClass constructor accesses
6876a4599b7e create NodeClass for each Node subclass during class initialization of the latter
Doug Simon <doug.simon@oracle.com>
parents: 15040
diff changeset
74 // both FieldIntrospection.allClasses and NodeClass.nextIterableId.
6876a4599b7e create NodeClass for each Node subclass during class initialization of the latter
Doug Simon <doug.simon@oracle.com>
parents: 15040
diff changeset
75 synchronized (GetNodeClassLock) {
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
76 try (TimerCloseable t = Init.start()) {
17147
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
77 value = (NodeClass) allClasses.get(key);
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
78 if (value == null) {
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
79 GeneratedNode gen = c.getAnnotation(GeneratedNode.class);
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
80 if (gen != null) {
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
81 Class<? extends Node> originalNodeClass = (Class<? extends Node>) gen.value();
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
82 value = (NodeClass) allClasses.get(originalNodeClass);
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
83 assert value != null;
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
84 if (value.genClass == null) {
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
85 value.genClass = (Class<? extends Node>) c;
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
86 } else {
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
87 assert value.genClass == c;
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
88 }
16991
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
89 } else {
17148
3837c6aa9fd0 ensure NodeClass initialization follows class hierarchy order
Doug Simon <doug.simon@oracle.com>
parents: 17147
diff changeset
90 Class<?> superclass = c.getSuperclass();
3837c6aa9fd0 ensure NodeClass initialization follows class hierarchy order
Doug Simon <doug.simon@oracle.com>
parents: 17147
diff changeset
91 if (superclass != NODE_CLASS) {
3837c6aa9fd0 ensure NodeClass initialization follows class hierarchy order
Doug Simon <doug.simon@oracle.com>
parents: 17147
diff changeset
92 // Ensure NodeClass for superclass exists
3837c6aa9fd0 ensure NodeClass initialization follows class hierarchy order
Doug Simon <doug.simon@oracle.com>
parents: 17147
diff changeset
93 get(superclass);
3837c6aa9fd0 ensure NodeClass initialization follows class hierarchy order
Doug Simon <doug.simon@oracle.com>
parents: 17147
diff changeset
94 }
17147
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
95 value = new NodeClass(key);
16991
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
96 }
17147
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
97 Object old = allClasses.putIfAbsent(key, value);
7a3f6543d383 added timer for NodeClass initializer (-Dgraal.debug.timer.NodeClassCreation=true)
Doug Simon <doug.simon@oracle.com>
parents: 17128
diff changeset
98 assert old == null : old + " " + key;
16982
5762848171e7 replaced 'node.getClass() == <literal>.getGenClass()' idiom with new 'NodeClass.is(Class<? extends Node.class> cls)' mechanism
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
99 }
15106
6876a4599b7e create NodeClass for each Node subclass during class initialization of the latter
Doug Simon <doug.simon@oracle.com>
parents: 15040
diff changeset
100 }
6876a4599b7e create NodeClass for each Node subclass during class initialization of the latter
Doug Simon <doug.simon@oracle.com>
parents: 15040
diff changeset
101 }
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
102 }
15106
6876a4599b7e create NodeClass for each Node subclass during class initialization of the latter
Doug Simon <doug.simon@oracle.com>
parents: 15040
diff changeset
103 return value;
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
104 }
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
105
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
106 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
107 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
108 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
109
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 private static int nextIterableId = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111
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
112 private final Edges 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
113 private final Edges successors;
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
114 private final Fields properties;
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
115
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 private final boolean canGVN;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 private final int startGVNNumber;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118 private final String shortName;
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
119 private final String nameTemplate;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120 private final int iterableId;
15002
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
121 private final EnumSet<InputType> allowedUsageTypes;
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
122 private int[] iterableIds;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123
16991
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
124 /**
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
125 * The {@linkplain GeneratedNode generated} node class denoted by this object. This value is
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
126 * lazily initialized to avoid class initialization circularity issues. A sentinel value of
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
127 * {@code Node.class} is used to denote absence of a generated class.
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
128 */
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
129 private Class<? extends Node> genClass;
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
130
11642
5507e2824bc6 added metric to count IterableNodeTypes (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11631
diff changeset
131 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
132 private final DebugMetric nodeIterableCount;
11642
5507e2824bc6 added metric to count IterableNodeTypes (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11631
diff changeset
133
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
134 /**
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
135 * 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
136 */
16239
de84713267fa use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16206
diff changeset
137 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
138
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
139 /**
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 * 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
141 */
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
142 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
143 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
144
13127
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
145 public NodeClass(Class<?> clazz) {
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
146 this(clazz, new DefaultCalcOffset(), null, 0);
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
147 }
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
148
17188
55a924683e72 removed generated inputs/successors iterators and Position related methods
Doug Simon <doug.simon@oracle.com>
parents: 17187
diff changeset
149 private static long[] sortedOffsets(ArrayList<Long> list1, ArrayList<Long> list2) {
17008
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16991
diff changeset
150 if (list1.isEmpty() && list2.isEmpty()) {
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16991
diff changeset
151 return new long[0];
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16991
diff changeset
152 }
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16991
diff changeset
153 return sortedLongCopy(list1, list2);
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16991
diff changeset
154 }
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16991
diff changeset
155
13127
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
156 public NodeClass(Class<?> clazz, 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
157 super(clazz);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 assert NODE_CLASS.isAssignableFrom(clazz);
16239
de84713267fa use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16206
diff changeset
159
de84713267fa use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16206
diff changeset
160 this.isCanonicalizable = Canonicalizable.class.isAssignableFrom(clazz);
de84713267fa use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16206
diff changeset
161 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
162 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
163 }
2a1f3a8f76f1 handle Canonicalizable.Unary/Binary in CanonicalizerPhase and EquationalReasoner
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16154
diff changeset
164
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
165 this.isSimplifiable = Simplifiable.class.isAssignableFrom(clazz);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
166
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
167 FieldScanner fs = new FieldScanner(calcOffset);
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
168 try (TimerCloseable t = Init_FieldScanning.start()) {
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
169 fs.scan(clazz);
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
170 }
17008
81c9a1fc9072 select generated input and successor iterators if Node.USE_GENERATED_NODES
Doug Simon <doug.simon@oracle.com>
parents: 16991
diff changeset
171
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
172 try (TimerCloseable t1 = Init_Edges.start()) {
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
173 successors = new SuccessorEdges(clazz, fs.successorOffsets.size(), sortedOffsets(fs.successorOffsets, fs.successorListOffsets), fs.fieldNames, fs.fieldTypes);
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
174 inputs = new InputEdges(clazz, fs.inputOffsets.size(), sortedOffsets(fs.inputOffsets, fs.inputListOffsets), fs.fieldNames, fs.fieldTypes, fs.types, fs.optionalInputs);
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
175 }
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
176 try (TimerCloseable t1 = Init_Data.start()) {
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
177 properties = new Fields(clazz, sortedLongCopy(fs.dataOffsets), fs.fieldNames, fs.fieldTypes);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
179
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
180 isLeafNode = inputs.getCount() + successors.getCount() == 0;
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
181 fieldNames = fs.fieldNames;
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
182 fieldTypes = fs.fieldTypes;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 canGVN = Node.ValueNumberable.class.isAssignableFrom(clazz);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185 startGVNNumber = clazz.hashCode();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
187 String newNameTemplate = null;
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
188 String newShortName;
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
189 try (TimerCloseable t1 = Init_Naming.start()) {
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
190 newShortName = clazz.getSimpleName();
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
191 if (newShortName.endsWith("Node") && !newShortName.equals("StartNode") && !newShortName.equals("EndNode")) {
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
192 newShortName = newShortName.substring(0, newShortName.length() - 4);
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
193 }
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
194 NodeInfo info = clazz.getAnnotation(NodeInfo.class);
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
195 assert info != null : "missing " + NodeInfo.class.getSimpleName() + " annotation on " + clazz;
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
196 if (!info.shortName().isEmpty()) {
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
197 newShortName = info.shortName();
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
198 }
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
199 if (!info.nameTemplate().isEmpty()) {
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
200 newNameTemplate = info.nameTemplate();
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
201 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
202 }
15002
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
203 EnumSet<InputType> newAllowedUsageTypes = EnumSet.noneOf(InputType.class);
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
204 try (TimerCloseable t1 = Init_AllowedUsages.start()) {
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
205 Class<?> current = clazz;
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
206 do {
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
207 NodeInfo currentInfo = current.getAnnotation(NodeInfo.class);
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
208 if (currentInfo != null) {
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
209 if (currentInfo.allowedUsageTypes().length > 0) {
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
210 newAllowedUsageTypes.addAll(Arrays.asList(currentInfo.allowedUsageTypes()));
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
211 }
15002
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
212 }
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
213 current = current.getSuperclass();
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
214 } while (current != Node.class);
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
215 }
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
216 this.nameTemplate = newNameTemplate == null ? newShortName : newNameTemplate;
15002
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
217 this.allowedUsageTypes = newAllowedUsageTypes;
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
218 this.shortName = newShortName;
13127
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
219 if (presetIterableIds != null) {
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
220 this.iterableIds = presetIterableIds;
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
221 this.iterableId = presetIterableId;
f42f1f5d5ce0 Allow custom field offset providers
Christian Wimmer <christian.wimmer@oracle.com>
parents: 12701
diff changeset
222 } 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
223 ITERABLE_NODE_TYPES.increment();
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
224 try (TimerCloseable t1 = Init_IterableIds.start()) {
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
225 this.iterableId = nextIterableId++;
17148
3837c6aa9fd0 ensure NodeClass initialization follows class hierarchy order
Doug Simon <doug.simon@oracle.com>
parents: 17147
diff changeset
226
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
227 Class<?> superclass = clazz.getSuperclass();
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
228 while (superclass != NODE_CLASS) {
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
229 if (IterableNodeType.class.isAssignableFrom(superclass)) {
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
230 NodeClass superNodeClass = NodeClass.get(superclass);
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
231 assert !containsId(this.iterableId, superNodeClass.iterableIds);
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
232 superNodeClass.iterableIds = Arrays.copyOf(superNodeClass.iterableIds, superNodeClass.iterableIds.length + 1);
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
233 superNodeClass.iterableIds[superNodeClass.iterableIds.length - 1] = this.iterableId;
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
234 }
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
235 superclass = superclass.getSuperclass();
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
236 }
17175
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
237
63870b298b39 added timers for NodeClass creation
Doug Simon <doug.simon@oracle.com>
parents: 17148
diff changeset
238 this.iterableIds = new int[]{iterableId};
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
239 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
240 } 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
241 this.iterableId = Node.NOT_ITERABLE;
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
242 this.iterableIds = null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243 }
14616
aa7bcf1fa423 expanded Debug API to avoid any allocation for timer and metric creation if debugging is disabled
Doug Simon <doug.simon@oracle.com>
parents: 14157
diff changeset
244 nodeIterableCount = Debug.metric("NodeIterable_%s", shortName);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246
16991
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
247 /**
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
248 * Gets the {@linkplain GeneratedNode generated} node class (if any) described by the object.
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
249 */
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
250 @SuppressWarnings("unchecked")
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
251 public Class<? extends Node> getGenClass() {
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
252 if (USE_GENERATED_NODES) {
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
253 if (genClass == null) {
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
254 if (!isAbstract(getClazz().getModifiers())) {
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
255 String genClassName = getClazz().getName().replace('$', '_') + "Gen";
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
256 try {
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
257 genClass = (Class<? extends Node>) Class.forName(genClassName);
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
258 } catch (ClassNotFoundException e) {
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
259 throw new GraalInternalError("Could not find generated class " + genClassName + " for " + getClazz());
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
260 }
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
261 } else {
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
262 // Sentinel value denoting no generated class
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
263 genClass = Node.class;
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
264 }
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
265 }
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
266 return genClass.equals(Node.class) ? null : genClass;
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
267 }
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
268 return null;
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
269 }
4a6d852dbb68 added support to get the generated Node class represented by a NodeClass instance
Doug Simon <doug.simon@oracle.com>
parents: 16987
diff changeset
270
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
271 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
272 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
273 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
274 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
275 }
39d979dae809 need extra logic when computing Node iterable ids and USE_GENERATED_NODES == true
Doug Simon <doug.simon@oracle.com>
parents: 16986
diff changeset
276 }
39d979dae809 need extra logic when computing Node iterable ids and USE_GENERATED_NODES == true
Doug Simon <doug.simon@oracle.com>
parents: 16986
diff changeset
277 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
278 }
39d979dae809 need extra logic when computing Node iterable ids and USE_GENERATED_NODES == true
Doug Simon <doug.simon@oracle.com>
parents: 16986
diff changeset
279
16982
5762848171e7 replaced 'node.getClass() == <literal>.getGenClass()' idiom with new 'NodeClass.is(Class<? extends Node.class> cls)' mechanism
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
280 /**
17051
c25fcf343b4f improved javadoc for NodeClass.is()
Doug Simon <doug.simon@oracle.com>
parents: 17044
diff changeset
281 * Determines if a given {@link Node} class is described by this {@link NodeClass} object. This
c25fcf343b4f improved javadoc for NodeClass.is()
Doug Simon <doug.simon@oracle.com>
parents: 17044
diff changeset
282 * is useful for doing an exact type test (as opposed to an instanceof test) on a node. For
c25fcf343b4f improved javadoc for NodeClass.is()
Doug Simon <doug.simon@oracle.com>
parents: 17044
diff changeset
283 * example:
c25fcf343b4f improved javadoc for NodeClass.is()
Doug Simon <doug.simon@oracle.com>
parents: 17044
diff changeset
284 *
c25fcf343b4f improved javadoc for NodeClass.is()
Doug Simon <doug.simon@oracle.com>
parents: 17044
diff changeset
285 * <pre>
c25fcf343b4f improved javadoc for NodeClass.is()
Doug Simon <doug.simon@oracle.com>
parents: 17044
diff changeset
286 * if (node.getNodeClass().is(BeginNode.class)) { ... }
17231
58f1d1335ef4 force inline Fields.getObject(Object, int, Class) so that a constant value bound to its last parameter is connected with the DeferredPiNode used in Fields.getObject(Object, long, Class)
Doug Simon <doug.simon@oracle.com>
parents: 17226
diff changeset
287 *
17051
c25fcf343b4f improved javadoc for NodeClass.is()
Doug Simon <doug.simon@oracle.com>
parents: 17044
diff changeset
288 * // Due to generated Node classes, the test below
c25fcf343b4f improved javadoc for NodeClass.is()
Doug Simon <doug.simon@oracle.com>
parents: 17044
diff changeset
289 * // is *not* the same as the test above:
c25fcf343b4f improved javadoc for NodeClass.is()
Doug Simon <doug.simon@oracle.com>
parents: 17044
diff changeset
290 * if (node.getClass() == BeginNode.class) { ... }
c25fcf343b4f improved javadoc for NodeClass.is()
Doug Simon <doug.simon@oracle.com>
parents: 17044
diff changeset
291 * </pre>
16986
f7359a0ce946 tweaked comparison of a Node against a node class
Doug Simon <doug.simon@oracle.com>
parents: 16982
diff changeset
292 *
f7359a0ce946 tweaked comparison of a Node against a node class
Doug Simon <doug.simon@oracle.com>
parents: 16982
diff changeset
293 * @param nodeClass a {@linkplain GeneratedNode non-generated} {@link Node} class
16982
5762848171e7 replaced 'node.getClass() == <literal>.getGenClass()' idiom with new 'NodeClass.is(Class<? extends Node.class> cls)' mechanism
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
294 */
5762848171e7 replaced 'node.getClass() == <literal>.getGenClass()' idiom with new 'NodeClass.is(Class<? extends Node.class> cls)' mechanism
Doug Simon <doug.simon@oracle.com>
parents: 16919
diff changeset
295 public boolean is(Class<? extends Node> nodeClass) {
16986
f7359a0ce946 tweaked comparison of a Node against a node class
Doug Simon <doug.simon@oracle.com>
parents: 16982
diff changeset
296 assert nodeClass.getAnnotation(GeneratedNode.class) == null : "cannot test NodeClas against generated " + nodeClass;
f7359a0ce946 tweaked comparison of a Node against a node class
Doug Simon <doug.simon@oracle.com>
parents: 16982
diff changeset
297 return nodeClass == getClazz();
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
298 }
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
299
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
300 public String shortName() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
301 return shortName;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
302 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
303
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
304 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
305 nodeIterableCount.increment();
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
306 return iterableIds;
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
307 }
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
308
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
309 public int iterableId() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310 return iterableId;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
311 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
312
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
313 public boolean valueNumberable() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
314 return canGVN;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
315 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
316
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
317 /**
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
318 * 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
319 */
16239
de84713267fa use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16206
diff changeset
320 public boolean isCanonicalizable() {
de84713267fa use default methods to select Canonicalizable behavior
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16206
diff changeset
321 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
322 }
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
323
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
324 /**
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
325 * 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
326 */
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
327 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
328 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
329 }
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
330
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
331 public static int cacheSize() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
332 return nextIterableId;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
333 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
334
15002
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
335 public EnumSet<InputType> getAllowedUsageTypes() {
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
336 return allowedUsageTypes;
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
337 }
06e50d290784 isAllowedUsageType on Nodes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15001
diff changeset
338
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
339 protected static class FieldScanner extends BaseFieldScanner {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
340
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
341 public final ArrayList<Long> inputOffsets = new ArrayList<>();
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
342 public final ArrayList<Long> inputListOffsets = new ArrayList<>();
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
343 public final ArrayList<Long> successorOffsets = new ArrayList<>();
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
344 public final ArrayList<Long> successorListOffsets = new ArrayList<>();
15001
27c04ee36dcb input types
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
345 public final HashMap<Long, InputType> types = new HashMap<>();
16332
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16239
diff changeset
346 public final HashSet<Long> optionalInputs = new HashSet<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
347
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
348 protected FieldScanner(CalcOffset calc) {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
349 super(calc);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
350 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
351
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
352 @Override
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
353 protected void scanField(Field field, Class<?> type, long offset) {
16332
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16239
diff changeset
354 if (field.isAnnotationPresent(Node.Input.class) || field.isAnnotationPresent(Node.OptionalInput.class)) {
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
355 assert !field.isAnnotationPresent(Node.Successor.class) : "field cannot be both input and successor";
16332
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16239
diff changeset
356 assert field.isAnnotationPresent(Node.Input.class) ^ field.isAnnotationPresent(Node.OptionalInput.class) : "inputs can either be optional or non-optional";
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
357 if (INPUT_LIST_CLASS.isAssignableFrom(type)) {
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
358 // NodeInputList fields should not be final since they are
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
359 // written (via Unsafe) in clearInputs()
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
360 GraalInternalError.guarantee(!Modifier.isFinal(field.getModifiers()), "NodeInputList input field %s should not be final", field);
9808
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
361 GraalInternalError.guarantee(!Modifier.isPublic(field.getModifiers()), "NodeInputList input field %s should not be public", field);
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
362 inputListOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
363 } else {
9808
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
364 GraalInternalError.guarantee(NODE_CLASS.isAssignableFrom(type) || type.isInterface(), "invalid input type: %s", type);
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
365 GraalInternalError.guarantee(!Modifier.isFinal(field.getModifiers()), "Node input field %s should not be final", field);
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
366 inputOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
367 }
16332
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16239
diff changeset
368 if (field.isAnnotationPresent(Node.Input.class)) {
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16239
diff changeset
369 types.put(offset, field.getAnnotation(Node.Input.class).value());
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16239
diff changeset
370 } else {
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16239
diff changeset
371 types.put(offset, field.getAnnotation(Node.OptionalInput.class).value());
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16239
diff changeset
372 }
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16239
diff changeset
373 if (field.isAnnotationPresent(Node.OptionalInput.class)) {
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16239
diff changeset
374 optionalInputs.add(offset);
ddd68e267e34 explicitly define optional inputs in @Input
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16239
diff changeset
375 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
376 } else if (field.isAnnotationPresent(Node.Successor.class)) {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
377 if (SUCCESSOR_LIST_CLASS.isAssignableFrom(type)) {
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
378 // NodeSuccessorList fields should not be final since they are
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
379 // written (via Unsafe) in clearSuccessors()
f90dcdbbb75e switched to using new NodeFieldIterator and NodeFieldIterable for traversing Node inputs and successors
Doug Simon <doug.simon@oracle.com>
parents: 16841
diff changeset
380 GraalInternalError.guarantee(!Modifier.isFinal(field.getModifiers()), "NodeSuccessorList successor field % should not be final", field);
9808
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
381 GraalInternalError.guarantee(!Modifier.isPublic(field.getModifiers()), "NodeSuccessorList successor field %s should not be public", field);
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
382 successorListOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
383 } else {
9808
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
384 GraalInternalError.guarantee(NODE_CLASS.isAssignableFrom(type), "invalid successor type: %s", type);
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
385 GraalInternalError.guarantee(!Modifier.isFinal(field.getModifiers()), "Node successor field %s should not be final", field);
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
386 successorOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
387 }
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
388 } else {
9808
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
389 GraalInternalError.guarantee(!NODE_CLASS.isAssignableFrom(type) || field.getName().equals("Null"), "suspicious node field: %s", field);
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
390 GraalInternalError.guarantee(!INPUT_LIST_CLASS.isAssignableFrom(type), "suspicious node input list field: %s", field);
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
391 GraalInternalError.guarantee(!SUCCESSOR_LIST_CLASS.isAssignableFrom(type), "suspicious node successor list field: %s", field);
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
392 dataOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
393 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
394 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
395 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
396
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
397 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
398 public String toString() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 StringBuilder str = new StringBuilder();
15295
21663230ba88 Move FieldIntrospection to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15241
diff changeset
400 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
401 inputs.appendFields(str);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
402 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
403 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
404 str.append("] [");
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
405 properties.appendFields(str);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
406 str.append("]");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
407 return str.toString();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
408 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409
12696
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
410 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
411 if (o instanceof Object[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
412 return Arrays.deepHashCode((Object[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
413 } else if (o instanceof byte[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
414 return Arrays.hashCode((byte[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
415 } else if (o instanceof short[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
416 return Arrays.hashCode((short[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
417 } else if (o instanceof int[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
418 return Arrays.hashCode((int[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
419 } else if (o instanceof long[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
420 return Arrays.hashCode((long[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
421 } else if (o instanceof char[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
422 return Arrays.hashCode((char[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
423 } else if (o instanceof float[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
424 return Arrays.hashCode((float[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
425 } else if (o instanceof double[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
426 return Arrays.hashCode((double[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
427 } else if (o instanceof boolean[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
428 return Arrays.hashCode((boolean[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
429 } else if (o != null) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
430 return o.hashCode();
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
431 } else {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
432 return 0;
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
433 }
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
434 }
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
435
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436 public int valueNumber(Node n) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
437 int number = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438 if (canGVN) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
439 number = startGVNNumber;
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
440 for (int i = 0; i < properties.getCount(); ++i) {
a552dd335bde generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents: 17225
diff changeset
441 Class<?> type = properties.getType(i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
442 if (type.isPrimitive()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
443 if (type == Integer.TYPE) {
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
444 int intValue = properties.getInt(n, i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445 number += intValue;
6657
768793150bcd more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents: 6414
diff changeset
446 } else if (type == Long.TYPE) {
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
447 long longValue = properties.getLong(n, i);
6657
768793150bcd more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents: 6414
diff changeset
448 number += longValue ^ (longValue >>> 32);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
449 } else if (type == Boolean.TYPE) {
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
450 boolean booleanValue = properties.getBoolean(n, i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
451 if (booleanValue) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
452 number += 7;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
453 }
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
454 } else if (type == Float.TYPE) {
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
455 float floatValue = properties.getFloat(n, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
456 number += Float.floatToRawIntBits(floatValue);
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
457 } else if (type == Double.TYPE) {
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
458 double doubleValue = properties.getDouble(n, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
459 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
460 number += longValue ^ (longValue >>> 32);
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
461 } else if (type == Short.TYPE) {
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
462 short shortValue = properties.getShort(n, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
463 number += shortValue;
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
464 } else if (type == Character.TYPE) {
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
465 char charValue = properties.getChar(n, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
466 number += charValue;
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
467 } else if (type == Byte.TYPE) {
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
468 byte byteValue = properties.getByte(n, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
469 number += byteValue;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
470 } else {
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
471 assert false : "unhandled property type: " + type;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
472 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
473 } else {
17231
58f1d1335ef4 force inline Fields.getObject(Object, int, Class) so that a constant value bound to its last parameter is connected with the DeferredPiNode used in Fields.getObject(Object, long, Class)
Doug Simon <doug.simon@oracle.com>
parents: 17226
diff changeset
474 Object o = properties.getObject(n, i);
12696
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
475 number += deepHashCode0(o);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
476 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
477 number *= 13;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
479 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
480 return number;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
481 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
482
12696
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
483 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
484 assert e1 != null;
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
485 boolean eq;
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
486 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
487 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
488 } 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
489 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
490 } 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
491 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
492 } 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
493 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
494 } 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
495 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
496 } 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
497 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
498 } 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
499 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
500 } 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
501 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
502 } 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
503 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
504 } else {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
505 eq = e1.equals(e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
506 }
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
507 return eq;
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
508 }
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
509
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
510 public boolean valueEqual(Node a, Node b) {
15186
5e2cffe8b815 allow valueEqual for non-GVN node classes
Lukas Stadler <lukas.stadler@oracle.com>
parents: 15106
diff changeset
511 if (a.getClass() != b.getClass()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
512 return a == b;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
513 }
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
514 for (int i = 0; i < properties.getCount(); ++i) {
a552dd335bde generalized support for unsafe access to a subset of the fields of an object
Doug Simon <doug.simon@oracle.com>
parents: 17225
diff changeset
515 Class<?> type = properties.getType(i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
516 if (type.isPrimitive()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
517 if (type == Integer.TYPE) {
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
518 int aInt = properties.getInt(a, i);
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
519 int bInt = properties.getInt(b, i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
520 if (aInt != bInt) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
521 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
522 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
523 } else if (type == Boolean.TYPE) {
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
524 boolean aBoolean = properties.getBoolean(a, i);
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
525 boolean bBoolean = properties.getBoolean(b, i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
526 if (aBoolean != bBoolean) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
527 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
528 }
5301
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
529 } else if (type == Long.TYPE) {
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
530 long aLong = properties.getLong(a, i);
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
531 long bLong = properties.getLong(b, i);
5301
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
532 if (aLong != bLong) {
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
533 return false;
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
534 }
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
535 } else if (type == Float.TYPE) {
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
536 float aFloat = properties.getFloat(a, i);
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
537 float bFloat = properties.getFloat(b, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
538 if (aFloat != bFloat) {
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
539 return false;
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
540 }
10785
debb9d8e0282 allow double fields in value number computation and thus, in floating nodes
Doug Simon <doug.simon@oracle.com>
parents: 10424
diff changeset
541 } else if (type == Double.TYPE) {
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
542 double aDouble = properties.getDouble(a, i);
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
543 double bDouble = properties.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
544 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
545 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
546 }
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
547 } else if (type == Short.TYPE) {
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
548 short aShort = properties.getShort(a, i);
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
549 short bShort = properties.getShort(b, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
550 if (aShort != bShort) {
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
551 return false;
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
552 }
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
553 } else if (type == Character.TYPE) {
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
554 char aChar = properties.getChar(a, i);
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
555 char bChar = properties.getChar(b, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
556 if (aChar != bChar) {
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
557 return false;
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
558 }
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
559 } else if (type == Byte.TYPE) {
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
560 byte aByte = properties.getByte(a, i);
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
561 byte bByte = properties.getByte(b, i);
12701
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
562 if (aByte != bByte) {
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
563 return false;
42a60780c2c9 Add some missing cases for NodeClass.(getDebugProperties|valueEqual|valueNumber)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12696
diff changeset
564 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
565 } else {
5301
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
566 assert false : "unhandled type: " + type;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
567 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
568 } else {
17231
58f1d1335ef4 force inline Fields.getObject(Object, int, Class) so that a constant value bound to its last parameter is connected with the DeferredPiNode used in Fields.getObject(Object, long, Class)
Doug Simon <doug.simon@oracle.com>
parents: 17226
diff changeset
569 Object objectA = properties.getObject(a, i);
58f1d1335ef4 force inline Fields.getObject(Object, int, Class) so that a constant value bound to its last parameter is connected with the DeferredPiNode used in Fields.getObject(Object, long, Class)
Doug Simon <doug.simon@oracle.com>
parents: 17226
diff changeset
570 Object objectB = properties.getObject(b, i);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
571 if (objectA != objectB) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
572 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
573 if (!deepEquals0(objectA, objectB)) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
574 return false;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
575 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
576 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
577 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
578 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
579 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
580 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
581 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
582 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
583 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
584
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
585 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
586 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
587 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
588 }
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
589 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
590 if (pos.getIndex() >= toEdges.getCount()) {
5214
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
591 return false;
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
592 }
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
593 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
594 return false;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
595 }
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
596 return toEdges.isSame(fromEdges, pos.getIndex());
15827
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
597 }
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
598
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
599 /**
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
600 * Gets the non-edge properties defined by this node class.
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
601 */
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
602 public Fields getProperties() {
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
603 return properties;
15827
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
604 }
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
605
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
606 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
607 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
608 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
609 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
610 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
611 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
612 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
613 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
614 } 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
615 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
616 }
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 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
618 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
619 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
620 index++;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
621 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
622
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
623 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
624 NodeList<Node> list = edges.getNodeList(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
625 assert list != null : 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
626 edges.initializeList(node, index, updateEdgeListCopy(node, list, duplicationReplacement, edges.type()));
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
627 index++;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
628 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
629 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
630
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
631 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
632 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
633 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
634 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
635
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
636 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
637 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
638
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
639 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
640 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
641 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
642 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
643 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
644 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
645 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
646 return result;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
647 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
648
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
649 /**
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
650 * 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
651 */
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
652 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
653 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
654 }
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
655
15827
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
656 /**
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
657 * 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
658 * implement node factories in svm.
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
659 */
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
660 public void initRawNode(Node node) {
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
661 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
662 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
663 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
664 }
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
665
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
666 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
667 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
668 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
669 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
670 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
671 }
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
672 }
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
673 }
4e770fa50889 Make NodeClass more flexible
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15551
diff changeset
674
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
675 public Class<?> getJavaClass() {
15295
21663230ba88 Move FieldIntrospection to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents: 15241
diff changeset
676 return getClazz();
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
677 }
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
678
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
679 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
680 * The template used to build the {@link Verbosity#Name} version. Variable part are specified
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
681 * using &#123;i#inputName&#125; or &#123;p#propertyName&#125;.
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
682 */
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
683 public String getNameTemplate() {
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
684 return nameTemplate;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
685 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
686
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
687 interface InplaceUpdateClosure {
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
688
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
689 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
690 }
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
691
11675
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11674
diff changeset
692 static Map<Node, Node> addGraphDuplicate(final Graph graph, final Graph oldGraph, int estimatedNodeCount, Iterable<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
693 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
694 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
695 if (estimatedNodeCount > denseThreshold) {
12685
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
696 // Use dense map
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
697 newNodes = new NodeNodeMap(oldGraph);
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
698 } else {
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
699 // 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
700 newNodes = newIdentityMap();
12685
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
701 }
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
702 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
703
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
704 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
705
17210
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
706 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
707 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
708 if (target == null) {
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
709 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
710 if (replacements != null) {
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
711 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
712 }
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
713 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
714 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
715 } 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
716 // patch to the outer world
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
717 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
718 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
719
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
720 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
721 return target;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
722 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
723
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
724 };
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
725
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
726 // 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
727 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
728 Node node = newNodes.get(oldNode);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
729 NodeClass nodeClass = node.getNodeClass();
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
730 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
731 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
732 } 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
733 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
734 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
735 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
736
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
737 return newNodes;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
738 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
739
11675
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11674
diff changeset
740 private static void createNodeDuplicates(final Graph graph, Iterable<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
741 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
742 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
743 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
744 Node replacement = node;
3522f7c99c5f Allow null DuplicationReplacement in addDuplicates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
745 if (replacements != null) {
3522f7c99c5f Allow null DuplicationReplacement in addDuplicates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
746 replacement = replacements.replacement(node);
3522f7c99c5f Allow null DuplicationReplacement in addDuplicates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
747 }
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
748 if (replacement != node) {
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
749 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
750 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
751 } else {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
752 Node newNode = node.clone(graph, false);
12612
42a2c235652f replace ".count() == 0" with ".isEmpty()"
Doug Simon <doug.simon@oracle.com>
parents: 12574
diff changeset
753 assert newNode.inputs().isEmpty() || newNode.usages().isEmpty();
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
754 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
755 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
756 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
757 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
758 }
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
759 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
760
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
761 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
762 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
763 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
764 }
ef64e2682bb6 added Edges class to consolidate code operating on set of input or successor edges and to better isolate magic used to access edges
Doug Simon <doug.simon@oracle.com>
parents: 17188
diff changeset
765
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
766 private static void transferEdges(final Graph graph, final DuplicationReplacement replacements, final Map<Node, Node> newNodes, Node oldNode, 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
767 NodeClass nodeClass = node.getNodeClass();
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
768 NodeClass oldNodeClass = oldNode.getNodeClass();
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
769 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
770 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
771 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
772 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
773 continue;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
774 }
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
775 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
776 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
777 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
778 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
779 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
780 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
781 }
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
782 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
783 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
784 } 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
785 // 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
786 target = oldEdge;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
787 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
788 }
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
789 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
790 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
791 }
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
792
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
793 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
794 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
795 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
796 }