Example usage for org.objectweb.asm Opcodes LSTORE

List of usage examples for org.objectweb.asm Opcodes LSTORE

Introduction

In this page you can find the example usage for org.objectweb.asm Opcodes LSTORE.

Prototype

int LSTORE

To view the source code for org.objectweb.asm Opcodes LSTORE.

Click Source Link

Usage

From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.AODMutator2.java

License:Apache License

@Override
public void visitInsn(int opcode) {
    switch (opcode) {
    case Opcodes.IADD:
    case Opcodes.ISUB:
    case Opcodes.IMUL:
    case Opcodes.IDIV:
    case Opcodes.IREM:
        if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) {
            int storage = this.newLocal(Type.INT_TYPE);
            mv.visitVarInsn(Opcodes.ISTORE, storage);
            mv.visitInsn(Opcodes.POP);//from w  ww .  j  a va 2  s.com
            mv.visitVarInsn(Opcodes.ILOAD, storage);
            /*
             * Alternative : mv.visitInsn(Opcodes.SWAP);
             * mv.visitInsn(Opcodes.POP);
             * mv.visitVarInsn(Opcodes.ILOAD,storage);
             */
        } else {
            mv.visitInsn(opcode);
        }
        break;
    case Opcodes.FADD:
    case Opcodes.FSUB:
    case Opcodes.FMUL:
    case Opcodes.FDIV:
    case Opcodes.FREM:
        if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) {
            int storage = this.newLocal(Type.FLOAT_TYPE);
            mv.visitVarInsn(Opcodes.FSTORE, storage);
            mv.visitInsn(Opcodes.POP);
            mv.visitVarInsn(Opcodes.FLOAD, storage);
        } else {
            mv.visitInsn(opcode);
        }
        break;
    case Opcodes.LADD:
    case Opcodes.LSUB:
    case Opcodes.LMUL:
    case Opcodes.LDIV:
    case Opcodes.LREM:
        if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) {
            int storage = this.newLocal(Type.LONG_TYPE);
            mv.visitVarInsn(Opcodes.LSTORE, storage);
            mv.visitInsn(Opcodes.POP2);
            mv.visitVarInsn(Opcodes.LLOAD, storage);
        } else {
            mv.visitInsn(opcode);
        }
        break;
    case Opcodes.DADD:
    case Opcodes.DSUB:
    case Opcodes.DMUL:
    case Opcodes.DDIV:
    case Opcodes.DREM:
        if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) {
            int storage = this.newLocal(Type.DOUBLE_TYPE);
            mv.visitVarInsn(Opcodes.DSTORE, storage);
            mv.visitInsn(Opcodes.POP2);
            mv.visitVarInsn(Opcodes.DLOAD, storage);
        } else {
            mv.visitInsn(opcode);
        }
        break;
    default:
        mv.visitInsn(opcode);
        break;
    }
}

From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.OBBNMutator3.java

License:Apache License

@Override
public void visitInsn(int opcode) {
    switch (opcode) {
    case Opcodes.IAND:
    case Opcodes.IOR:
        if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) {
            int storage = this.newLocal(Type.INT_TYPE);
            mv.visitVarInsn(Opcodes.ISTORE, storage);
            mv.visitInsn(Opcodes.POP);/* ww  w . ja v  a2 s . c o m*/
            mv.visitVarInsn(Opcodes.ILOAD, storage);
        } else {
            mv.visitInsn(opcode);
        }
        break;
    case Opcodes.LAND:
    case Opcodes.LOR:
        if (this.shouldMutate(OpcodeToType.typeOfOpcode(opcode))) {
            int storage = this.newLocal(Type.LONG_TYPE);
            mv.visitVarInsn(Opcodes.LSTORE, storage);
            mv.visitInsn(Opcodes.POP2);
            mv.visitVarInsn(Opcodes.LLOAD, storage);
        } else {
            mv.visitInsn(opcode);
        }
        break;
    default:
        mv.visitInsn(opcode);
        break;
    }
}

From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator1.java

License:Apache License

