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

Towards goto removal.
author Thomas Wuerthinger <thomas@wuerthinger.net>
date Wed, 25 May 2011 14:33:44 +0200
parents 915456e4959e
children
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: 2582
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.debug.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
29 import com.sun.c1x.util.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
30 import com.sun.c1x.value.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
31 import com.sun.cri.ci.*;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
32
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 * Denotes the beginning of a basic block, and holds information
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
35 * about the basic block, including the successor and
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
36 * predecessor blocks, exception handlers, liveness information, etc.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
37 */
2634
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2625
diff changeset
38 public final class BlockBegin extends StateSplit {
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
39
2781
bda5972a40a5 remove unnecessary BlockBegin nodes in frontend
Lukas Stadler <lukas.stadler@jku.at>
parents: 2773
diff changeset
40 private static final int INPUT_COUNT = 0;
2616
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2611
diff changeset
41
2756
bfcdda4fdd73 Removed the direct connection between BlockBegin and BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2752
diff changeset
42 private static final int SUCCESSOR_COUNT = 0;
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
43
2616
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2611
diff changeset
44 @Override
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2611
diff changeset
45 protected int inputCount() {
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2611
diff changeset
46 return super.inputCount() + INPUT_COUNT;
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2611
diff changeset
47 }
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2611
diff changeset
48
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2611
diff changeset
49 @Override
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2611
diff changeset
50 protected int successorCount() {
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2611
diff changeset
51 return super.successorCount() + SUCCESSOR_COUNT;
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2611
diff changeset
52 }
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2611
diff changeset
53
3558ca7088c0 FrameState and Graphviz changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2611
diff changeset
54 /**
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
55 * The last node in the block (which contains the successors).
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
56 */
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
57 public BlockEnd end() {
2756
bfcdda4fdd73 Removed the direct connection between BlockBegin and BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2752
diff changeset
58 Instruction next = next();
bfcdda4fdd73 Removed the direct connection between BlockBegin and BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2752
diff changeset
59 while (!(next instanceof BlockEnd)) {
bfcdda4fdd73 Removed the direct connection between BlockBegin and BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2752
diff changeset
60 next = next.next();
bfcdda4fdd73 Removed the direct connection between BlockBegin and BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2752
diff changeset
61 }
bfcdda4fdd73 Removed the direct connection between BlockBegin and BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2752
diff changeset
62 return (BlockEnd) next;
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
63 }
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
2634
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2625
diff changeset
65 @Override
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2625
diff changeset
66 public boolean needsStateAfter() {
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2625
diff changeset
67 return false;
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2625
diff changeset
68 }
4dd0573f510b FrameState fixes.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2625
diff changeset
69
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
70 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
71 * A unique id used in tracing.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
72 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
73 public final int blockID;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
74
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2764
diff changeset
75 public final boolean isLoopHeader;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
76 private int linearScanNumber;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
77
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
78 /**
2716
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
79 * Index of bytecode that generated this node when appended in a basic block.
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
80 * Negative values indicate special cases.
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
81 */
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
82 private int bci;
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
83
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
84 /**
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
85 * Constructs a new BlockBegin at the specified bytecode index.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
86 * @param bci the bytecode index of the start
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
87 * @param blockID the ID of the block
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
88 * @param graph
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
89 */
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2764
diff changeset
90 public BlockBegin(int bci, int blockID, boolean isLoopHeader, Graph graph) {
2602
0c6564c254af new node layout: BlockBegin, BlockEnd
Lukas Stadler <lukas.stadler@jku.at>
parents: 2582
diff changeset
91 super(CiKind.Illegal, INPUT_COUNT, SUCCESSOR_COUNT, graph);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
92 this.blockID = blockID;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
93 linearScanNumber = -1;
2727
1ddcbcd33325 Clean up.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2726
diff changeset
94 this.bci = bci;
2768
43ffa0e47a46 Towards removing stateAfter on BlockEnd.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2764
diff changeset
95 this.isLoopHeader = isLoopHeader;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
96 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
97
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
98 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
99 * Gets the linear scan number of this block.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
100 * @return the linear scan number
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 public int linearScanNumber() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
103 return linearScanNumber;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
104 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
105
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
106 public void setLinearScanNumber(int linearScanNumber) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
107 this.linearScanNumber = linearScanNumber;
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 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
111 * Iterate over this block, its exception handlers, and its successors, in that order.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
112 * @param closure the closure to apply to each block
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
113 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
114 public void iteratePreOrder(BlockClosure closure) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
115 // XXX: identity hash map might be too slow, consider a boolean array or a mark field
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
116 iterate(new IdentityHashMap<BlockBegin, BlockBegin>(), closure);
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
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
119 /**
2716
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
120 * Gets the bytecode index of this instruction.
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
121 * @return the bytecode index of this instruction
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
122 */
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
123 public int bci() {
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
124 return bci;
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
125 }
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
126
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
127 private void iterate(IdentityHashMap<BlockBegin, BlockBegin> mark, BlockClosure closure) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
128 if (!mark.containsKey(this)) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
129 mark.put(this, this);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
130 closure.apply(this);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
131 BlockEnd e = end();
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
132
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
133 Instruction inst = this;
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
134 ArrayList<BlockBegin> excBlocks = new ArrayList<BlockBegin>();
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
135 while (inst != null) {
2773
27512ea6bbcb exception dispatch simplification:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2768
diff changeset
136 if (inst instanceof ExceptionEdgeInstruction) {
2781
bda5972a40a5 remove unnecessary BlockBegin nodes in frontend
Lukas Stadler <lukas.stadler@jku.at>
parents: 2773
diff changeset
137 excBlocks.add((BlockBegin) ((ExceptionEdgeInstruction) inst).exceptionEdge());
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
138 }
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
139 inst = inst.next();
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
140 }
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
141 while (excBlocks.remove(null)) {
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
142 // nothing
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
143 }
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
144 if (excBlocks.size() > 0) {
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
145 iterateReverse(mark, closure, excBlocks);
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
146 }
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
147
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
148 assert e != null : "block must have block end";
2581
4a36a0bd6d18 added GraalGraph to classpath, Node as superclass of Value
Lukas Stadler <lukas.stadler@jku.at>
parents: 2565
diff changeset
149 iterateReverse(mark, closure, e.blockSuccessors());
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
150 }
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 private void iterateReverse(IdentityHashMap<BlockBegin, BlockBegin> mark, BlockClosure closure, List<BlockBegin> list) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
154 for (int i = list.size() - 1; i >= 0; i--) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
155 list.get(i).iterate(mark, closure);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
156 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
157 }
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 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
160 public void accept(ValueVisitor v) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
161 v.visitBlockBegin(this);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
162 }
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 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
165 public String toString() {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
166 StringBuilder builder = new StringBuilder();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
167 builder.append("block #");
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
168 builder.append(blockID);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
169 builder.append(",");
2741
a3cd5eb68837 more GraphBuilder cleanup, moved mergeOrClone to GraphBuilder
Lukas Stadler <lukas.stadler@jku.at>
parents: 2735
diff changeset
170 builder.append(blockID); // was: depthFirstNumber
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
171 builder.append(" [");
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
172
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
173 builder.append("]");
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
174 if (end() != null) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
175 builder.append(" -> ");
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
176 boolean hasSucc = false;
2788
df4c5254c5cc Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
177 for (Instruction s : end().blockSuccessors()) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
178 if (hasSucc) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
179 builder.append(", ");
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
180 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
181 builder.append("#");
2788
df4c5254c5cc Towards goto removal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2782
diff changeset
182 builder.append(s.id());
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
183 hasSucc = true;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
184 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
185 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
186 return builder.toString();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
187 }
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 public void printWithoutPhis(LogStream out) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
190 // print block id
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
191 BlockEnd end = end();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
192 out.print("B").print(blockID).print(" ");
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
193
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
194 // print flags
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
195 StringBuilder sb = new StringBuilder(8);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
196 if (sb.length() != 0) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
197 out.print('(').print(sb.toString()).print(')');
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
198 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
199
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
200 // print block bci range
2716
c1a9bf38da28 Removed bci from the Instruction class.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2715
diff changeset
201 out.print('[').print(-1).print(", ").print(-1).print(']');
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
202
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
203 // print block successors
2581
4a36a0bd6d18 added GraalGraph to classpath, Node as superclass of Value
Lukas Stadler <lukas.stadler@jku.at>
parents: 2565
diff changeset
204 if (end != null && end.blockSuccessors().size() > 0) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
205 out.print(" .");
2581
4a36a0bd6d18 added GraalGraph to classpath, Node as superclass of Value
Lukas Stadler <lukas.stadler@jku.at>
parents: 2565
diff changeset
206 for (BlockBegin successor : end.blockSuccessors()) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
207 out.print(" B").print(successor.blockID);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
208 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
209 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
210
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
211 // print predecessors
2581
4a36a0bd6d18 added GraalGraph to classpath, Node as superclass of Value
Lukas Stadler <lukas.stadler@jku.at>
parents: 2565
diff changeset
212 if (!blockPredecessors().isEmpty()) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
213 out.print(" pred:");
2707
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
214 for (Instruction pred : blockPredecessors()) {
7ed72769d51a exception handling related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2677
diff changeset
215 out.print(" B").print(pred.block().blockID);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
216 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
217 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
218 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
219
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
220 @Override
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
221 public void print(LogStream out) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
222
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
223 printWithoutPhis(out);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
224
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
225 // print phi functions
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
226 boolean hasPhisInLocals = false;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
227 boolean hasPhisOnStack = false;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
228
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
229 if (end() != null && end().stateAfter() != null) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
230 FrameState state = stateBefore();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
231
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
232 int i = 0;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
233 while (!hasPhisOnStack && i < state.stackSize()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
234 Value value = state.stackAt(i);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
235 hasPhisOnStack = isPhiAtBlock(value);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
236 if (value != null && !value.isIllegal()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
237 i += value.kind.sizeInSlots();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
238 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
239 i++;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
240 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
241 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
242
2564
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
243 for (i = 0; !hasPhisInLocals && i < state.localsSize();) {
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
244 Value value = state.localAt(i);
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
245 hasPhisInLocals = isPhiAtBlock(value);
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
246 // also ignore illegal HiWords
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
247 if (value != null && !value.isIllegal()) {
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
248 i += value.kind.sizeInSlots();
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
249 } else {
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
250 i++;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
251 }
2564
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
252 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
253 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
254
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
255 // print values in locals
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
256 if (hasPhisInLocals) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
257 out.println();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
258 out.println("Locals:");
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
259
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
260 FrameState state = stateBefore();
2564
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
261 int i = 0;
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
262 while (i < state.localsSize()) {
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
263 Value value = state.localAt(i);
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
264 if (value != null) {
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
265 out.println(stateString(i, value));
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
266 // also ignore illegal HiWords
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
267 i += value.isIllegal() ? 1 : value.kind.sizeInSlots();
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
268 } else {
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
269 i++;
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
270 }
2564
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
271 }
274360f98f97 Remove inlining (2nd part) removed IRScope
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 2516
diff changeset
272 out.println();
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
273 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
274
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
275 // print values on stack
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
276 if (hasPhisOnStack) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
277 out.println();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
278 out.println("Stack:");
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
279 int i = 0;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
280 while (i < stateBefore().stackSize()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
281 Value value = stateBefore().stackAt(i);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
282 if (value != null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
283 out.println(stateString(i, value));
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
284 i += value.kind.sizeInSlots();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
285 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
286 i++;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
287 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
288 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
289 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
290
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
291 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
292
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
293 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
294 * Determines if a given instruction is a phi whose {@linkplain Phi#block() join block} is a given block.
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
295 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
296 * @param value the instruction to test
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
297 * @param block the block that may be the join block of {@code value} if {@code value} is a phi
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
298 * @return {@code true} if {@code value} is a phi and its join block is {@code block}
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
299 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
300 private boolean isPhiAtBlock(Value value) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
301 return value instanceof Phi && ((Phi) value).block() == this;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
302 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
303
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
304
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
305 /**
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
306 * Formats a given instruction as a value in a {@linkplain FrameState frame state}. If the instruction is a phi defined at a given
2764
99912abb3ff7 Phi clean up. Phis no longer save their local/stack index.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
307 * block, its {@linkplain Phi#valueCount() inputs} are appended to the returned string.
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
308 *
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
309 * @param index the index of the value in the frame state
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
310 * @param value the frame state value
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
311 * @param block if {@code value} is a phi, then its inputs are formatted if {@code block} is its
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
312 * {@linkplain Phi#block() join point}
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
313 * @return the instruction representation as a string
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
314 */
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
315 public String stateString(int index, Value value) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
316 StringBuilder sb = new StringBuilder(30);
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
317 sb.append(String.format("%2d %s", index, Util.valueString(value)));
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
318 if (value instanceof Phi) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
319 Phi phi = (Phi) value;
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
320 // print phi operands
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
321 if (phi.block() == this) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
322 sb.append(" [");
2764
99912abb3ff7 Phi clean up. Phis no longer save their local/stack index.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
323 for (int j = 0; j < phi.valueCount(); j++) {
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
324 sb.append(' ');
2764
99912abb3ff7 Phi clean up. Phis no longer save their local/stack index.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2759
diff changeset
325 Value operand = phi.valueAt(j);
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
326 if (operand != null) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
327 sb.append(Util.valueString(operand));
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
328 } else {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
329 sb.append("NULL");
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
330 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
331 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
332 sb.append("] ");
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
333 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
334 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
335 if (value != null && value.hasSubst()) {
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
336 sb.append("alias ").append(Util.valueString(value.subst()));
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
337 }
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
338 return sb.toString();
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
339 }
2674
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2645
diff changeset
340
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2645
diff changeset
341 @Override
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2645
diff changeset
342 public String shortName() {
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2645
diff changeset
343 return "BlockBegin #" + blockID;
6ab73784566a * BlockBegin.predecessors changed to List<BlockEnd>
Lukas Stadler <lukas.stadler@jku.at>
parents: 2645
diff changeset
344 }
2507
9ec15d6914ca Pull over of compiler from maxine repository.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
diff changeset
345 }