protected final Object removeThis(final CharSequence reason, Frame frame, Object o1, Object o2, Object o3) { return removeThisImpl(reason).acceptAndExecute(frame, o1, o2, o3); }
public final NodeCost getNodeCost() { switch (count()) { case 0: case 1: return NodeCost.UNINITIALIZED; case 2: return NodeCost.MONOMORPHIC; default: return NodeCost.POLYMORPHIC; } }
private int countSameImpl(SpecializationNode node) { if (next != null) { return next.countSameImpl(node) + (isSame(node) ? 1 : 0); } else { return 0; } }
public SpecializationNode call() throws Exception { SpecializationNode next = source.createNext(frame); if (next == null) { next = source.createFallback(); } if (next == null) { return null; } SpecializationNode start = source.findStart(); if (start.index == Integer.MAX_VALUE) { return insertAt(start, next, this); } else { return insertSorted(start, next, this, start.merge(next, frame)); } }
protected final Object uninitialized(Frame frame) { CompilerDirectives.transferToInterpreterAndInvalidate(); SpecializationNode newNode = atomic(new InsertionEvent0(this, "insert new specialization", frame)); if (newNode == null) { return unsupported(frame); } return newNode.acceptAndExecute(frame); }
protected final Object remove(String reason, Frame frame) { return atomic(new RemoveEvent0(this, reason, frame)).acceptAndExecute(frame); }
private static SpecializationNode removeSameImpl(SpecializationNode toRemove, CharSequence reason) { SpecializationNode start = toRemove.findStart(); SpecializationNode current = start; while (current != null) { if (current.isSame(toRemove)) { NodeUtil.nonAtomicReplace(current, current.next, reason); if (current == start) { start = start.next; } } current = current.next; } return toRemove.findEnd().findStart(); }
static SpecializationNode insertSorted(SpecializationNode start, final SpecializationNode generated, final CharSequence message, final SpecializationNode merged) { if (merged == generated) { // new node if (start.count() == 2) { SpecializationNode polymorphic = start.createPolymorphic(); /* * For nodes with all parameters evaluated in the execute method we do not need a * polymorphic node. the generated code returns null in createPolymorphic in this * case. */ if (polymorphic != null) { insertAt(start, polymorphic, "insert polymorphic"); } } SpecializationNode current = start; while (current != null && current.index < generated.index) { current = current.next; } return insertAt(current, generated, message); } else { // existing node return start; } }
protected final int countSame(SpecializationNode node) { return findStart().countSameImpl(node); }
protected final SpecializationNode polymorphicMerge(SpecializationNode newNode, SpecializationNode merged) { if (merged == newNode && count() <= 2) { return removeSame(new SlowPathEvent0(this, "merged polymorphic to monomorphic", null)); } return merged; }
@Override public final String toString() { Class<?> clazz = getClass(); StringBuilder b = new StringBuilder(); b.append(clazz.getSimpleName()); appendFields(b, clazz); if (next != null) { b.append("\n -> ").append(next.toString()); } return b.toString(); }
@ExplodeLoop protected static void check(Assumption[] assumptions) throws InvalidAssumptionException { if (assumptions != null) { CompilerAsserts.compilationConstant(assumptions.length); for (Assumption assumption : assumptions) { check(assumption); } } }
public SpecializationNode call() throws Exception { SpecializationNode next = source.createNext(frame, o1); if (next == null) { next = source.createFallback(); } if (next == null) { return null; } SpecializationNode start = source.findStart(); if (start.index == Integer.MAX_VALUE) { return insertAt(start, next, this); } else { return insertSorted(start, next, this, start.merge(next, frame, o1)); } }
protected final Object uninitialized(Frame frame, Object o1, Object o2) { CompilerDirectives.transferToInterpreterAndInvalidate(); SpecializationNode newNode = atomic(new InsertionEvent2(this, "insert new specialization", frame, o1, o2)); if (newNode == null) { return unsupported(frame, o1, o2); } return newNode.acceptAndExecute(frame, o1, o2); }
protected final Object remove(String reason, Frame frame, Object o1) { return atomic(new RemoveEvent1(this, reason, frame, o1)).acceptAndExecute(frame, o1); }
protected final SpecializationNode removeSame(final CharSequence reason) { SpecializationNode start = SpecializationNode.this.findStart(); SpecializationNode current = start; while (current != null) { if (current.isSame(SpecializationNode.this)) { NodeUtil.nonAtomicReplace(current, current.next, reason); if (current == start) { start = start.next; } } current = current.next; } return SpecializationNode.this.findEnd().findStart(); }
public SpecializationNode call() throws Exception { SpecializationNode next = source.createNext(frame, o1, o2, o3, o4, o5); if (next == null) { next = source.createFallback(); } if (next == null) { return null; } SpecializationNode start = source.findStart(); if (start.index == Integer.MAX_VALUE) { return insertAt(start, next, this); } else { return insertSorted(start, next, this, start.merge(next, frame, o1, o2, o3, o4, o5)); } }