comparison truffle/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/SpecializationNode.java @ 21951:9c8c0937da41

Moving all sources into truffle subdirectory
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 17 Jun 2015 10:58:08 +0200
parents graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/SpecializationNode.java@b1530a6cce8c
children dc83cc1f94f2
comparison
equal deleted inserted replaced
21950:2a5011c7e641 21951:9c8c0937da41
1 /*
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package com.oracle.truffle.api.dsl.internal;
26
27 import java.lang.reflect.*;
28 import java.util.*;
29 import java.util.concurrent.*;
30
31 import com.oracle.truffle.api.*;
32 import com.oracle.truffle.api.dsl.*;
33 import com.oracle.truffle.api.dsl.internal.SlowPathEvent.SlowPathEvent0;
34 import com.oracle.truffle.api.dsl.internal.SlowPathEvent.SlowPathEvent1;
35 import com.oracle.truffle.api.dsl.internal.SlowPathEvent.SlowPathEvent2;
36 import com.oracle.truffle.api.dsl.internal.SlowPathEvent.SlowPathEvent3;
37 import com.oracle.truffle.api.dsl.internal.SlowPathEvent.SlowPathEvent4;
38 import com.oracle.truffle.api.dsl.internal.SlowPathEvent.SlowPathEvent5;
39 import com.oracle.truffle.api.dsl.internal.SlowPathEvent.SlowPathEventN;
40 import com.oracle.truffle.api.frame.*;
41 import com.oracle.truffle.api.nodes.*;
42
43 /**
44 * Internal implementation dependent base class for generated specialized nodes.
45 */
46 @NodeInfo(cost = NodeCost.NONE)
47 @SuppressWarnings("unused")
48 public abstract class SpecializationNode extends Node {
49
50 @Child protected SpecializationNode next;
51
52 final int index;
53
54 public SpecializationNode() {
55 this(-1);
56 }
57
58 public SpecializationNode(int index) {
59 this.index = index;
60 }
61
62 @Override
63 public final NodeCost getCost() {
64 return NodeCost.NONE;
65 }
66
67 public void reset() {
68 SpecializationNode start = findStart();
69 SpecializationNode end = findEnd();
70 if (start != end) {
71 start.replace(end, "reset specialization");
72 }
73 }
74
75 public static Node updateRoot(Node node) {
76 updateRootImpl(((SpecializedNode) node).getSpecializationNode(), node);
77 return node;
78 }
79
80 private static void updateRootImpl(SpecializationNode start, Node node) {
81 NodeFieldAccessor[] fields = NodeClass.get(start).getFields();
82 for (int i = fields.length - 1; i >= 0; i--) {
83 NodeFieldAccessor f = fields[i];
84 if (f.getName().equals("root")) {
85 f.putObject(start, node);
86 break;
87 }
88 }
89 if (start.next != null) {
90 updateRootImpl(start.next, node);
91 }
92 }
93
94 protected final SpecializationNode polymorphicMerge(SpecializationNode newNode, SpecializationNode merged) {
95 if (merged == newNode && count() <= 2) {
96 return removeSame(new SlowPathEvent0(this, "merged polymorphic to monomorphic", null));
97 }
98 return merged;
99 }
100
101 public final NodeCost getNodeCost() {
102 switch (count()) {
103 case 0:
104 case 1:
105 return NodeCost.UNINITIALIZED;
106 case 2:
107 return NodeCost.MONOMORPHIC;
108 default:
109 return NodeCost.POLYMORPHIC;
110 }
111 }
112
113 protected abstract Node[] getSuppliedChildren();
114
115 protected SpecializationNode merge(SpecializationNode newNode, Frame frame) {
116 if (isIdentical(newNode, frame)) {
117 return this;
118 }
119 return next != null ? next.merge(newNode, frame) : newNode;
120 }
121
122 protected SpecializationNode merge(SpecializationNode newNode, Frame frame, Object o1) {
123 if (isIdentical(newNode, frame, o1)) {
124 return this;
125 }
126 return next != null ? next.merge(newNode, frame, o1) : newNode;
127 }
128
129 protected SpecializationNode merge(SpecializationNode newNode, Frame frame, Object o1, Object o2) {
130 if (isIdentical(newNode, frame, o1, o2)) {
131 return this;
132 }
133 return next != null ? next.merge(newNode, frame, o1, o2) : newNode;
134 }
135
136 protected SpecializationNode merge(SpecializationNode newNode, Frame frame, Object o1, Object o2, Object o3) {
137 if (isIdentical(newNode, frame, o1, o2, o3)) {
138 return this;
139 }
140 return next != null ? next.merge(newNode, frame, o1, o2, o3) : newNode;
141 }
142
143 protected SpecializationNode merge(SpecializationNode newNode, Frame frame, Object o1, Object o2, Object o3, Object o4) {
144 if (isIdentical(newNode, frame, o1, o2, o3, o4)) {
145 return this;
146 }
147 return next != null ? next.merge(newNode, frame, o1, o2, o3, o4) : newNode;
148 }
149
150 protected SpecializationNode merge(SpecializationNode newNode, Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
151 if (isIdentical(newNode, frame, o1, o2, o3, o4, o5)) {
152 return this;
153 }
154 return next != null ? next.merge(newNode, frame, o1, o2, o3, o4, o5) : newNode;
155 }
156
157 protected SpecializationNode merge(SpecializationNode newNode, Frame frame, Object... args) {
158 if (isIdentical(newNode, frame, args)) {
159 return this;
160 }
161 return next != null ? next.merge(newNode, frame, args) : newNode;
162 }
163
164 protected boolean isSame(SpecializationNode other) {
165 return getClass() == other.getClass();
166 }
167
168 protected boolean isIdentical(SpecializationNode newNode, Frame frame) {
169 return isSame(newNode);
170 }
171
172 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1) {
173 return isSame(newNode);
174 }
175
176 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1, Object o2) {
177 return isSame(newNode);
178 }
179
180 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1, Object o2, Object o3) {
181 return isSame(newNode);
182 }
183
184 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1, Object o2, Object o3, Object o4) {
185 return isSame(newNode);
186 }
187
188 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
189 return isSame(newNode);
190 }
191
192 protected boolean isIdentical(SpecializationNode newNode, Frame frame, Object... args) {
193 return isSame(newNode);
194 }
195
196 protected final int countSame(SpecializationNode node) {
197 return findStart().countSameImpl(node);
198 }
199
200 private int countSameImpl(SpecializationNode node) {
201 if (next != null) {
202 return next.countSameImpl(node) + (isSame(node) ? 1 : 0);
203 } else {
204 return 0;
205 }
206 }
207
208 @Override
209 public final boolean equals(Object obj) {
210 if (obj instanceof SpecializationNode) {
211 return ((SpecializationNode) obj).isSame(this);
212 }
213 return super.equals(obj);
214 }
215
216 @Override
217 public final int hashCode() {
218 return index;
219 }
220
221 private int count() {
222 return next != null ? next.count() + 1 : 1;
223 }
224
225 private SpecializationNode findEnd() {
226 SpecializationNode node = this;
227 while (node.next != null) {
228 node = node.next;
229 }
230 return node;
231 }
232
233 protected final Object removeThis(final CharSequence reason, Frame frame) {
234 return removeThisImpl(reason).acceptAndExecute(frame);
235 }
236
237 protected final Object removeThis(final CharSequence reason, Frame frame, Object o1) {
238 return removeThisImpl(reason).acceptAndExecute(frame, o1);
239 }
240
241 protected final Object removeThis(final CharSequence reason, Frame frame, Object o1, Object o2) {
242 return removeThisImpl(reason).acceptAndExecute(frame, o1, o2);
243 }
244
245 protected final Object removeThis(final CharSequence reason, Frame frame, Object o1, Object o2, Object o3) {
246 return removeThisImpl(reason).acceptAndExecute(frame, o1, o2, o3);
247 }
248
249 protected final Object removeThis(final CharSequence reason, Frame frame, Object o1, Object o2, Object o3, Object o4) {
250 return removeThisImpl(reason).acceptAndExecute(frame, o1, o2, o3, o4);
251 }
252
253 protected final Object removeThis(final CharSequence reason, Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
254 return removeThisImpl(reason).acceptAndExecute(frame, o1, o2, o3, o4, o5);
255 }
256
257 protected final Object removeThis(final CharSequence reason, Frame frame, Object... args) {
258 return removeThisImpl(reason).acceptAndExecute(frame, args);
259 }
260
261 private SpecializationNode removeThisImpl(final CharSequence reason) {
262 this.replace(this.next, reason);
263 return findEnd().findStart();
264 }
265
266 protected final SpecializationNode removeSame(final CharSequence reason) {
267 SpecializationNode start = SpecializationNode.this.findStart();
268 SpecializationNode current = start;
269 while (current != null) {
270 if (current.isSame(SpecializationNode.this)) {
271 NodeUtil.nonAtomicReplace(current, current.next, reason);
272 if (current == start) {
273 start = start.next;
274 }
275 }
276 current = current.next;
277 }
278 return SpecializationNode.this.findEnd().findStart();
279 }
280
281 /** Find the topmost of the specialization chain. */
282 private SpecializationNode findStart() {
283 SpecializationNode node = this;
284 Node parent = this.getParent();
285 while (parent instanceof SpecializationNode) {
286 SpecializationNode parentCast = ((SpecializationNode) parent);
287 if (parentCast.next != node) {
288 break;
289 }
290 node = parentCast;
291 parent = node.getParent();
292 }
293 return node;
294 }
295
296 private Node findRoot() {
297 return findStart().getParent();
298 }
299
300 private SpecializedNode findSpecializedNode() {
301 return (SpecializedNode) findEnd().findStart().getParent();
302 }
303
304 private static SpecializationNode removeSameImpl(SpecializationNode toRemove, CharSequence reason) {
305 SpecializationNode start = toRemove.findStart();
306 SpecializationNode current = start;
307 while (current != null) {
308 if (current.isSame(toRemove)) {
309 NodeUtil.nonAtomicReplace(current, current.next, reason);
310 if (current == start) {
311 start = start.next;
312 }
313 }
314 current = current.next;
315 }
316 return toRemove.findEnd().findStart();
317 }
318
319 public Object acceptAndExecute(Frame frame) {
320 throw new UnsupportedOperationException();
321 }
322
323 public Object acceptAndExecute(Frame frame, Object o1) {
324 throw new UnsupportedOperationException();
325 }
326
327 public Object acceptAndExecute(Frame frame, Object o1, Object o2) {
328 throw new UnsupportedOperationException();
329 }
330
331 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3) {
332 throw new UnsupportedOperationException();
333 }
334
335 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3, Object o4) {
336 throw new UnsupportedOperationException();
337 }
338
339 public Object acceptAndExecute(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
340 throw new UnsupportedOperationException();
341 }
342
343 public Object acceptAndExecute(Frame frame, Object... args) {
344 throw new UnsupportedOperationException();
345 }
346
347 protected SpecializationNode createFallback() {
348 return null;
349 }
350
351 protected SpecializationNode createPolymorphic() {
352 return null;
353 }
354
355 protected SpecializationNode createNext(Frame frame) {
356 throw new UnsupportedOperationException();
357 }
358
359 protected SpecializationNode createNext(Frame frame, Object o1) {
360 throw new UnsupportedOperationException();
361 }
362
363 protected SpecializationNode createNext(Frame frame, Object o1, Object o2) {
364 throw new UnsupportedOperationException();
365 }
366
367 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3) {
368 throw new UnsupportedOperationException();
369 }
370
371 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3, Object o4) {
372 throw new UnsupportedOperationException();
373 }
374
375 protected SpecializationNode createNext(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
376 throw new UnsupportedOperationException();
377 }
378
379 protected SpecializationNode createNext(Frame frame, Object... args) {
380 throw new UnsupportedOperationException();
381 }
382
383 protected final Object uninitialized(Frame frame) {
384 CompilerDirectives.transferToInterpreterAndInvalidate();
385 SpecializationNode newNode = atomic(new InsertionEvent0(this, "insert new specialization", frame));
386 if (newNode == null) {
387 return unsupported(frame);
388 }
389 return newNode.acceptAndExecute(frame);
390 }
391
392 protected final Object uninitialized(Frame frame, Object o1) {
393 CompilerDirectives.transferToInterpreterAndInvalidate();
394 SpecializationNode newNode = atomic(new InsertionEvent1(this, "insert new specialization", frame, o1));
395 if (newNode == null) {
396 return unsupported(frame, o1);
397 }
398 return newNode.acceptAndExecute(frame, o1);
399 }
400
401 protected final Object uninitialized(Frame frame, Object o1, Object o2) {
402 CompilerDirectives.transferToInterpreterAndInvalidate();
403 SpecializationNode newNode = atomic(new InsertionEvent2(this, "insert new specialization", frame, o1, o2));
404 if (newNode == null) {
405 return unsupported(frame, o1, o2);
406 }
407 return newNode.acceptAndExecute(frame, o1, o2);
408 }
409
410 protected final Object uninitialized(Frame frame, Object o1, Object o2, Object o3) {
411 CompilerDirectives.transferToInterpreterAndInvalidate();
412 SpecializationNode newNode = atomic(new InsertionEvent3(this, "insert new specialization", frame, o1, o2, o3));
413 if (newNode == null) {
414 return unsupported(frame, o1, o2, o3);
415 }
416 return newNode.acceptAndExecute(frame, o1, o2, o3);
417 }
418
419 protected final Object uninitialized(Frame frame, Object o1, Object o2, Object o3, Object o4) {
420 CompilerDirectives.transferToInterpreterAndInvalidate();
421 SpecializationNode newNode = atomic(new InsertionEvent4(this, "insert new specialization", frame, o1, o2, o3, o4));
422 if (newNode == null) {
423 return unsupported(frame, o1, o2, o3, o4);
424 }
425 return newNode.acceptAndExecute(frame, o1, o2, o3, o4);
426 }
427
428 protected final Object uninitialized(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
429 CompilerDirectives.transferToInterpreterAndInvalidate();
430 SpecializationNode newNode = atomic(new InsertionEvent5(this, "insert new specialization", frame, o1, o2, o3, o4, o5));
431 if (newNode == null) {
432 return unsupported(frame, o1, o2, o3, o4, o5);
433 }
434 return newNode.acceptAndExecute(frame, o1, o2, o3, o4, o5);
435 }
436
437 protected final Object uninitialized(Frame frame, Object... args) {
438 CompilerDirectives.transferToInterpreterAndInvalidate();
439 SpecializationNode newNode = atomic(new InsertionEventN(this, "insert new specialization", frame, args));
440 if (newNode == null) {
441 return unsupported(frame, args);
442 }
443 return newNode.acceptAndExecute(frame, args);
444 }
445
446 protected final Object remove(String reason, Frame frame) {
447 return atomic(new RemoveEvent0(this, reason, frame)).acceptAndExecute(frame);
448 }
449
450 protected final Object remove(String reason, Frame frame, Object o1) {
451 return atomic(new RemoveEvent1(this, reason, frame, o1)).acceptAndExecute(frame, o1);
452 }
453
454 protected final Object remove(String reason, Frame frame, Object o1, Object o2) {
455 return atomic(new RemoveEvent2(this, reason, frame, o1, o2)).acceptAndExecute(frame, o1, o2);
456 }
457
458 protected final Object remove(String reason, Frame frame, Object o1, Object o2, Object o3) {
459 return atomic(new RemoveEvent3(this, reason, frame, o1, o2, o3)).acceptAndExecute(frame, o1, o2, o3);
460 }
461
462 protected final Object remove(String reason, Frame frame, Object o1, Object o2, Object o3, Object o4) {
463 return atomic(new RemoveEvent4(this, reason, frame, o1, o2, o3, o4)).acceptAndExecute(frame, o1, o2, o3, o4);
464 }
465
466 protected final Object remove(String reason, Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
467 return atomic(new RemoveEvent5(this, reason, frame, o1, o2, o3, o4, o5)).acceptAndExecute(frame, o1, o2, o3, o4, o5);
468 }
469
470 protected final Object remove(String reason, Frame frame, Object... args) {
471 return atomic(new RemoveEventN(this, reason, frame, args)).acceptAndExecute(frame, args);
472 }
473
474 protected Object unsupported(Frame frame) {
475 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren());
476 }
477
478 protected Object unsupported(Frame frame, Object o1) {
479 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1);
480 }
481
482 protected Object unsupported(Frame frame, Object o1, Object o2) {
483 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2);
484 }
485
486 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3) {
487 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2, o3);
488 }
489
490 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3, Object o4) {
491 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2, o3, o4);
492 }
493
494 protected Object unsupported(Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
495 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), o1, o2, o3, o4, o5);
496 }
497
498 protected Object unsupported(Frame frame, Object... args) {
499 throw new UnsupportedSpecializationException(findRoot(), getSuppliedChildren(), args);
500 }
501
502 static SpecializationNode insertSorted(SpecializationNode start, final SpecializationNode generated, final CharSequence message, final SpecializationNode merged) {
503 if (merged == generated) {
504 // new node
505 if (start.count() == 2) {
506 SpecializationNode polymorphic = start.createPolymorphic();
507 /*
508 * For nodes with all parameters evaluated in the execute method we do not need a
509 * polymorphic node. the generated code returns null in createPolymorphic in this
510 * case.
511 */
512 if (polymorphic != null) {
513 insertAt(start, polymorphic, "insert polymorphic");
514 }
515 }
516 SpecializationNode current = start;
517 while (current != null && current.index < generated.index) {
518 current = current.next;
519 }
520 return insertAt(current, generated, message);
521 } else {
522 // existing node
523 return start;
524 }
525 }
526
527 static <T> SpecializationNode insertAt(SpecializationNode node, SpecializationNode insertBefore, CharSequence reason) {
528 insertBefore.next = node;
529 // always guaranteed to be executed inside of an atomic block
530 return NodeUtil.nonAtomicReplace(node, insertBefore, reason);
531 }
532
533 @Override
534 public final String toString() {
535 Class<?> clazz = getClass();
536 StringBuilder b = new StringBuilder();
537 b.append(clazz.getSimpleName());
538
539 appendFields(b, clazz);
540 if (next != null) {
541 b.append("\n -> ").append(next.toString());
542 }
543 return b.toString();
544 }
545
546 private void appendFields(StringBuilder b, Class<?> clazz) {
547 Field[] fields = clazz.getDeclaredFields();
548 if (fields.length == 0) {
549 return;
550 }
551 b.append("(");
552 String sep = "";
553 for (Field field : fields) {
554 if (Modifier.isStatic(field.getModifiers())) {
555 continue;
556 }
557 b.append(sep);
558 String name = field.getName();
559 if (name.equals("root")) {
560 continue;
561 }
562 b.append(field.getName());
563 b.append(" = ");
564 try {
565 field.setAccessible(true);
566 Object value = field.get(this);
567 if (value instanceof Object[]) {
568 b.append(Arrays.toString((Object[]) field.get(this)));
569 } else {
570 b.append(field.get(this));
571 }
572 } catch (IllegalArgumentException e) {
573 b.append(e.toString());
574 } catch (IllegalAccessException e) {
575 b.append(e.toString());
576 }
577 sep = ", ";
578 }
579 b.append(")");
580 }
581
582 protected static void check(Assumption assumption) throws InvalidAssumptionException {
583 if (assumption != null) {
584 assumption.check();
585 }
586 }
587
588 @ExplodeLoop
589 protected static void check(Assumption[] assumptions) throws InvalidAssumptionException {
590 if (assumptions != null) {
591 CompilerAsserts.compilationConstant(assumptions.length);
592 for (Assumption assumption : assumptions) {
593 check(assumption);
594 }
595 }
596 }
597
598 protected static boolean isValid(Assumption assumption) {
599 if (assumption != null) {
600 return assumption.isValid();
601 }
602 return true;
603 }
604
605 protected static boolean isValid(Assumption[] assumptions) {
606 if (assumptions != null) {
607 for (Assumption assumption : assumptions) {
608 if (!isValid(assumption)) {
609 return false;
610 }
611 }
612 }
613 return true;
614 }
615
616 private static final class InsertionEvent0 extends SlowPathEvent0 implements Callable<SpecializationNode> {
617
618 public InsertionEvent0(SpecializationNode source, String reason, Frame frame) {
619 super(source, reason, frame);
620 }
621
622 public SpecializationNode call() throws Exception {
623 SpecializationNode next = source.createNext(frame);
624 if (next == null) {
625 next = source.createFallback();
626 }
627 if (next == null) {
628 return null;
629 }
630 SpecializationNode start = source.findStart();
631 if (start.index == Integer.MAX_VALUE) {
632 return insertAt(start, next, this);
633 } else {
634 return insertSorted(start, next, this, start.merge(next, frame));
635 }
636 }
637
638 }
639
640 private static final class InsertionEvent1 extends SlowPathEvent1 implements Callable<SpecializationNode> {
641
642 public InsertionEvent1(SpecializationNode source, String reason, Frame frame, Object o1) {
643 super(source, reason, frame, o1);
644 }
645
646 public SpecializationNode call() throws Exception {
647 SpecializationNode next = source.createNext(frame, o1);
648 if (next == null) {
649 next = source.createFallback();
650 }
651 if (next == null) {
652 return null;
653 }
654 SpecializationNode start = source.findStart();
655 if (start.index == Integer.MAX_VALUE) {
656 return insertAt(start, next, this);
657 } else {
658 return insertSorted(start, next, this, start.merge(next, frame, o1));
659 }
660 }
661
662 }
663
664 private static final class InsertionEvent2 extends SlowPathEvent2 implements Callable<SpecializationNode> {
665
666 public InsertionEvent2(SpecializationNode source, String reason, Frame frame, Object o1, Object o2) {
667 super(source, reason, frame, o1, o2);
668 }
669
670 public SpecializationNode call() throws Exception {
671 SpecializationNode next = source.createNext(frame, o1, o2);
672 if (next == null) {
673 next = source.createFallback();
674 }
675 if (next == null) {
676 return null;
677 }
678 SpecializationNode start = source.findStart();
679 if (start.index == Integer.MAX_VALUE) {
680 return insertAt(start, next, this);
681 } else {
682 return insertSorted(start, next, this, start.merge(next, frame, o1, o2));
683 }
684 }
685
686 }
687
688 private static final class InsertionEvent3 extends SlowPathEvent3 implements Callable<SpecializationNode> {
689
690 public InsertionEvent3(SpecializationNode source, String reason, Frame frame, Object o1, Object o2, Object o3) {
691 super(source, reason, frame, o1, o2, o3);
692 }
693
694 public SpecializationNode call() throws Exception {
695 SpecializationNode next = source.createNext(frame, o1, o2, o3);
696 if (next == null) {
697 next = source.createFallback();
698 }
699 if (next == null) {
700 return null;
701 }
702 SpecializationNode start = source.findStart();
703 if (start.index == Integer.MAX_VALUE) {
704 return insertAt(start, next, this);
705 } else {
706 return insertSorted(start, next, this, start.merge(next, frame, o1, o2, o3));
707 }
708 }
709
710 }
711
712 private static final class InsertionEvent4 extends SlowPathEvent4 implements Callable<SpecializationNode> {
713
714 public InsertionEvent4(SpecializationNode source, String reason, Frame frame, Object o1, Object o2, Object o3, Object o4) {
715 super(source, reason, frame, o1, o2, o3, o4);
716 }
717
718 public SpecializationNode call() throws Exception {
719 SpecializationNode next = source.createNext(frame, o1, o2, o3, o4);
720 if (next == null) {
721 next = source.createFallback();
722 }
723 if (next == null) {
724 return null;
725 }
726 SpecializationNode start = source.findStart();
727 if (start.index == Integer.MAX_VALUE) {
728 return insertAt(start, next, this);
729 } else {
730 return insertSorted(start, next, this, start.merge(next, frame, o1, o2, o3, o4));
731 }
732 }
733
734 }
735
736 private static final class InsertionEvent5 extends SlowPathEvent5 implements Callable<SpecializationNode> {
737
738 public InsertionEvent5(SpecializationNode source, String reason, Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
739 super(source, reason, frame, o1, o2, o3, o4, o5);
740 }
741
742 public SpecializationNode call() throws Exception {
743 SpecializationNode next = source.createNext(frame, o1, o2, o3, o4, o5);
744 if (next == null) {
745 next = source.createFallback();
746 }
747 if (next == null) {
748 return null;
749 }
750 SpecializationNode start = source.findStart();
751 if (start.index == Integer.MAX_VALUE) {
752 return insertAt(start, next, this);
753 } else {
754 return insertSorted(start, next, this, start.merge(next, frame, o1, o2, o3, o4, o5));
755 }
756 }
757
758 }
759
760 private static final class InsertionEventN extends SlowPathEventN implements Callable<SpecializationNode> {
761
762 public InsertionEventN(SpecializationNode source, String reason, Frame frame, Object[] args) {
763 super(source, reason, frame, args);
764 }
765
766 public SpecializationNode call() throws Exception {
767 SpecializationNode next = source.createNext(frame, args);
768 if (next == null) {
769 next = source.createFallback();
770 }
771 if (next == null) {
772 return null;
773 }
774 SpecializationNode start = source.findStart();
775 if (start.index == Integer.MAX_VALUE) {
776 return insertAt(start, next, this);
777 } else {
778 return insertSorted(start, next, this, start.merge(next, frame, args));
779 }
780 }
781 }
782
783 private static final class RemoveEvent0 extends SlowPathEvent0 implements Callable<SpecializationNode> {
784
785 public RemoveEvent0(SpecializationNode source, String reason, Frame frame) {
786 super(source, reason, frame);
787 }
788
789 public SpecializationNode call() throws Exception {
790 return source.removeSame(this);
791 }
792
793 }
794
795 private static final class RemoveEvent1 extends SlowPathEvent1 implements Callable<SpecializationNode> {
796
797 public RemoveEvent1(SpecializationNode source, String reason, Frame frame, Object o1) {
798 super(source, reason, frame, o1);
799 }
800
801 public SpecializationNode call() throws Exception {
802 return source.removeSame(this);
803 }
804
805 }
806
807 private static final class RemoveEvent2 extends SlowPathEvent2 implements Callable<SpecializationNode> {
808
809 public RemoveEvent2(SpecializationNode source, String reason, Frame frame, Object o1, Object o2) {
810 super(source, reason, frame, o1, o2);
811 }
812
813 public SpecializationNode call() throws Exception {
814 return source.removeSame(this);
815 }
816
817 }
818
819 private static final class RemoveEvent3 extends SlowPathEvent3 implements Callable<SpecializationNode> {
820
821 public RemoveEvent3(SpecializationNode source, String reason, Frame frame, Object o1, Object o2, Object o3) {
822 super(source, reason, frame, o1, o2, o3);
823 }
824
825 public SpecializationNode call() throws Exception {
826 return source.removeSame(this);
827 }
828
829 }
830
831 private static final class RemoveEvent4 extends SlowPathEvent4 implements Callable<SpecializationNode> {
832
833 public RemoveEvent4(SpecializationNode source, String reason, Frame frame, Object o1, Object o2, Object o3, Object o4) {
834 super(source, reason, frame, o1, o2, o3, o4);
835 }
836
837 public SpecializationNode call() throws Exception {
838 return source.removeSame(this);
839 }
840
841 }
842
843 private static final class RemoveEvent5 extends SlowPathEvent5 implements Callable<SpecializationNode> {
844
845 public RemoveEvent5(SpecializationNode source, String reason, Frame frame, Object o1, Object o2, Object o3, Object o4, Object o5) {
846 super(source, reason, frame, o1, o2, o3, o4, o5);
847 }
848
849 public SpecializationNode call() throws Exception {
850 return source.removeSame(this);
851 }
852
853 }
854
855 private static final class RemoveEventN extends SlowPathEventN implements Callable<SpecializationNode> {
856
857 public RemoveEventN(SpecializationNode source, String reason, Frame frame, Object[] args) {
858 super(source, reason, frame, args);
859 }
860
861 public SpecializationNode call() throws Exception {
862 return source.removeSame(this);
863 }
864 }
865
866 }