diff options
Diffstat (limited to 'dx/src/com/android/dx/io')
-rw-r--r-- | dx/src/com/android/dx/io/DexBuffer.java | 2 | ||||
-rw-r--r-- | dx/src/com/android/dx/io/OpcodeInfo.java | 195 | ||||
-rw-r--r-- | dx/src/com/android/dx/io/Opcodes.java | 39 | ||||
-rw-r--r-- | dx/src/com/android/dx/io/instructions/DecodedInstruction.java | 5 | ||||
-rw-r--r-- | dx/src/com/android/dx/io/instructions/InstructionCodec.java | 133 |
5 files changed, 3 insertions, 371 deletions
diff --git a/dx/src/com/android/dx/io/DexBuffer.java b/dx/src/com/android/dx/io/DexBuffer.java index e6f908bfa..39e5858e6 100644 --- a/dx/src/com/android/dx/io/DexBuffer.java +++ b/dx/src/com/android/dx/io/DexBuffer.java @@ -217,7 +217,7 @@ public final class DexBuffer { return length; } - private static int fourByteAlign(int position) { + public static int fourByteAlign(int position) { return (position + 3) & ~3; } diff --git a/dx/src/com/android/dx/io/OpcodeInfo.java b/dx/src/com/android/dx/io/OpcodeInfo.java index c8fcf25d5..2040d352c 100644 --- a/dx/src/com/android/dx/io/OpcodeInfo.java +++ b/dx/src/com/android/dx/io/OpcodeInfo.java @@ -931,162 +931,6 @@ public final class OpcodeInfo { new Info(Opcodes.USHR_INT_LIT8, "ushr-int/lit8", InstructionCodec.FORMAT_22B, IndexType.NONE); - public static final Info CONST_CLASS_JUMBO = - new Info(Opcodes.CONST_CLASS_JUMBO, "const-class/jumbo", - InstructionCodec.FORMAT_41C, IndexType.TYPE_REF); - - public static final Info CHECK_CAST_JUMBO = - new Info(Opcodes.CHECK_CAST_JUMBO, "check-cast/jumbo", - InstructionCodec.FORMAT_41C, IndexType.TYPE_REF); - - public static final Info INSTANCE_OF_JUMBO = - new Info(Opcodes.INSTANCE_OF_JUMBO, "instance-of/jumbo", - InstructionCodec.FORMAT_52C, IndexType.TYPE_REF); - - public static final Info NEW_INSTANCE_JUMBO = - new Info(Opcodes.NEW_INSTANCE_JUMBO, "new-instance/jumbo", - InstructionCodec.FORMAT_41C, IndexType.TYPE_REF); - - public static final Info NEW_ARRAY_JUMBO = - new Info(Opcodes.NEW_ARRAY_JUMBO, "new-array/jumbo", - InstructionCodec.FORMAT_52C, IndexType.TYPE_REF); - - public static final Info FILLED_NEW_ARRAY_JUMBO = - new Info(Opcodes.FILLED_NEW_ARRAY_JUMBO, "filled-new-array/jumbo", - InstructionCodec.FORMAT_5RC, IndexType.TYPE_REF); - - public static final Info IGET_JUMBO = - new Info(Opcodes.IGET_JUMBO, "iget/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info IGET_WIDE_JUMBO = - new Info(Opcodes.IGET_WIDE_JUMBO, "iget-wide/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info IGET_OBJECT_JUMBO = - new Info(Opcodes.IGET_OBJECT_JUMBO, "iget-object/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info IGET_BOOLEAN_JUMBO = - new Info(Opcodes.IGET_BOOLEAN_JUMBO, "iget-boolean/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info IGET_BYTE_JUMBO = - new Info(Opcodes.IGET_BYTE_JUMBO, "iget-byte/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info IGET_CHAR_JUMBO = - new Info(Opcodes.IGET_CHAR_JUMBO, "iget-char/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info IGET_SHORT_JUMBO = - new Info(Opcodes.IGET_SHORT_JUMBO, "iget-short/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info IPUT_JUMBO = - new Info(Opcodes.IPUT_JUMBO, "iput/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info IPUT_WIDE_JUMBO = - new Info(Opcodes.IPUT_WIDE_JUMBO, "iput-wide/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info IPUT_OBJECT_JUMBO = - new Info(Opcodes.IPUT_OBJECT_JUMBO, "iput-object/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info IPUT_BOOLEAN_JUMBO = - new Info(Opcodes.IPUT_BOOLEAN_JUMBO, "iput-boolean/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info IPUT_BYTE_JUMBO = - new Info(Opcodes.IPUT_BYTE_JUMBO, "iput-byte/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info IPUT_CHAR_JUMBO = - new Info(Opcodes.IPUT_CHAR_JUMBO, "iput-char/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info IPUT_SHORT_JUMBO = - new Info(Opcodes.IPUT_SHORT_JUMBO, "iput-short/jumbo", - InstructionCodec.FORMAT_52C, IndexType.FIELD_REF); - - public static final Info SGET_JUMBO = - new Info(Opcodes.SGET_JUMBO, "sget/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info SGET_WIDE_JUMBO = - new Info(Opcodes.SGET_WIDE_JUMBO, "sget-wide/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info SGET_OBJECT_JUMBO = - new Info(Opcodes.SGET_OBJECT_JUMBO, "sget-object/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info SGET_BOOLEAN_JUMBO = - new Info(Opcodes.SGET_BOOLEAN_JUMBO, "sget-boolean/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info SGET_BYTE_JUMBO = - new Info(Opcodes.SGET_BYTE_JUMBO, "sget-byte/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info SGET_CHAR_JUMBO = - new Info(Opcodes.SGET_CHAR_JUMBO, "sget-char/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info SGET_SHORT_JUMBO = - new Info(Opcodes.SGET_SHORT_JUMBO, "sget-short/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info SPUT_JUMBO = - new Info(Opcodes.SPUT_JUMBO, "sput/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info SPUT_WIDE_JUMBO = - new Info(Opcodes.SPUT_WIDE_JUMBO, "sput-wide/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info SPUT_OBJECT_JUMBO = - new Info(Opcodes.SPUT_OBJECT_JUMBO, "sput-object/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info SPUT_BOOLEAN_JUMBO = - new Info(Opcodes.SPUT_BOOLEAN_JUMBO, "sput-boolean/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info SPUT_BYTE_JUMBO = - new Info(Opcodes.SPUT_BYTE_JUMBO, "sput-byte/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info SPUT_CHAR_JUMBO = - new Info(Opcodes.SPUT_CHAR_JUMBO, "sput-char/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info SPUT_SHORT_JUMBO = - new Info(Opcodes.SPUT_SHORT_JUMBO, "sput-short/jumbo", - InstructionCodec.FORMAT_41C, IndexType.FIELD_REF); - - public static final Info INVOKE_VIRTUAL_JUMBO = - new Info(Opcodes.INVOKE_VIRTUAL_JUMBO, "invoke-virtual/jumbo", - InstructionCodec.FORMAT_5RC, IndexType.METHOD_REF); - - public static final Info INVOKE_SUPER_JUMBO = - new Info(Opcodes.INVOKE_SUPER_JUMBO, "invoke-super/jumbo", - InstructionCodec.FORMAT_5RC, IndexType.METHOD_REF); - - public static final Info INVOKE_DIRECT_JUMBO = - new Info(Opcodes.INVOKE_DIRECT_JUMBO, "invoke-direct/jumbo", - InstructionCodec.FORMAT_5RC, IndexType.METHOD_REF); - - public static final Info INVOKE_STATIC_JUMBO = - new Info(Opcodes.INVOKE_STATIC_JUMBO, "invoke-static/jumbo", - InstructionCodec.FORMAT_5RC, IndexType.METHOD_REF); - - public static final Info INVOKE_INTERFACE_JUMBO = - new Info(Opcodes.INVOKE_INTERFACE_JUMBO, "invoke-interface/jumbo", - InstructionCodec.FORMAT_5RC, IndexType.METHOD_REF); - // END(opcode-info-defs) // Static initialization. @@ -1320,45 +1164,6 @@ public final class OpcodeInfo { set(SHL_INT_LIT8); set(SHR_INT_LIT8); set(USHR_INT_LIT8); - set(CONST_CLASS_JUMBO); - set(CHECK_CAST_JUMBO); - set(INSTANCE_OF_JUMBO); - set(NEW_INSTANCE_JUMBO); - set(NEW_ARRAY_JUMBO); - set(FILLED_NEW_ARRAY_JUMBO); - set(IGET_JUMBO); - set(IGET_WIDE_JUMBO); - set(IGET_OBJECT_JUMBO); - set(IGET_BOOLEAN_JUMBO); - set(IGET_BYTE_JUMBO); - set(IGET_CHAR_JUMBO); - set(IGET_SHORT_JUMBO); - set(IPUT_JUMBO); - set(IPUT_WIDE_JUMBO); - set(IPUT_OBJECT_JUMBO); - set(IPUT_BOOLEAN_JUMBO); - set(IPUT_BYTE_JUMBO); - set(IPUT_CHAR_JUMBO); - set(IPUT_SHORT_JUMBO); - set(SGET_JUMBO); - set(SGET_WIDE_JUMBO); - set(SGET_OBJECT_JUMBO); - set(SGET_BOOLEAN_JUMBO); - set(SGET_BYTE_JUMBO); - set(SGET_CHAR_JUMBO); - set(SGET_SHORT_JUMBO); - set(SPUT_JUMBO); - set(SPUT_WIDE_JUMBO); - set(SPUT_OBJECT_JUMBO); - set(SPUT_BOOLEAN_JUMBO); - set(SPUT_BYTE_JUMBO); - set(SPUT_CHAR_JUMBO); - set(SPUT_SHORT_JUMBO); - set(INVOKE_VIRTUAL_JUMBO); - set(INVOKE_SUPER_JUMBO); - set(INVOKE_DIRECT_JUMBO); - set(INVOKE_STATIC_JUMBO); - set(INVOKE_INTERFACE_JUMBO); // END(opcode-info-init) } diff --git a/dx/src/com/android/dx/io/Opcodes.java b/dx/src/com/android/dx/io/Opcodes.java index 4a255f7d4..6dba49d9e 100644 --- a/dx/src/com/android/dx/io/Opcodes.java +++ b/dx/src/com/android/dx/io/Opcodes.java @@ -259,45 +259,6 @@ public final class Opcodes { public static final int SHL_INT_LIT8 = 0xe0; public static final int SHR_INT_LIT8 = 0xe1; public static final int USHR_INT_LIT8 = 0xe2; - public static final int CONST_CLASS_JUMBO = 0x00ff; - public static final int CHECK_CAST_JUMBO = 0x01ff; - public static final int INSTANCE_OF_JUMBO = 0x02ff; - public static final int NEW_INSTANCE_JUMBO = 0x03ff; - public static final int NEW_ARRAY_JUMBO = 0x04ff; - public static final int FILLED_NEW_ARRAY_JUMBO = 0x05ff; - public static final int IGET_JUMBO = 0x06ff; - public static final int IGET_WIDE_JUMBO = 0x07ff; - public static final int IGET_OBJECT_JUMBO = 0x08ff; - public static final int IGET_BOOLEAN_JUMBO = 0x09ff; - public static final int IGET_BYTE_JUMBO = 0x0aff; - public static final int IGET_CHAR_JUMBO = 0x0bff; - public static final int IGET_SHORT_JUMBO = 0x0cff; - public static final int IPUT_JUMBO = 0x0dff; - public static final int IPUT_WIDE_JUMBO = 0x0eff; - public static final int IPUT_OBJECT_JUMBO = 0x0fff; - public static final int IPUT_BOOLEAN_JUMBO = 0x10ff; - public static final int IPUT_BYTE_JUMBO = 0x11ff; - public static final int IPUT_CHAR_JUMBO = 0x12ff; - public static final int IPUT_SHORT_JUMBO = 0x13ff; - public static final int SGET_JUMBO = 0x14ff; - public static final int SGET_WIDE_JUMBO = 0x15ff; - public static final int SGET_OBJECT_JUMBO = 0x16ff; - public static final int SGET_BOOLEAN_JUMBO = 0x17ff; - public static final int SGET_BYTE_JUMBO = 0x18ff; - public static final int SGET_CHAR_JUMBO = 0x19ff; - public static final int SGET_SHORT_JUMBO = 0x1aff; - public static final int SPUT_JUMBO = 0x1bff; - public static final int SPUT_WIDE_JUMBO = 0x1cff; - public static final int SPUT_OBJECT_JUMBO = 0x1dff; - public static final int SPUT_BOOLEAN_JUMBO = 0x1eff; - public static final int SPUT_BYTE_JUMBO = 0x1fff; - public static final int SPUT_CHAR_JUMBO = 0x20ff; - public static final int SPUT_SHORT_JUMBO = 0x21ff; - public static final int INVOKE_VIRTUAL_JUMBO = 0x22ff; - public static final int INVOKE_SUPER_JUMBO = 0x23ff; - public static final int INVOKE_DIRECT_JUMBO = 0x24ff; - public static final int INVOKE_STATIC_JUMBO = 0x25ff; - public static final int INVOKE_INTERFACE_JUMBO = 0x26ff; // END(opcodes) // TODO: Generate these payload opcodes with opcode-gen. diff --git a/dx/src/com/android/dx/io/instructions/DecodedInstruction.java b/dx/src/com/android/dx/io/instructions/DecodedInstruction.java index e418a1c0b..a8bc8592e 100644 --- a/dx/src/com/android/dx/io/instructions/DecodedInstruction.java +++ b/dx/src/com/android/dx/io/instructions/DecodedInstruction.java @@ -21,7 +21,6 @@ import com.android.dx.io.OpcodeInfo; import com.android.dx.io.Opcodes; import com.android.dx.util.DexException; import com.android.dx.util.Hex; - import java.io.EOFException; /** @@ -59,7 +58,7 @@ public abstract class DecodedInstruction { /** * literal value argument; also used for special verification error - * constants (formats 20bc and 40sc) as well as should-be-zero values + * constants (format 20bc) as well as should-be-zero values * (formats 10x, 20t, 30t, and 32x) */ private final long literal; @@ -90,7 +89,7 @@ public abstract class DecodedInstruction { decoded[in.cursor()] = DecodedInstruction.decode(in); } } catch (EOFException ex) { - throw new AssertionError("shouldn't happen"); + throw new DexException(ex); } return decoded; diff --git a/dx/src/com/android/dx/io/instructions/InstructionCodec.java b/dx/src/com/android/dx/io/instructions/InstructionCodec.java index b864b8365..2e803ed6b 100644 --- a/dx/src/com/android/dx/io/instructions/InstructionCodec.java +++ b/dx/src/com/android/dx/io/instructions/InstructionCodec.java @@ -605,139 +605,6 @@ public enum InstructionCodec { } }, - FORMAT_33X() { - @Override public DecodedInstruction decode(int opcodeUnit, - CodeInput in) throws EOFException { - int ab = in.read(); - int a = byte0(ab); - int b = byte1(ab); - int c = in.read(); - return new ThreeRegisterDecodedInstruction( - this, opcodeUnit, 0, null, - 0, 0L, - a, b, c); - } - - @Override public void encode(DecodedInstruction insn, CodeOutput out) { - out.write( - insn.getOpcodeUnit(), - codeUnit(insn.getA(), insn.getB()), - insn.getCUnit()); - } - }, - - FORMAT_32S() { - @Override public DecodedInstruction decode(int opcodeUnit, - CodeInput in) throws EOFException { - int ab = in.read(); - int a = byte0(ab); - int b = byte1(ab); - int literal = (short) in.read(); // sign-extend - return new TwoRegisterDecodedInstruction( - this, opcodeUnit, 0, null, - 0, literal, - a, b); - } - - @Override public void encode(DecodedInstruction insn, CodeOutput out) { - out.write( - insn.getOpcodeUnit(), - codeUnit(insn.getA(), insn.getB()), - insn.getLiteralUnit()); - } - }, - - FORMAT_40SC() { - @Override public DecodedInstruction decode(int opcodeUnit, - CodeInput in) throws EOFException { - // Note: We use the literal field to hold the decoded AA value. - int index = in.readInt(); - int literal = in.read(); - return new ZeroRegisterDecodedInstruction( - this, opcodeUnit, index, IndexType.VARIES, - 0, literal); - } - - @Override public void encode(DecodedInstruction insn, CodeOutput out) { - int index = insn.getIndex(); - out.write( - insn.getOpcodeUnit(), - unit0(index), - unit1(index), - insn.getLiteralUnit()); - } - }, - - FORMAT_41C() { - @Override public DecodedInstruction decode(int opcodeUnit, - CodeInput in) throws EOFException { - int index = in.readInt(); - int a = in.read(); - IndexType indexType = OpcodeInfo.getIndexType(opcodeUnit); - return new OneRegisterDecodedInstruction( - this, opcodeUnit, index, indexType, - 0, 0L, - a); - } - - @Override public void encode(DecodedInstruction insn, CodeOutput out) { - int index = insn.getIndex(); - out.write( - insn.getOpcodeUnit(), - unit0(index), - unit1(index), - insn.getAUnit()); - } - }, - - FORMAT_52C() { - @Override public DecodedInstruction decode(int opcodeUnit, - CodeInput in) throws EOFException { - int index = in.readInt(); - int a = in.read(); - int b = in.read(); - IndexType indexType = OpcodeInfo.getIndexType(opcodeUnit); - return new TwoRegisterDecodedInstruction( - this, opcodeUnit, index, indexType, - 0, 0L, - a, b); - } - - @Override public void encode(DecodedInstruction insn, CodeOutput out) { - int index = insn.getIndex(); - out.write( - insn.getOpcodeUnit(), - unit0(index), - unit1(index), - insn.getAUnit(), - insn.getBUnit()); - } - }, - - FORMAT_5RC() { - @Override public DecodedInstruction decode(int opcodeUnit, - CodeInput in) throws EOFException { - int index = in.readInt(); - int registerCount = in.read(); - int a = in.read(); - IndexType indexType = OpcodeInfo.getIndexType(opcodeUnit); - return new RegisterRangeDecodedInstruction( - this, opcodeUnit, index, indexType, - 0, 0L, - a, registerCount); - } - - @Override public void encode(DecodedInstruction insn, CodeOutput out) { - int index = insn.getIndex(); - out.write( - insn.getOpcodeUnit(), - unit0(index), - unit1(index), - insn.getRegisterCountUnit(), - insn.getAUnit()); - } - }, - FORMAT_PACKED_SWITCH_PAYLOAD() { @Override public DecodedInstruction decode(int opcodeUnit, CodeInput in) throws EOFException { |