comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java @ 9278:8cf939b349dd

Frame API: automatically change frame slot type for uninitialized slots
author Andreas Woess <andreas.woess@jku.at>
date Wed, 24 Apr 2013 14:14:22 +0200
parents 07f8d136a05e
children cd1a1d92b3e3
comparison
equal deleted inserted replaced
9277:1fcaf6edc69d 9278:8cf939b349dd
154 return locals[index]; 154 return locals[index];
155 } 155 }
156 } 156 }
157 157
158 private void verifySet(FrameSlot slot, Class accessType) throws FrameSlotTypeException { 158 private void verifySet(FrameSlot slot, Class accessType) throws FrameSlotTypeException {
159 if (slot.getType() != accessType) { 159 Class<?> slotType = slot.getType();
160 throw new FrameSlotTypeException(); 160 if (slotType != accessType) {
161 if (slotType == null) {
162 slot.setType(accessType);
163 } else {
164 throw new FrameSlotTypeException();
165 }
161 } 166 }
162 int slotIndex = slot.getIndex(); 167 int slotIndex = slot.getIndex();
163 if (slotIndex >= tags.length) { 168 if (slotIndex >= tags.length) {
164 resize(); 169 resize();
165 } 170 }
166 tags[slotIndex] = accessType; 171 tags[slotIndex] = accessType;
167 } 172 }
168 173
169 private void verifyGet(FrameSlot slot, Class accessType) throws FrameSlotTypeException { 174 private void verifyGet(FrameSlot slot, Class accessType) throws FrameSlotTypeException {
170 Class<?> slotType = slot.getType(); 175 Class<?> slotType = slot.getType();
171 int slotIndex = slot.getIndex();
172 if (slotType != accessType) { 176 if (slotType != accessType) {
173 if (slotType == null) { 177 if (slotType == null && accessType == Object.class) {
174 slot.setType(Object.class); 178 slot.setType(Object.class);
175 this.setObject(slot, descriptor.getTypeConversion().getDefaultValue()); 179 this.setObject(slot, descriptor.getTypeConversion().getDefaultValue());
176 if (accessType != Object.class) {
177 throw new FrameSlotTypeException();
178 }
179 } else { 180 } else {
180 throw new FrameSlotTypeException(); 181 throw new FrameSlotTypeException();
181 } 182 }
182 } 183 }
184 int slotIndex = slot.getIndex();
183 if (slotIndex >= tags.length) { 185 if (slotIndex >= tags.length) {
184 resize(); 186 resize();
185 } 187 }
186 Class tag = tags[slotIndex]; 188 if (tags[slotIndex] != accessType) {
187 if (tag != slotType) {
188 descriptor.getTypeConversion().updateFrameSlot(this, slot, getValue(slot)); 189 descriptor.getTypeConversion().updateFrameSlot(this, slot, getValue(slot));
189 if (tags[slotIndex] != slotType) { 190 if (tags[slotIndex] != accessType) {
190 throw new FrameSlotTypeException(); 191 throw new FrameSlotTypeException();
191 } 192 }
192 } 193 }
193 } 194 }
194 195