@Override
public void visitVarInsn(int opcode, int var) {
    mv.visitVarInsn(opcode, var);

    switch (opcode) {
    case Opcodes.ILOAD:
        if (this.shouldMutate("Incremented (a++) integer local variable number " + var)) {
            mv.visitIincInsn(var, 1);
        }/*from ww w .j  ava2s.c  o  m*/
        break;
    case Opcodes.FLOAD:
        if (this.shouldMutate("Incremented (a++) float local variable number " + var)) {
            mv.visitInsn(Opcodes.DUP);
            mv.visitInsn(Opcodes.FCONST_1);
            mv.visitInsn(Opcodes.FADD);
            mv.visitVarInsn(Opcodes.FSTORE, var);
        }
        break;
    case Opcodes.LLOAD:
        if (this.shouldMutate("Incremented (a++) long local variable number " + var)) {
            mv.visitInsn(Opcodes.DUP2);
            mv.visitInsn(Opcodes.LCONST_1);
            mv.visitInsn(Opcodes.LADD);
            mv.visitVarInsn(Opcodes.LSTORE, var);
        }
        break;
    case Opcodes.DLOAD:
        if (this.shouldMutate("Incremented (a++) double local variable number " + var)) {
            mv.visitInsn(Opcodes.DUP2);
            mv.visitInsn(Opcodes.DCONST_1);
            mv.visitInsn(Opcodes.DADD);
            mv.visitVarInsn(Opcodes.DSTORE, var);
        }
        break;

    default:
        break;
    }
}

From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator2.java

License:Apache License

@Override
public void visitVarInsn(int opcode, int var) {
    mv.visitVarInsn(opcode, var);
    switch (opcode) {
    case Opcodes.ILOAD:
        if (this.shouldMutate("Decremented (a--) integer local variable number " + var)) {
            mv.visitIincInsn(var, -1);
        }//from   w ww.  j ava  2 s  .c  o m
        break;
    case Opcodes.FLOAD:
        if (this.shouldMutate("Decremented (a--) float local variable number " + var)) {
            mv.visitInsn(Opcodes.DUP);
            mv.visitInsn(Opcodes.FCONST_1);
            mv.visitInsn(Opcodes.FSUB);
            mv.visitVarInsn(Opcodes.FSTORE, var);
        }
        break;
    case Opcodes.LLOAD:
        if (this.shouldMutate("Decremented (a--) long local variable number " + var)) {
            mv.visitInsn(Opcodes.DUP2);
            mv.visitInsn(Opcodes.LCONST_1);
            mv.visitInsn(Opcodes.LSUB);
            mv.visitVarInsn(Opcodes.LSTORE, var);
        }
        break;
    case Opcodes.DLOAD:
        if (this.shouldMutate("Decremented (a--) double local variable number " + var)) {
            mv.visitInsn(Opcodes.DUP2);
            mv.visitInsn(Opcodes.DCONST_1);
            mv.visitInsn(Opcodes.DSUB);
            mv.visitVarInsn(Opcodes.DSTORE, var);
        }
        break;
    default:
        break;
    }
}

From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator3.java

License:Apache License

@Override
public void visitVarInsn(int opcode, int var) {
    switch (opcode) {
    case Opcodes.ILOAD:
        if (this.shouldMutate("Incremented (++a) integer local variable number " + var)) {
            mv.visitIincInsn(var, 1);
        }/*from w ww .  j a  v  a2s  .  c  o  m*/
        mv.visitVarInsn(opcode, var);
        break;
    case Opcodes.FLOAD:
        if (this.shouldMutate("Incremented (++a) float local variable number " + var)) {
            mv.visitVarInsn(opcode, var);
            mv.visitInsn(Opcodes.FCONST_1);
            mv.visitInsn(Opcodes.FADD);
            mv.visitVarInsn(Opcodes.FSTORE, var);
        }
        mv.visitVarInsn(opcode, var);
        break;
    case Opcodes.LLOAD:
        if (this.shouldMutate("Incremented (++a) long local variable number " + var)) {
            mv.visitVarInsn(opcode, var);
            mv.visitInsn(Opcodes.LCONST_1);
            mv.visitInsn(Opcodes.LADD);
            mv.visitVarInsn(Opcodes.LSTORE, var);
        }
        mv.visitVarInsn(opcode, var);
        break;
    case Opcodes.DLOAD:
        if (this.shouldMutate("Incremented (++a) double local variable number " + var)) {
            mv.visitVarInsn(opcode, var);
            mv.visitInsn(Opcodes.DCONST_1);
            mv.visitInsn(Opcodes.DADD);
            mv.visitVarInsn(Opcodes.DSTORE, var);
        }
        mv.visitVarInsn(opcode, var);
        break;
    default:
        mv.visitVarInsn(opcode, var);
        break;
    }
}

