annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java @ 10785:debb9d8e0282

allow double fields in value number computation and thus, in floating nodes
author Doug Simon <doug.simon@oracle.com>
date Tue, 16 Jul 2013 16:36:21 +0200
parents e6cf435419b2
children ca53d08b8ef9
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 /*
9720
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
2 * Copyright (c) 2011, 2013, 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
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
25 import java.lang.reflect.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26 import java.util.*;
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
27 import java.util.Map.Entry;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
29 import com.oracle.graal.graph.Graph.DuplicationReplacement;
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
30 import com.oracle.graal.graph.Node.Verbosity;
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
31
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
32 public class NodeClass extends FieldIntrospection {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
33
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
34 public static final NodeClass get(Class<?> c) {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
35 NodeClass clazz = (NodeClass) allClasses.get(c);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
36 if (clazz != null) {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
37 return clazz;
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
38 }
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
39
9720
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
40 /*
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
41 * Using putIfAbsent doesn't work here, because the creation of NodeClass needs to be
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
42 * serialized. (the NodeClass constructor looks at allClasses, and it also uses the static
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
43 * field nextIterableId)
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
44 *
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
45 * The fact that ConcurrentHashMap.put and .get are used should make the double-checked
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
46 * locking idiom work, since it internally uses volatile.
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
47 */
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
48
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
49 synchronized (allClasses) {
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
50 clazz = (NodeClass) allClasses.get(c);
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
51 if (clazz == null) {
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
52 clazz = new NodeClass(c);
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
53 NodeClass oldClass = (NodeClass) allClasses.putIfAbsent(c, clazz);
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
54 assert oldClass == null;
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
55 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
56 return clazz;
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
57 }
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
58 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
60 static final int NOT_ITERABLE = -1;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
62 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
63 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
64 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
65
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 private static int nextIterableId = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 private final int directInputCount;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 private final long[] inputOffsets;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 private final int directSuccessorCount;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71 private final long[] successorOffsets;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 private final Class<?>[] dataTypes;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73 private final boolean canGVN;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 private final int startGVNNumber;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 private final String shortName;
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
76 private final String nameTemplate;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 private final int iterableId;
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
78 private int[] iterableIds;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
80 public NodeClass(Class<?> clazz) {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
81 super(clazz);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 assert NODE_CLASS.isAssignableFrom(clazz);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84 FieldScanner scanner = new FieldScanner(new DefaultCalcOffset());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85 scanner.scan(clazz);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 directInputCount = scanner.inputOffsets.size();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88 inputOffsets = sortedLongCopy(scanner.inputOffsets, scanner.inputListOffsets);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
89 directSuccessorCount = scanner.successorOffsets.size();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
90 successorOffsets = sortedLongCopy(scanner.successorOffsets, scanner.successorListOffsets);
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
91
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
92 dataOffsets = sortedLongCopy(scanner.dataOffsets);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
93 dataTypes = new Class[dataOffsets.length];
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
94 for (int i = 0; i < dataOffsets.length; i++) {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
95 dataTypes[i] = scanner.fieldTypes.get(dataOffsets[i]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
96 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
97
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
98 fieldNames = scanner.fieldNames;
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
99 fieldTypes = scanner.fieldTypes;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
101 canGVN = Node.ValueNumberable.class.isAssignableFrom(clazz);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102 startGVNNumber = clazz.hashCode();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
104 String newShortName = clazz.getSimpleName();
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
105 if (newShortName.endsWith("Node") && !newShortName.equals("StartNode") && !newShortName.equals("EndNode")) {
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
106 newShortName = newShortName.substring(0, newShortName.length() - 4);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 }
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
108 String newNameTemplate = null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109 NodeInfo info = clazz.getAnnotation(NodeInfo.class);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 if (info != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111 if (!info.shortName().isEmpty()) {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
112 newShortName = info.shortName();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 }
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
114 if (!info.nameTemplate().isEmpty()) {
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
115 newNameTemplate = info.nameTemplate();
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
116 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 }
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
118 this.nameTemplate = newNameTemplate == null ? newShortName : newNameTemplate;
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
119 this.shortName = newShortName;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120 if (Node.IterableNodeType.class.isAssignableFrom(clazz)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 this.iterableId = nextIterableId++;
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
122 List<NodeClass> existingClasses = new LinkedList<>();
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
123 for (FieldIntrospection nodeClass : allClasses.values()) {
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
124 if (clazz.isAssignableFrom(nodeClass.clazz)) {
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
125 existingClasses.add((NodeClass) nodeClass);
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
126 }
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
127 if (nodeClass.clazz.isAssignableFrom(clazz) && Node.IterableNodeType.class.isAssignableFrom(nodeClass.clazz)) {
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
128 NodeClass superNodeClass = (NodeClass) nodeClass;
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
129 superNodeClass.iterableIds = Arrays.copyOf(superNodeClass.iterableIds, superNodeClass.iterableIds.length + 1);
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
130 superNodeClass.iterableIds[superNodeClass.iterableIds.length - 1] = this.iterableId;
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
131 }
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
132 }
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
133 int[] ids = new int[existingClasses.size() + 1];
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
134 ids[0] = iterableId;
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
135 int i = 1;
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
136 for (NodeClass other : existingClasses) {
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
137 ids[i++] = other.iterableId;
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
138 }
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
139 this.iterableIds = ids;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 this.iterableId = NOT_ITERABLE;
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
142 this.iterableIds = null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
146 @Override
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
147 protected void rescanFieldOffsets(CalcOffset calc) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
148 FieldScanner scanner = new FieldScanner(calc);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149 scanner.scan(clazz);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
150 assert directInputCount == scanner.inputOffsets.size();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
151 copyInto(inputOffsets, sortedLongCopy(scanner.inputOffsets, scanner.inputListOffsets));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
152 assert directSuccessorCount == scanner.successorOffsets.size();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 copyInto(successorOffsets, sortedLongCopy(scanner.successorOffsets, scanner.successorListOffsets));
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
154 copyInto(dataOffsets, sortedLongCopy(scanner.dataOffsets));
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
155
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
156 for (int i = 0; i < dataOffsets.length; i++) {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
157 dataTypes[i] = scanner.fieldTypes.get(dataOffsets[i]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
160 fieldNames.clear();
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
161 fieldNames.putAll(scanner.fieldNames);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
162 fieldTypes.clear();
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
163 fieldTypes.putAll(scanner.fieldTypes);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
164 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
165
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
166 public String shortName() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
167 return shortName;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
170 public int[] iterableIds() {
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
171 return iterableIds;
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
172 }
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
173
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 public int iterableId() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 return iterableId;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178 public boolean valueNumberable() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 return canGVN;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
182 public static int cacheSize() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183 return nextIterableId;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
186 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
187
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
188 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
189 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
190 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
191 public final ArrayList<Long> successorListOffsets = new ArrayList<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
193 protected FieldScanner(CalcOffset calc) {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
194 super(calc);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
197 @Override
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
198 protected void scanField(Field field, Class<?> type, long offset) {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
199 if (field.isAnnotationPresent(Node.Input.class)) {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
200 assert !field.isAnnotationPresent(Node.Successor.class) : "field cannot be both input and successor";
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
201 if (INPUT_LIST_CLASS.isAssignableFrom(type)) {
9808
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
202 GraalInternalError.guarantee(Modifier.isFinal(field.getModifiers()), "NodeInputList input field %s should be final", field);
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
203 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
204 inputListOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
205 } else {
9808
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
206 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
207 GraalInternalError.guarantee(!Modifier.isFinal(field.getModifiers()), "Node input field %s should not be final", field);
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
208 GraalInternalError.guarantee(Modifier.isPrivate(field.getModifiers()), "Node input field %s should be private", field);
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
209 inputOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
210 }
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
211 if (field.getAnnotation(Node.Input.class).notDataflow()) {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
212 fieldNames.put(offset, field.getName() + "#NDF");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
214 } 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
215 if (SUCCESSOR_LIST_CLASS.isAssignableFrom(type)) {
9808
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
216 GraalInternalError.guarantee(Modifier.isFinal(field.getModifiers()), "NodeSuccessorList successor field % should be final", field);
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
217 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
218 successorListOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
219 } else {
9808
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
220 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
221 GraalInternalError.guarantee(!Modifier.isFinal(field.getModifiers()), "Node successor field %s should not be final", field);
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
222 GraalInternalError.guarantee(Modifier.isPrivate(field.getModifiers()), "Node successor field %s should be private", field);
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
223 successorOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
224 }
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
225 } else {
9808
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
226 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
227 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
228 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
229 dataOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
230 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
231 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
233
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
234 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
235 public String toString() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
236 StringBuilder str = new StringBuilder();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237 str.append("NodeClass ").append(clazz.getSimpleName()).append(" [");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238 for (int i = 0; i < inputOffsets.length; i++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
239 str.append(i == 0 ? "" : ", ").append(inputOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
240 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241 str.append("] [");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 for (int i = 0; i < successorOffsets.length; i++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243 str.append(i == 0 ? "" : ", ").append(successorOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 str.append("] [");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246 for (int i = 0; i < dataOffsets.length; i++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
247 str.append(i == 0 ? "" : ", ").append(dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
248 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
249 str.append("]");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 return str.toString();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
251 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
252
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
253 /**
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
254 * Describes an edge slot for a {@link NodeClass}.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
255 *
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
256 * @see NodeClass#get(Node, Position)
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
257 * @see NodeClass#getName(Position)
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
258 */
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
259 public static final class Position {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
260
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
261 public final boolean input;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
262 public final int index;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263 public final int subIndex;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
264
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
265 public Position(boolean input, int index, int subIndex) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266 this.input = input;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267 this.index = index;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
268 this.subIndex = subIndex;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
269 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
271 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
272 public String toString() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
273 return (input ? "input " : "successor ") + index + "/" + subIndex;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
274 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
275
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
276 public Node get(Node node) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
277 return node.getNodeClass().get(node, this);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
278 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
280 public void set(Node node, Node value) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281 node.getNodeClass().set(node, this, value);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
282 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
283
5214
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
284 public boolean isValidFor(Node node, Node from) {
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
285 return node.getNodeClass().isValid(this, from.getNodeClass());
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
286 }
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
287
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
288 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
289 public int hashCode() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
290 final int prime = 31;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
291 int result = 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
292 result = prime * result + index;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
293 result = prime * result + (input ? 1231 : 1237);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
294 result = prime * result + subIndex;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
295 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
296 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
297
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
298 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
299 public boolean equals(Object obj) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
300 if (this == obj) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
301 return true;
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 if (obj == null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
304 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
305 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
306 if (getClass() != obj.getClass()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
307 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
308 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
309 Position other = (Position) obj;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310 if (index != other.index) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
311 return false;
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 if (input != other.input) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
314 return false;
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 if (subIndex != other.subIndex) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
317 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
318 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
321 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
322
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
323 private static Node getNode(Node node, long offset) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
324 return (Node) unsafe.getObject(node, offset);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
325 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
326
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
327 @SuppressWarnings("unchecked")
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
328 private static NodeList<Node> getNodeList(Node node, long offset) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
329 return (NodeList<Node>) unsafe.getObject(node, offset);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
330 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
331
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
332 private static void putNode(Node node, long offset, Node value) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
333 unsafe.putObject(node, offset, value);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
334 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
335
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
336 private static void putNodeList(Node node, long offset, NodeList value) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
337 unsafe.putObject(node, offset, value);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
338 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
339
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
340 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
341 * An iterator that will iterate over the fields given in {@link #offsets}. The first
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
342 * {@link #directCount} offsets are treated as fields of type {@link Node}, while the rest of
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
343 * the fields are treated as {@link NodeList}s. All elements of these NodeLists will be visited
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
344 * by the iterator as well. This iterator can be used to iterate over the inputs or successors
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
345 * of a node.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
346 *
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
347 * An iterator of this type will not return null values, unless the field values are modified
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
348 * concurrently. Concurrent modifications are detected by an assertion on a best-effort basis.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
349 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
350 public static final class NodeClassIterator implements Iterator<Node> {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
351
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
352 private final Node node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
353 private final int modCount;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
354 private final int directCount;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
355 private final long[] offsets;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
356 private int index;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
357 private int subIndex;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
358
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
359 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
360 * Creates an iterator that will iterate over fields in the given node.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
361 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
362 * @param node the node which contains the fields.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
363 * @param offsets the offsets of the fields.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
364 * @param directCount the number of fields that should be treated as fields of type
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
365 * {@link Node}, the rest are treated as {@link NodeList}s.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
366 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
367 private NodeClassIterator(Node node, long[] offsets, int directCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368 this.node = node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
369 this.modCount = node.modCount();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
370 this.offsets = offsets;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
371 this.directCount = directCount;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
372 index = NOT_ITERABLE;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
373 subIndex = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
374 forward();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
375 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
377 private void forward() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
378 if (index < directCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
379 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
380 while (index < directCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
381 Node element = getNode(node, offsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
382 if (element != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
383 return;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
384 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
385 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
386 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 subIndex++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
389 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
390 while (index < offsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391 NodeList<Node> list = getNodeList(node, offsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
392 while (subIndex < list.size()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
393 if (list.get(subIndex) != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
394 return;
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 subIndex++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
397 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
398 subIndex = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
400 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
401 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
402
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
403 private Node nextElement() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
404 if (index < directCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
405 return getNode(node, offsets[index]);
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
406 } else if (index < offsets.length) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
407 NodeList<Node> list = getNodeList(node, offsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
408 return list.get(subIndex);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409 }
7258
9bee93f61522 Cleanups: remove unused NodeUsagesList.replaceFirst and FrameState.block
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7123
diff changeset
410 throw new NoSuchElementException();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
411 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
412
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
413 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
414 public boolean hasNext() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
415 try {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
416 return index < offsets.length;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
417 } finally {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
418 assert modCount == node.modCount() : "must not be modified";
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
419 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
420 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
421
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
422 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
423 public Node next() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
424 try {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
425 return nextElement();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
426 } finally {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
427 forward();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
428 assert modCount == node.modCount();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
429 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
430 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
431
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
432 public Position nextPosition() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
433 try {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434 if (index < directCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
435 return new Position(offsets == node.getNodeClass().inputOffsets, index, NOT_ITERABLE);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
437 return new Position(offsets == node.getNodeClass().inputOffsets, index, subIndex);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
439 } finally {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
440 forward();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
441 assert modCount == node.modCount();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
442 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
443 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
444
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
446 public void remove() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
447 throw new UnsupportedOperationException();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
448 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
449 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
450
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
451 public int valueNumber(Node n) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
452 int number = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
453 if (canGVN) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
454 number = startGVNNumber;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
455 for (int i = 0; i < dataOffsets.length; ++i) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
456 Class<?> type = dataTypes[i];
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
457 if (type.isPrimitive()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
458 if (type == Integer.TYPE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
459 int intValue = unsafe.getInt(n, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
460 number += intValue;
6657
768793150bcd more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents: 6414
diff changeset
461 } else if (type == Long.TYPE) {
768793150bcd more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents: 6414
diff changeset
462 long longValue = unsafe.getLong(n, dataOffsets[i]);
768793150bcd more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents: 6414
diff changeset
463 number += longValue ^ (longValue >>> 32);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
464 } else if (type == Boolean.TYPE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
465 boolean booleanValue = unsafe.getBoolean(n, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
466 if (booleanValue) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
467 number += 7;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
469 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
470 assert false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
471 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
472 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
473 Object o = unsafe.getObject(n, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
474 if (o != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
475 number += o.hashCode();
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478 number *= 13;
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
481 return number;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
482 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
483
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
484 /**
5711
4d7175cf3526 enabled Eclipse/JDT javadoc checking and fixed resulting warnings
Doug Simon <doug.simon@oracle.com>
parents: 5693
diff changeset
485 * Populates a given map with the names and values of all data fields.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
486 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487 * @param node the node from which to take the values.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
488 * @param properties a map that will be populated.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
489 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
490 public void getDebugProperties(Node node, Map<Object, Object> properties) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
491 for (int i = 0; i < dataOffsets.length; ++i) {
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
492 Class<?> type = fieldTypes.get(dataOffsets[i]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
493 Object value = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
494 if (type.isPrimitive()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
495 if (type == Integer.TYPE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
496 value = unsafe.getInt(node, dataOffsets[i]);
5361
dec5a35ddbe2 lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents: 5313
diff changeset
497 } else if (type == Long.TYPE) {
dec5a35ddbe2 lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents: 5313
diff changeset
498 value = unsafe.getLong(node, dataOffsets[i]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
499 } else if (type == Boolean.TYPE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
500 value = unsafe.getBoolean(node, dataOffsets[i]);
5313
be1a8ff480db Visualizer: display long properties correctly, "!InstanceOf" for negated InstanceOfNodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 5301
diff changeset
501 } else if (type == Long.TYPE) {
be1a8ff480db Visualizer: display long properties correctly, "!InstanceOf" for negated InstanceOfNodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 5301
diff changeset
502 value = unsafe.getLong(node, dataOffsets[i]);
5287
e96c8d2925da let NodeClass.getDebugProperties handle arrays and doubles
Lukas Stadler <lukas.stadler@jku.at>
parents: 5261
diff changeset
503 } else if (type == Double.TYPE) {
5313
be1a8ff480db Visualizer: display long properties correctly, "!InstanceOf" for negated InstanceOfNodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 5301
diff changeset
504 value = unsafe.getDouble(node, dataOffsets[i]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
505 } else {
5313
be1a8ff480db Visualizer: display long properties correctly, "!InstanceOf" for negated InstanceOfNodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 5301
diff changeset
506 assert false : "unhandled property type: " + type;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
507 }
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
508 } else {
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
509 value = unsafe.getObject(node, dataOffsets[i]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
510 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
511 properties.put(fieldNames.get(dataOffsets[i]), value);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
512 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
513 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
514
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
515 public boolean valueEqual(Node a, Node b) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
516 if (!canGVN || a.getNodeClass() != b.getNodeClass()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
517 return a == b;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
518 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
519 for (int i = 0; i < dataOffsets.length; ++i) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
520 Class<?> type = dataTypes[i];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
521 if (type.isPrimitive()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
522 if (type == Integer.TYPE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
523 int aInt = unsafe.getInt(a, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
524 int bInt = unsafe.getInt(b, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
525 if (aInt != bInt) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
526 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
527 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
528 } else if (type == Boolean.TYPE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
529 boolean aBoolean = unsafe.getBoolean(a, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
530 boolean bBoolean = unsafe.getBoolean(b, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
531 if (aBoolean != bBoolean) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
532 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
533 }
5301
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
534 } else if (type == Long.TYPE) {
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
535 long aLong = unsafe.getLong(a, dataOffsets[i]);
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
536 long bLong = unsafe.getLong(b, dataOffsets[i]);
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
537 if (aLong != bLong) {
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
538 return false;
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
539 }
10785
debb9d8e0282 allow double fields in value number computation and thus, in floating nodes
Doug Simon <doug.simon@oracle.com>
parents: 10424
diff changeset
540 } else if (type == Double.TYPE) {
debb9d8e0282 allow double fields in value number computation and thus, in floating nodes
Doug Simon <doug.simon@oracle.com>
parents: 10424
diff changeset
541 double aDouble = unsafe.getDouble(a, dataOffsets[i]);
debb9d8e0282 allow double fields in value number computation and thus, in floating nodes
Doug Simon <doug.simon@oracle.com>
parents: 10424
diff changeset
542 double bDouble = unsafe.getDouble(b, dataOffsets[i]);
debb9d8e0282 allow double fields in value number computation and thus, in floating nodes
Doug Simon <doug.simon@oracle.com>
parents: 10424
diff changeset
543 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
544 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
545 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
546 } else {
5301
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
547 assert false : "unhandled type: " + type;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
548 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
549 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
550 Object objectA = unsafe.getObject(a, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
551 Object objectB = unsafe.getObject(b, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
552 if (objectA != objectB) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
553 if (objectA != null && objectB != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
554 if (!(objectA.equals(objectB))) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
555 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
556 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
557 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
558 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
559 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
560 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
561 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
562 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
563 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
564 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
565
5214
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
566 public boolean isValid(Position pos, NodeClass from) {
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
567 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
568 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
569 }
5214
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
570 long[] offsets = pos.input ? inputOffsets : successorOffsets;
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
571 if (pos.index >= offsets.length) {
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
572 return false;
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
573 }
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
574 long[] fromOffsets = pos.input ? from.inputOffsets : from.successorOffsets;
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
575 if (pos.index >= fromOffsets.length) {
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
576 return false;
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
577 }
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
578 return offsets[pos.index] == fromOffsets[pos.index];
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
579 }
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
580
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
581 public Node get(Node node, Position pos) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
582 long offset = pos.input ? inputOffsets[pos.index] : successorOffsets[pos.index];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
583 if (pos.subIndex == NOT_ITERABLE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
584 return getNode(node, offset);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
585 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
586 return getNodeList(node, offset).get(pos.subIndex);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
587 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
588 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
589
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
590 public String getName(Position pos) {
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
591 return fieldNames.get(pos.input ? inputOffsets[pos.index] : successorOffsets[pos.index]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
592 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
593
7283
3964f3d4eb18 Extend loop unswicthing to Switch nodes (integer or type)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7258
diff changeset
594 public void set(Node node, Position pos, Node x) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
595 long offset = pos.input ? inputOffsets[pos.index] : successorOffsets[pos.index];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
596 if (pos.subIndex == NOT_ITERABLE) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
597 Node old = getNode(node, offset);
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
598 assert x == null || fieldTypes.get((pos.input ? inputOffsets : successorOffsets)[pos.index]).isAssignableFrom(x.getClass()) : this + ".set(node, pos, " + x + ")";
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
599 putNode(node, offset, x);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
600 if (pos.input) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
601 node.updateUsages(old, x);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
602 } else {
5487
9743ae819f73 Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5486
diff changeset
603 node.updatePredecessor(old, x);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
604 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
605 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
606 NodeList<Node> list = getNodeList(node, offset);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
607 if (pos.subIndex < list.size()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
608 list.set(pos.subIndex, x);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
609 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
610 while (pos.subIndex < list.size() - 1) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
611 list.add(null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
612 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
613 list.add(x);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
614 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
615 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
616 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
617
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
618 public NodeClassIterable getInputIterable(final Node node) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
619 assert clazz.isInstance(node);
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
620 return new NodeClassIterable() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
621
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
622 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
623 public NodeClassIterator iterator() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
624 return new NodeClassIterator(node, inputOffsets, directInputCount);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
625 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
626
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
627 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
628 public boolean contains(Node other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
629 return inputContains(node, other);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
630 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
631 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
632 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
633
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
634 public NodeClassIterable getSuccessorIterable(final Node node) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
635 assert clazz.isInstance(node);
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
636 return new NodeClassIterable() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
637
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
638 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
639 public NodeClassIterator iterator() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
640 return new NodeClassIterator(node, successorOffsets, directSuccessorCount);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
641 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
642
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
643 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
644 public boolean contains(Node other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
645 return successorContains(node, other);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
646 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
647 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
648 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
649
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
650 public boolean replaceFirstInput(Node node, Node old, Node other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
651 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
652 while (index < directInputCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
653 Node input = getNode(node, inputOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
654 if (input == old) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
655 assert other == null || fieldTypes.get(inputOffsets[index]).isAssignableFrom(other.getClass()) : "Can not assign " + other.getClass() + " to " + fieldTypes.get(inputOffsets[index]) +
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
656 " in " + node;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
657 putNode(node, inputOffsets[index], other);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
658 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
659 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
660 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
661 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
662 while (index < inputOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
663 NodeList<Node> list = getNodeList(node, inputOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
664 assert list != null : clazz;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
665 if (list.replaceFirst(old, other)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
666 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
667 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
668 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
669 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
670 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
671 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
672
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
673 public boolean replaceFirstSuccessor(Node node, Node old, Node other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
674 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
675 while (index < directSuccessorCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
676 Node successor = getNode(node, successorOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
677 if (successor == old) {
10424
e6cf435419b2 Fix after lowering phase refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9808
diff changeset
678 assert other == null || fieldTypes.get(successorOffsets[index]).isAssignableFrom(other.getClass()) : fieldTypes.get(successorOffsets[index]) + " is not compatible with " +
e6cf435419b2 Fix after lowering phase refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9808
diff changeset
679 other.getClass();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
680 putNode(node, successorOffsets[index], other);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
681 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
682 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
683 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
684 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
685 while (index < successorOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
686 NodeList<Node> list = getNodeList(node, successorOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
687 assert list != null : clazz + " " + successorOffsets[index] + " " + node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
688 if (list.replaceFirst(old, other)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
689 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
690 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
691 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
692 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
693 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
694 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
695
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
696 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
697 * Clear all inputs in the given node. This is accomplished by setting input fields to null and
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
698 * replacing input lists with new lists. (which is important so that this method can be used to
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
699 * clear the inputs of cloned nodes.)
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
700 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
701 * @param node the node to be cleared
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
702 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
703 public void clearInputs(Node node) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
704 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
705 while (index < directInputCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
706 putNode(node, inputOffsets[index++], null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
707 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
708 while (index < inputOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
709 long curOffset = inputOffsets[index++];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
710 int size = (getNodeList(node, curOffset)).initialSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
711 // replacing with a new list object is the expected behavior!
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
712 putNodeList(node, curOffset, new NodeInputList<>(node, size));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
713 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
714 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
715
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
716 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
717 * Clear all successors in the given node. This is accomplished by setting successor fields to
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
718 * null and replacing successor lists with new lists. (which is important so that this method
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
719 * can be used to clear the successors of cloned nodes.)
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
720 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
721 * @param node the node to be cleared
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
722 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
723 public void clearSuccessors(Node node) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
724 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
725 while (index < directSuccessorCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
726 putNode(node, successorOffsets[index++], null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
727 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
728 while (index < successorOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
729 long curOffset = successorOffsets[index++];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
730 int size = getNodeList(node, curOffset).initialSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
731 // replacing with a new list object is the expected behavior!
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
732 putNodeList(node, curOffset, new NodeSuccessorList<>(node, size));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
733 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
734 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
735
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
736 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
737 * Copies the inputs from node to newNode. The nodes are expected to be of the exact same
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
738 * NodeClass type.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
739 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
740 * @param node the node from which the inputs should be copied.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
741 * @param newNode the node to which the inputs should be copied.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
742 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
743 public void copyInputs(Node node, Node newNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
744 assert node.getClass() == clazz && newNode.getClass() == clazz;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
745
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
746 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
747 while (index < directInputCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
748 putNode(newNode, inputOffsets[index], getNode(node, inputOffsets[index]));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
749 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
750 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
751 while (index < inputOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
752 NodeList<Node> list = getNodeList(newNode, inputOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
753 list.copy(getNodeList(node, inputOffsets[index]));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
754 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
755 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
756 }
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 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
759 * Copies the successors from node to newNode. The nodes are expected to be of the exact same
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
760 * NodeClass type.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
761 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
762 * @param node the node from which the successors should be copied.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
763 * @param newNode the node to which the successors should be copied.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
764 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
765 public void copySuccessors(Node node, Node newNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
766 assert node.getClass() == clazz && newNode.getClass() == clazz;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
767
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
768 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
769 while (index < directSuccessorCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
770 putNode(newNode, successorOffsets[index], getNode(node, successorOffsets[index]));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
771 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
772 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
773 while (index < successorOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
774 NodeList<Node> list = getNodeList(newNode, successorOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
775 list.copy(getNodeList(node, successorOffsets[index]));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
776 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
777 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
778 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
779
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
780 public boolean edgesEqual(Node node, Node other) {
9450
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
781 return inputsEqual(node, other) && successorsEqual(node, other);
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
782 }
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
783
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
784 public boolean inputsEqual(Node node, Node other) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
785 assert node.getClass() == clazz && other.getClass() == clazz;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
786 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
787 while (index < directInputCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
788 if (getNode(other, inputOffsets[index]) != getNode(node, inputOffsets[index])) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
789 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
790 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
791 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
792 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
793 while (index < inputOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
794 NodeList<Node> list = getNodeList(other, inputOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
795 if (!list.equals(getNodeList(node, inputOffsets[index]))) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
796 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
797 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
798 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
799 }
9450
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
800 return true;
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
801 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
802
9450
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
803 public boolean successorsEqual(Node node, Node other) {
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
804 assert node.getClass() == clazz && other.getClass() == clazz;
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
805 int index = 0;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
806 while (index < directSuccessorCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
807 if (getNode(other, successorOffsets[index]) != getNode(node, successorOffsets[index])) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
808 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
809 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
810 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
811 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
812 while (index < successorOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
813 NodeList<Node> list = getNodeList(other, successorOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
814 if (!list.equals(getNodeList(node, successorOffsets[index]))) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
815 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
816 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
817 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
818 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
819 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
820 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
821
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
822 public boolean inputContains(Node node, Node other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
823 assert node.getClass() == clazz;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
824
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
825 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
826 while (index < directInputCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
827 if (getNode(node, inputOffsets[index]) == other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
828 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
829 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
830 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
831 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
832 while (index < inputOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
833 NodeList<Node> list = getNodeList(node, inputOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
834 if (list.contains(other)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
835 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
836 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
837 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
838 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
839 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
840 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
841
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
842 public boolean successorContains(Node node, Node other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
843 assert node.getClass() == clazz;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
844
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
845 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
846 while (index < directSuccessorCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
847 if (getNode(node, successorOffsets[index]) == other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
848 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
849 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
850 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
851 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
852 while (index < successorOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
853 NodeList<Node> list = getNodeList(node, successorOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
854 if (list.contains(other)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
855 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
856 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
857 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
858 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
859 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
860 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
861
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
862 public List<Position> getFirstLevelInputPositions() {
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
863 List<Position> positions = new ArrayList<>(inputOffsets.length);
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
864 for (int i = 0; i < inputOffsets.length; i++) {
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
865 positions.add(new Position(true, i, NOT_ITERABLE));
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
866 }
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
867 return positions;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
868 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
869
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
870 public List<Position> getFirstLevelSuccessorPositions() {
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
871 List<Position> positions = new ArrayList<>(successorOffsets.length);
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
872 for (int i = 0; i < successorOffsets.length; i++) {
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
873 positions.add(new Position(false, i, NOT_ITERABLE));
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
874 }
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
875 return positions;
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
876 }
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
877
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
878 public Class<?> getJavaClass() {
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
879 return clazz;
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
880 }
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
881
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
882 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
883 * 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
884 * 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
885 */
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
886 public String getNameTemplate() {
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
887 return nameTemplate;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
888 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
889
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
890 static Map<Node, Node> addGraphDuplicate(Graph graph, Iterable<Node> nodes, DuplicationReplacement replacements) {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
891 Map<Node, Node> newNodes = new IdentityHashMap<>();
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
892 Map<Node, Node> replacementsMap = new IdentityHashMap<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
893 // create node duplicates
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
894 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
895 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
896 assert !node.isDeleted() : "trying to duplicate deleted node: " + node;
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
897 Node replacement = replacements.replacement(node);
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
898 if (replacement != node) {
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
899 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
900 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
901 } else {
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
902 Node newNode = node.clone(graph);
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
903 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
904 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
905 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
906 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
907 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
908 // re-wire inputs
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
909 for (Entry<Node, Node> entry : newNodes.entrySet()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
910 Node oldNode = entry.getKey();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
911 Node node = entry.getValue();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
912 for (NodeClassIterator iter = oldNode.inputs().iterator(); iter.hasNext();) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
913 Position pos = iter.nextPosition();
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
914 if (!pos.isValidFor(node, oldNode)) {
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
915 continue;
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
916 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
917 Node input = oldNode.getNodeClass().get(oldNode, pos);
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
918 Node target = newNodes.get(input);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
919 if (target == 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
920 target = replacementsMap.get(input);
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
921 if (target == null) {
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
922 Node replacement = replacements.replacement(input);
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
923 if (replacement != input) {
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
924 replacementsMap.put(input, replacement);
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
925 assert isAssignable(node.getNodeClass().fieldTypes.get(node.getNodeClass().inputOffsets[pos.index]), replacement);
5486
85986efe747e Check edge types for replacements in addDuplicate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5478
diff changeset
926 target = replacement;
5693
0356d95f01ba While inlining, ensure proper anchoring of things that where anchored to the StartNode
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5519
diff changeset
927 } else if (input.graph() == graph) { // patch to the outer world
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
928 target = input;
5486
85986efe747e Check edge types for replacements in addDuplicate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5478
diff changeset
929 }
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
930 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
931 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
932 node.getNodeClass().set(node, pos, target);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
933 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
934 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
935
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
936 // re-wire successors
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
937 for (Entry<Node, Node> entry : newNodes.entrySet()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
938 Node oldNode = entry.getKey();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
939 Node node = entry.getValue();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
940 for (NodeClassIterator iter = oldNode.successors().iterator(); iter.hasNext();) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
941 Position pos = iter.nextPosition();
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
942 if (!pos.isValidFor(node, oldNode)) {
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
943 continue;
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
944 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
945 Node succ = oldNode.getNodeClass().get(oldNode, pos);
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
946 Node target = newNodes.get(succ);
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
947 if (target == null) {
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
948 target = replacementsMap.get(succ);
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
949 if (target == null) {
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
950 Node replacement = replacements.replacement(succ);
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
951 if (replacement != succ) {
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
952 replacementsMap.put(succ, replacement);
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
953 assert isAssignable(node.getNodeClass().fieldTypes.get(node.getNodeClass().successorOffsets[pos.index]), replacement);
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
954 target = replacement;
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
955 }
5486
85986efe747e Check edge types for replacements in addDuplicate
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5478
diff changeset
956 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
957 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
958 node.getNodeClass().set(node, pos, target);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
959 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
960 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
961 return newNodes;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
962 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
963
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
964 private static boolean isAssignable(Class<?> fieldType, Node replacement) {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
965 return replacement == null || !NODE_CLASS.isAssignableFrom(fieldType) || fieldType.isAssignableFrom(replacement.getClass());
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
966 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
967 }