Mercurial > hg > graal-jvmci-8
comparison graal/GraalCompiler/src/com/sun/c1x/value/MutableFrameState.java @ 2610:39aa89baa165
cleanup: FrameState copy methods, ImmutableFrameState
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Fri, 06 May 2011 13:03:33 +0200 |
parents | cc1f1d396288 |
children |
comparison
equal
deleted
inserted
replaced
2603:01c5c0443158 | 2610:39aa89baa165 |
---|---|
37 * {@link FrameState}s must not be cast to {@code MutableFrameState}s. Instead, a new copy must be created using | 37 * {@link FrameState}s must not be cast to {@code MutableFrameState}s. Instead, a new copy must be created using |
38 * {@link FrameState#copy()}. | 38 * {@link FrameState#copy()}. |
39 * Contrariwise and as an optimization, an instance referenced as {@code MutableFrameState} can be assigned to | 39 * Contrariwise and as an optimization, an instance referenced as {@code MutableFrameState} can be assigned to |
40 * a variable, field, or method parameter of type {@link FrameState} without creating an immutable copy before | 40 * a variable, field, or method parameter of type {@link FrameState} without creating an immutable copy before |
41 * (using {@link #immutableCopy(int)}) if the state is not mutated after the assignment. | 41 * (using {@link #immutableCopy(int)}) if the state is not mutated after the assignment. |
42 * | |
43 * @author Michael Duller | |
44 */ | 42 */ |
45 public final class MutableFrameState extends FrameState { | 43 public final class MutableFrameState extends FrameState { |
46 | 44 |
47 public MutableFrameState(int bci, int maxLocals, int maxStack) { | 45 public MutableFrameState(int bci, int maxLocals, int maxStack) { |
48 super(bci, maxLocals, maxStack); | 46 super(bci, maxLocals, maxStack); |
49 } | |
50 | |
51 /** | |
52 * Replace the local variables in this frame state with the local variables from the specified frame state. This is | |
53 * used in inlining. | |
54 * | |
55 * @param with the frame state containing the new local variables | |
56 */ | |
57 public void replaceLocals(FrameState with) { | |
58 assert with.maxLocals == maxLocals; | |
59 System.arraycopy(with.values, 0, values, 0, maxLocals); | |
60 } | |
61 | |
62 /** | |
63 * Replace the stack in this frame state with the stack from the specified frame state. This is used in inlining. | |
64 * | |
65 * @param with the frame state containing the new local variables | |
66 */ | |
67 public void replaceStack(FrameState with) { | |
68 System.arraycopy(with.values, with.maxLocals, values, maxLocals, with.stackIndex); | |
69 stackIndex = with.stackIndex; | |
70 assert stackIndex >= 0; | |
71 } | |
72 | |
73 /** | |
74 * Replace the locks in this frame state with the locks from the specified frame state. This is used in inlining. | |
75 * | |
76 * @param with the frame state containing the new local variables | |
77 */ | |
78 public void replaceLocks(FrameState with) { | |
79 if (with.locks == null) { | |
80 locks = null; | |
81 } else { | |
82 locks = Util.uncheckedCast(with.locks.clone()); | |
83 } | |
84 } | 47 } |
85 | 48 |
86 /** | 49 /** |
87 * Clears all values on this stack. | 50 * Clears all values on this stack. |
88 */ | 51 */ |
347 /** | 310 /** |
348 * Gets an immutable copy of this state. | 311 * Gets an immutable copy of this state. |
349 * @param bci the bytecode index of the new frame state | 312 * @param bci the bytecode index of the new frame state |
350 */ | 313 */ |
351 public FrameState immutableCopy(int bci) { | 314 public FrameState immutableCopy(int bci) { |
352 return copy(bci, true, true, true); | 315 return immutableCopy(bci, true, true, true); |
353 } | 316 } |
354 | 317 |
355 private static void assertHigh(Value x) { | 318 private static void assertHigh(Value x) { |
356 assert x == null; | 319 assert x == null; |
357 } | 320 } |