Mercurial > hg > truffle
annotate graal/GraalCompiler/src/com/sun/c1x/ir/BlockEnd.java @ 2703:42450f536d24
More cleanup towards separation of graphbuilding<>graph<>lirgeneration
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Wed, 18 May 2011 17:04:47 +0200 |
parents | 6ab73784566a |
children | 7ed72769d51a |
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.c1x.value.*; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
29 import com.sun.cri.ci.*; |
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 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
32 * 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
|
33 * block, including branches, switches, throws, and goto's. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
34 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
35 public abstract class BlockEnd extends Instruction { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
36 |
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
|
37 private static final int INPUT_COUNT = 0; |
2602
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
38 |
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
|
39 private static final int SUCCESSOR_COUNT = 1; |
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
|
40 private static final int SUCCESSOR_STATE_AFTER = 0; |
2602
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
41 private final int blockSuccessorCount; |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
42 |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
43 @Override |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
44 protected int inputCount() { |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
45 return super.inputCount() + INPUT_COUNT; |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
46 } |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
47 |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
48 @Override |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
49 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
|
50 return super.successorCount() + blockSuccessorCount + SUCCESSOR_COUNT; |
2602
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 |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
53 /** |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2602
diff
changeset
|
54 * The state for this instruction. |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2602
diff
changeset
|
55 */ |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2602
diff
changeset
|
56 @Override |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2602
diff
changeset
|
57 public FrameState stateAfter() { |
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
|
58 return (FrameState) successors().get(super.successorCount() + SUCCESSOR_STATE_AFTER); |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2602
diff
changeset
|
59 } |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2602
diff
changeset
|
60 |
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2602
diff
changeset
|
61 public FrameState setStateAfter(FrameState n) { |
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 (FrameState) successors().set(super.successorCount() + SUCCESSOR_STATE_AFTER, n); |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2602
diff
changeset
|
63 } |
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
|
64 |
2616
3558ca7088c0
FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
2602
diff
changeset
|
65 /** |
2602
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
66 * 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
|
67 */ |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
68 public BlockBegin blockSuccessor(int index) { |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
69 assert index >= 0 && index < blockSuccessorCount; |
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
|
70 return (BlockBegin) successors().get(super.successorCount() + SUCCESSOR_COUNT + index); |
2602
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
71 } |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
72 |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
73 public BlockBegin setBlockSuccessor(int index, BlockBegin n) { |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
74 assert index >= 0 && index < blockSuccessorCount; |
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
|
75 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
|
76 } |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
77 |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
78 public int blockSuccessorCount() { |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
79 return blockSuccessorCount; |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
80 } |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
81 |
2624
8e44074058af
remove explicit pointer from BlockEnd to BlockBegin
Lukas Stadler <lukas.stadler@jku.at>
parents:
2621
diff
changeset
|
82 private boolean isSafepoint; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
83 |
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 * 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
|
86 * @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
|
87 * @param stateAfter the frame state at the end of this block |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
88 * @param isSafepoint {@code true} if this instruction is a safepoint instruction |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
89 * @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
|
90 */ |
2602
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
91 public BlockEnd(CiKind kind, FrameState stateAfter, boolean isSafepoint, List<BlockBegin> blockSuccessors, int inputCount, int successorCount, Graph graph) { |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
92 this(kind, stateAfter, isSafepoint, blockSuccessors.size(), inputCount, successorCount, graph); |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
93 for (int i = 0; i < blockSuccessors.size(); i++) { |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
94 setBlockSuccessor(i, blockSuccessors.get(i)); |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
95 } |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
96 } |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
97 |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
98 public BlockEnd(CiKind kind, FrameState stateAfter, boolean isSafepoint, 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
|
99 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
|
100 this.blockSuccessorCount = blockSuccessorCount; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
101 setStateAfter(stateAfter); |
2538
e1ba5a93e997
Clean up on Value class and LIRGenerator/LIRItem-related things.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2509
diff
changeset
|
102 this.isSafepoint = isSafepoint; |
2507
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 |
2602
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
105 public BlockEnd(CiKind kind, FrameState stateAfter, boolean isSafepoint, Graph graph) { |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
106 this(kind, stateAfter, isSafepoint, 2, 0, 0, graph); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
107 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
108 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
109 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
110 * Checks whether this instruction is a safepoint. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
111 * @return {@code true} if this instruction is a safepoint |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
112 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
113 public boolean isSafepoint() { |
2538
e1ba5a93e997
Clean up on Value class and LIRGenerator/LIRItem-related things.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2509
diff
changeset
|
114 return isSafepoint; |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
115 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
116 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
117 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
118 * 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
|
119 * @return the beginning of this basic block |
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 public BlockBegin begin() { |
2624
8e44074058af
remove explicit pointer from BlockEnd to BlockBegin
Lukas Stadler <lukas.stadler@jku.at>
parents:
2621
diff
changeset
|
122 for (Node n : predecessors()) { |
8e44074058af
remove explicit pointer from BlockEnd to BlockBegin
Lukas Stadler <lukas.stadler@jku.at>
parents:
2621
diff
changeset
|
123 if (n instanceof BlockBegin) { |
8e44074058af
remove explicit pointer from BlockEnd to BlockBegin
Lukas Stadler <lukas.stadler@jku.at>
parents:
2621
diff
changeset
|
124 return (BlockBegin) n; |
8e44074058af
remove explicit pointer from BlockEnd to BlockBegin
Lukas Stadler <lukas.stadler@jku.at>
parents:
2621
diff
changeset
|
125 } |
8e44074058af
remove explicit pointer from BlockEnd to BlockBegin
Lukas Stadler <lukas.stadler@jku.at>
parents:
2621
diff
changeset
|
126 } |
8e44074058af
remove explicit pointer from BlockEnd to BlockBegin
Lukas Stadler <lukas.stadler@jku.at>
parents:
2621
diff
changeset
|
127 return null; |
2507
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 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
131 * 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
|
132 * this method updates all occurrences in the list. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
133 * @param oldSucc the old successor to replace |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
134 * @param newSucc the new successor |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
135 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
136 public void substituteSuccessor(BlockBegin oldSucc, BlockBegin newSucc) { |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
137 assert newSucc != null; |
2602
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
138 for (int i = 0; i < blockSuccessorCount; i++) { |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
139 if (blockSuccessor(i) == oldSucc) { |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
140 setBlockSuccessor(i, newSucc); |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
141 } |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
142 } |
2507
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 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
145 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
146 * 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
|
147 * @return the default successor |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
148 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
149 public BlockBegin defaultSuccessor() { |
2602
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
150 return blockSuccessor(blockSuccessorCount - 1); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
151 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
152 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
153 /** |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
154 * 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
|
155 * successor list if found. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
156 * @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
|
157 * @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
|
158 */ |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
159 public int successorIndex(BlockBegin b) { |
2602
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
160 for (int i = 0; i < blockSuccessorCount; i++) { |
0c6564c254af
new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents:
2581
diff
changeset
|
161 if (blockSuccessor(i) == b) { |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
162 return i; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
163 } |
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 return -1; |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
166 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
167 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
168 /** |
2674
6ab73784566a
* BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents:
2661
diff
changeset
|
169 * 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
|
170 */ |
6ab73784566a
* BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents:
2661
diff
changeset
|
171 public void reorderSuccessor(int i, int backEdgeIndex) { |
6ab73784566a
* BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents:
2661
diff
changeset
|
172 assert i >= 0 && i < blockSuccessorCount; |
6ab73784566a
* BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents:
2661
diff
changeset
|
173 BlockBegin successor = blockSuccessor(i); |
6ab73784566a
* BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents:
2661
diff
changeset
|
174 if (successor != null) { |
6ab73784566a
* BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents:
2661
diff
changeset
|
175 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
|
176 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
|
177 } |
6ab73784566a
* BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents:
2661
diff
changeset
|
178 } |
6ab73784566a
* BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents:
2661
diff
changeset
|
179 |
6ab73784566a
* BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents:
2661
diff
changeset
|
180 /** |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
181 * Gets this block end's list of successors. |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
182 * @return the successor list |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
183 */ |
2661
194d93d089bd
Towards clean up of canTrap().
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2624
diff
changeset
|
184 @SuppressWarnings("unchecked") |
2581
4a36a0bd6d18
added GraalGraph to classpath, Node as superclass of Value
Lukas Stadler <lukas.stadler@jku.at>
parents:
2546
diff
changeset
|
185 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
|
186 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
|
187 return Collections.unmodifiableList(list); |
2507
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
188 } |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
189 |
9ec15d6914ca
Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff
changeset
|
190 } |