Esempio n. 1
0
  private static void shiftIndex0(
      CodeIterator ci, int index, int opcode, int lessThan, int delta, int opcode_i_0, int opcode_i)
      throws BadBytecode {
    int var = (opcode - opcode_i_0) % 4;
    if (var < lessThan) return;

    var += delta;
    if (var < 4) ci.writeByte(opcode + delta, index);
    else {
      opcode = (opcode - opcode_i_0) / 4 + opcode_i;
      if (var < 0x100) {
        int pos = ci.insertExGap(1);
        ci.writeByte(opcode, pos - 1);
        ci.writeByte(var, pos);
      } else {
        int pos = ci.insertExGap(3);
        ci.writeByte(WIDE, pos - 1);
        ci.writeByte(opcode, pos);
        ci.write16bit(var, pos + 1);
      }
    }
  }
Esempio n. 2
0
  private static void shiftIndex8(CodeIterator ci, int index, int opcode, int lessThan, int delta)
      throws BadBytecode {
    int var = ci.byteAt(index + 1);
    if (var < lessThan) return;

    var += delta;
    if (var < 0x100) ci.writeByte(var, index + 1);
    else {
      int pos = ci.insertExGap(2);
      ci.writeByte(WIDE, pos - 2);
      ci.writeByte(opcode, pos - 1);
      ci.write16bit(var, pos);
    }
  }
Esempio n. 3
0
  /**
   * @param lessThan If the index of the local variable is less than this value, it does not change.
   *     Otherwise, the index is increased.
   * @param delta the indexes of the local variables are increased by this value.
   */
  private static void shiftIndex(CodeIterator ci, int lessThan, int delta) throws BadBytecode {
    int index = ci.next();
    int opcode = ci.byteAt(index);
    if (opcode < ILOAD) return;
    else if (opcode < IASTORE) {
      if (opcode < ILOAD_0) {
        // iload, lload, fload, dload, aload
        shiftIndex8(ci, index, opcode, lessThan, delta);
      } else if (opcode < IALOAD) {
        // iload_0, ..., aload_3
        shiftIndex0(ci, index, opcode, lessThan, delta, ILOAD_0, ILOAD);
      } else if (opcode < ISTORE) return;
      else if (opcode < ISTORE_0) {
        // istore, lstore, ...
        shiftIndex8(ci, index, opcode, lessThan, delta);
      } else {
        // istore_0, ..., astore_3
        shiftIndex0(ci, index, opcode, lessThan, delta, ISTORE_0, ISTORE);
      }
    } else if (opcode == IINC) {
      int var = ci.byteAt(index + 1);
      if (var < lessThan) return;

      var += delta;
      if (var < 0x100) ci.writeByte(var, index + 1);
      else {
        int plus = (byte) ci.byteAt(index + 2);
        int pos = ci.insertExGap(3);
        ci.writeByte(WIDE, pos - 3);
        ci.writeByte(IINC, pos - 2);
        ci.write16bit(var, pos - 1);
        ci.write16bit(plus, pos + 1);
      }
    } else if (opcode == RET) shiftIndex8(ci, index, opcode, lessThan, delta);
    else if (opcode == WIDE) {
      int var = ci.u16bitAt(index + 2);
      if (var < lessThan) return;

      var += delta;
      ci.write16bit(var, index + 2);
    }
  }