comparison truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java @ 22491:a73f1d7a5a3e

document FrameDescriptor methods getVersion and getNotInFrameAssumption
author Andreas Woess <andreas.woess@oracle.com>
date Thu, 10 Dec 2015 18:18:32 +0100
parents fa86f9f3848d
children 67d312302970
comparison
equal deleted inserted replaced
22490:fa86f9f3848d 22491:a73f1d7a5a3e
88 } 88 }
89 89
90 /** 90 /**
91 * Adds frame slot. Delegates to 91 * Adds frame slot. Delegates to
92 * {@link #addFrameSlot(java.lang.Object, java.lang.Object, com.oracle.truffle.api.frame.FrameSlotKind) 92 * {@link #addFrameSlot(java.lang.Object, java.lang.Object, com.oracle.truffle.api.frame.FrameSlotKind)
93 * addFrameSlot}(identifier, <code>null</code>, {@link FrameSlotKind#Illegal}). This is slow 93 * addFrameSlot}(identifier, <code>null</code>, {@link FrameSlotKind#Illegal}). This is a slow
94 * operation that switches to interpreter mode. 94 * operation that switches to interpreter mode.
95 * 95 *
96 * @param identifier key for the slot 96 * @param identifier key for the slot
97 * @return the newly created slot 97 * @return the newly created slot
98 */ 98 */
101 } 101 }
102 102
103 /** 103 /**
104 * Adds frame slot. Delegates to 104 * Adds frame slot. Delegates to
105 * {@link #addFrameSlot(java.lang.Object, java.lang.Object, com.oracle.truffle.api.frame.FrameSlotKind) 105 * {@link #addFrameSlot(java.lang.Object, java.lang.Object, com.oracle.truffle.api.frame.FrameSlotKind)
106 * addFrameSlot}(identifier, <code>null</code>, <code>kind</code>). This is slow operation that 106 * addFrameSlot}(identifier, <code>null</code>, <code>kind</code>). This is a slow operation
107 * switches to interpreter mode. 107 * that switches to interpreter mode.
108 * 108 *
109 * @param identifier key for the slot 109 * @param identifier key for the slot
110 * @param kind the kind of the new slot 110 * @param kind the kind of the new slot
111 * @return the newly created slot 111 * @return the newly created slot
112 */ 112 */
113 public FrameSlot addFrameSlot(Object identifier, FrameSlotKind kind) { 113 public FrameSlot addFrameSlot(Object identifier, FrameSlotKind kind) {
114 return addFrameSlot(identifier, null, kind); 114 return addFrameSlot(identifier, null, kind);
115 } 115 }
116 116
117 /** 117 /**
118 * Adds new frame slot to {@link #getSlots()} list. This is slow operation that switches to 118 * Adds new frame slot to {@link #getSlots()} list. This is a slow operation that switches to
119 * interpreter mode. 119 * interpreter mode.
120 * 120 *
121 * @param identifier key for the slot - it needs proper {@link #equals(java.lang.Object)} and 121 * @param identifier key for the slot - it needs proper {@link #equals(java.lang.Object)} and
122 * {@link Object#hashCode()} implementations 122 * {@link Object#hashCode()} implementations
123 * @param info additional {@link FrameSlot#getInfo() information for the slot} 123 * @param info additional {@link FrameSlot#getInfo() information for the slot}
134 invalidateNotInFrameAssumption(identifier); 134 invalidateNotInFrameAssumption(identifier);
135 return slot; 135 return slot;
136 } 136 }
137 137
138 /** 138 /**
139 * Finds an existing slot. This is slow operation. 139 * Finds an existing slot. This is a slow operation.
140 * 140 *
141 * @param identifier the key of the slot to search for 141 * @param identifier the key of the slot to search for
142 * @return the slot or <code>null</code> 142 * @return the slot or <code>null</code>
143 */ 143 */
144 public FrameSlot findFrameSlot(Object identifier) { 144 public FrameSlot findFrameSlot(Object identifier) {
145 CompilerAsserts.neverPartOfCompilation("interpreter-only. includes hashmap operations."); 145 CompilerAsserts.neverPartOfCompilation("interpreter-only. includes hashmap operations.");
146 return identifierToSlotMap.get(identifier); 146 return identifierToSlotMap.get(identifier);
147 } 147 }
148 148
149 /** 149 /**
150 * Finds an existing slot or creates new one. This is slow operation. 150 * Finds an existing slot or creates new one. This is a slow operation.
151 * 151 *
152 * @param identifier the key of the slot to search for 152 * @param identifier the key of the slot to search for
153 * @return the slot 153 * @return the slot
154 */ 154 */
155 public FrameSlot findOrAddFrameSlot(Object identifier) { 155 public FrameSlot findOrAddFrameSlot(Object identifier) {
159 } 159 }
160 return addFrameSlot(identifier); 160 return addFrameSlot(identifier);
161 } 161 }
162 162
163 /** 163 /**
164 * Finds an existing slot or creates new one. This is slow operation. 164 * Finds an existing slot or creates new one. This is a slow operation.
165 * 165 *
166 * @param identifier the key of the slot to search for 166 * @param identifier the key of the slot to search for
167 * @param kind the kind for the newly created slot 167 * @param kind the kind for the newly created slot
168 * @return the found or newly created slot 168 * @return the found or newly created slot
169 */ 169 */
174 } 174 }
175 return addFrameSlot(identifier, kind); 175 return addFrameSlot(identifier, kind);
176 } 176 }
177 177
178 /** 178 /**
179 * Finds an existing slot or creates new one. This is slow operation. 179 * Finds an existing slot or creates new one. This is a slow operation.
180 * 180 *
181 * @param identifier the key of the slot to search for 181 * @param identifier the key of the slot to search for
182 * @param info info for the newly created slot 182 * @param info info for the newly created slot
183 * @param kind the kind for the newly created slot 183 * @param kind the kind for the newly created slot
184 * @return the found or newly created slot 184 * @return the found or newly created slot
191 return addFrameSlot(identifier, info, kind); 191 return addFrameSlot(identifier, info, kind);
192 } 192 }
193 193
194 /** 194 /**
195 * Removes a slot. If the identifier is found, its slot is removed from this descriptor. This is 195 * Removes a slot. If the identifier is found, its slot is removed from this descriptor. This is
196 * slow operation. 196 * a slow operation.
197 * 197 *
198 * @param identifier identifies the slot to remove 198 * @param identifier identifies the slot to remove
199 */ 199 */
200 public void removeFrameSlot(Object identifier) { 200 public void removeFrameSlot(Object identifier) {
201 CompilerAsserts.neverPartOfCompilation("interpreter-only. includes hashmap operations."); 201 CompilerAsserts.neverPartOfCompilation("interpreter-only. includes hashmap operations.");
261 clonedFrameDescriptor.slots.addAll(slots); 261 clonedFrameDescriptor.slots.addAll(slots);
262 clonedFrameDescriptor.identifierToSlotMap.putAll(identifierToSlotMap); 262 clonedFrameDescriptor.identifierToSlotMap.putAll(identifierToSlotMap);
263 return clonedFrameDescriptor; 263 return clonedFrameDescriptor;
264 } 264 }
265 265
266 /**
267 * Invalidates the current, and create a new version assumption.
268 */
266 void updateVersion() { 269 void updateVersion() {
267 version.invalidate(); 270 version.invalidate();
268 version = createVersion(); 271 version = createVersion();
269 } 272 }
270 273
274 /**
275 * Returns an assumption reflecting the frame's current version, which is updated every time a
276 * slot is added or removed, or an existing slot's kind is changed. This assumption is
277 * associated with compiled code that depends on the internal frame layout.
278 *
279 * @return an assumption invalidated when a slot is added or removed, or a slot kind changed.
280 */
271 public Assumption getVersion() { 281 public Assumption getVersion() {
272 return version; 282 return version;
273 } 283 }
274 284
275 private static Assumption createVersion() { 285 private static Assumption createVersion() {
283 */ 293 */
284 public Object getDefaultValue() { 294 public Object getDefaultValue() {
285 return defaultValue; 295 return defaultValue;
286 } 296 }
287 297
298 /**
299 * Make an assumption that no slot with the specified identifier is present in this frame
300 * descriptor. Invalidated when a frame slot with the identifier is added.
301 *
302 * @param identifier frame slot identifier
303 * @return an assumption that this frame descriptor does not contain a slot with the identifier
304 * @throws IllegalArgumentException if the frame descriptor contains a slot with the identifier
305 */
288 public Assumption getNotInFrameAssumption(Object identifier) { 306 public Assumption getNotInFrameAssumption(Object identifier) {
289 if (identifierToSlotMap.containsKey(identifier)) { 307 if (identifierToSlotMap.containsKey(identifier)) {
290 throw new IllegalArgumentException("Cannot get not-in-frame assumption for existing frame slot!"); 308 throw new IllegalArgumentException("Cannot get not-in-frame assumption for existing frame slot!");
291 } 309 }
292 310