Mercurial > hg > graal-compiler
comparison graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/StackSlot.java @ 7530:5e3d1a68664e
applied mx eclipseformat to all Java files
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 23 Jan 2013 16:34:57 +0100 |
parents | 2463eb24b644 |
children | 4e1278443941 |
comparison
equal
deleted
inserted
replaced
7529:4a11124a3563 | 7530:5e3d1a68664e |
---|---|
25 import static com.oracle.graal.api.meta.Kind.*; | 25 import static com.oracle.graal.api.meta.Kind.*; |
26 | 26 |
27 import com.oracle.graal.api.meta.*; | 27 import com.oracle.graal.api.meta.*; |
28 | 28 |
29 /** | 29 /** |
30 * Represents a compiler spill slot or an outgoing stack-based argument in a method's frame | 30 * Represents a compiler spill slot or an outgoing stack-based argument in a method's frame or an |
31 * or an incoming stack-based argument in a method's {@linkplain #isInCallerFrame() caller's frame}. | 31 * incoming stack-based argument in a method's {@linkplain #isInCallerFrame() caller's frame}. |
32 */ | 32 */ |
33 public final class StackSlot extends Value { | 33 public final class StackSlot extends Value { |
34 | |
34 private static final long serialVersionUID = -7725071921307318433L; | 35 private static final long serialVersionUID = -7725071921307318433L; |
35 | 36 |
36 private final int offset; | 37 private final int offset; |
37 private final boolean addFrameSize; | 38 private final boolean addFrameSize; |
38 | 39 |
39 /** | 40 /** |
40 * Gets a {@link StackSlot} instance representing a stack slot at a given index | 41 * Gets a {@link StackSlot} instance representing a stack slot at a given index holding a value |
41 * holding a value of a given kind. | 42 * of a given kind. |
42 * | 43 * |
43 * @param kind The kind of the value stored in the stack slot. | 44 * @param kind The kind of the value stored in the stack slot. |
44 * @param offset The offset of the stack slot (in bytes) | 45 * @param offset The offset of the stack slot (in bytes) |
45 * @param addFrameSize Specifies if the offset is relative to the stack pointer, | 46 * @param addFrameSize Specifies if the offset is relative to the stack pointer, or the |
46 * or the beginning of the frame (stack pointer + total frame size). | 47 * beginning of the frame (stack pointer + total frame size). |
47 */ | 48 */ |
48 public static StackSlot get(Kind kind, int offset, boolean addFrameSize) { | 49 public static StackSlot get(Kind kind, int offset, boolean addFrameSize) { |
49 assert kind.getStackKind() == kind; | 50 assert kind.getStackKind() == kind; |
50 assert addFrameSize || offset >= 0; | 51 assert addFrameSize || offset >= 0; |
51 | 52 |
69 } | 70 } |
70 return new StackSlot(kind, offset, addFrameSize); | 71 return new StackSlot(kind, offset, addFrameSize); |
71 } | 72 } |
72 | 73 |
73 /** | 74 /** |
74 * Private constructor to enforce use of {@link #get(Kind, int, boolean)} so that a cache can be used. | 75 * Private constructor to enforce use of {@link #get(Kind, int, boolean)} so that a cache can be |
76 * used. | |
75 */ | 77 */ |
76 private StackSlot(Kind kind, int offset, boolean addFrameSize) { | 78 private StackSlot(Kind kind, int offset, boolean addFrameSize) { |
77 super(kind); | 79 super(kind); |
78 this.offset = offset; | 80 this.offset = offset; |
79 this.addFrameSize = addFrameSize; | 81 this.addFrameSize = addFrameSize; |
80 } | 82 } |
81 | 83 |
82 /** | 84 /** |
83 * Gets the offset of this stack slot, relative to the stack pointer. | 85 * Gets the offset of this stack slot, relative to the stack pointer. |
86 * | |
84 * @return The offset of this slot (in bytes). | 87 * @return The offset of this slot (in bytes). |
85 */ | 88 */ |
86 public int getOffset(int totalFrameSize) { | 89 public int getOffset(int totalFrameSize) { |
87 assert totalFrameSize > 0 || !addFrameSize; | 90 assert totalFrameSize > 0 || !addFrameSize; |
88 int result = offset + (addFrameSize ? totalFrameSize : 0); | 91 int result = offset + (addFrameSize ? totalFrameSize : 0); |
150 return get(getKind(), offset, true); | 153 return get(getKind(), offset, true); |
151 } | 154 } |
152 return this; | 155 return this; |
153 } | 156 } |
154 | 157 |
155 | |
156 private static final int CACHE_GRANULARITY = 8; | 158 private static final int CACHE_GRANULARITY = 8; |
157 private static final int SPILL_CACHE_PER_KIND_SIZE = 100; | 159 private static final int SPILL_CACHE_PER_KIND_SIZE = 100; |
158 private static final int PARAM_CACHE_PER_KIND_SIZE = 10; | 160 private static final int PARAM_CACHE_PER_KIND_SIZE = 10; |
159 | 161 |
160 private static final StackSlot[][] SPILL_CACHE = makeCache(SPILL_CACHE_PER_KIND_SIZE, -1, true); | 162 private static final StackSlot[][] SPILL_CACHE = makeCache(SPILL_CACHE_PER_KIND_SIZE, -1, true); |
161 private static final StackSlot[][] IN_CACHE = makeCache(PARAM_CACHE_PER_KIND_SIZE, 1, true); | 163 private static final StackSlot[][] IN_CACHE = makeCache(PARAM_CACHE_PER_KIND_SIZE, 1, true); |
162 private static final StackSlot[][] OUT_CACHE = makeCache(PARAM_CACHE_PER_KIND_SIZE, 1, false); | 164 private static final StackSlot[][] OUT_CACHE = makeCache(PARAM_CACHE_PER_KIND_SIZE, 1, false); |
163 | 165 |
164 private static StackSlot[][] makeCache(int cachePerKindSize, int sign, boolean addFrameSize) { | 166 private static StackSlot[][] makeCache(int cachePerKindSize, int sign, boolean addFrameSize) { |
165 StackSlot[][] cache = new StackSlot[Kind.values().length][]; | 167 StackSlot[][] cache = new StackSlot[Kind.values().length][]; |
166 for (Kind kind : new Kind[] {Illegal, Int, Long, Float, Double, Object, Jsr}) { | 168 for (Kind kind : new Kind[]{Illegal, Int, Long, Float, Double, Object, Jsr}) { |
167 StackSlot[] slots = new StackSlot[cachePerKindSize]; | 169 StackSlot[] slots = new StackSlot[cachePerKindSize]; |
168 for (int i = 0; i < cachePerKindSize; i++) { | 170 for (int i = 0; i < cachePerKindSize; i++) { |
169 slots[i] = new StackSlot(kind, sign * i * CACHE_GRANULARITY, addFrameSize); | 171 slots[i] = new StackSlot(kind, sign * i * CACHE_GRANULARITY, addFrameSize); |
170 } | 172 } |
171 cache[kind.ordinal()] = slots; | 173 cache[kind.ordinal()] = slots; |