annotate graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java @ 12696:22780dc399da

Support arbitrary array types in global value numbering.
author Roland Schatz <roland.schatz@oracle.com>
date Wed, 06 Nov 2013 16:56:05 +0100
parents 43301f080126
children 42a60780c2c9
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
11524
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11434
diff changeset
25 import static com.oracle.graal.graph.Graph.*;
dede53632f3e removed Node.modCount field (GRAAL-452)
Doug Simon <doug.simon@oracle.com>
parents: 11434
diff changeset
26
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
27 import java.lang.reflect.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 import java.util.*;
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
29 import java.util.concurrent.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30
11642
5507e2824bc6 added metric to count IterableNodeTypes (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11631
diff changeset
31 import com.oracle.graal.debug.*;
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
32 import com.oracle.graal.graph.Graph.DuplicationReplacement;
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12612
diff changeset
33 import com.oracle.graal.graph.Node.*;
11882
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
34 import com.oracle.graal.graph.spi.*;
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
35
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
36 /**
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
37 * Lazily associated metadata for every {@link Node} type. The metadata includes:
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
38 * <ul>
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
39 * <li>The offsets of fields annotated with {@link Input} and {@link Successor} as well as methods
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
40 * for iterating over such fields.</li>
11631
1aed684853f6 refactored IterableNodeType into a top level type to avoid problems it was causing for javac and JDT (CR-1408)
Doug Simon <doug.simon@oracle.com>
parents: 11556
diff changeset
41 * <li>The identifier for an {@link IterableNodeType} class.</li>
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
42 * </ul>
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
43 */
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
44 public final class NodeClass extends FieldIntrospection {
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
45
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
46 /**
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
47 * Maps {@link Class} values (for {@link Node} types) to {@link NodeClass} values.
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
48 *
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
49 * Only a single Registry instance can be created. If a runtime creates a specialized registry,
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
50 * it must do so before the class initializer of {@link NodeClass} is executed.
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
51 */
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
52 public static class Registry {
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
53
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
54 private static Registry instance;
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
55
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
56 /**
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
57 * Gets the singleton {@link Registry} instance, creating it first if necessary.
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
58 */
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
59 static synchronized Registry instance() {
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
60 if (instance == null) {
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
61 return new Registry();
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
62 }
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
63 return instance;
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
64 }
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
65
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
66 protected Registry() {
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
67 assert instance == null : "exactly one registry can be created";
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
68 instance = this;
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
69 }
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
70
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
71 /**
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
72 * @return the {@link NodeClass} value for {@code key} or {@code null} if no such mapping
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
73 * exists
9720
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
74 */
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
75 protected NodeClass get(Class<? extends Node> key) {
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
76 return (NodeClass) allClasses.get(key);
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
77 }
9720
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
78
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
79 /**
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
80 * Same as {@link #get(Class)} except that a {@link NodeClass} is created if no such mapping
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
81 * exists. The creation of a {@link NodeClass} must be serialized as
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
82 * {@link NodeClass#NodeClass(Class)} accesses both {@link FieldIntrospection#allClasses}
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
83 * and {@link NodeClass#nextIterableId}.
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
84 * <p>
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
85 * The fact that {@link ConcurrentHashMap#put} {@link ConcurrentHashMap#get} are used should
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
86 * make the double-checked locking idiom work in the way {@link NodeClass#get(Class)} uses
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
87 * this method and {@link #get(Class)}.
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
88 */
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
89 final synchronized NodeClass make(Class<? extends Node> key) {
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
90 NodeClass value = (NodeClass) allClasses.get(key);
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
91 if (value == null) {
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
92 value = new NodeClass(key);
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
93 Object old = allClasses.putIfAbsent(key, value);
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
94 assert old == null;
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
95 registered(key, value);
9720
d30cc6543973 fix concurrency issue in NodeClass.get
Lukas Stadler <lukas.stadler@jku.at>
parents: 9716
diff changeset
96 }
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
97 return value;
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
98 }
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
99
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
100 /**
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
101 * Hook for a subclass to be notified of a new mapping added to the registry.
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
102 *
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
103 * @param key
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
104 * @param value
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
105 */
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
106 protected void registered(Class<? extends Node> key, NodeClass value) {
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
107
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
108 }
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
109 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
111 private static final Registry registry = Registry.instance();
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
112
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
113 /**
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
114 * Gets the {@link NodeClass} associated with a given {@link Class}.
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
115 */
11434
0d9fe4e80ab8 moved warning suppression annotation to placate JDT
Doug Simon <doug.simon@oracle.com>
parents: 11431
diff changeset
116 @SuppressWarnings("unchecked")
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
117 public static NodeClass get(Class<?> c) {
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
118 Class<? extends Node> key = (Class<? extends Node>) c;
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
119 NodeClass value = registry.get(key);
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
120 if (value != null) {
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
121 return value;
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
122 }
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
123 return registry.make(key);
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
124 }
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
125
12483
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
126 public static final int NOT_ITERABLE = -1;
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
127 public static final int NODE_LIST = -2;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
129 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
130 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
131 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
132
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 private static int nextIterableId = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 private final int directInputCount;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 private final long[] inputOffsets;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 private final int directSuccessorCount;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 private final long[] successorOffsets;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 private final Class<?>[] dataTypes;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 private final boolean canGVN;
11653
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11642
diff changeset
141 private final boolean isLeafNode;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142 private final int startGVNNumber;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 private final String shortName;
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
144 private final String nameTemplate;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 private final int iterableId;
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
146 private int[] iterableIds;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147
11642
5507e2824bc6 added metric to count IterableNodeTypes (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11631
diff changeset
148 private static final DebugMetric ITERABLE_NODE_TYPES = Debug.metric("IterableNodeTypes");
11663
d213be26ffb4 added metric to count number of times a typed node iterator is used per IterableNodeType (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11653
diff changeset
149 private final DebugMetric nodeIterableCount;
11642
5507e2824bc6 added metric to count IterableNodeTypes (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11631
diff changeset
150
11882
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
151 /**
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
152 * Determines if this node type implements {@link Canonicalizable}.
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
153 */
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
154 private final boolean isCanonicalizable;
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
155
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
156 /**
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
157 * Determines if this node type implements {@link Simplifiable}.
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
158 */
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
159 private final boolean isSimplifiable;
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
160
11431
ca53d08b8ef9 removed Node.nodeClass field (GRAAL-359)
Doug Simon <doug.simon@oracle.com>
parents: 10785
diff changeset
161 private NodeClass(Class<?> clazz) {
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
162 super(clazz);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163 assert NODE_CLASS.isAssignableFrom(clazz);
11882
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
164 this.isCanonicalizable = Canonicalizable.class.isAssignableFrom(clazz);
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
165 this.isSimplifiable = Simplifiable.class.isAssignableFrom(clazz);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
166
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
167 FieldScanner scanner = new FieldScanner(new DefaultCalcOffset());
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168 scanner.scan(clazz);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
170 directInputCount = scanner.inputOffsets.size();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 inputOffsets = sortedLongCopy(scanner.inputOffsets, scanner.inputListOffsets);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
172 directSuccessorCount = scanner.successorOffsets.size();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
173 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
174
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
175 dataOffsets = sortedLongCopy(scanner.dataOffsets);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
176 dataTypes = new Class[dataOffsets.length];
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
177 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
178 dataTypes[i] = scanner.fieldTypes.get(dataOffsets[i]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
180
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
181 fieldNames = scanner.fieldNames;
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
182 fieldTypes = scanner.fieldTypes;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 canGVN = Node.ValueNumberable.class.isAssignableFrom(clazz);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185 startGVNNumber = clazz.hashCode();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
187 String newShortName = clazz.getSimpleName();
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
188 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
189 newShortName = newShortName.substring(0, newShortName.length() - 4);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 }
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
191 String newNameTemplate = null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192 NodeInfo info = clazz.getAnnotation(NodeInfo.class);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 if (info != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194 if (!info.shortName().isEmpty()) {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
195 newShortName = info.shortName();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 }
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
197 if (!info.nameTemplate().isEmpty()) {
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
198 newNameTemplate = info.nameTemplate();
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
199 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
200 }
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
201 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
202 this.shortName = newShortName;
11631
1aed684853f6 refactored IterableNodeType into a top level type to avoid problems it was causing for javac and JDT (CR-1408)
Doug Simon <doug.simon@oracle.com>
parents: 11556
diff changeset
203 if (IterableNodeType.class.isAssignableFrom(clazz)) {
11642
5507e2824bc6 added metric to count IterableNodeTypes (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11631
diff changeset
204 ITERABLE_NODE_TYPES.increment();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
205 this.iterableId = nextIterableId++;
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
206 List<NodeClass> existingClasses = new LinkedList<>();
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
207 for (FieldIntrospection nodeClass : allClasses.values()) {
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
208 if (clazz.isAssignableFrom(nodeClass.clazz)) {
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
209 existingClasses.add((NodeClass) nodeClass);
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
210 }
11631
1aed684853f6 refactored IterableNodeType into a top level type to avoid problems it was causing for javac and JDT (CR-1408)
Doug Simon <doug.simon@oracle.com>
parents: 11556
diff changeset
211 if (nodeClass.clazz.isAssignableFrom(clazz) && IterableNodeType.class.isAssignableFrom(nodeClass.clazz)) {
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
212 NodeClass superNodeClass = (NodeClass) nodeClass;
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
213 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
214 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
215 }
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
216 }
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
217 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
218 ids[0] = iterableId;
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
219 int i = 1;
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
220 for (NodeClass other : existingClasses) {
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
221 ids[i++] = other.iterableId;
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
222 }
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
223 this.iterableIds = ids;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
224 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
225 this.iterableId = NOT_ITERABLE;
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
226 this.iterableIds = null;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
227 }
11653
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11642
diff changeset
228
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11642
diff changeset
229 isLeafNode = (this.inputOffsets.length == 0 && this.successorOffsets.length == 0);
11663
d213be26ffb4 added metric to count number of times a typed node iterator is used per IterableNodeType (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11653
diff changeset
230 nodeIterableCount = Debug.metric("NodeIterable_" + shortName);
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
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
233 @Override
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
234 protected void rescanFieldOffsets(CalcOffset calc) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
235 FieldScanner scanner = new FieldScanner(calc);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
236 scanner.scan(clazz);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237 assert directInputCount == scanner.inputOffsets.size();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238 copyInto(inputOffsets, sortedLongCopy(scanner.inputOffsets, scanner.inputListOffsets));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
239 assert directSuccessorCount == scanner.successorOffsets.size();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
240 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
241 copyInto(dataOffsets, sortedLongCopy(scanner.dataOffsets));
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
242
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
243 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
244 dataTypes[i] = scanner.fieldTypes.get(dataOffsets[i]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
247 fieldNames.clear();
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
248 fieldNames.putAll(scanner.fieldNames);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
249 fieldTypes.clear();
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
250 fieldTypes.putAll(scanner.fieldTypes);
3733
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
253 public String shortName() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254 return shortName;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
257 public int[] iterableIds() {
11663
d213be26ffb4 added metric to count number of times a typed node iterator is used per IterableNodeType (GRAAL-471)
Doug Simon <doug.simon@oracle.com>
parents: 11653
diff changeset
258 nodeIterableCount.increment();
7332
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
259 return iterableIds;
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
260 }
c5a9bcd9493d Support sub-types for typed node iterators
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7283
diff changeset
261
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
262 public int iterableId() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263 return iterableId;
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266 public boolean valueNumberable() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267 return canGVN;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
268 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
269
11653
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11642
diff changeset
270 public boolean isLeafNode() {
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11642
diff changeset
271 return isLeafNode;
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11642
diff changeset
272 }
64a9ed9f1e8d Introduce NodeClass.isLeafNode(). Avoid cloning of leaf nodes if equal node is found in destination graph.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11642
diff changeset
273
11882
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
274 /**
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
275 * Determines if this node type implements {@link Canonicalizable}.
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
276 */
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
277 public boolean isCanonicalizable() {
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
278 return isCanonicalizable;
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
279 }
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
280
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
281 /**
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
282 * Determines if this node type implements {@link Simplifiable}.
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
283 */
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
284 public boolean isSimplifiable() {
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
285 return isSimplifiable;
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
286 }
51059863da73 replace instanceof type tests for Canonicalizable and Simplifiable with extra boolean properties in NodeClass (GRAAL-506)
Doug Simon <doug.simon@oracle.com>
parents: 11676
diff changeset
287
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
288 public static int cacheSize() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
289 return nextIterableId;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
290 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
291
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
292 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
293
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
294 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
295 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
296 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
297 public final ArrayList<Long> successorListOffsets = new ArrayList<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
298
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
299 protected FieldScanner(CalcOffset calc) {
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
300 super(calc);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
301 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
302
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
303 @Override
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
304 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
305 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
306 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
307 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
308 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
309 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
310 inputListOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
311 } else {
9808
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
312 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
313 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
314 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
315 inputOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
316 }
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
317 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
318 fieldNames.put(offset, field.getName() + "#NDF");
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
320 } 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
321 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
322 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
323 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
324 successorListOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
325 } else {
9808
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
326 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
327 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
328 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
329 successorOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
330 }
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
331 } else {
9808
12fdb8fe0a35 turn assertions in NodeClass.FieldScanner into guarantees
Lukas Stadler <lukas.stadler@jku.at>
parents: 9720
diff changeset
332 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
333 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
334 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
335 dataOffsets.add(offset);
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
336 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
337 }
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 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
341 public String toString() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
342 StringBuilder str = new StringBuilder();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
343 str.append("NodeClass ").append(clazz.getSimpleName()).append(" [");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
344 for (int i = 0; i < inputOffsets.length; i++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
345 str.append(i == 0 ? "" : ", ").append(inputOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
346 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
347 str.append("] [");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
348 for (int i = 0; i < successorOffsets.length; i++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
349 str.append(i == 0 ? "" : ", ").append(successorOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
350 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
351 str.append("] [");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
352 for (int i = 0; i < dataOffsets.length; i++) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
353 str.append(i == 0 ? "" : ", ").append(dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
354 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
355 str.append("]");
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
356 return str.toString();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
357 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
358
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
359 /**
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
360 * 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
361 *
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
362 * @see NodeClass#get(Node, Position)
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
363 * @see NodeClass#getName(Position)
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
364 */
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
365 public static final class Position {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
366
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
367 public final boolean input;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368 public final int index;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
369 public final int subIndex;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
370
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
371 public Position(boolean input, int index, int subIndex) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
372 this.input = input;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
373 this.index = index;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
374 this.subIndex = subIndex;
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 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
378 public String toString() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
379 return (input ? "input " : "successor ") + index + "/" + subIndex;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
380 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
381
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
382 public Node get(Node node) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
383 return node.getNodeClass().get(node, this);
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
386 public void set(Node node, Node value) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387 node.getNodeClass().set(node, this, value);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
389
5214
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
390 public boolean isValidFor(Node node, Node from) {
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
391 return node.getNodeClass().isValid(this, from.getNodeClass());
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
392 }
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
393
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
394 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
395 public int hashCode() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
396 final int prime = 31;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
397 int result = 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
398 result = prime * result + index;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 result = prime * result + (input ? 1231 : 1237);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
400 result = prime * result + subIndex;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
401 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
402 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
403
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
404 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
405 public boolean equals(Object obj) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
406 if (this == obj) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
407 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
408 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409 if (obj == null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
410 return false;
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 if (getClass() != obj.getClass()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
413 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
414 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
415 Position other = (Position) obj;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
416 if (index != other.index) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
417 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
418 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
419 if (input != other.input) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
420 return false;
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 if (subIndex != other.subIndex) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
423 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
424 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
425 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
426 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
427 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
428
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
429 private static Node getNode(Node node, long offset) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
430 return (Node) unsafe.getObject(node, offset);
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
433 @SuppressWarnings("unchecked")
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434 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
435 return (NodeList<Node>) unsafe.getObject(node, offset);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
437
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438 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
439 unsafe.putObject(node, offset, value);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
440 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
441
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
442 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
443 unsafe.putObject(node, offset, value);
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
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
446 /**
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
447 * An iterator that will iterate over the fields given in {@link #getOffsets()}. The first
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
448 * {@link #getDirectCount()} offsets are treated as fields of type {@link Node}, while the rest
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
449 * of the fields are treated as {@link NodeList}s. All elements of these NodeLists will be
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
450 * visited by the iterator as well. This iterator can be used to iterate over the inputs or
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
451 * successors of a node.
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
452 *
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
453 * 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
454 * 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
455 */
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
456 public abstract static class NodeClassIterator implements Iterator<Node> {
12047
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
457 protected final Node node;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
458 private int index;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
459 private int subIndex;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
460
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
461 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
462 * 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
463 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
464 * @param node the node which contains the fields.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
465 */
12047
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
466 NodeClassIterator(Node node) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
467 this.node = node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468 index = NOT_ITERABLE;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
469 subIndex = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
470 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
471
12047
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
472 void forward() {
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
473 if (index < getDirectCount()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
474 index++;
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
475 while (index < getDirectCount()) {
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
476 Node element = getNode(node, getOffsets()[index]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
477 if (element != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478 return;
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 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
481 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
482 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
483 subIndex++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
484 }
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
485 while (index < getOffsets().length) {
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
486 NodeList<Node> list = getNodeList(node, getOffsets()[index]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487 while (subIndex < list.size()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
488 if (list.get(subIndex) != null) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
489 return;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
490 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
491 subIndex++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
492 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
493 subIndex = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
494 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
495 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
496 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
497
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
498 private Node nextElement() {
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
499 if (index < getDirectCount()) {
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
500 return getNode(node, getOffsets()[index]);
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
501 } else if (index < getOffsets().length) {
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
502 NodeList<Node> list = getNodeList(node, getOffsets()[index]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
503 return list.get(subIndex);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
504 }
7258
9bee93f61522 Cleanups: remove unused NodeUsagesList.replaceFirst and FrameState.block
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7123
diff changeset
505 throw new NoSuchElementException();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
506 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
507
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
508 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
509 public boolean hasNext() {
12047
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
510 return index < getOffsets().length;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
511 }
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 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
514 public Node next() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
515 try {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
516 return nextElement();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
517 } finally {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
518 forward();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
519 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
520 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
521
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
522 public Position nextPosition() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
523 try {
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
524 if (index < getDirectCount()) {
12378
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
525 return new Position(getOffsets() == getNodeClass().inputOffsets, index, NOT_ITERABLE);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
526 } else {
12378
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
527 return new Position(getOffsets() == getNodeClass().inputOffsets, index, subIndex);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
528 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
529 } finally {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
530 forward();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
531 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
532 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
533
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
534 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
535 public void remove() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
536 throw new UnsupportedOperationException();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
537 }
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
538
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
539 protected abstract int getDirectCount();
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
540
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
541 protected abstract long[] getOffsets();
12378
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
542
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
543 protected abstract NodeClass getNodeClass();
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
544 }
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
545
12047
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
546 private class NodeClassInputsIterator extends NodeClassIterator {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
547 NodeClassInputsIterator(Node node) {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
548 this(node, true);
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
549 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
550
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
551 NodeClassInputsIterator(Node node, boolean forward) {
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
552 super(node);
12378
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
553 assert NodeClass.this == node.getNodeClass();
12047
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
554 if (forward) {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
555 forward();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
556 }
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
557 }
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
558
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
559 @Override
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
560 protected int getDirectCount() {
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
561 return directInputCount;
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
562 }
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
563
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
564 @Override
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
565 protected long[] getOffsets() {
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
566 return inputOffsets;
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
567 }
12378
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
568
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
569 @Override
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
570 protected NodeClass getNodeClass() {
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
571 return NodeClass.this;
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
572 }
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
573 }
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
574
12047
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
575 private final class NodeClassInputsWithModCountIterator extends NodeClassInputsIterator {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
576 private final int modCount;
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
577
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
578 private NodeClassInputsWithModCountIterator(Node node) {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
579 super(node, false);
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
580 assert MODIFICATION_COUNTS_ENABLED;
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
581 this.modCount = node.modCount();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
582 forward();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
583 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
584
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
585 @Override
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
586 public boolean hasNext() {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
587 try {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
588 return super.hasNext();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
589 } finally {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
590 assert modCount == node.modCount() : "must not be modified";
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
591 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
592 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
593
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
594 @Override
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
595 public Node next() {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
596 try {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
597 return super.next();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
598 } finally {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
599 assert modCount == node.modCount() : "must not be modified";
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
600 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
601 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
602
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
603 @Override
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
604 public Position nextPosition() {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
605 try {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
606 return super.nextPosition();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
607 } finally {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
608 assert modCount == node.modCount();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
609 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
610 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
611 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
612
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
613 private class NodeClassSuccessorsIterator extends NodeClassIterator {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
614 NodeClassSuccessorsIterator(Node node) {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
615 this(node, true);
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
616 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
617
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
618 NodeClassSuccessorsIterator(Node node, boolean forward) {
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
619 super(node);
12378
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
620 assert NodeClass.this == node.getNodeClass();
12047
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
621 if (forward) {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
622 forward();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
623 }
12046
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
624 }
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
625
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
626 @Override
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
627 protected int getDirectCount() {
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
628 return directSuccessorCount;
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
629 }
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
630
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
631 @Override
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
632 protected long[] getOffsets() {
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
633 return successorOffsets;
c3a1d5bfc3ee NodeClassIterator: specialize instance for each type of iterator (inputs/successors) in order to share directCount/offsets directly with NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 11882
diff changeset
634 }
12378
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
635
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
636 @Override
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
637 protected NodeClass getNodeClass() {
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
638 return NodeClass.this;
1e76b14e1b3a NodeClassIterator: remove reference to NodeClass
Bernhard Urban <bernhard.urban@jku.at>
parents: 12047
diff changeset
639 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
640 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
641
12047
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
642 private final class NodeClassSuccessorsWithModCountIterator extends NodeClassSuccessorsIterator {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
643 private final int modCount;
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
644
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
645 private NodeClassSuccessorsWithModCountIterator(Node node) {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
646 super(node, false);
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
647 assert MODIFICATION_COUNTS_ENABLED;
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
648 this.modCount = node.modCount();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
649 forward();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
650 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
651
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
652 @Override
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
653 public boolean hasNext() {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
654 try {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
655 return super.hasNext();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
656 } finally {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
657 assert modCount == node.modCount() : "must not be modified";
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
658 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
659 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
660
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
661 @Override
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
662 public Node next() {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
663 try {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
664 return super.next();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
665 } finally {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
666 assert modCount == node.modCount() : "must not be modified";
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
667 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
668 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
669
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
670 @Override
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
671 public Position nextPosition() {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
672 try {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
673 return super.nextPosition();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
674 } finally {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
675 assert modCount == node.modCount();
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
676 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
677 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
678 }
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
679
12696
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
680 private static int deepHashCode0(Object o) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
681 if (o instanceof Object[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
682 return Arrays.deepHashCode((Object[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
683 } else if (o instanceof byte[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
684 return Arrays.hashCode((byte[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
685 } else if (o instanceof short[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
686 return Arrays.hashCode((short[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
687 } else if (o instanceof int[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
688 return Arrays.hashCode((int[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
689 } else if (o instanceof long[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
690 return Arrays.hashCode((long[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
691 } else if (o instanceof char[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
692 return Arrays.hashCode((char[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
693 } else if (o instanceof float[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
694 return Arrays.hashCode((float[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
695 } else if (o instanceof double[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
696 return Arrays.hashCode((double[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
697 } else if (o instanceof boolean[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
698 return Arrays.hashCode((boolean[]) o);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
699 } else if (o != null) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
700 return o.hashCode();
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
701 } else {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
702 return 0;
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
703 }
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
704 }
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
705
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
706 public int valueNumber(Node n) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
707 int number = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
708 if (canGVN) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
709 number = startGVNNumber;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
710 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
711 Class<?> type = dataTypes[i];
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
712 if (type.isPrimitive()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
713 if (type == Integer.TYPE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
714 int intValue = unsafe.getInt(n, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
715 number += intValue;
6657
768793150bcd more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents: 6414
diff changeset
716 } else if (type == Long.TYPE) {
768793150bcd more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents: 6414
diff changeset
717 long longValue = unsafe.getLong(n, dataOffsets[i]);
768793150bcd more PEA refactoring, multiple iterations
Lukas Stadler <lukas.stadler@jku.at>
parents: 6414
diff changeset
718 number += longValue ^ (longValue >>> 32);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
719 } else if (type == Boolean.TYPE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
720 boolean booleanValue = unsafe.getBoolean(n, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
721 if (booleanValue) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
722 number += 7;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
723 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
724 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
725 assert false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
726 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
727 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
728 Object o = unsafe.getObject(n, dataOffsets[i]);
12696
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
729 number += deepHashCode0(o);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
730 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
731 number *= 13;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
732 }
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 return number;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
735 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
736
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
737 /**
5711
4d7175cf3526 enabled Eclipse/JDT javadoc checking and fixed resulting warnings
Doug Simon <doug.simon@oracle.com>
parents: 5693
diff changeset
738 * 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
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 to take the values.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
741 * @param properties a map that will be populated.
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 getDebugProperties(Node node, Map<Object, Object> properties) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
744 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
745 Class<?> type = fieldTypes.get(dataOffsets[i]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
746 Object value = null;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
747 if (type.isPrimitive()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
748 if (type == Integer.TYPE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
749 value = unsafe.getInt(node, dataOffsets[i]);
5361
dec5a35ddbe2 lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents: 5313
diff changeset
750 } else if (type == Long.TYPE) {
dec5a35ddbe2 lowering checkcasts with Java snippets (incomplete)
Doug Simon <doug.simon@oracle.com>
parents: 5313
diff changeset
751 value = unsafe.getLong(node, dataOffsets[i]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
752 } else if (type == Boolean.TYPE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
753 value = unsafe.getBoolean(node, dataOffsets[i]);
12669
1152cf83f0b9 added support for reading float debug properties from a node
Doug Simon <doug.simon@oracle.com>
parents: 12658
diff changeset
754 } else if (type == Float.TYPE) {
1152cf83f0b9 added support for reading float debug properties from a node
Doug Simon <doug.simon@oracle.com>
parents: 12658
diff changeset
755 value = unsafe.getFloat(node, dataOffsets[i]);
5287
e96c8d2925da let NodeClass.getDebugProperties handle arrays and doubles
Lukas Stadler <lukas.stadler@jku.at>
parents: 5261
diff changeset
756 } 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
757 value = unsafe.getDouble(node, dataOffsets[i]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
758 } else {
5313
be1a8ff480db Visualizer: display long properties correctly, "!InstanceOf" for negated InstanceOfNodes
Lukas Stadler <lukas.stadler@jku.at>
parents: 5301
diff changeset
759 assert false : "unhandled property type: " + type;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
760 }
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
761 } else {
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
762 value = unsafe.getObject(node, dataOffsets[i]);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
763 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
764 properties.put(fieldNames.get(dataOffsets[i]), value);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
765 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
766 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
767
12696
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
768 private static boolean deepEquals0(Object e1, Object e2) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
769 assert e1 != null;
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
770 boolean eq;
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
771 if (e1 instanceof Object[] && e2 instanceof Object[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
772 eq = Arrays.deepEquals((Object[]) e1, (Object[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
773 } else if (e1 instanceof byte[] && e2 instanceof byte[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
774 eq = Arrays.equals((byte[]) e1, (byte[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
775 } else if (e1 instanceof short[] && e2 instanceof short[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
776 eq = Arrays.equals((short[]) e1, (short[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
777 } else if (e1 instanceof int[] && e2 instanceof int[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
778 eq = Arrays.equals((int[]) e1, (int[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
779 } else if (e1 instanceof long[] && e2 instanceof long[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
780 eq = Arrays.equals((long[]) e1, (long[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
781 } else if (e1 instanceof char[] && e2 instanceof char[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
782 eq = Arrays.equals((char[]) e1, (char[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
783 } else if (e1 instanceof float[] && e2 instanceof float[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
784 eq = Arrays.equals((float[]) e1, (float[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
785 } else if (e1 instanceof double[] && e2 instanceof double[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
786 eq = Arrays.equals((double[]) e1, (double[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
787 } else if (e1 instanceof boolean[] && e2 instanceof boolean[]) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
788 eq = Arrays.equals((boolean[]) e1, (boolean[]) e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
789 } else {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
790 eq = e1.equals(e2);
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
791 }
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
792 return eq;
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
793 }
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
794
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
795 public boolean valueEqual(Node a, Node b) {
11666
3967f9f306f8 Factor usages of getNodeClass().
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11653
diff changeset
796 if (!canGVN || a.getClass() != b.getClass()) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
797 return a == b;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
798 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
799 for (int i = 0; i < dataOffsets.length; ++i) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
800 Class<?> type = dataTypes[i];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
801 if (type.isPrimitive()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
802 if (type == Integer.TYPE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
803 int aInt = unsafe.getInt(a, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
804 int bInt = unsafe.getInt(b, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
805 if (aInt != bInt) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
806 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
807 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
808 } else if (type == Boolean.TYPE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
809 boolean aBoolean = unsafe.getBoolean(a, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
810 boolean bBoolean = unsafe.getBoolean(b, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
811 if (aBoolean != bBoolean) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
812 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
813 }
5301
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
814 } else if (type == Long.TYPE) {
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
815 long aLong = unsafe.getLong(a, dataOffsets[i]);
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
816 long bLong = unsafe.getLong(b, dataOffsets[i]);
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
817 if (aLong != bLong) {
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
818 return false;
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
819 }
10785
debb9d8e0282 allow double fields in value number computation and thus, in floating nodes
Doug Simon <doug.simon@oracle.com>
parents: 10424
diff changeset
820 } 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
821 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
822 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
823 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
824 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
825 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
826 } else {
5301
23ea81293bd5 let NodeClass.valueEqual handle long fields
Lukas Stadler <lukas.stadler@jku.at>
parents: 5299
diff changeset
827 assert false : "unhandled type: " + type;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
828 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
829 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
830 Object objectA = unsafe.getObject(a, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
831 Object objectB = unsafe.getObject(b, dataOffsets[i]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
832 if (objectA != objectB) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
833 if (objectA != null && objectB != null) {
12696
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
834 if (!deepEquals0(objectA, objectB)) {
22780dc399da Support arbitrary array types in global value numbering.
Roland Schatz <roland.schatz@oracle.com>
parents: 12687
diff changeset
835 return false;
3733
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 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
838 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
839 }
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 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
843 return true;
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
5214
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
846 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
847 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
848 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
849 }
5214
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
850 long[] offsets = pos.input ? inputOffsets : successorOffsets;
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
851 if (pos.index >= offsets.length) {
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
852 return false;
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
853 }
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
854 long[] fromOffsets = pos.input ? from.inputOffsets : from.successorOffsets;
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
855 if (pos.index >= fromOffsets.length) {
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
856 return false;
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
857 }
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
858 return offsets[pos.index] == fromOffsets[pos.index];
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
859 }
1020e363a05d Loop peeling
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5061
diff changeset
860
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
861 public Node get(Node node, Position pos) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
862 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
863 if (pos.subIndex == NOT_ITERABLE) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
864 return getNode(node, offset);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
865 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
866 return getNodeList(node, offset).get(pos.subIndex);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
867 }
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
12483
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
870 public NodeList<?> getNodeList(Node node, Position pos) {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
871 long offset = pos.input ? inputOffsets[pos.index] : successorOffsets[pos.index];
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
872 assert pos.subIndex == NODE_LIST;
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
873 return getNodeList(node, offset);
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
874 }
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
875
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
876 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
877 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
878 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
879
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
880 void updateInputSuccInPlace(Node node, InplaceUpdateClosure duplicationReplacement) {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
881 int index = 0;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
882 while (index < directInputCount) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
883 Node input = getNode(node, inputOffsets[index]);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
884 if (input != null) {
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
885 Node newInput = duplicationReplacement.replacement(input, true);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
886 node.updateUsages(null, newInput);
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12612
diff changeset
887 assert Node.verifyUniqueIfExternal(newInput, node.graph());
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
888 putNode(node, inputOffsets[index], newInput);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
889 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
890 index++;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
891 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
892
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
893 if (index < inputOffsets.length) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
894 updateInputLists(node, duplicationReplacement, index);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
895 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
896
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
897 index = 0;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
898 while (index < directSuccessorCount) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
899 Node successor = getNode(node, successorOffsets[index]);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
900 if (successor != null) {
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
901 Node newSucc = duplicationReplacement.replacement(successor, false);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
902 node.updatePredecessor(null, newSucc);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
903 putNode(node, successorOffsets[index], newSucc);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
904 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
905 index++;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
906 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
907
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
908 if (index < successorOffsets.length) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
909 updateSuccLists(node, duplicationReplacement, index);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
910 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
911 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
912
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
913 private void updateInputLists(Node node, InplaceUpdateClosure duplicationReplacement, int startIndex) {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
914 int index = startIndex;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
915 while (index < inputOffsets.length) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
916 NodeList<Node> list = getNodeList(node, inputOffsets[index]);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
917 putNodeList(node, inputOffsets[index], updateInputListCopy(list, node, duplicationReplacement));
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
918 assert list != null : clazz;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
919 index++;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
920 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
921 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
922
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
923 private void updateSuccLists(Node node, InplaceUpdateClosure duplicationReplacement, int startIndex) {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
924 int index = startIndex;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
925 while (index < successorOffsets.length) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
926 NodeList<Node> list = getNodeList(node, successorOffsets[index]);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
927 putNodeList(node, successorOffsets[index], updateSuccListCopy(list, node, duplicationReplacement));
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
928 assert list != null : clazz;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
929 index++;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
930 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
931 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
932
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
933 private static NodeInputList<Node> updateInputListCopy(NodeList<Node> list, Node node, InplaceUpdateClosure duplicationReplacement) {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
934 int size = list.size();
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
935 NodeInputList<Node> result = new NodeInputList<>(node, size);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
936 for (int i = 0; i < list.count(); ++i) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
937 Node oldNode = list.get(i);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
938 if (oldNode != null) {
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
939 Node newNode = duplicationReplacement.replacement(oldNode, true);
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12612
diff changeset
940 assert Node.verifyUniqueIfExternal(newNode, node.graph());
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
941 result.set(i, newNode);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
942 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
943 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
944 return result;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
945 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
946
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
947 private static NodeSuccessorList<Node> updateSuccListCopy(NodeList<Node> list, Node node, InplaceUpdateClosure duplicationReplacement) {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
948 int size = list.size();
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
949 NodeSuccessorList<Node> result = new NodeSuccessorList<>(node, size);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
950 for (int i = 0; i < list.count(); ++i) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
951 Node oldNode = list.get(i);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
952 if (oldNode != null) {
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
953 Node newNode = duplicationReplacement.replacement(oldNode, false);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
954 result.set(i, newNode);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
955 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
956 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
957 return result;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
958 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
959
7283
3964f3d4eb18 Extend loop unswicthing to Switch nodes (integer or type)
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7258
diff changeset
960 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
961 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
962 if (pos.subIndex == NOT_ITERABLE) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
963 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
964 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
965 putNode(node, offset, x);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
966 if (pos.input) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
967 node.updateUsages(old, x);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
968 } else {
5487
9743ae819f73 Move virtual chain help methods from SuperBlock to GraphUtil
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5486
diff changeset
969 node.updatePredecessor(old, x);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
970 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
971 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
972 NodeList<Node> list = getNodeList(node, offset);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
973 if (pos.subIndex < list.size()) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
974 list.set(pos.subIndex, x);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
975 } else {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
976 while (pos.subIndex < list.size() - 1) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
977 list.add(null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
978 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
979 list.add(x);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
980 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
981 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
982 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
983
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
984 public NodeClassIterable getInputIterable(final Node node) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
985 assert clazz.isInstance(node);
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
986 return new NodeClassIterable() {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
987
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
988 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
989 public NodeClassIterator iterator() {
12047
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
990 if (MODIFICATION_COUNTS_ENABLED) {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
991 return new NodeClassInputsWithModCountIterator(node);
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
992 } else {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
993 return new NodeClassInputsIterator(node);
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
994 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
995 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
996
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
997 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
998 public boolean contains(Node other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
999 return inputContains(node, other);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1000 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1001 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1002 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1003
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
1004 public NodeClassIterable getSuccessorIterable(final Node node) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1005 assert clazz.isInstance(node);
7123
b914b9b4c578 graal.graph refactorings
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6657
diff changeset
1006 return new NodeClassIterable() {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
1007
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1008 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1009 public NodeClassIterator iterator() {
12047
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
1010 if (MODIFICATION_COUNTS_ENABLED) {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
1011 return new NodeClassSuccessorsWithModCountIterator(node);
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
1012 } else {
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
1013 return new NodeClassSuccessorsIterator(node);
dcd412a084a2 NodeClassIterator: seperate implementation for modCount check
Bernhard Urban <bernhard.urban@jku.at>
parents: 12046
diff changeset
1014 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1015 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1016
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1017 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1018 public boolean contains(Node other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1019 return successorContains(node, other);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1020 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1021 };
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1022 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1023
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1024 public boolean replaceFirstInput(Node node, Node old, Node other) {
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12612
diff changeset
1025 assert Node.verifyUniqueIfExternal(other, node.graph());
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1026 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1027 while (index < directInputCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1028 Node input = getNode(node, inputOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1029 if (input == old) {
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
1030 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
1031 " in " + node;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1032 putNode(node, inputOffsets[index], other);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1033 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1034 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1035 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1036 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1037 while (index < inputOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1038 NodeList<Node> list = getNodeList(node, inputOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1039 assert list != null : clazz;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1040 if (list.replaceFirst(old, other)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1041 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1042 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1043 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1044 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1045 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1046 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1047
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1048 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
1049 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1050 while (index < directSuccessorCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1051 Node successor = getNode(node, successorOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1052 if (successor == old) {
10424
e6cf435419b2 Fix after lowering phase refactoring.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9808
diff changeset
1053 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
1054 other.getClass();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1055 putNode(node, successorOffsets[index], other);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1056 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1057 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1058 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1059 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1060 while (index < successorOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1061 NodeList<Node> list = getNodeList(node, successorOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1062 assert list != null : clazz + " " + successorOffsets[index] + " " + node;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1063 if (list.replaceFirst(old, other)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1064 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1065 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1066 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1067 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1068 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1069 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1070
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1071 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
1072 * 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
1073 * 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
1074 * clear the inputs of cloned nodes.)
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
1075 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1076 * @param node the node to be cleared
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1077 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1078 public void clearInputs(Node node) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1079 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1080 while (index < directInputCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1081 putNode(node, inputOffsets[index++], null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1082 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1083 while (index < inputOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1084 long curOffset = inputOffsets[index++];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1085 int size = (getNodeList(node, curOffset)).initialSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1086 // 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
1087 putNodeList(node, curOffset, new NodeInputList<>(node, size));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1088 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1089 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1090
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1091 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
1092 * 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
1093 * 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
1094 * 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
1095 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1096 * @param node the node to be cleared
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1097 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1098 public void clearSuccessors(Node node) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1099 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1100 while (index < directSuccessorCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1101 putNode(node, successorOffsets[index++], null);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1102 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1103 while (index < successorOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1104 long curOffset = successorOffsets[index++];
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1105 int size = getNodeList(node, curOffset).initialSize;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1106 // 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
1107 putNodeList(node, curOffset, new NodeSuccessorList<>(node, size));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1108 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1109 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1110
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1111 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
1112 * 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
1113 * NodeClass type.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
1114 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1115 * @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
1116 * @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
1117 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1118 public void copyInputs(Node node, Node newNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1119 assert node.getClass() == clazz && newNode.getClass() == clazz;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1120
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1121 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1122 while (index < directInputCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1123 putNode(newNode, inputOffsets[index], getNode(node, inputOffsets[index]));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1124 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1125 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1126 while (index < inputOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1127 NodeList<Node> list = getNodeList(newNode, inputOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1128 list.copy(getNodeList(node, inputOffsets[index]));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1129 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1130 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1131 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1132
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1133 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
1134 * 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
1135 * NodeClass type.
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
1136 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1137 * @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
1138 * @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
1139 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1140 public void copySuccessors(Node node, Node newNode) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1141 assert node.getClass() == clazz && newNode.getClass() == clazz;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1142
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1143 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1144 while (index < directSuccessorCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1145 putNode(newNode, successorOffsets[index], getNode(node, successorOffsets[index]));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1146 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1147 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1148 while (index < successorOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1149 NodeList<Node> list = getNodeList(newNode, successorOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1150 list.copy(getNodeList(node, successorOffsets[index]));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1151 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1152 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1153 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1154
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1155 public boolean edgesEqual(Node node, Node other) {
9450
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
1156 return inputsEqual(node, other) && successorsEqual(node, other);
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
1157 }
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
1158
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
1159 public boolean inputsEqual(Node node, Node other) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1160 assert node.getClass() == clazz && other.getClass() == clazz;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1161 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1162 while (index < directInputCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1163 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
1164 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1165 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1166 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1167 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1168 while (index < inputOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1169 NodeList<Node> list = getNodeList(other, inputOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1170 if (!list.equals(getNodeList(node, inputOffsets[index]))) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1171 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1172 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1173 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1174 }
9450
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
1175 return true;
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
1176 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1177
9450
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
1178 public boolean successorsEqual(Node node, Node other) {
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
1179 assert node.getClass() == clazz && other.getClass() == clazz;
ca34e36c53e8 Add loop safepoint elimination
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7530
diff changeset
1180 int index = 0;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1181 while (index < directSuccessorCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1182 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
1183 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1184 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1185 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1186 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1187 while (index < successorOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1188 NodeList<Node> list = getNodeList(other, successorOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1189 if (!list.equals(getNodeList(node, successorOffsets[index]))) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1190 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1191 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1192 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1193 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1194 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1195 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1196
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1197 public boolean inputContains(Node node, Node other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1198 assert node.getClass() == clazz;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1199
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1200 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1201 while (index < directInputCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1202 if (getNode(node, inputOffsets[index]) == other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1203 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1204 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1205 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1206 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1207 while (index < inputOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1208 NodeList<Node> list = getNodeList(node, inputOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1209 if (list.contains(other)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1210 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1211 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1212 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1213 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1214 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1215 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1216
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1217 public boolean successorContains(Node node, Node other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1218 assert node.getClass() == clazz;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1219
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1220 int index = 0;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1221 while (index < directSuccessorCount) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1222 if (getNode(node, successorOffsets[index]) == other) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1223 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1224 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1225 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1226 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1227 while (index < successorOffsets.length) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1228 NodeList<Node> list = getNodeList(node, successorOffsets[index]);
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1229 if (list.contains(other)) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1230 return true;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1231 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1232 index++;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1233 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1234 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1235 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1236
12483
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1237 public Collection<Position> getFirstLevelInputPositions() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1238 return new AbstractCollection<Position>() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1239 @Override
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1240 public Iterator<Position> iterator() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1241 return new Iterator<NodeClass.Position>() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1242 int i = 0;
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1243
12558
5de6526474bb added missing @Override's
twisti
parents: 12510
diff changeset
1244 @Override
12483
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1245 public void remove() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1246 throw new UnsupportedOperationException();
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1247 }
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1248
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1249 public Position next() {
12510
11dc3108904f Fix NodeClass.getFirstLevel(Input|Successor)Positions to use the NODE_LIST constant instead of 0
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
1250 Position pos = new Position(true, i, i >= directInputCount ? NODE_LIST : NOT_ITERABLE);
12483
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1251 i++;
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1252 return pos;
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1253 }
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1254
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1255 public boolean hasNext() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1256 return i < inputOffsets.length;
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1257 }
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1258 };
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1259 }
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1260
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1261 @Override
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1262 public int size() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1263 return inputOffsets.length;
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1264 }
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1265 };
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1266 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1267
12483
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1268 public Collection<Position> getFirstLevelSuccessorPositions() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1269 return new AbstractCollection<Position>() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1270 @Override
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1271 public Iterator<Position> iterator() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1272 return new Iterator<NodeClass.Position>() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1273 int i = 0;
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1274
12558
5de6526474bb added missing @Override's
twisti
parents: 12510
diff changeset
1275 @Override
12483
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1276 public void remove() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1277 throw new UnsupportedOperationException();
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1278 }
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1279
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1280 public Position next() {
12510
11dc3108904f Fix NodeClass.getFirstLevel(Input|Successor)Positions to use the NODE_LIST constant instead of 0
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12483
diff changeset
1281 Position pos = new Position(false, i, i >= directSuccessorCount ? NODE_LIST : NOT_ITERABLE);
12483
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1282 i++;
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1283 return pos;
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1284 }
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1285
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1286 public boolean hasNext() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1287 return i < successorOffsets.length;
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1288 }
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1289 };
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1290 }
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1291
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1292 @Override
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1293 public int size() {
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1294 return successorOffsets.length;
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1295 }
134671fbf973 Optimize Binary Graph format for more compact size
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12378
diff changeset
1296 };
5813
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
1297 }
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
1298
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
1299 public Class<?> getJavaClass() {
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
1300 return clazz;
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
1301 }
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
1302
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
1303 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7332
diff changeset
1304 * 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
1305 * 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
1306 */
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
1307 public String getNameTemplate() {
3b8bc07f8d17 Add ability to give an existing to getDebugProperties
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5810
diff changeset
1308 return nameTemplate;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1309 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1310
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1311 interface InplaceUpdateClosure {
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1312
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1313 Node replacement(Node node, boolean isInput);
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1314 }
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1315
11675
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11674
diff changeset
1316 static Map<Node, Node> addGraphDuplicate(final Graph graph, final Graph oldGraph, int estimatedNodeCount, Iterable<Node> nodes, final DuplicationReplacement replacements) {
12685
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
1317 final Map<Node, Node> newNodes;
12687
43301f080126 added graph compression (GRAAL-571)
Doug Simon <doug.simon@oracle.com>
parents: 12685
diff changeset
1318 if (estimatedNodeCount > (oldGraph.getNodeCount() + oldGraph.getNodesDeletedSinceLastCompression() >> 4)) {
12685
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
1319 // Use dense map
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
1320 newNodes = new NodeNodeMap(oldGraph);
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
1321 } else {
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
1322 // Use sparse map
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
1323 newNodes = new IdentityHashMap<>();
478c82dde838 commented choice of data structure in NodeClass.addGraphDuplicate()
Doug Simon <doug.simon@oracle.com>
parents: 12669
diff changeset
1324 }
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1325 createNodeDuplicates(graph, nodes, replacements, newNodes);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1326
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1327 InplaceUpdateClosure replacementClosure = new InplaceUpdateClosure() {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1328
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1329 public Node replacement(Node node, boolean isInput) {
12655
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12612
diff changeset
1330 if (node.isExternal() && node instanceof ValueNumberable) {
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12612
diff changeset
1331 return graph.uniqueWithoutAdd(node);
2c4aa758ee18 made ConstantNodes external to a Graph (GRAAL-508)
Doug Simon <doug.simon@oracle.com>
parents: 12612
diff changeset
1332 }
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1333 Node target = newNodes.get(node);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1334 if (target == null) {
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1335 Node replacement = node;
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1336 if (replacements != null) {
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1337 replacement = replacements.replacement(node);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1338 }
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1339 if (replacement != node) {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1340 target = replacement;
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1341 } else if (node.graph() == graph && isInput) {
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1342 // patch to the outer world
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1343 target = node;
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1344 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1345
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1346 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1347 return target;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1348 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1349
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1350 };
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1351
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1352 // re-wire inputs
11675
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11674
diff changeset
1353 for (Node oldNode : nodes) {
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11674
diff changeset
1354 Node node = newNodes.get(oldNode);
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1355 NodeClass oldNodeClass = oldNode.getNodeClass();
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1356 NodeClass nodeClass = node.getNodeClass();
11676
435c8b984680 Distinguish inputs and successors in in-place updates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11675
diff changeset
1357 if (replacements == null || replacements.replacement(oldNode) == oldNode) {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1358 nodeClass.updateInputSuccInPlace(node, replacementClosure);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1359 } else {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1360 transferValuesDifferentNodeClass(graph, replacements, newNodes, oldNode, node, oldNodeClass, nodeClass);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1361 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1362 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1363
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1364 return newNodes;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1365 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1366
11675
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11674
diff changeset
1367 private static void createNodeDuplicates(final Graph graph, Iterable<Node> nodes, final DuplicationReplacement replacements, final Map<Node, Node> newNodes) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1368 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
1369 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
1370 assert !node.isDeleted() : "trying to duplicate deleted node: " + node;
11671
3522f7c99c5f Allow null DuplicationReplacement in addDuplicates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
1371 Node replacement = node;
3522f7c99c5f Allow null DuplicationReplacement in addDuplicates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
1372 if (replacements != null) {
3522f7c99c5f Allow null DuplicationReplacement in addDuplicates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
1373 replacement = replacements.replacement(node);
3522f7c99c5f Allow null DuplicationReplacement in addDuplicates.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11669
diff changeset
1374 }
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
1375 if (replacement != node) {
5519
cedae73d9c2a Fix problem with jython and tmt
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5489
diff changeset
1376 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
1377 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
1378 } else {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1379 Node newNode = node.clone(graph, false);
12612
42a2c235652f replace ".count() == 0" with ".isEmpty()"
Doug Simon <doug.simon@oracle.com>
parents: 12574
diff changeset
1380 assert newNode.inputs().isEmpty() || newNode.usages().isEmpty();
5478
4a99bfc329f0 Add posibility to provide a replacement function instead of map for duplication.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 5361
diff changeset
1381 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
1382 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
1383 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1384 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1385 }
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1386 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1387
11675
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11674
diff changeset
1388 private static void transferValuesDifferentNodeClass(final Graph graph, final DuplicationReplacement replacements, final Map<Node, Node> newNodes, Node oldNode, Node node, NodeClass oldNodeClass,
77d9f12797c5 Use NodeMap in inlining utility when number of nodes is high.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11674
diff changeset
1389 NodeClass nodeClass) {
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1390 for (NodeClassIterator iter = oldNode.inputs().iterator(); iter.hasNext();) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1391 Position pos = iter.nextPosition();
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1392 if (!nodeClass.isValid(pos, oldNodeClass)) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1393 continue;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1394 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1395 Node input = oldNodeClass.get(oldNode, pos);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1396 Node target = newNodes.get(input);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1397 if (target == null) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1398 Node replacement = input;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1399 if (replacements != null) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1400 replacement = replacements.replacement(input);
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
1401 }
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1402 if (replacement != input) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1403 assert isAssignable(nodeClass.fieldTypes.get(nodeClass.inputOffsets[pos.index]), replacement);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1404 target = replacement;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1405 } else if (input.graph() == graph) { // patch to the outer world
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1406 target = input;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1407 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1408 }
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1409 nodeClass.set(node, pos, target);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1410 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1411
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1412 for (NodeClassIterator iter = oldNode.successors().iterator(); iter.hasNext();) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1413 Position pos = iter.nextPosition();
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1414 if (!nodeClass.isValid(pos, oldNodeClass)) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1415 continue;
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1416 }
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1417 Node succ = oldNodeClass.get(oldNode, pos);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1418 Node target = newNodes.get(succ);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1419 if (target == null) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1420 Node replacement = replacements.replacement(succ);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1421 if (replacement != succ) {
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1422 assert isAssignable(nodeClass.fieldTypes.get(node.getNodeClass().successorOffsets[pos.index]), replacement);
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1423 target = 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
1424 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1425 }
11674
8505bcff4bdc New graph duplication mechanism that allows in-place fixing of edges.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11673
diff changeset
1426 nodeClass.set(node, pos, target);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1427 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1428 }
5858
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
1429
911315a3e642 Factor out common infrastructure from NodeClass and LIRInstructionClass
Christian Wimmer <christian.wimmer@oracle.com>
parents: 5813
diff changeset
1430 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
1431 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
1432 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1433 }