private boolean hasManyPreceedingNullTests(int pc) { int ifNullTests = 0; BitSet seen = new BitSet(); try { for (Iterator<Location> i = classContext.getCFG(method).locationIterator(); i.hasNext();) { Location loc = i.next(); int pc2 = loc.getHandle().getPosition(); if (pc2 >= pc || pc2 < pc - 30) continue; Instruction ins = loc.getHandle().getInstruction(); if ((ins instanceof IFNONNULL || ins instanceof IFNULL || ins instanceof NullnessConversationInstruction) && !seen.get(pc2)) { ifNullTests++; seen.set(pc2); } } boolean result = ifNullTests > 2; // System.out.println("Preceeding null tests " + ifNullTests + " " + // ifNonnullTests + " " + result); return result; } catch (CFGBuilderException e) { return false; } }
@Override public MatchResult match(InstructionHandle handle, ConstantPoolGen cpg, ValueNumberFrame before, ValueNumberFrame after, BindingSet bindingSet) throws DataflowAnalysisException { // Instruction must be IFNULL or IFNONNULL. Instruction ins = handle.getInstruction(); if (!(ins instanceof IFNULL || ins instanceof IFNONNULL)) return null; // Ensure reference used is consistent with previous uses of // same variable. LocalVariable ref = new LocalVariable(before.getTopValue()); return addOrCheckDefinition(ref, bindingSet); }
void insertAbortedCheck(MethodGen m, InstructionList il, InstructionHandle pos) { // Generates: // if (cashmere.getParent() != null && cashmere.getParent().aborted) { // throw new ibis.cashmere.impl.aborts.AbortException(); // } InstructionHandle abo = insertThrowAbort(m, il, pos); il.insert(abo, getCashmere(ins_f)); il.insert(abo, ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "getParent", irType, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); // test for null (root job) il.insert(abo, new IFNULL(pos)); il.insert(abo, getCashmere(ins_f)); il.insert(abo, ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "getParent", irType, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); il.insert(abo, ins_f.createFieldAccess( "ibis.cashmere.impl.spawnSync.InvocationRecord", "aborted", Type.BOOLEAN, Constants.GETFIELD)); il.insert(abo, new IFEQ(pos)); /* ////@@@@@@@@@@2 this needs fixing :-( // Test for parent.eek, if non-null, throw it (exception in inlet). il.insert(abo, getCashmere(ins_f)); il.insert(abo, ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "getParent", irType, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); il.insert(abo, ins_f.createFieldAccess( "ibis.cashmere.impl.spawnSync.InvocationRecord", "eek", new ObjectType("java.lang.Throwable"), Constants.GETFIELD)); il.insert(abo, new IFNULL(abo)); il.insert(abo, getCashmere(ins_f)); il.insert(abo, ins_f.createInvoke("ibis.cashmere.impl.Cashmere", "getParent", irType, Type.NO_ARGS, Constants.INVOKEVIRTUAL)); il.insert(abo, ins_f.createFieldAccess( "ibis.cashmere.impl.spawnSync.InvocationRecord", "eek", new ObjectType("java.lang.Throwable"), Constants.GETFIELD)); il.insert(abo, new ATHROW()); */ }
@Override public boolean acceptBranch(Edge edge, InstructionHandle source) { boolean isIfNull = (source.getInstruction() instanceof IFNULL); return edge.getType() == (isIfNull ? IFCMP_EDGE : FALL_THROUGH_EDGE); }