comparison graal/GraalCompiler/src/com/sun/c1x/value/FrameState.java @ 2565:cc1f1d396288

Remove inlining (3rd part)
author Gilles Duboscq <gilles.duboscq@oracle.com>
date Fri, 29 Apr 2011 16:46:30 +0200
parents 274360f98f97
children 46586c77b129
comparison
equal deleted inserted replaced
2564:274360f98f97 2565:cc1f1d396288
26 26
27 import com.sun.c1x.*; 27 import com.sun.c1x.*;
28 import com.sun.c1x.graph.*; 28 import com.sun.c1x.graph.*;
29 import com.sun.c1x.ir.*; 29 import com.sun.c1x.ir.*;
30 import com.sun.cri.ci.*; 30 import com.sun.cri.ci.*;
31 import com.sun.cri.ri.*;
32 31
33 /** 32 /**
34 * The {@code FrameState} class encapsulates the frame state (i.e. local variables and 33 * The {@code FrameState} class encapsulates the frame state (i.e. local variables and
35 * operand stack) at a particular point in the abstract interpretation. 34 * operand stack) at a particular point in the abstract interpretation.
36 * 35 *
60 /** 59 /**
61 * The number of local variables. 60 * The number of local variables.
62 */ 61 */
63 protected final int maxLocals; 62 protected final int maxLocals;
64 63
65 //XXX temporary while removing IRScope
66 @Deprecated
67 public final RiMethod method;
68
69 /** 64 /**
70 * The bytecode index to which this frame state applies. This will be {@code -1} 65 * The bytecode index to which this frame state applies. This will be {@code -1}
71 * iff this state is mutable. 66 * iff this state is mutable.
72 */ 67 */
73 public final int bci; 68 public final int bci;
92 * @param irScope the inlining context of the method 87 * @param irScope the inlining context of the method
93 * @param bci the bytecode index of the frame state 88 * @param bci the bytecode index of the frame state
94 * @param maxLocals maximum number of locals 89 * @param maxLocals maximum number of locals
95 * @param maxStack maximum size of the stack 90 * @param maxStack maximum size of the stack
96 */ 91 */
97 public FrameState(RiMethod method, int bci, int maxLocals, int maxStack) { 92 public FrameState(int bci, int maxLocals, int maxStack) {
98 this.method = method;
99 this.bci = bci; 93 this.bci = bci;
100 this.values = new Value[maxLocals + Math.max(maxStack, MINIMUM_STACK_SLOTS)]; 94 this.values = new Value[maxLocals + Math.max(maxStack, MINIMUM_STACK_SLOTS)];
101 this.maxLocals = maxLocals; 95 this.maxLocals = maxLocals;
102 C1XMetrics.FrameStatesCreated++; 96 C1XMetrics.FrameStatesCreated++;
103 C1XMetrics.FrameStateValuesCreated += this.values.length; 97 C1XMetrics.FrameStateValuesCreated += this.values.length;
111 * @param withLocks indicates whether to copy the lock state 105 * @param withLocks indicates whether to copy the lock state
112 * 106 *
113 * @return a new frame state with the specified components 107 * @return a new frame state with the specified components
114 */ 108 */
115 public MutableFrameState copy(int bci, boolean withLocals, boolean withStack, boolean withLocks) { 109 public MutableFrameState copy(int bci, boolean withLocals, boolean withStack, boolean withLocks) {
116 final MutableFrameState other = new MutableFrameState(method, bci, localsSize(), maxStackSize()); 110 final MutableFrameState other = new MutableFrameState(bci, localsSize(), maxStackSize());
117 if (withLocals && withStack) { 111 if (withLocals && withStack) {
118 // fast path: use array copy 112 // fast path: use array copy
119 int valuesSize = valuesSize(); 113 int valuesSize = valuesSize();
120 assert other.values.length >= valuesSize : "array size: " + other.values.length + ", valuesSize: " + valuesSize + ", maxStackSize: " + maxStackSize() + ", localsSize: " + localsSize(); 114 assert other.values.length >= valuesSize : "array size: " + other.values.length + ", valuesSize: " + valuesSize + ", maxStackSize: " + maxStackSize() + ", localsSize: " + localsSize();
121 assert values.length >= valuesSize : "array size: " + values.length + ", valuesSize: " + valuesSize + ", maxStackSize: " + maxStackSize() + ", localsSize: " + localsSize(); 115 assert values.length >= valuesSize : "array size: " + values.length + ", valuesSize: " + valuesSize + ", maxStackSize: " + maxStackSize() + ", localsSize: " + localsSize();
154 */ 148 */
155 public FrameState immutableCopyCodePosOnly() { 149 public FrameState immutableCopyCodePosOnly() {
156 return copy(bci, false, false, false); 150 return copy(bci, false, false, false);
157 } 151 }
158 152
159 public boolean isSameAcrossScopes(FrameState other) { 153 public boolean isSame(FrameState other) {
160 assert stackSize() == other.stackSize(); 154 assert stackSize() == other.stackSize();
161 assert localsSize() == other.localsSize(); 155 assert localsSize() == other.localsSize();
162 assert locksSize() == other.locksSize(); 156 assert locksSize() == other.locksSize();
163 for (int i = 0; i < stackIndex; i++) { 157 for (int i = 0; i < stackIndex; i++) {
164 Value x = stackAt(i); 158 Value x = stackAt(i);
189 /** 183 /**
190 * Gets number of locks held by this frame state. 184 * Gets number of locks held by this frame state.
191 */ 185 */
192 public int locksSize() { 186 public int locksSize() {
193 return locks == null ? 0 : locks.size(); 187 return locks == null ? 0 : locks.size();
194 }
195
196 @Deprecated
197 public int totalLocksSize() {
198 return locksSize();
199 } 188 }
200 189
201 /** 190 /**
202 * Gets the current size (height) of the stack. 191 * Gets the current size (height) of the stack.
203 */ 192 */
555 544
556 @Override 545 @Override
557 public String toString() { 546 public String toString() {
558 StringBuilder sb = new StringBuilder(); 547 StringBuilder sb = new StringBuilder();
559 String nl = String.format("%n"); 548 String nl = String.format("%n");
560 CiUtil.appendLocation(sb, this.method, this.bci).append(nl); 549 sb.append("[bci: ").append(this.bci).append("]").append(nl);
561 for (int i = 0; i < this.localsSize(); ++i) { 550 for (int i = 0; i < this.localsSize(); ++i) {
562 Value value = this.localAt(i); 551 Value value = this.localAt(i);
563 sb.append(String.format(" local[%d] = %-8s : %s%n", i, value == null ? "bogus" : value.kind.javaName, value)); 552 sb.append(String.format(" local[%d] = %-8s : %s%n", i, value == null ? "bogus" : value.kind.javaName, value));
564 } 553 }
565 for (int i = 0; i < this.stackSize(); ++i) { 554 for (int i = 0; i < this.stackSize(); ++i) {
570 Value value = this.lockAt(i); 559 Value value = this.lockAt(i);
571 sb.append(String.format(" lock[%d] = %-8s : %s%n", i, value == null ? "bogus" : value.kind.javaName, value)); 560 sb.append(String.format(" lock[%d] = %-8s : %s%n", i, value == null ? "bogus" : value.kind.javaName, value));
572 } 561 }
573 return sb.toString(); 562 return sb.toString();
574 } 563 }
575
576 public CiCodePos toCodePos() {
577 return new CiCodePos(null, method, bci);
578 }
579 } 564 }