2795
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
1 /*
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
4 *
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation.
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
8 *
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code).
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
14 *
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation,
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
18 *
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
21 * questions.
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
22 */
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
23 package com.sun.c1x.ir;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
24
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
25 import com.oracle.graal.graph.*;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
26 import com.sun.c1x.debug.*;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
27 import com.sun.c1x.util.*;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
28 import com.sun.c1x.value.*;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
29 import com.sun.cri.ci.*;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
30
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
31 /**
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
32 * Denotes the beginning of a basic block, and holds information
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
33 * about the basic block, including the successor and
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
34 * predecessor blocks, exception handlers, liveness information, etc.
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
35 */
|
2799
|
36 public class Merge extends StateSplit {
|
2795
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
37
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
38 private static final int INPUT_COUNT = 0;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
39
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
40 private static final int SUCCESSOR_COUNT = 0;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
41
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
42 @Override
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
43 protected int inputCount() {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
44 return super.inputCount() + INPUT_COUNT;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
45 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
46
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
47 @Override
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
48 protected int successorCount() {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
49 return super.successorCount() + SUCCESSOR_COUNT;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
50 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
51
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
52 @Override
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
53 public boolean needsStateAfter() {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
54 return false;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
55 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
56
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
57 /**
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
58 * Constructs a new Merge at the specified bytecode index.
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
59 * @param bci the bytecode index of the start
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
60 * @param blockID the ID of the block
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
61 * @param graph
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
62 */
|
2799
|
63 public Merge(Graph graph) {
|
2795
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
64 super(CiKind.Illegal, INPUT_COUNT, SUCCESSOR_COUNT, graph);
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
65 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
66
|
2799
|
67 protected Merge(int inputCount, int successorCount, Graph graph) {
|
|
68 super(CiKind.Illegal, inputCount + INPUT_COUNT, successorCount + SUCCESSOR_COUNT, graph);
|
2795
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
69 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
70
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
71 @Override
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
72 public void accept(ValueVisitor v) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
73 v.visitMerge(this);
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
74 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
75
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
76 @Override
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
77 public String toString() {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
78 StringBuilder builder = new StringBuilder();
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
79 builder.append("merge #");
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
80 builder.append(id());
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
81 builder.append(" [");
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
82
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
83 builder.append("]");
|
2800
|
84
|
|
85 builder.append(" -> ");
|
|
86 boolean hasSucc = false;
|
|
87 for (Node s : this.successors()) {
|
|
88 if (hasSucc) {
|
|
89 builder.append(", ");
|
2795
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
90 }
|
2800
|
91 builder.append("#");
|
|
92 if (s != null) {
|
2795
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
93 builder.append(s.id());
|
2800
|
94 } else {
|
|
95 builder.append("null");
|
2795
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
96 }
|
2800
|
97 hasSucc = true;
|
|
98 }
|
|
99
|
2795
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
100 return builder.toString();
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
101 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
102
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
103 public void printWithoutPhis(LogStream out) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
104 // print block id
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
105 out.print("B").print(id()).print(" ");
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
106
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
107 // print flags
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
108 StringBuilder sb = new StringBuilder(8);
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
109 if (sb.length() != 0) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
110 out.print('(').print(sb.toString()).print(')');
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
111 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
112
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
113 // print block bci range
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
114 out.print('[').print(-1).print(", ").print(-1).print(']');
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
115
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
116 // print block successors
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
117 //if (end != null && end.blockSuccessors().size() > 0) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
118 out.print(" .");
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
119 for (Node successor : this.successors()) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
120 if (successor instanceof Value) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
121 out.print((Value) successor);
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
122 } else {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
123 out.print(successor.toString());
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
124 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
125 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
126 //}
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
127
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
128 // print predecessors
|
2805
c3f64b66fc78
Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
diff
changeset
|
129 // if (!blockPredecessors().isEmpty()) {
|
c3f64b66fc78
Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
diff
changeset
|
130 // out.print(" pred:");
|
c3f64b66fc78
Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
diff
changeset
|
131 // for (Instruction pred : blockPredecessors()) {
|
c3f64b66fc78
Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
diff
changeset
|
132 // out.print(pred.block());
|
c3f64b66fc78
Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
diff
changeset
|
133 // }
|
c3f64b66fc78
Towards removing the next pointer from Constant and ArithmeticOp
Thomas Wuerthinger <thomas@wuerthinger.net>
diff
changeset
|
134 // }
|
2795
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
135 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
136
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
137 @Override
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
138 public void print(LogStream out) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
139
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
140 printWithoutPhis(out);
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
141
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
142 // print phi functions
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
143 boolean hasPhisInLocals = false;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
144 boolean hasPhisOnStack = false;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
145
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
146 //if (end() != null && end().stateAfter() != null) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
147 FrameState state = stateBefore();
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
148
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
149 int i = 0;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
150 while (!hasPhisOnStack && i < state.stackSize()) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
151 Value value = state.stackAt(i);
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
152 hasPhisOnStack = isPhiAtBlock(value);
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
153 if (value != null && !value.isIllegal()) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
154 i += value.kind.sizeInSlots();
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
155 } else {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
156 i++;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
157 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
158 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
159
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
160 for (i = 0; !hasPhisInLocals && i < state.localsSize();) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
161 Value value = state.localAt(i);
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
162 hasPhisInLocals = isPhiAtBlock(value);
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
163 // also ignore illegal HiWords
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
164 if (value != null && !value.isIllegal()) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
165 i += value.kind.sizeInSlots();
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
166 } else {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
167 i++;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
168 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
169 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
170 //}
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
171
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
172 // print values in locals
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
173 if (hasPhisInLocals) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
174 out.println();
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
175 out.println("Locals:");
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
176
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
177 int j = 0;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
178 while (j < state.localsSize()) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
179 Value value = state.localAt(j);
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
180 if (value != null) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
181 out.println(stateString(j, value));
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
182 // also ignore illegal HiWords
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
183 j += value.isIllegal() ? 1 : value.kind.sizeInSlots();
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
184 } else {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
185 j++;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
186 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
187 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
188 out.println();
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
189 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
190
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
191 // print values on stack
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
192 if (hasPhisOnStack) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
193 out.println();
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
194 out.println("Stack:");
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
195 int j = 0;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
196 while (j < stateBefore().stackSize()) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
197 Value value = stateBefore().stackAt(j);
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
198 if (value != null) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
199 out.println(stateString(j, value));
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
200 j += value.kind.sizeInSlots();
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
201 } else {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
202 j++;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
203 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
204 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
205 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
206
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
207 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
208
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
209 /**
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
210 * Determines if a given instruction is a phi whose {@linkplain Phi#block() join block} is a given block.
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
211 *
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
212 * @param value the instruction to test
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
213 * @param block the block that may be the join block of {@code value} if {@code value} is a phi
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
214 * @return {@code true} if {@code value} is a phi and its join block is {@code block}
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
215 */
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
216 private boolean isPhiAtBlock(Value value) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
217 return value instanceof Phi && ((Phi) value).block() == this;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
218 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
219
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
220
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
221 /**
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
222 * Formats a given instruction as a value in a {@linkplain FrameState frame state}. If the instruction is a phi defined at a given
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
223 * block, its {@linkplain Phi#valueCount() inputs} are appended to the returned string.
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
224 *
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
225 * @param index the index of the value in the frame state
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
226 * @param value the frame state value
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
227 * @param block if {@code value} is a phi, then its inputs are formatted if {@code block} is its
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
228 * {@linkplain Phi#block() join point}
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
229 * @return the instruction representation as a string
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
230 */
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
231 public String stateString(int index, Value value) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
232 StringBuilder sb = new StringBuilder(30);
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
233 sb.append(String.format("%2d %s", index, Util.valueString(value)));
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
234 if (value instanceof Phi) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
235 Phi phi = (Phi) value;
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
236 // print phi operands
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
237 if (phi.block() == this) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
238 sb.append(" [");
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
239 for (int j = 0; j < phi.valueCount(); j++) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
240 sb.append(' ');
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
241 Value operand = phi.valueAt(j);
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
242 if (operand != null) {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
243 sb.append(Util.valueString(operand));
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
244 } else {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
245 sb.append("NULL");
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
246 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
247 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
248 sb.append("] ");
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
249 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
250 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
251 return sb.toString();
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
252 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
253
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
254 @Override
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
255 public String shortName() {
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
256 return "Merge #" + id();
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
257 }
|
Gilles Duboscq <gilles.duboscq@oracle.com>
parents:
diff
changeset
|
258 }
|