@Test public void testIsSame() { Instructions ins = mock(Instructions.class); Frame frame = mock(Frame.class); Stack stack = new Stack(42); Variables variables = new Variables(42); when(frame.getStack()).thenReturn(stack); when(frame.getVariables()).thenReturn(variables); IfICmpEq ifeq = new IfICmpEq(ins, InstructionType.IF_ICMPEQ); InstructionContext ifeqCtx = new InstructionContext(ifeq, frame); ifeqCtx.pop(new StackContext(getConstantCtx(ins, 1), INT, new Value(1))); ifeqCtx.pop(new StackContext(getConstantCtx(ins, 1), INT, new Value(1))); IfNe ifne = new IfNe(ins, InstructionType.IFNE); InstructionContext ifneCtx = new InstructionContext(ifne, frame); ifneCtx.pop(new StackContext(getConstantCtx(ins, 42), INT, new Value(42))); assertTrue(ifeq.isSame(ifeqCtx, ifneCtx)); }
@Override public boolean isSame(InstructionContext thisIc, InstructionContext otherIc) { if (!(otherIc.getInstruction() instanceof ComparisonInstruction)) { return false; } if (!this.isSameField(thisIc, otherIc)) { return false; } if (thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass()) { return true; } if (otherIc.getInstruction() instanceof IfEq || otherIc.getInstruction() instanceof IfNe) { StackContext s1 = thisIc.getPops().get(0), s2 = thisIc.getPops().get(1); if (isZero(s1) || isZero(s2) || isOne(s1) || isOne(s2)) { return true; } } else if (otherIc.getInstruction() instanceof IfICmpNe) { return true; } return false; }
IfICmpEq extends If { @Override public boolean isSame(InstructionContext thisIc, InstructionContext otherIc) { if (!(otherIc.getInstruction() instanceof ComparisonInstruction)) { return false; } if (!this.isSameField(thisIc, otherIc)) { return false; } if (thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass()) { return true; } if (otherIc.getInstruction() instanceof IfEq || otherIc.getInstruction() instanceof IfNe) { StackContext s1 = thisIc.getPops().get(0), s2 = thisIc.getPops().get(1); if (isZero(s1) || isZero(s2) || isOne(s1) || isOne(s2)) { return true; } } else if (otherIc.getInstruction() instanceof IfICmpNe) { return true; } return false; } }
IfICmpEq extends If { @Override public boolean isSame(InstructionContext thisIc, InstructionContext otherIc) { if (!(otherIc.getInstruction() instanceof ComparisonInstruction)) { return false; } if (!this.isSameField(thisIc, otherIc)) { return false; } if (thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass()) { return true; } if (otherIc.getInstruction() instanceof IfEq || otherIc.getInstruction() instanceof IfNe) { StackContext s1 = thisIc.getPops().get(0), s2 = thisIc.getPops().get(1); if (isZero(s1) || isZero(s2) || isOne(s1) || isOne(s2)) { return true; } } else if (otherIc.getInstruction() instanceof IfICmpNe) { return true; } return false; } IfICmpEq(Instructions instructions, InstructionType type);  IfICmpEq(Instructions instructions, Label to); }
IfICmpEq extends If { @Override public boolean isSame(InstructionContext thisIc, InstructionContext otherIc) { if (!(otherIc.getInstruction() instanceof ComparisonInstruction)) { return false; } if (!this.isSameField(thisIc, otherIc)) { return false; } if (thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass()) { return true; } if (otherIc.getInstruction() instanceof IfEq || otherIc.getInstruction() instanceof IfNe) { StackContext s1 = thisIc.getPops().get(0), s2 = thisIc.getPops().get(1); if (isZero(s1) || isZero(s2) || isOne(s1) || isOne(s2)) { return true; } } else if (otherIc.getInstruction() instanceof IfICmpNe) { return true; } return false; } IfICmpEq(Instructions instructions, InstructionType type);  IfICmpEq(Instructions instructions, Label to); @Override boolean isSame(InstructionContext thisIc, InstructionContext otherIc); @Override void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other); }
IfICmpEq extends If { @Override public boolean isSame(InstructionContext thisIc, InstructionContext otherIc) { if (!(otherIc.getInstruction() instanceof ComparisonInstruction)) { return false; } if (!this.isSameField(thisIc, otherIc)) { return false; } if (thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass()) { return true; } if (otherIc.getInstruction() instanceof IfEq || otherIc.getInstruction() instanceof IfNe) { StackContext s1 = thisIc.getPops().get(0), s2 = thisIc.getPops().get(1); if (isZero(s1) || isZero(s2) || isOne(s1) || isOne(s2)) { return true; } } else if (otherIc.getInstruction() instanceof IfICmpNe) { return true; } return false; } IfICmpEq(Instructions instructions, InstructionType type);  IfICmpEq(Instructions instructions, Label to); @Override boolean isSame(InstructionContext thisIc, InstructionContext otherIc); @Override void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other);  }