From source file:org.pitest.mutationtest.engine.gregor.mutators.experimental.extended.UOIMutator4.java

License:Apache License

@Override
public void visitVarInsn(int opcode, int var) {
    switch (opcode) {
    case Opcodes.ILOAD:
        if (this.shouldMutate("Decremented (--a) integer local variable number " + var)) {
            mv.visitIincInsn(var, -1);
        }/*from  ww w.  j a  v  a  2 s.c om*/
        mv.visitVarInsn(opcode, var);

        break;

    case Opcodes.FLOAD:
        if (this.shouldMutate("Decremented (--a) float local variable number " + var)) {
            mv.visitVarInsn(opcode, var);
            mv.visitInsn(Opcodes.FCONST_1);
            mv.visitInsn(Opcodes.FSUB);
            mv.visitVarInsn(Opcodes.FSTORE, var);
        }
        mv.visitVarInsn(opcode, var);

        break;

    case Opcodes.LLOAD:
        if (this.shouldMutate("Decremented (--a) long local variable number " + var)) {
            mv.visitVarInsn(opcode, var);
            mv.visitInsn(Opcodes.LCONST_1);
            mv.visitInsn(Opcodes.LSUB);
            mv.visitVarInsn(Opcodes.LSTORE, var);
        }
        mv.visitVarInsn(opcode, var);
        break;

    case Opcodes.DLOAD:
        if (this.shouldMutate("Decremented (--a) double local variable number " + var)) {
            mv.visitVarInsn(opcode, var);
            mv.visitInsn(Opcodes.DCONST_1);
            mv.visitInsn(Opcodes.DSUB);
            mv.visitVarInsn(Opcodes.DSTORE, var);
        }
        mv.visitVarInsn(opcode, var);
        break;

    default:
        mv.visitVarInsn(opcode, var);
        break;
    }
}

From source file:org.sonar.java.bytecode.se.BytecodeEGWalkerExecuteTest.java

License:Open Source License

@Test
public void test_store() throws Exception {
    int[] storeOpcodes = new int[] { Opcodes.ISTORE, Opcodes.LSTORE, Opcodes.FSTORE, Opcodes.DSTORE,
            Opcodes.ASTORE };//from w ww .  j av  a 2 s  .  com
    SymbolicValue sv = new SymbolicValue();
    ProgramState startState = ProgramState.EMPTY_STATE.stackValue(sv);
    for (int opcode : storeOpcodes) {
        ProgramState programState = execute(new Instruction(opcode, 67), startState);
        assertThat(programState.getValue(67)).isEqualTo(sv);
    }
}

From source file:org.spongepowered.despector.emitter.bytecode.statement.BytecodeLocalAssignmentEmitter.java

License:Open Source License

@Override
public void emit(BytecodeEmitterContext ctx, LocalAssignment stmt, boolean semicolon) {
    MethodVisitor mv = ctx.getMethodVisitor();
    TypeSignature type = stmt.getLocal().getType();
    ctx.emitInstruction(stmt.getValue(), type);
    if (type == ClassTypeSignature.INT || type == ClassTypeSignature.BOOLEAN || type == ClassTypeSignature.BYTE
            || type == ClassTypeSignature.SHORT || type == ClassTypeSignature.CHAR) {
        mv.visitVarInsn(Opcodes.ISTORE, stmt.getLocal().getIndex());
    } else if (type == ClassTypeSignature.LONG) {
        mv.visitVarInsn(Opcodes.LSTORE, stmt.getLocal().getIndex());
    } else if (type == ClassTypeSignature.FLOAT) {
        mv.visitVarInsn(Opcodes.FSTORE, stmt.getLocal().getIndex());
    } else if (type == ClassTypeSignature.DOUBLE) {
        mv.visitVarInsn(Opcodes.DSTORE, stmt.getLocal().getIndex());
    } else {//w  ww.j  a  v  a 2  s .c  o  m
        mv.visitVarInsn(Opcodes.ISTORE, stmt.getLocal().getIndex());
    }
    ctx.updateStack(-1);
}

