annotate graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Node.java @ 2969:8102d939f4f3

Removed successor tags.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 15 Jun 2011 16:57:59 +0200
parents 0048537e3cd7
children c7ce8d00c33f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2549
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
1 /*
2674
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
2549
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
4 *
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
7 * published by the Free Software Foundation.
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
8 *
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
13 * accompanied this code).
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
14 *
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
15 * You should have received a copy of the GNU General Public License version
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
18 *
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
21 * questions.
c12715ca2cc7 Added Oracle header. Moved author declaration into package-info.java file.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2542
diff changeset
22 */
2874
d90bf514d647 Renamed packages.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2872
diff changeset
23 package com.oracle.max.graal.graph;
2542
7a0e1bd2bb64 Draft for graph classes
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff changeset
24
7a0e1bd2bb64 Draft for graph classes
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff changeset
25 import java.util.ArrayList;
7a0e1bd2bb64 Draft for graph classes
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff changeset
26 import java.util.Collections;
2787
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
27 import java.util.HashMap;
2674
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
28 import java.util.List;
2787
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
29 import java.util.Map;
2542
7a0e1bd2bb64 Draft for graph classes
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff changeset
30
2751
0fe79e7435c3 More scheduling. Removed need for cfg iteration in the phi simplifier.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2674
diff changeset
31 public abstract class Node {
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
32
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
33 public static final Node Null = null;
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
34 public static final int DeletedID = -1;
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
35
2674
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
36 final Graph graph;
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
37 private int id;
2674
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
38 final NodeArray inputs;
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
39 final NodeArray successors;
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
40 final ArrayList<Node> usages;
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
41 final ArrayList<Node> predecessors;
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
42 final ArrayList<Integer> predecessorsIndex;
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
43
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
44 public Node(int inputCount, int successorCount, Graph graph) {
2875
3570f1f7903e Changed GraphBuilder to inherit from Phase.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2874
diff changeset
45 assert graph != null : "cannot create a node for a null graph";
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
46 this.graph = graph;
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
47 this.id = graph.register(this);
2674
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
48 this.inputs = new NodeArray(this, inputCount);
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
49 this.successors = new NodeArray(this, successorCount);
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
50 this.predecessors = new ArrayList<Node>();
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
51 this.usages = new ArrayList<Node>();
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
52 this.predecessorsIndex = new ArrayList<Integer>();
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
53 }
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
54
2674
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
55 public List<Node> predecessors() {
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
56 return Collections.unmodifiableList(predecessors);
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
57 }
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
58
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
59 public List<Integer> predecessorsIndex() {
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
60 return Collections.unmodifiableList(predecessorsIndex);
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
61 }
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
62
2758
0c5791bc90fb More on scheduling.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2751
diff changeset
63 public List<Node> usages() {
0c5791bc90fb More on scheduling.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2751
diff changeset
64 return Collections.unmodifiableList(usages);
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
65 }
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
66
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
67 public NodeArray inputs() {
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
68 return inputs;
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
69 }
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
70
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
71 public NodeArray successors() {
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
72 return successors;
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
73 }
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
74
2554
9db994445118 more tests for GraalGraph, some changes and fixes
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2550
diff changeset
75 public int id() {
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
76 return id;
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
77 }
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
78
2554
9db994445118 more tests for GraalGraph, some changes and fixes
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2550
diff changeset
79 public Graph graph() {
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
80 return graph;
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
81 }
2542
7a0e1bd2bb64 Draft for graph classes
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff changeset
82
2839
87018b9c8304 Added Op and Phase class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2831
diff changeset
83 public <T extends Op> T lookup(Class<T> clazz) {
2831
f072013daba9 Added lookup method.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2792
diff changeset
84 return null;
f072013daba9 Added lookup method.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2792
diff changeset
85 }
f072013daba9 Added lookup method.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2792
diff changeset
86
2616
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2584
diff changeset
87 public String shortName() {
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2584
diff changeset
88 return getClass().getSimpleName();
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2584
diff changeset
89 }
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2584
diff changeset
90
2791
6d14aa4fbf90 Gotos removed (except for exception dispatch chains and edge splitting).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2790
diff changeset
91 public Node replace(Node other) {
6d14aa4fbf90 Gotos removed (except for exception dispatch chains and edge splitting).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2790
diff changeset
92 assert !isDeleted() && (other == null || !other.isDeleted());
2558
98eef19a381c Fixed delete() method
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2557
diff changeset
93 assert other == null || other.graph == graph;
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
94 for (Node usage : usages) {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
95 usage.inputs.replaceFirstOccurrence(this, other);
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
96 }
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
97 int z = 0;
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
98 for (Node predecessor : predecessors) {
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
99 int predIndex = predecessorsIndex.get(z);
2961
0966a5a904ad Created variable part in NodeArray.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2960
diff changeset
100 predecessor.successors.silentSet(predIndex, other);
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
101 ++z;
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
102 }
2558
98eef19a381c Fixed delete() method
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2557
diff changeset
103 if (other != null) {
98eef19a381c Fixed delete() method
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2557
diff changeset
104 other.usages.addAll(usages);
98eef19a381c Fixed delete() method
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2557
diff changeset
105 other.predecessors.addAll(predecessors);
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
106 other.predecessorsIndex.addAll(predecessorsIndex);
2558
98eef19a381c Fixed delete() method
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2557
diff changeset
107 }
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
108 usages.clear();
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
109 predecessors.clear();
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
110 predecessorsIndex.clear();
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
111 delete();
2791
6d14aa4fbf90 Gotos removed (except for exception dispatch chains and edge splitting).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2790
diff changeset
112 return other;
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
113 }
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
114
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
115 public boolean isDeleted() {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
116 return id == DeletedID;
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
117 }
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2880
diff changeset
118
2880
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
119 public void forceDelete() {
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
120 for (Node n : usages) {
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
121 n.inputs.silentRemove(this);
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
122 }
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
123 for (Node n : predecessors) {
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
124 n.successors.silentRemove(this);
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
125 }
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
126 usages.clear();
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
127 predecessors.clear();
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
128 predecessorsIndex.clear();
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
129 }
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
130
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
131 public void delete() {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
132 assert !isDeleted();
2966
0048537e3cd7 Added input to Merge node.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2961
diff changeset
133 assert checkDeletion() : "Could not delete " + this;
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
134 assert predecessorsIndex.size() == 0;
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
135 for (int i = 0; i < inputs.size(); ++i) {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
136 inputs.set(i, Null);
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
137 }
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
138 for (int i = 0; i < successors.size(); ++i) {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
139 successors.set(i, Null);
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
140 }
2674
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
141 assert predecessors().size() == 0 && usages().size() == 0;
2558
98eef19a381c Fixed delete() method
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2557
diff changeset
142 // make sure its not connected. pred usages
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
143 graph.unregister(this);
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
144 id = DeletedID;
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
145 assert isDeleted();
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
146 }
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
147
2935
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
148 private boolean checkDeletion() {
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
149 if (usages.size() != 0 || predecessors.size() != 0) {
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
150 System.out.println(this.shortName() + ", id: " + id + ", usages: " + usages.size() + ", predecessors: " + predecessors().size());
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
151 System.out.println("usages:");
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
152 for (Node n : usages()) {
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
153 System.out.print(n.id() + " (" + n.shortName() + ") ");
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
154 }
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
155 System.out.println("\npreds:");
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
156 for (Node n : predecessors()) {
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
157 System.out.print(n.id() + " (" + n.shortName() + ") ");
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
158 }
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
159 System.out.println();
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
160 return false;
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
161 }
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
162 return true;
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
163 }
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
164
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
165 public Node copy() {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
166 return copy(graph);
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
167 }
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
168
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
169 /**
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
170 *
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
171 * @param into
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
172 * @return
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
173 */
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
174 public abstract Node copy(Graph into);
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
175
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
176 /**
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
177 *
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
178 * @return
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
179 */
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
180 protected int inputCount() {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
181 return 0;
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
182 }
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
183
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
184 /**
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
185 *
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
186 * @return
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
187 */
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
188 protected int successorCount() {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
189 return 0;
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
190 }
2556
590c2f6a0c4f Checkstyle fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2554
diff changeset
191
2787
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
192 /**
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
193 * Provides a {@link Map} of properties of this node for use in debugging (e.g., to view in the ideal graph
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
194 * visualizer). Subclasses overriding this method should add to the map returned by their superclass.
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
195 */
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
196 public Map<Object, Object> getDebugProperties() {
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
197 Map<Object, Object> map = new HashMap<Object, Object>();
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
198 map.put("inputCount", inputCount());
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
199 map.put("usageCount", usages.size());
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
200 map.put("successorCount", successorCount());
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
201 map.put("predecessorCount", predecessors.size());
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
202 return map;
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
203 }
9253df721472 Allow to return a map of "debug properties" in Node and subclasses and show these properties in the IdealGraphVisualizer. Also, fix inputCount() and successorCount() for Local.
Peter Hofer <peter.hofer@jku.at>
parents: 2759
diff changeset
204
2559
46eab5817cc2 Modified assert in NodeArray.set method (also helps with a compilation issue in ECJ)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2558
diff changeset
205 @Override
46eab5817cc2 Modified assert in NodeArray.set method (also helps with a compilation issue in ECJ)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2558
diff changeset
206 public String toString() {
46eab5817cc2 Modified assert in NodeArray.set method (also helps with a compilation issue in ECJ)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2558
diff changeset
207 return this.getClass().getSimpleName() + "-" + this.id();
46eab5817cc2 Modified assert in NodeArray.set method (also helps with a compilation issue in ECJ)
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2558
diff changeset
208 }
2556
590c2f6a0c4f Checkstyle fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2554
diff changeset
209 }