Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/SpecializationNode.java @ 22509:53d05fc21834
SpecializationNode cleanup
author | Andreas Woess <andreas.woess@oracle.com> |
---|---|
date | Thu, 17 Dec 2015 16:37:45 +0100 |
parents | a619835e6709 |
children | 6fe6d2cb7cc1 |
comparison
equal
deleted
inserted
replaced
22508:a619835e6709 | 22509:53d05fc21834 |
---|---|
50 | 50 |
51 /** | 51 /** |
52 * Internal implementation dependent base class for generated specialized nodes. | 52 * Internal implementation dependent base class for generated specialized nodes. |
53 */ | 53 */ |
54 @NodeInfo(cost = NodeCost.NONE) | 54 @NodeInfo(cost = NodeCost.NONE) |
55 @SuppressWarnings("unused") | |
56 public abstract class SpecializationNode extends Node { | 55 public abstract class SpecializationNode extends Node { |
57 | 56 |
58 @Child protected SpecializationNode next; | 57 @Child protected SpecializationNode next; |
59 | 58 |
60 private final int index; | 59 private final int index; |
162 | 161 |
163 protected boolean isSame(SpecializationNode other) { | 162 protected boolean isSame(SpecializationNode other) { |
164 return getClass() == other.getClass(); | 163 return getClass() == other.getClass(); |
165 } | 164 } |
166 | 165 |
166 @SuppressWarnings("unused") | |
167 protected boolean isIdentical(SpecializationNode newNode, Frame frame) { | 167 protected boolean isIdentical(SpecializationNode newNode, Frame frame) { |
168 return isSame(newNode); | 168 return isSame(newNode); |
169 } | 169 } |
170 | 170 |
171 @SuppressWarnings("unused") | |
171 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1) { | 172 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1) { |
172 return isSame(newNode); | 173 return isSame(newNode); |
173 } | 174 } |
174 | 175 |
176 @SuppressWarnings("unused") | |
175 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1, Object o2) { | 177 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1, Object o2) { |
176 return isSame(newNode); | 178 return isSame(newNode); |
177 } | 179 } |
178 | 180 |
181 @SuppressWarnings("unused") | |
179 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1, Object o2, Object o3) { | 182 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1, Object o2, Object o3) { |
180 return isSame(newNode); | 183 return isSame(newNode); |
181 } | 184 } |
182 | 185 |
186 @SuppressWarnings("unused") | |
183 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1, Object o2, Object o3, Object o4) { | 187 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1, Object o2, Object o3, Object o4) { |
184 return isSame(newNode); | 188 return isSame(newNode); |
185 } | 189 } |
186 | 190 |
191 @SuppressWarnings("unused") | |
187 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) { | 192 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) { |
188 return isSame(newNode); | 193 return isSame(newNode); |
189 } | 194 } |
190 | 195 |
196 @SuppressWarnings("unused") | |
191 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object... args) { | 197 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object... args) { |
192 return isSame(newNode); | 198 return isSame(newNode); |
193 } | 199 } |
194 | 200 |
195 protected final int countSame(SpecializationNode node) { | 201 protected final int countSame(SpecializationNode node) { |
261 this.replace(this.next, reason); | 267 this.replace(this.next, reason); |
262 return findEnd().findStart(); | 268 return findEnd().findStart(); |
263 } | 269 } |
264 | 270 |
265 protected final SpecializationNode removeSame(final CharSequence reason) { | 271 protected final SpecializationNode removeSame(final CharSequence reason) { |
266 SpecializationNode start = SpecializationNode.this.findStart(); | 272 return removeSameImpl(SpecializationNode.this, reason); |
267 SpecializationNode current = start; | |
268 while (current != null) { | |
269 if (current.isSame(SpecializationNode.this)) { | |
270 NodeUtil.nonAtomicReplace(current, current.next, reason); | |
271 if (current == start) { | |
272 start = start.next; | |
273 } | |
274 } | |
275 current = current.next; | |
276 } | |
277 return SpecializationNode.this.findEnd().findStart(); | |
278 } | 273 } |
279 | 274 |
280 /** Find the topmost of the specialization chain. */ | 275 /** Find the topmost of the specialization chain. */ |
281 private SpecializationNode findStart() { | 276 private SpecializationNode findStart() { |
282 SpecializationNode node = this; | 277 SpecializationNode node = this; |
292 return node; | 287 return node; |
293 } | 288 } |
294 | 289 |
295 private Node findRoot() { | 290 private Node findRoot() { |
296 return findStart().getParent(); | 291 return findStart().getParent(); |
297 } | |
298 | |
299 private SpecializedNode findSpecializedNode() { | |
300 return (SpecializedNode) findEnd().findStart().getParent(); | |
301 } | 292 } |
302 | 293 |
303 private static SpecializationNode removeSameImpl(SpecializationNode toRemove, CharSequence reason) { | 294 private static SpecializationNode removeSameImpl(SpecializationNode toRemove, CharSequence reason) { |
304 SpecializationNode start = toRemove.findStart(); | 295 SpecializationNode start = toRemove.findStart(); |
305 SpecializationNode current = start; | 296 SpecializationNode current = start; |
313 current = current.next; | 304 current = current.next; |
314 } | 305 } |
315 return toRemove.findEnd().findStart(); | 306 return toRemove.findEnd().findStart(); |
316 } | 307 } |
317 | 308 |
309 @SuppressWarnings("unused") | |
318 public Object acceptAndExecute(Frame frame) { | 310 public Object acceptAndExecute(Frame frame) { |
319 throw new UnsupportedOperationException(); | 311 throw new UnsupportedOperationException(); |
320 } | 312 } |
321 | 313 |
314 @SuppressWarnings("unused") | |
322 public Object acceptAndExecute(Frame frame, Object o1) { | 315 public Object acceptAndExecute(Frame frame, Object o1) { |
323 throw new UnsupportedOperationException(); | 316 throw new UnsupportedOperationException(); |
324 } | 317 } |
325 | 318 |
319 @SuppressWarnings("unused") | |
326 public Object acceptAndExecute(Frame frame, Object o1, Object o2) { | 320 public Object acceptAndExecute(Frame frame, Object o1, Object o2) { |
327 throw new UnsupportedOperationException(); | 321 throw new UnsupportedOperationException(); |
328 } | 322 } |
329 | 323 |
324 @SuppressWarnings("unused") | |
330 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3) { | 325 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3) { |
331 throw new UnsupportedOperationException(); | 326 throw new UnsupportedOperationException(); |
332 } | 327 } |
333 | 328 |
329 @SuppressWarnings("unused") | |
334 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3, Object o4) { | 330 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3, Object o4) { |
335 throw new UnsupportedOperationException(); | 331 throw new UnsupportedOperationException(); |
336 } | 332 } |
337 | 333 |
334 @SuppressWarnings("unused") | |
338 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) { | 335 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) { |
339 throw new UnsupportedOperationException(); | 336 throw new UnsupportedOperationException(); |
340 } | 337 } |
341 | 338 |
339 @SuppressWarnings("unused") | |
342 public Object acceptAndExecute(Frame frame, Object... args) { | 340 public Object acceptAndExecute(Frame frame, Object... args) { |
343 throw new UnsupportedOperationException(); | 341 throw new UnsupportedOperationException(); |
344 } | 342 } |
345 | 343 |
346 protected SpecializationNode createFallback() { | 344 protected SpecializationNode createFallback() { |
349 | 347 |
350 protected SpecializationNode createPolymorphic() { | 348 protected SpecializationNode createPolymorphic() { |
351 return null; | 349 return null; |
352 } | 350 } |
353 | 351 |
352 @SuppressWarnings("unused") | |
354 protected SpecializationNode createNext(Frame frame) { | 353 protected SpecializationNode createNext(Frame frame) { |
355 throw new UnsupportedOperationException(); | 354 throw new UnsupportedOperationException(); |
356 } | 355 } |
357 | 356 |
357 @SuppressWarnings("unused") | |
358 protected SpecializationNode createNext(Frame frame, Object o1) { | 358 protected SpecializationNode createNext(Frame frame, Object o1) { |
359 throw new UnsupportedOperationException(); | 359 throw new UnsupportedOperationException(); |
360 } | 360 } |
361 | 361 |
362 @SuppressWarnings("unused") | |
362 protected SpecializationNode createNext(Frame frame, Object o1, Object o2) { | 363 protected SpecializationNode createNext(Frame frame, Object o1, Object o2) { |
363 throw new UnsupportedOperationException(); | 364 throw new UnsupportedOperationException(); |
364 } | 365 } |
365 | 366 |
367 @SuppressWarnings("unused") | |
366 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3) { | 368 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3) { |
367 throw new UnsupportedOperationException(); | 369 throw new UnsupportedOperationException(); |
368 } | 370 } |
369 | 371 |
372 @SuppressWarnings("unused") | |
370 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3, Object o4) { | 373 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3, Object o4) { |
371 throw new UnsupportedOperationException(); | 374 throw new UnsupportedOperationException(); |
372 } | 375 } |
373 | 376 |
377 @SuppressWarnings("unused") | |
374 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) { | 378 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) { |
375 throw new UnsupportedOperationException(); | 379 throw new UnsupportedOperationException(); |
376 } | 380 } |
377 | 381 |
382 @SuppressWarnings("unused") | |
378 protected SpecializationNode createNext(Frame frame, Object... args) { | 383 protected SpecializationNode createNext(Frame frame, Object... args) { |
379 throw new UnsupportedOperationException(); | 384 throw new UnsupportedOperationException(); |
380 } | 385 } |
381 | 386 |
382 protected final Object uninitialized(Frame frame) { | 387 protected final Object uninitialized(Frame frame) { |
468 | 473 |
469 protected final Object remove(String reason, Frame frame, Object... args) { | 474 protected final Object remove(String reason, Frame frame, Object... args) { |
470 return atomic(new RemoveEventN(this, reason, frame, args)).acceptAndExecute(frame, args); | 475 return atomic(new RemoveEventN(this, reason, frame, args)).acceptAndExecute(frame, args); |
471 } | 476 } |
472 | 477 |
478 @SuppressWarnings("unused") | |
473 protected Object unsupported(Frame frame) { | 479 protected Object unsupported(Frame frame) { |
474 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren()); | 480 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren()); |
475 } | 481 } |
476 | 482 |
483 @SuppressWarnings("unused") | |
477 protected Object unsupported(Frame frame, Object o1) { | 484 protected Object unsupported(Frame frame, Object o1) { |
478 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1); | 485 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1); |
479 } | 486 } |
480 | 487 |
488 @SuppressWarnings("unused") | |
481 protected Object unsupported(Frame frame, Object o1, Object o2) { | 489 protected Object unsupported(Frame frame, Object o1, Object o2) { |
482 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2); | 490 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2); |
483 } | 491 } |
484 | 492 |
493 @SuppressWarnings("unused") | |
485 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3) { | 494 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3) { |
486 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2, o3); | 495 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2, o3); |
487 } | 496 } |
488 | 497 |
498 @SuppressWarnings("unused") | |
489 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3, Object o4) { | 499 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3, Object o4) { |
490 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2, o3, o4); | 500 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2, o3, o4); |
491 } | 501 } |
492 | 502 |
503 @SuppressWarnings("unused") | |
493 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) { | 504 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) { |
494 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2, o3, o4, o5); | 505 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2, o3, o4, o5); |
495 } | 506 } |
496 | 507 |
508 @SuppressWarnings("unused") | |
497 protected Object unsupported(Frame frame, Object... args) { | 509 protected Object unsupported(Frame frame, Object... args) { |
498 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), args); | 510 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), args); |
499 } | 511 } |
500 | 512 |
501 static SpecializationNode insertSorted(SpecializationNode start, final SpecializationNode generated, final CharSequence message, final SpecializationNode merged) { | 513 static SpecializationNode insertSorted(SpecializationNode start, final SpecializationNode generated, final CharSequence message, final SpecializationNode merged) { |