case PACKED_SWITCH: { MethodLocation targetLocation = ((BuilderOffsetInstruction) instruction).getTarget().getLocation(); BuilderInstruction targetInstruction = targetLocation.instruction; if (targetInstruction == null) { switch (instruction.getOpcode()) { case GOTO: { int offset = ((BuilderOffsetInstruction) instruction).internalGetCodeOffset(); if (offset < Byte.MIN_VALUE || offset > Byte.MAX_VALUE) { BuilderOffsetInstruction replacement; if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) { replacement = new BuilderInstruction30t(Opcode.GOTO_32, ((BuilderOffsetInstruction) instruction).getTarget()); } else { replacement = new BuilderInstruction20t(Opcode.GOTO_16, ((BuilderOffsetInstruction) instruction).getTarget()); int offset = ((BuilderOffsetInstruction) instruction).internalGetCodeOffset(); if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) { BuilderOffsetInstruction replacement = new BuilderInstruction30t(Opcode.GOTO_32, ((BuilderOffsetInstruction) instruction).getTarget()); replaceInstruction(location.index, replacement); madeChanges = true;
if (jumpInsn instanceof InsnWithOffset) { InsnWithOffset offsetInsn = (InsnWithOffset) jumpInsn; Integer targetOffset = labelsToOffsets.get(boj.getTarget()); if (targetOffset == null) { continue; if (Math.abs(distance) > offsetInsn.getMaxJumpOffset()) { insertIntermediateJump(labelsToIndex.get(boj.getTarget()), j, stmtV, instructions, labelAssigner); hasChanged = true; continue l0;
@Override public int getCodeOffset() { int codeOffset = internalGetCodeOffset(); if ((this.getCodeUnits() == 1 && (codeOffset < Byte.MIN_VALUE || codeOffset > Byte.MAX_VALUE)) || (this.getCodeUnits() == 2 && (codeOffset < Short.MIN_VALUE || codeOffset > Short.MAX_VALUE))) { throw new IllegalStateException("Target is out of range"); } return codeOffset; }
int internalGetCodeOffset() { return target.getCodeAddress() - this.getLocation().getCodeAddress(); }
@Override public Op create(MethodLocation location, TIntObjectMap<MethodLocation> addressToLocation, VirtualMachine vm) { BuilderInstruction instruction = (BuilderInstruction) location.getInstruction(); Label target = ((BuilderOffsetInstruction) instruction).getTarget(); int targetAddress = target.getCodeAddress(); MethodLocation child = addressToLocation.get(targetAddress); return new GotoOp(location, child); } }
@Override public int getCodeOffset() { int codeOffset = internalGetCodeOffset(); if (this.getCodeUnits() == 1) { if (codeOffset < Byte.MIN_VALUE || codeOffset > Byte.MAX_VALUE) { throw new ExceptionWithContext("Invalid instruction offset: %d. " + "Offset must be in [-128, 127]", codeOffset); } } else if (this.getCodeUnits() == 2) { if (codeOffset < Short.MIN_VALUE || codeOffset > Short.MAX_VALUE) { throw new ExceptionWithContext("Invalid instruction offset: %d. " + "Offset must be in [-32768, 32767]", codeOffset); } } return codeOffset; }
int internalGetCodeOffset() { return target.getCodeAddress() - this.getLocation().getCodeAddress(); }
case PACKED_SWITCH: { MethodLocation targetLocation = ((BuilderOffsetInstruction) instruction).getTarget().getLocation(); BuilderInstruction targetInstruction = targetLocation.instruction; if (targetInstruction == null) { switch (instruction.getOpcode()) { case GOTO: { int offset = ((BuilderOffsetInstruction) instruction).internalGetCodeOffset(); if (offset < Byte.MIN_VALUE || offset > Byte.MAX_VALUE) { BuilderOffsetInstruction replacement; if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) { replacement = new BuilderInstruction30t(Opcode.GOTO_32, ((BuilderOffsetInstruction) instruction).getTarget()); } else { replacement = new BuilderInstruction20t(Opcode.GOTO_16, ((BuilderOffsetInstruction) instruction).getTarget()); int offset = ((BuilderOffsetInstruction) instruction).internalGetCodeOffset(); if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) { BuilderOffsetInstruction replacement = new BuilderInstruction30t(Opcode.GOTO_32, ((BuilderOffsetInstruction) instruction).getTarget()); replaceInstruction(location.index, replacement); madeChanges = true;
} else { BuilderOffsetInstruction original = (BuilderOffsetInstruction) manipulator.getInstruction(address); Label target = original.getTarget(); replacement = new BuilderInstruction30t(Opcode.GOTO_32, target);
@Override public int getCodeOffset() { int codeOffset = internalGetCodeOffset(); if (this.getCodeUnits() == 1) { if (codeOffset < Byte.MIN_VALUE || codeOffset > Byte.MAX_VALUE) { throw new ExceptionWithContext("Invalid instruction offset: %d. " + "Offset must be in [-128, 127]", codeOffset); } } else if (this.getCodeUnits() == 2) { if (codeOffset < Short.MIN_VALUE || codeOffset > Short.MAX_VALUE) { throw new ExceptionWithContext("Invalid instruction offset: %d. " + "Offset must be in [-32768, 32767]", codeOffset); } } return codeOffset; }
int internalGetCodeOffset() { return target.getCodeAddress() - this.getLocation().getCodeAddress(); }
case PACKED_SWITCH: { MethodLocation targetLocation = ((BuilderOffsetInstruction)instruction).getTarget().getLocation(); BuilderInstruction targetInstruction = targetLocation.instruction; if (targetInstruction == null) { switch (instruction.getOpcode()) { case GOTO: { int offset = ((BuilderOffsetInstruction)instruction).internalGetCodeOffset(); if (offset < Byte.MIN_VALUE || offset > Byte.MAX_VALUE) { BuilderOffsetInstruction replacement; if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) { replacement = new BuilderInstruction30t(Opcode.GOTO_32, ((BuilderOffsetInstruction)instruction).getTarget()); } else { replacement = new BuilderInstruction20t(Opcode.GOTO_16, ((BuilderOffsetInstruction)instruction).getTarget()); int offset = ((BuilderOffsetInstruction)instruction).internalGetCodeOffset(); if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) { BuilderOffsetInstruction replacement = new BuilderInstruction30t(Opcode.GOTO_32, ((BuilderOffsetInstruction)instruction).getTarget()); replaceInstruction(location.index, replacement); madeChanges = true;
case PACKED_SWITCH: { MethodLocation targetLocation = ((BuilderOffsetInstruction)instruction).getTarget().getLocation(); BuilderInstruction targetInstruction = targetLocation.instruction; if (targetInstruction == null) { switch (instruction.getOpcode()) { case GOTO: { int offset = ((BuilderOffsetInstruction)instruction).internalGetCodeOffset(); if (offset < Byte.MIN_VALUE || offset > Byte.MAX_VALUE) { BuilderOffsetInstruction replacement; if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) { replacement = new BuilderInstruction30t(Opcode.GOTO_32, ((BuilderOffsetInstruction)instruction).getTarget()); } else { replacement = new BuilderInstruction20t(Opcode.GOTO_16, ((BuilderOffsetInstruction)instruction).getTarget()); int offset = ((BuilderOffsetInstruction)instruction).internalGetCodeOffset(); if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) { BuilderOffsetInstruction replacement = new BuilderInstruction30t(Opcode.GOTO_32, ((BuilderOffsetInstruction)instruction).getTarget()); replaceInstruction(location.index, replacement); madeChanges = true;
case PACKED_SWITCH: { MethodLocation targetLocation = ((BuilderOffsetInstruction)instruction).getTarget().getLocation(); BuilderInstruction targetInstruction = targetLocation.instruction; if (targetInstruction == null) { switch (instruction.getOpcode()) { case GOTO: { int offset = ((BuilderOffsetInstruction)instruction).internalGetCodeOffset(); if (offset < Byte.MIN_VALUE || offset > Byte.MAX_VALUE) { BuilderOffsetInstruction replacement; if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) { replacement = new BuilderInstruction30t(Opcode.GOTO_32, ((BuilderOffsetInstruction)instruction).getTarget()); } else { replacement = new BuilderInstruction20t(Opcode.GOTO_16, ((BuilderOffsetInstruction)instruction).getTarget()); int offset = ((BuilderOffsetInstruction)instruction).internalGetCodeOffset(); if (offset < Short.MIN_VALUE || offset > Short.MAX_VALUE) { BuilderOffsetInstruction replacement = new BuilderInstruction30t(Opcode.GOTO_32, ((BuilderOffsetInstruction)instruction).getTarget()); replaceInstruction(location.index, replacement); madeChanges = true;