Search in sources :

Example 1 with ParallellMappingExecutor

use of net.runelite.asm.execution.ParallellMappingExecutor in project runelite by runelite.

the class MappingExecutorUtil method map.

public static ParallelExecutorMapping map(Method m1, Method m2) {
    ClassGroup group1 = m1.getClassFile().getGroup();
    ClassGroup group2 = m2.getClassFile().getGroup();
    Execution e = new Execution(group1);
    e.step = true;
    Frame frame = new Frame(e, m1);
    frame.initialize();
    e.frames.add(frame);
    Execution e2 = new Execution(group2);
    e2.step = true;
    Frame frame2 = new Frame(e2, m2);
    frame2.initialize();
    e2.frames.add(frame2);
    frame.other = frame2;
    frame2.other = frame;
    ParallellMappingExecutor parallel = new ParallellMappingExecutor(e, e2);
    ParallelExecutorMapping mappings = new ParallelExecutorMapping(m1.getClassFile().getGroup(), m2.getClassFile().getGroup());
    mappings.m1 = m1;
    mappings.m2 = m2;
    parallel.mappings = mappings;
    int same = 0;
    while (parallel.step()) {
        // get what each frame is paused/exited on
        InstructionContext p1 = parallel.getP1(), p2 = parallel.getP2();
        assert p1.getInstruction() instanceof MappableInstruction;
        assert p2.getInstruction() instanceof MappableInstruction;
        MappableInstruction mi1 = (MappableInstruction) p1.getInstruction(), mi2 = (MappableInstruction) p2.getInstruction();
        boolean isSame = mi1.isSame(p1, p2);
        assert isSame == mi2.isSame(p2, p1) : "isSame fail " + p1.getInstruction() + " <> " + p2.getInstruction();
        if (!isSame) {
            mappings.crashed = true;
            p1.getFrame().stop();
            p2.getFrame().stop();
            continue;
        }
        ++same;
        mi1.map(mappings, p1, p2);
    }
    mappings.same = same;
    return mappings;
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) Frame(net.runelite.asm.execution.Frame) MappableInstruction(net.runelite.asm.attributes.code.instruction.types.MappableInstruction) Execution(net.runelite.asm.execution.Execution) ClassGroup(net.runelite.asm.ClassGroup) ParallellMappingExecutor(net.runelite.asm.execution.ParallellMappingExecutor)

Aggregations

ClassGroup (net.runelite.asm.ClassGroup)1 MappableInstruction (net.runelite.asm.attributes.code.instruction.types.MappableInstruction)1 Execution (net.runelite.asm.execution.Execution)1 Frame (net.runelite.asm.execution.Frame)1 InstructionContext (net.runelite.asm.execution.InstructionContext)1 ParallellMappingExecutor (net.runelite.asm.execution.ParallellMappingExecutor)1