annotate graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java @ 2788:df4c5254c5cc

Towards goto removal.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 25 May 2011 14:33:44 +0200
parents 915456e4959e
children 50677668afe3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
1 /*
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
4 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
7 * published by the Free Software Foundation.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
8 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
13 * accompanied this code).
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
14 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
18 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
21 * questions.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
22 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
23 package com.sun.c1x.ir;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
24
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
25 import java.util.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
26
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
27 import com.oracle.graal.graph.*;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
28 import com.sun.cri.ci.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
29
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
30 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
31 * The {@code BlockEnd} instruction is a base class for all instructions that end a basic
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
32 * block, including branches, switches, throws, and goto's.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
33 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
34 public abstract class BlockEnd extends Instruction {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
35
2621
dd115f80acf8 changed stateAfter FrameState to successor (instead of input), checkstyle fixes, added fixed root node to graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
36 private static final int INPUT_COUNT = 0;
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
37
2788
df4c5254c5cc Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
38 private static final int SUCCESSOR_COUNT = 0;
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
39 private final int blockSuccessorCount;
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
40
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
41 @Override
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
42 protected int inputCount() {
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
43 return super.inputCount() + INPUT_COUNT;
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
44 }
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
45
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
46 @Override
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
47 protected int successorCount() {
2621
dd115f80acf8 changed stateAfter FrameState to successor (instead of input), checkstyle fixes, added fixed root node to graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
48 return super.successorCount() + blockSuccessorCount + SUCCESSOR_COUNT;
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
49 }
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
50
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
51 /**
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
52 * The list of instructions that produce input for this instruction.
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
53 */
2779
93ec3f067420 Changed CriticalEdgeFinder to use LIRBlock.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2776
diff changeset
54 public Instruction blockSuccessor(int index) {
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
55 assert index >= 0 && index < blockSuccessorCount;
2779
93ec3f067420 Changed CriticalEdgeFinder to use LIRBlock.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2776
diff changeset
56 return (Instruction) successors().get(super.successorCount() + SUCCESSOR_COUNT + index);
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
57 }
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
58
2750
6048da340364 less references to BlockBegin in BlockEnd instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 2730
diff changeset
59 public Instruction setBlockSuccessor(int index, Instruction n) {
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
60 assert index >= 0 && index < blockSuccessorCount;
2781
bda5972a40a5 remove unnecessary BlockBegin nodes in frontend
Lukas Stadler <lukas.stadler@jku.at>
parents: 2776
diff changeset
61 // assert n == null || n instanceof BlockBegin : "only BlockBegins, for now... " + n.getClass();
2621
dd115f80acf8 changed stateAfter FrameState to successor (instead of input), checkstyle fixes, added fixed root node to graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
62 return (BlockBegin) successors().set(super.successorCount() + SUCCESSOR_COUNT + index, n);
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
63 }
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
64
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
65 public int blockSuccessorCount() {
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
66 return blockSuccessorCount;
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
67 }
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
68
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
69 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
70 * Constructs a new block end with the specified value type.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
71 * @param kind the type of the value produced by this instruction
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
72 * @param successors the list of successor blocks. If {@code null}, a new one will be created.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
73 */
2774
93fd92c9f8b0 Removed usage of stateAfter on BlockEnd instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
74 public BlockEnd(CiKind kind, List<? extends Instruction> blockSuccessors, int inputCount, int successorCount, Graph graph) {
93fd92c9f8b0 Removed usage of stateAfter on BlockEnd instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
75 this(kind, blockSuccessors.size(), inputCount, successorCount, graph);
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
76 for (int i = 0; i < blockSuccessors.size(); i++) {
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
77 setBlockSuccessor(i, blockSuccessors.get(i));
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
78 }
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
79 }
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
80
2774
93fd92c9f8b0 Removed usage of stateAfter on BlockEnd instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
81 public BlockEnd(CiKind kind, int blockSuccessorCount, int inputCount, int successorCount, Graph graph) {
2621
dd115f80acf8 changed stateAfter FrameState to successor (instead of input), checkstyle fixes, added fixed root node to graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
82 super(kind, inputCount + INPUT_COUNT, successorCount + blockSuccessorCount + SUCCESSOR_COUNT, graph);
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
83 this.blockSuccessorCount = blockSuccessorCount;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
84 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
85
2774
93fd92c9f8b0 Removed usage of stateAfter on BlockEnd instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
86 public BlockEnd(CiKind kind, Graph graph) {
93fd92c9f8b0 Removed usage of stateAfter on BlockEnd instructions.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2769
diff changeset
87 this(kind, 2, 0, 0, graph);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
88 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
89
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
90 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
91 * Gets the block begin associated with this block end.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
92 * @return the beginning of this basic block
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
93 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
94 public BlockBegin begin() {
2624
8e44074058af remove explicit pointer from BlockEnd to BlockBegin
Lukas Stadler <lukas.stadler@jku.at>
parents: 2621
diff changeset
95 for (Node n : predecessors()) {
8e44074058af remove explicit pointer from BlockEnd to BlockBegin
Lukas Stadler <lukas.stadler@jku.at>
parents: 2621
diff changeset
96 if (n instanceof BlockBegin) {
8e44074058af remove explicit pointer from BlockEnd to BlockBegin
Lukas Stadler <lukas.stadler@jku.at>
parents: 2621
diff changeset
97 return (BlockBegin) n;
8e44074058af remove explicit pointer from BlockEnd to BlockBegin
Lukas Stadler <lukas.stadler@jku.at>
parents: 2621
diff changeset
98 }
8e44074058af remove explicit pointer from BlockEnd to BlockBegin
Lukas Stadler <lukas.stadler@jku.at>
parents: 2621
diff changeset
99 }
8e44074058af remove explicit pointer from BlockEnd to BlockBegin
Lukas Stadler <lukas.stadler@jku.at>
parents: 2621
diff changeset
100 return null;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
101 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
102
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
103 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
104 * Substitutes a successor block in this block end's successor list. Note that
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
105 * this method updates all occurrences in the list.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
106 * @param oldSucc the old successor to replace
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
107 * @param newSucc the new successor
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
108 */
2769
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2762
diff changeset
109 public int substituteSuccessor(BlockBegin oldSucc, BlockBegin newSucc) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
110 assert newSucc != null;
2769
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2762
diff changeset
111 int count = 0;
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
112 for (int i = 0; i < blockSuccessorCount; i++) {
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
113 if (blockSuccessor(i) == oldSucc) {
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
114 setBlockSuccessor(i, newSucc);
2769
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2762
diff changeset
115 count++;
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
116 }
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
117 }
2769
dd6419f4bfe2 Fixed several issues with incorrect predecessor count/order. One known issue around exception dispatch remaining in fop.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2762
diff changeset
118 return count;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
119 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
120
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
121 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
122 * Gets the successor corresponding to the default (fall through) case.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
123 * @return the default successor
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
124 */
2779
93ec3f067420 Changed CriticalEdgeFinder to use LIRBlock.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2776
diff changeset
125 public Instruction defaultSuccessor() {
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
126 return blockSuccessor(blockSuccessorCount - 1);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
127 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
128
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
129 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
130 * Searches for the specified successor and returns its index into the
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
131 * successor list if found.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
132 * @param b the block to search for in the successor list
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
133 * @return the index of the block in the list if found; <code>-1</code> otherwise
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
134 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
135 public int successorIndex(BlockBegin b) {
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
136 for (int i = 0; i < blockSuccessorCount; i++) {
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
137 if (blockSuccessor(i) == b) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
138 return i;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
139 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
140 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
141 return -1;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
142 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
143
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
144 /**
2674
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
145 * This method reorders the predecessors of the i-th successor in such a way that this BlockEnd is at position backEdgeIndex.
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
146 */
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
147 public void reorderSuccessor(int i, int backEdgeIndex) {
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
148 assert i >= 0 && i < blockSuccessorCount;
2750
6048da340364 less references to BlockBegin in BlockEnd instructions
Lukas Stadler <lukas.stadler@jku.at>
parents: 2730
diff changeset
149 Instruction successor = blockSuccessor(i);
2674
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
150 if (successor != null) {
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
151 successors().set(super.successorCount() + SUCCESSOR_COUNT + i, Node.Null);
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
152 successors().set(super.successorCount() + SUCCESSOR_COUNT + i, successor, backEdgeIndex);
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
153 }
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
154 }
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
155
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2661
diff changeset
156 /**
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
157 * Gets this block end's list of successors.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
158 * @return the successor list
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
159 */
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2674
diff changeset
160 @SuppressWarnings({ "unchecked", "rawtypes"})
2581
4a36a0bd6d18 added GraalGraph to classpath, Node as superclass of Value
Lukas Stadler <lukas.stadler@jku.at>
parents: 2546
diff changeset
161 public List<BlockBegin> blockSuccessors() {
2621
dd115f80acf8 changed stateAfter FrameState to successor (instead of input), checkstyle fixes, added fixed root node to graph
Lukas Stadler <lukas.stadler@jku.at>
parents: 2616
diff changeset
162 List<BlockBegin> list = (List) successors().subList(super.successorCount() + SUCCESSOR_COUNT, super.successorCount() + blockSuccessorCount + SUCCESSOR_COUNT);
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2581
diff changeset
163 return Collections.unmodifiableList(list);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
164 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
165
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2674
diff changeset
166 public void clearSuccessors() {
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2674
diff changeset
167 for (int i = 0; i < blockSuccessorCount(); i++) {
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2674
diff changeset
168 setBlockSuccessor(i, null);
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2674
diff changeset
169 }
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2674
diff changeset
170 }
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2674
diff changeset
171
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
172 }