From source file:pku.sei.checkedcoverage.slicing.Slicer.java

License:Creative Commons License

/**
 * select the last location that was not checked, and create new slice criterion for it.
 * remove the relative lines from unchecked lines, until all location are sliced.
 * @return the new created slice location for every class.
 *//*from w w  w  . j  a va2s  . c  o m*/
public static HashMap<String, TreeSet<Long>> sliceForUnchecked() {
    System.out.println("Trying to add checks");
    HashMap<String, TreeSet<Long>> sliceCreated = new HashMap<String, TreeSet<Long>>();
    HashMap<String, HashSet<Instruction>> uncheckedMap = getUncheckedMap();
    Iterator<String> it = uncheckedMap.keySet().iterator();
    List<String> cris = new ArrayList<String>();
    int crisNr = 0;
    while (it.hasNext()) {
        String key = it.next();
        sliceCreated.put(key, new TreeSet<Long>());
        HashSet<Instruction> insts = uncheckedMap.get(key);
        TreeSet<Integer> unchecked = new TreeSet<Integer>();
        HashMap<Integer, String> critInfoMap = new HashMap<Integer, String>();
        HashMap<Integer, HashSet<String>> varsMap = new HashMap<Integer, HashSet<String>>();
        for (Instruction inst : insts) {
            if (inst.getType().equals(InstructionType.FIELD) || inst.getType().equals(InstructionType.VAR)) {
                unchecked.add(inst.getLineNumber());
                if (!critInfoMap.containsKey(inst.getLineNumber())) {
                    critInfoMap.put(inst.getLineNumber(),
                            inst.getMethod().getReadClass().getName() + "." + inst.getMethod().getName());
                }
                if (!varsMap.containsKey(inst.getLineNumber())) {
                    varsMap.put(inst.getLineNumber(), new HashSet<String>());
                }
                if (inst.getType().equals(InstructionType.FIELD)) {
                    FieldInstruction fieldinst = (FieldInstruction) inst;
                    varsMap.get(inst.getLineNumber()).add(fieldinst.getFieldName());
                } else if (inst.getType().equals(InstructionType.VAR)) {
                    VarInstruction varinst = (VarInstruction) inst;
                    if (varinst.getOpcode() == Opcodes.DSTORE || varinst.getOpcode() == Opcodes.ASTORE
                            || varinst.getOpcode() == Opcodes.LSTORE || varinst.getOpcode() == Opcodes.ISTORE
                            || varinst.getOpcode() == Opcodes.FSTORE || varinst.getOpcode() == Opcodes.RET) {
                        String varname = inst.getMethod().getLocalVariables()[varinst.getLocalVarIndex()]
                                .getName();
                        varsMap.get(inst.getLineNumber()).add(varname);
                    }
                }
            }
        }
        while (!unchecked.isEmpty()) {
            int last = unchecked.last();
            String cri = critInfoMap.get(last) + ":" + last + ":*";
            cris.add(cri);
            System.out.println(++crisNr + " new check(s) added!" + cri);
            unchecked.removeAll(sliceUnchecked(cri));
            sliceCreated.get(key).add((long) last);
            unchecked.remove(last);
        }
    }
    System.out.println("Done!");
    return sliceCreated;
}

From source file:pku.sei.checkedcoverage.slicing.Slicer.java

License:Creative Commons License

