Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/SpecializationNode.java @ 18776:c0fb70634640
Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 05 Jan 2015 01:31:08 +0100 |
parents | a720bf2e2f43 |
children | 71e372cae32e |
comparison
equal
deleted
inserted
replaced
18775:a069a87b9a02 | 18776:c0fb70634640 |
---|---|
173 current = current.next; | 173 current = current.next; |
174 } | 174 } |
175 return start; | 175 return start; |
176 } | 176 } |
177 | 177 |
178 public Object acceptAndExecute(VirtualFrame frame) { | 178 public Object acceptAndExecute(Frame frame) { |
179 throw new UnsupportedOperationException(); | 179 throw new UnsupportedOperationException(); |
180 } | 180 } |
181 | 181 |
182 public Object acceptAndExecute(VirtualFrame frame, Object o1) { | 182 public Object acceptAndExecute(Frame frame, Object o1) { |
183 throw new UnsupportedOperationException(); | 183 throw new UnsupportedOperationException(); |
184 } | 184 } |
185 | 185 |
186 public Object acceptAndExecute(VirtualFrame frame, Object o1, Object o2) { | 186 public Object acceptAndExecute(Frame frame, Object o1, Object o2) { |
187 throw new UnsupportedOperationException(); | 187 throw new UnsupportedOperationException(); |
188 } | 188 } |
189 | 189 |
190 public Object acceptAndExecute(VirtualFrame frame, Object o1, Object o2, Object o3) { | 190 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3) { |
191 throw new UnsupportedOperationException(); | 191 throw new UnsupportedOperationException(); |
192 } | 192 } |
193 | 193 |
194 public Object acceptAndExecute(VirtualFrame frame, Object o1, Object o2, Object o3, Object o4) { | 194 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3, Object o4) { |
195 throw new UnsupportedOperationException(); | 195 throw new UnsupportedOperationException(); |
196 } | 196 } |
197 | 197 |
198 public Object acceptAndExecute(VirtualFrame frame, Object... args) { | 198 public Object acceptAndExecute(Frame frame, Object... args) { |
199 throw new UnsupportedOperationException(); | 199 throw new UnsupportedOperationException(); |
200 } | 200 } |
201 | 201 |
202 protected SpecializationNode createFallback() { | 202 protected SpecializationNode createFallback() { |
203 return null; | 203 return null; |
205 | 205 |
206 protected SpecializationNode createPolymorphic() { | 206 protected SpecializationNode createPolymorphic() { |
207 return null; | 207 return null; |
208 } | 208 } |
209 | 209 |
210 protected SpecializationNode createNext(VirtualFrame frame) { | 210 protected SpecializationNode createNext(Frame frame) { |
211 throw new UnsupportedOperationException(); | 211 throw new UnsupportedOperationException(); |
212 } | 212 } |
213 | 213 |
214 protected SpecializationNode createNext(VirtualFrame frame, Object o1) { | 214 protected SpecializationNode createNext(Frame frame, Object o1) { |
215 throw new UnsupportedOperationException(); | 215 throw new UnsupportedOperationException(); |
216 } | 216 } |
217 | 217 |
218 protected SpecializationNode createNext(VirtualFrame frame, Object o1, Object o2) { | 218 protected SpecializationNode createNext(Frame frame, Object o1, Object o2) { |
219 throw new UnsupportedOperationException(); | 219 throw new UnsupportedOperationException(); |
220 } | 220 } |
221 | 221 |
222 protected SpecializationNode createNext(VirtualFrame frame, Object o1, Object o2, Object o3) { | 222 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3) { |
223 throw new UnsupportedOperationException(); | 223 throw new UnsupportedOperationException(); |
224 } | 224 } |
225 | 225 |
226 protected SpecializationNode createNext(VirtualFrame frame, Object o1, Object o2, Object o3, Object o4) { | 226 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3, Object o4) { |
227 throw new UnsupportedOperationException(); | 227 throw new UnsupportedOperationException(); |
228 } | 228 } |
229 | 229 |
230 protected SpecializationNode createNext(VirtualFrame frame, Object... args) { | 230 protected SpecializationNode createNext(Frame frame, Object... args) { |
231 throw new UnsupportedOperationException(); | 231 throw new UnsupportedOperationException(); |
232 } | 232 } |
233 | 233 |
234 protected final Object uninitialized(VirtualFrame frame) { | 234 protected final Object uninitialized(Frame frame) { |
235 CompilerDirectives.transferToInterpreterAndInvalidate(); | 235 CompilerDirectives.transferToInterpreterAndInvalidate(); |
236 SpecializationNode nextSpecialization = createNext(frame); | 236 SpecializationNode nextSpecialization = createNext(frame); |
237 if (nextSpecialization == null) { | 237 if (nextSpecialization == null) { |
238 nextSpecialization = createFallback(); | 238 nextSpecialization = createFallback(); |
239 } | 239 } |
241 return unsupported(frame); | 241 return unsupported(frame); |
242 } | 242 } |
243 return insertSpecialization(nextSpecialization, new RewriteEvent0(findParentNode(), "inserted new specialization")).acceptAndExecute(frame); | 243 return insertSpecialization(nextSpecialization, new RewriteEvent0(findParentNode(), "inserted new specialization")).acceptAndExecute(frame); |
244 } | 244 } |
245 | 245 |
246 protected final Object uninitialized(VirtualFrame frame, Object o1) { | 246 protected final Object uninitialized(Frame frame, Object o1) { |
247 CompilerDirectives.transferToInterpreterAndInvalidate(); | 247 CompilerDirectives.transferToInterpreterAndInvalidate(); |
248 SpecializationNode nextSpecialization = createNext(frame, o1); | 248 SpecializationNode nextSpecialization = createNext(frame, o1); |
249 if (nextSpecialization == null) { | 249 if (nextSpecialization == null) { |
250 nextSpecialization = createFallback(); | 250 nextSpecialization = createFallback(); |
251 } | 251 } |
253 return unsupported(frame, o1); | 253 return unsupported(frame, o1); |
254 } | 254 } |
255 return insertSpecialization(nextSpecialization, new RewriteEvent1(findParentNode(), "inserted new specialization", o1)).acceptAndExecute(frame, o1); | 255 return insertSpecialization(nextSpecialization, new RewriteEvent1(findParentNode(), "inserted new specialization", o1)).acceptAndExecute(frame, o1); |
256 } | 256 } |
257 | 257 |
258 protected final Object uninitialized(VirtualFrame frame, Object o1, Object o2) { | 258 protected final Object uninitialized(Frame frame, Object o1, Object o2) { |
259 CompilerDirectives.transferToInterpreterAndInvalidate(); | 259 CompilerDirectives.transferToInterpreterAndInvalidate(); |
260 SpecializationNode nextSpecialization = createNext(frame, o1, o2); | 260 SpecializationNode nextSpecialization = createNext(frame, o1, o2); |
261 if (nextSpecialization == null) { | 261 if (nextSpecialization == null) { |
262 nextSpecialization = createFallback(); | 262 nextSpecialization = createFallback(); |
263 } | 263 } |
265 return unsupported(frame, o1, o2); | 265 return unsupported(frame, o1, o2); |
266 } | 266 } |
267 return insertSpecialization(nextSpecialization, new RewriteEvent2(findParentNode(), "inserted new specialization", o1, o2)).acceptAndExecute(frame, o1, o2); | 267 return insertSpecialization(nextSpecialization, new RewriteEvent2(findParentNode(), "inserted new specialization", o1, o2)).acceptAndExecute(frame, o1, o2); |
268 } | 268 } |
269 | 269 |
270 protected final Object uninitialized(VirtualFrame frame, Object o1, Object o2, Object o3) { | 270 protected final Object uninitialized(Frame frame, Object o1, Object o2, Object o3) { |
271 CompilerDirectives.transferToInterpreterAndInvalidate(); | 271 CompilerDirectives.transferToInterpreterAndInvalidate(); |
272 SpecializationNode nextSpecialization = createNext(frame, o1, o2, o3); | 272 SpecializationNode nextSpecialization = createNext(frame, o1, o2, o3); |
273 if (nextSpecialization == null) { | 273 if (nextSpecialization == null) { |
274 nextSpecialization = createFallback(); | 274 nextSpecialization = createFallback(); |
275 } | 275 } |
277 return unsupported(frame, o1, o2, o3); | 277 return unsupported(frame, o1, o2, o3); |
278 } | 278 } |
279 return insertSpecialization(nextSpecialization, new RewriteEvent3(findParentNode(), "inserted new specialization", o1, o2, o3)).acceptAndExecute(frame, o1, o2, o3); | 279 return insertSpecialization(nextSpecialization, new RewriteEvent3(findParentNode(), "inserted new specialization", o1, o2, o3)).acceptAndExecute(frame, o1, o2, o3); |
280 } | 280 } |
281 | 281 |
282 protected final Object uninitialized(VirtualFrame frame, Object o1, Object o2, Object o3, Object o4) { | 282 protected final Object uninitialized(Frame frame, Object o1, Object o2, Object o3, Object o4) { |
283 CompilerDirectives.transferToInterpreterAndInvalidate(); | 283 CompilerDirectives.transferToInterpreterAndInvalidate(); |
284 SpecializationNode nextSpecialization = createNext(frame, o1, o2, o3, o4); | 284 SpecializationNode nextSpecialization = createNext(frame, o1, o2, o3, o4); |
285 if (nextSpecialization == null) { | 285 if (nextSpecialization == null) { |
286 nextSpecialization = createFallback(); | 286 nextSpecialization = createFallback(); |
287 } | 287 } |
289 return unsupported(frame, o1, o2, o3, o4); | 289 return unsupported(frame, o1, o2, o3, o4); |
290 } | 290 } |
291 return insertSpecialization(nextSpecialization, new RewriteEvent4(findParentNode(), "inserts new specialization", o1, o2, o3, o4)).acceptAndExecute(frame, o1, o2, o3, o4); | 291 return insertSpecialization(nextSpecialization, new RewriteEvent4(findParentNode(), "inserts new specialization", o1, o2, o3, o4)).acceptAndExecute(frame, o1, o2, o3, o4); |
292 } | 292 } |
293 | 293 |
294 protected final Object uninitialized(VirtualFrame frame, Object... args) { | 294 protected final Object uninitialized(Frame frame, Object... args) { |
295 CompilerDirectives.transferToInterpreterAndInvalidate(); | 295 CompilerDirectives.transferToInterpreterAndInvalidate(); |
296 SpecializationNode nextSpecialization = createNext(frame, args); | 296 SpecializationNode nextSpecialization = createNext(frame, args); |
297 if (nextSpecialization == null) { | 297 if (nextSpecialization == null) { |
298 nextSpecialization = createFallback(); | 298 nextSpecialization = createFallback(); |
299 } | 299 } |
305 | 305 |
306 private boolean needsPolymorphic() { | 306 private boolean needsPolymorphic() { |
307 return findStart().count() == 2; | 307 return findStart().count() == 2; |
308 } | 308 } |
309 | 309 |
310 protected final Object remove(String reason, VirtualFrame frame) { | 310 protected final Object remove(String reason, Frame frame) { |
311 return removeSame(new RewriteEvent0(findParentNode(), reason)).acceptAndExecute(frame); | 311 return removeSame(new RewriteEvent0(findParentNode(), reason)).acceptAndExecute(frame); |
312 } | 312 } |
313 | 313 |
314 protected final Object remove(String reason, VirtualFrame frame, Object o1) { | 314 protected final Object remove(String reason, Frame frame, Object o1) { |
315 return removeSame(new RewriteEvent1(findParentNode(), reason, o1)).acceptAndExecute(frame, o1); | 315 return removeSame(new RewriteEvent1(findParentNode(), reason, o1)).acceptAndExecute(frame, o1); |
316 } | 316 } |
317 | 317 |
318 protected final Object remove(String reason, VirtualFrame frame, Object o1, Object o2) { | 318 protected final Object remove(String reason, Frame frame, Object o1, Object o2) { |
319 return removeSame(new RewriteEvent2(findParentNode(), reason, o1, o2)).acceptAndExecute(frame, o1, o2); | 319 return removeSame(new RewriteEvent2(findParentNode(), reason, o1, o2)).acceptAndExecute(frame, o1, o2); |
320 } | 320 } |
321 | 321 |
322 protected final Object remove(String reason, VirtualFrame frame, Object o1, Object o2, Object o3) { | 322 protected final Object remove(String reason, Frame frame, Object o1, Object o2, Object o3) { |
323 return removeSame(new RewriteEvent3(findParentNode(), reason, o1, o2, o3)).acceptAndExecute(frame, o1, o2, o3); | 323 return removeSame(new RewriteEvent3(findParentNode(), reason, o1, o2, o3)).acceptAndExecute(frame, o1, o2, o3); |
324 } | 324 } |
325 | 325 |
326 protected final Object remove(String reason, VirtualFrame frame, Object o1, Object o2, Object o3, Object o4) { | 326 protected final Object remove(String reason, Frame frame, Object o1, Object o2, Object o3, Object o4) { |
327 return removeSame(new RewriteEvent4(findParentNode(), reason, o1, o2, o3, o4)).acceptAndExecute(frame, o1, o2, o3, o4); | 327 return removeSame(new RewriteEvent4(findParentNode(), reason, o1, o2, o3, o4)).acceptAndExecute(frame, o1, o2, o3, o4); |
328 } | 328 } |
329 | 329 |
330 protected final Object remove(String reason, VirtualFrame frame, Object... args) { | 330 protected final Object remove(String reason, Frame frame, Object... args) { |
331 return removeSame(new RewriteEventN(findParentNode(), reason, args)).acceptAndExecute(frame, args); | 331 return removeSame(new RewriteEventN(findParentNode(), reason, args)).acceptAndExecute(frame, args); |
332 } | 332 } |
333 | 333 |
334 protected Object unsupported(VirtualFrame frame) { | 334 protected Object unsupported(Frame frame) { |
335 throw new UnsupportedSpecializationException(findParentNode(), getSuppliedChildren()); | 335 throw new UnsupportedSpecializationException(findParentNode(), getSuppliedChildren()); |
336 } | 336 } |
337 | 337 |
338 protected Object unsupported(VirtualFrame frame, Object o1) { | 338 protected Object unsupported(Frame frame, Object o1) { |
339 throw new UnsupportedSpecializationException(findParentNode(), getSuppliedChildren(), o1); | 339 throw new UnsupportedSpecializationException(findParentNode(), getSuppliedChildren(), o1); |
340 } | 340 } |
341 | 341 |
342 protected Object unsupported(VirtualFrame frame, Object o1, Object o2) { | 342 protected Object unsupported(Frame frame, Object o1, Object o2) { |
343 throw new UnsupportedSpecializationException(findParentNode(), getSuppliedChildren(), o1, o2); | 343 throw new UnsupportedSpecializationException(findParentNode(), getSuppliedChildren(), o1, o2); |
344 } | 344 } |
345 | 345 |
346 protected Object unsupported(VirtualFrame frame, Object o1, Object o2, Object o3) { | 346 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3) { |
347 throw new UnsupportedSpecializationException(findParentNode(), getSuppliedChildren(), o1, o2, o3); | 347 throw new UnsupportedSpecializationException(findParentNode(), getSuppliedChildren(), o1, o2, o3); |
348 } | 348 } |
349 | 349 |
350 protected Object unsupported(VirtualFrame frame, Object o1, Object o2, Object o3, Object o4) { | 350 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3, Object o4) { |
351 throw new UnsupportedSpecializationException(findParentNode(), getSuppliedChildren(), o1, o2, o3, o4); | 351 throw new UnsupportedSpecializationException(findParentNode(), getSuppliedChildren(), o1, o2, o3, o4); |
352 } | 352 } |
353 | 353 |
354 protected Object unsupported(VirtualFrame frame, Object... args) { | 354 protected Object unsupported(Frame frame, Object... args) { |
355 throw new UnsupportedSpecializationException(findParentNode(), getSuppliedChildren(), args); | 355 throw new UnsupportedSpecializationException(findParentNode(), getSuppliedChildren(), args); |
356 } | 356 } |
357 | 357 |
358 private SpecializationNode insertSpecialization(final SpecializationNode generated, final CharSequence message) { | 358 private SpecializationNode insertSpecialization(final SpecializationNode generated, final CharSequence message) { |
359 return atomic(new Callable<SpecializationNode>() { | 359 return atomic(new Callable<SpecializationNode>() { |