annotate graal/com.oracle.max.graal.graph/src/com/oracle/max/graal/graph/Node.java @ 2960:49a8b14e9d24

Tentative change that adds successor tags.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Tue, 14 Jun 2011 16:41:27 +0200
parents 9b8f30608e62
children 0966a5a904ad
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;
2960
49a8b14e9d24 Tentative change that adds successor tags.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2935
diff changeset
43 final int[] successorTags;
2550
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
44
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
45 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
46 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
47 this.graph = graph;
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
48 this.id = graph.register(this);
2674
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
49 this.inputs = new NodeArray(this, inputCount);
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
50 this.successors = new NodeArray(this, successorCount);
2960
49a8b14e9d24 Tentative change that adds successor tags.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2935
diff changeset
51 this.successorTags = new int[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
52 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
53 this.usages = new ArrayList<Node>();
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
54 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
55 }
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
56
2674
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
57 public List<Node> predecessors() {
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
58 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
59 }
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
60
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
61 public List<Integer> predecessorsIndex() {
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
62 return Collections.unmodifiableList(predecessorsIndex);
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
63 }
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
64
2758
0c5791bc90fb More on scheduling.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2751
diff changeset
65 public List<Node> usages() {
0c5791bc90fb More on scheduling.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2751
diff changeset
66 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
67 }
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
68
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
69 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
70 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
71 }
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
72
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
73 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
74 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
75 }
2960
49a8b14e9d24 Tentative change that adds successor tags.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2935
diff changeset
76
49a8b14e9d24 Tentative change that adds successor tags.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2935
diff changeset
77 public int[] successorTags() {
49a8b14e9d24 Tentative change that adds successor tags.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2935
diff changeset
78 return successorTags;
49a8b14e9d24 Tentative change that adds successor tags.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2935
diff changeset
79 }
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
2554
9db994445118 more tests for GraalGraph, some changes and fixes
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2550
diff changeset
81 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
82 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
83 }
d9b2a8653054 Enabled checkstyle for the GraalGraph project. Fixed checkstyle errors. Set correct code formatter.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2549
diff changeset
84
2554
9db994445118 more tests for GraalGraph, some changes and fixes
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2550
diff changeset
85 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
86 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
87 }
2542
7a0e1bd2bb64 Draft for graph classes
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff changeset
88
2839
87018b9c8304 Added Op and Phase class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2831
diff changeset
89 public <T extends Op> T lookup(Class<T> clazz) {
2831
f072013daba9 Added lookup method.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2792
diff changeset
90 return null;
f072013daba9 Added lookup method.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2792
diff changeset
91 }
f072013daba9 Added lookup method.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2792
diff changeset
92
2616
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2584
diff changeset
93 public String shortName() {
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2584
diff changeset
94 return getClass().getSimpleName();
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2584
diff changeset
95 }
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2584
diff changeset
96
2791
6d14aa4fbf90 Gotos removed (except for exception dispatch chains and edge splitting).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2790
diff changeset
97 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
98 assert !isDeleted() && (other == null || !other.isDeleted());
2558
98eef19a381c Fixed delete() method
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2557
diff changeset
99 assert other == null || other.graph == graph;
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
100 for (Node usage : usages) {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
101 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
102 }
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
103 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
104 for (Node predecessor : predecessors) {
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
105 int predIndex = predecessorsIndex.get(z);
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
106 predecessor.successors.nodes[predIndex] = other;
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
107 ++z;
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
108 }
2558
98eef19a381c Fixed delete() method
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2557
diff changeset
109 if (other != null) {
98eef19a381c Fixed delete() method
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2557
diff changeset
110 other.usages.addAll(usages);
98eef19a381c Fixed delete() method
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2557
diff changeset
111 other.predecessors.addAll(predecessors);
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
112 other.predecessorsIndex.addAll(predecessorsIndex);
2558
98eef19a381c Fixed delete() method
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2557
diff changeset
113 }
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
114 usages.clear();
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
115 predecessors.clear();
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
116 predecessorsIndex.clear();
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
117 delete();
2791
6d14aa4fbf90 Gotos removed (except for exception dispatch chains and edge splitting).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2790
diff changeset
118 return other;
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
119 }
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
120
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
121 public boolean isDeleted() {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
122 return id == DeletedID;
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
123 }
2888
224412c24426 Changed C1X=>Graal and c1x=>graal in Java code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2880
diff changeset
124
2880
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
125 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
126 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
127 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
128 }
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
129 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
130 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
131 }
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
132 usages.clear();
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
133 predecessors.clear();
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
134 predecessorsIndex.clear();
385a4d7c2a78 Added new duplication phase (for verification). Fixes in Node.copy method implementations.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2875
diff changeset
135 }
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
136
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
137 public void delete() {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
138 assert !isDeleted();
2935
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
139 assert checkDeletion();
2790
50677668afe3 Towards making goto removal work.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
140 assert predecessorsIndex.size() == 0;
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
141 for (int i = 0; i < inputs.size(); ++i) {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
142 inputs.set(i, Null);
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
143 }
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
144 for (int i = 0; i < successors.size(); ++i) {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
145 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
146 }
2674
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
147 assert predecessors().size() == 0 && usages().size() == 0;
2558
98eef19a381c Fixed delete() method
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2557
diff changeset
148 // make sure its not connected. pred usages
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
149 graph.unregister(this);
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
150 id = DeletedID;
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
151 assert isDeleted();
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
152 }
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
153
2935
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
154 private boolean checkDeletion() {
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
155 if (usages.size() != 0 || predecessors.size() != 0) {
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
156 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
157 System.out.println("usages:");
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
158 for (Node n : usages()) {
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
159 System.out.print(n.id() + " (" + n.shortName() + ") ");
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
160 }
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
161 System.out.println("\npreds:");
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
162 for (Node n : predecessors()) {
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
163 System.out.print(n.id() + " (" + n.shortName() + ") ");
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
164 }
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
165 System.out.println();
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
166 return false;
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
167 }
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
168 return true;
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
169 }
9b8f30608e62 deoptimization action (invalidate, reprofile, ...)
Lukas Stadler <lukas.stadler@jku.at>
parents: 2888
diff changeset
170
2557
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
171 public Node copy() {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
172 return copy(graph);
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
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 * @param into
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 public abstract Node copy(Graph into);
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
181
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 * @return
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 protected int inputCount() {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
187 return 0;
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
188 }
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
189
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
190 /**
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
191 *
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
192 * @return
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
193 */
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
194 protected int successorCount() {
f14f8c24f77d Node and Graph design changes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2556
diff changeset
195 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
196 }
2556
590c2f6a0c4f Checkstyle fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2554
diff changeset
197
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
198 /**
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 * 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
200 * 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
201 */
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 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
203 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
204 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
205 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
206 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
207 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
208 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
209 }
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
210
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
211 @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
212 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
213 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
214 }
2556
590c2f6a0c4f Checkstyle fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2554
diff changeset
215 }