public void process(ThreadId threadId, final List<SlicingCriterion> sc, boolean multithreaded)
        throws InterruptedException {
    DependencesExtractor<SlicerInstance> depExtractor = DependencesExtractor.forTrace(this.trace,
            SlicerInstanceFactory.instance);
    for (ProgressMonitor mon : this.progressMonitors)
        depExtractor.addProgressMonitor(mon);

    VisitorCapability[] capabilities = { VisitorCapability.CONTROL_DEPENDENCES,
            VisitorCapability.DATA_DEPENDENCES_READ_AFTER_WRITE, VisitorCapability.INSTRUCTION_EXECUTIONS,
            VisitorCapability.METHOD_ENTRY_LEAVE, VisitorCapability.CONTROL_DEPENDENCES };
    if (this.untracedCallVisitors.size() > 0)
        capabilities[capabilities.length - 1] = VisitorCapability.UNTRACED_METHOD_CALLS;

    final List<SliceVisitor> sliceVisitors0 = Slicer.this.sliceVisitors;
    final List<UntracedCallVisitor> untracedCallVisitors0 = Slicer.this.untracedCallVisitors;
    depExtractor.registerVisitor(new DependencesVisitorAdapter<SlicerInstance>() {
        private final List<SlicingCriterionInstance> slicingCritInst = instantiateSlicingCriteria(sc);
        @SuppressWarnings("unchecked")
        private IntegerMap<Object>[] interestingLocalVariables = (IntegerMap<Object>[]) new IntegerMap<?>[0];
        private long[] critOccurenceNumbers = new long[2]; // 0 if not in a criterion
        private final SliceVisitor[] sliceVisitorsArray = sliceVisitors0
                .toArray(new SliceVisitor[sliceVisitors0.size()]);
        private final UntracedCallVisitor[] untracedCallsVisitorsArray = untracedCallVisitors0
                .toArray(new UntracedCallVisitor[untracedCallVisitors0.size()]);

        private ReadMethod enteredMethod;

        private List<SlicingCriterionInstance> instantiateSlicingCriteria(List<SlicingCriterion> criteria) {
            if (criteria.isEmpty())
                return Collections.emptyList();
            else if (criteria.size() == 1)
                return Collections.singletonList(criteria.get(0).getInstance());
            else {
                List<SlicingCriterionInstance> instances = new ArrayList<SlicingCriterionInstance>(
                        criteria.size());
                for (SlicingCriterion crit : criteria)
                    instances.add(crit.getInstance());
                return instances;
            }//from ww  w . j  a  va  2 s .co  m
        }

        @Override
        public void visitInstructionExecution(SlicerInstance instance) {
            int stackDepth = instance.getStackDepth();
            if (this.critOccurenceNumbers.length <= stackDepth) {
                long[] newCritOccurenceNumbers = new long[2
                        * Math.max(this.critOccurenceNumbers.length, stackDepth)];
                System.arraycopy(this.critOccurenceNumbers, 0, newCritOccurenceNumbers, 0,
                        this.critOccurenceNumbers.length);
                this.critOccurenceNumbers = newCritOccurenceNumbers;
            }
            Instruction instruction = instance.getInstruction();
            for (SlicingCriterionInstance crit : this.slicingCritInst) {
                if (crit.matches(instance)) {
                    this.critOccurenceNumbers[stackDepth] = crit.getOccurenceNumber();
                    assert (this.critOccurenceNumbers[stackDepth] > 0);
                    // for each criterion, there are three cases:
                    //  - track all data read in this line
                    //  - track a given set of local variables
                    //  - track the control dependences of this instruction
                    // only in the last case, the instructions from that line are added to the dynamic slice
                    if (crit.matchAllData()) {
                        instance.allDataInteresting = true;
                        instance.onlyIfAfterCriterion = true;
                        instance.onDynamicSlice = true; // it's not really on the dynamic slice, but we have to set this
                        instance.criterionDistance = 0;
                    } else {
                        if (crit.hasLocalVariables()) {
                            if (this.interestingLocalVariables.length <= stackDepth) {
                                @SuppressWarnings("unchecked")
                                IntegerMap<Object>[] newInterestingLocalVariables = (IntegerMap<Object>[]) new IntegerMap<?>[Math
                                        .max(stackDepth + 1, this.interestingLocalVariables.length * 3 / 2)];
                                System.arraycopy(this.interestingLocalVariables, 0,
                                        newInterestingLocalVariables, 0, this.interestingLocalVariables.length);
                                this.interestingLocalVariables = newInterestingLocalVariables;
                            }
                            List<LocalVariable> localVariables = crit.getLocalVariables();
                            if (this.interestingLocalVariables[stackDepth] == null)
                                this.interestingLocalVariables[stackDepth] = new IntegerMap<Object>(
                                        localVariables.size() * 4 / 3 + 1);
                            for (LocalVariable i : localVariables)
                                this.interestingLocalVariables[stackDepth].put(i.getIndex(), null);
                        } else {
                            Instruction insn = instruction;
                            if (insn.getType() != InstructionType.LABEL)
                                for (SliceVisitor vis : this.sliceVisitorsArray)
                                    vis.visitMatchedInstance(instance);
                            instance.onDynamicSlice = true;
                            instance.criterionDistance = 0;
                        }
                    }
                } else if (this.critOccurenceNumbers[stackDepth] != 0) {
                    this.critOccurenceNumbers[stackDepth] = 0;
                }
            }
            if (this.interestingLocalVariables.length > stackDepth
                    && this.interestingLocalVariables[stackDepth] != null) {
                switch (instruction.getOpcode()) {
                case Opcodes.ISTORE:
                case Opcodes.ASTORE:
                case Opcodes.LSTORE:
                case Opcodes.FSTORE:
                case Opcodes.DSTORE:
                    VarInstruction varInsn = (VarInstruction) instruction;
                    if (this.interestingLocalVariables[stackDepth].containsKey(varInsn.getLocalVarIndex())) {
                        this.interestingLocalVariables[stackDepth].remove(varInsn.getLocalVarIndex());
                        if (this.interestingLocalVariables[stackDepth].isEmpty())
                            this.interestingLocalVariables[stackDepth] = null;
                        for (SliceVisitor vis : this.sliceVisitorsArray)
                            vis.visitMatchedInstance(instance);
                        instance.onDynamicSlice = true;
                        // and we want to know where the data comes from...
                        instance.allDataInteresting = true;
                        instance.criterionDistance = 0;
                    }
                    break;
                case Opcodes.INVOKEINTERFACE:
                case Opcodes.INVOKESPECIAL:
                case Opcodes.INVOKESTATIC:
                case Opcodes.INVOKEVIRTUAL:
                    if (this.enteredMethod != null) {
                        MethodInvocationInstruction mtdInvInsn = (MethodInvocationInstruction) instruction;
                        int paramCount = instruction.getOpcode() == INVOKESTATIC ? 0 : 1;
                        for (int param = mtdInvInsn.getParameterCount() - 1; param >= 0; --param)
                            paramCount += mtdInvInsn.parameterIsLong(param) ? 2 : 1;
                        boolean enteredMethodMatches = this.enteredMethod.getName()
                                .equals(mtdInvInsn.getInvokedMethodName())
                                && this.enteredMethod.getDesc().equals(mtdInvInsn.getInvokedMethodDesc());
                        if (enteredMethodMatches) {
                            boolean localVarsMatched = false;
                            for (int varNr = 0; varNr < paramCount; ++varNr) {
                                if (this.interestingLocalVariables[stackDepth].containsKey(varNr)) {
                                    this.interestingLocalVariables[stackDepth].remove(varNr);
                                    if (this.interestingLocalVariables[stackDepth].isEmpty())
                                        this.interestingLocalVariables[stackDepth] = null;
                                    localVarsMatched = true;
                                    instance.onDynamicSlice = true;
                                    // and we want to know where the data comes from...
                                    // TODO
                                    instance.allDataInteresting = true;
                                    instance.criterionDistance = 0;
                                }
                            }
                            if (localVarsMatched)
                                for (SliceVisitor vis : this.sliceVisitorsArray)
                                    vis.visitMatchedInstance(instance);
                        }
                    }
                }
            }
            this.enteredMethod = null;
        }

        @Override
        public void visitControlDependence(SlicerInstance from, SlicerInstance to) {
            if (from.onDynamicSlice) {
                Instruction insn = to.getInstruction();
                if (insn.getType() == InstructionType.LABEL || insn.getOpcode() == Opcodes.GOTO) {
                    if (to.predecessors == null)
                        to.predecessors = Collections.singleton(from);
                    else {
                        if (to.predecessors.size() == 1)
                            to.predecessors = new HashSet<SlicerInstance>(to.predecessors);
                        to.predecessors.add(from);
                    }
                    if (from.criterionDistance < to.criterionDistance)
                        to.criterionDistance = from.criterionDistance;
                } else if (from.predecessors != null) {
                    assert (!from.predecessors.isEmpty());
                    for (SlicerInstance pred : from.predecessors) {
                        int distance = pred.criterionDistance + 1;
                        delegateControlSliceDependence(pred, to, distance);
                        if (distance < to.criterionDistance)
                            to.criterionDistance = distance;
                    }
                } else {
                    int distance = from.criterionDistance + 1;
                    delegateControlSliceDependence(from, to, distance);
                    if (distance < to.criterionDistance)
                        to.criterionDistance = distance;
                }
                to.onDynamicSlice = true;
            }
        }

        private void delegateControlSliceDependence(SlicerInstance from, SlicerInstance to, int distance) {

            for (SliceVisitor vis : this.sliceVisitorsArray)
                vis.visitSliceDependence(from, to, null, distance);

            // since "to" controls the execution of "from", we want to track all data dependences of "to"
            // to find out why it took this decision
            // exception: method invocations; here we only want to track why the method was executed,
            // but not the data that it consumed
            // important to check that "from" comes from inside the method which is called by "from"
            boolean calledMethodDependence = false;
            if (to.getInstruction().getType() == InstructionType.METHODINVOCATION) {
                MethodInvocationInstruction mtdInv = (MethodInvocationInstruction) to.getInstruction();
                ReadMethod calledMethod = from.getInstruction().getMethod();
                if (mtdInv.getInvokedMethodName().equals(calledMethod.getName())
                        && mtdInv.getInvokedMethodDesc().equals(calledMethod.getDesc())) {
                    calledMethodDependence = true;
                }
            }
            if (!calledMethodDependence) {
                to.allDataInteresting = true;
            }
        }

        @Override
        public void visitDataDependence(SlicerInstance from, SlicerInstance to,
                Collection<? extends Variable> fromVars, Variable toVar, DataDependenceType type)
                throws InterruptedException {
            assert type == DataDependenceType.READ_AFTER_WRITE;

            if (from.onDynamicSlice && // from must definitively be on the dynamic slice
            ((from.allDataInteresting
                    && (!from.onlyIfAfterCriterion || this.critOccurenceNumbers[to.getStackDepth()] == 0)) || // and either we want to track all data dependencies
            (from.interestingVariable != null && ( // or (if the interestingVariable is set) ...
            from.interestingVariable.equals(toVar) || // the interestingVariable must be the one we are just visiting
            (from.moreInterestingVariables != null && from.moreInterestingVariables.contains(toVar)))))) { // or it must be in the set of more variables
                Instruction insn = to.getInstruction();
                assert insn.getType() != InstructionType.LABEL;
                if (from.onlyIfAfterCriterion) {
                    to.criterionDistance = 0;
                    for (SliceVisitor vis : this.sliceVisitorsArray)
                        vis.visitMatchedInstance(to);
                } else {
                    int distance = from.criterionDistance + 1;
                    if (distance < to.criterionDistance)
                        to.criterionDistance = distance;
                    for (SliceVisitor vis : this.sliceVisitorsArray)
                        vis.visitSliceDependence(from, to, toVar, distance);
                }
                if (!fromVars.isEmpty()) {
                    Iterator<? extends Variable> varIt = fromVars.iterator();
                    assert varIt
                            .hasNext() : "Iterator of a non-empty collection should have at least one element";
                    Variable first = varIt.next();
                    if (to.interestingVariable == null || to.interestingVariable.equals(first)) {
                        to.interestingVariable = first;
                        first = varIt.hasNext() ? varIt.next() : null;
                    }
                    if (first != null) {
                        if (to.moreInterestingVariables == null)
                            to.moreInterestingVariables = new HashSet<Variable>(8);
                        to.moreInterestingVariables.add(first);
                        while (varIt.hasNext())
                            to.moreInterestingVariables.add(varIt.next());
                    }
                }
                to.onDynamicSlice = true;
            }
        }

        @Override
        public void visitMethodLeave(ReadMethod method, int stackDepth) throws InterruptedException {
            if (this.interestingLocalVariables.length > stackDepth
                    && this.interestingLocalVariables[stackDepth] != null) {
                this.interestingLocalVariables[stackDepth] = null;
            }
        }

        @Override
        public void visitMethodEntry(ReadMethod method, int stackDepth) throws InterruptedException {
            if (this.interestingLocalVariables.length > stackDepth
                    && this.interestingLocalVariables[stackDepth] != null) {
                this.enteredMethod = method;
                this.interestingLocalVariables[stackDepth] = null;
            }
        }

        @Override
        public void visitUntracedMethodCall(SlicerInstance instrInstance) throws InterruptedException {
            for (UntracedCallVisitor vis : this.untracedCallsVisitorsArray)
                vis.visitUntracedMethodCall(instrInstance);
        }

    }, capabilities);

    depExtractor.processBackwardTrace(threadId, multithreaded);
}