com.android.dx.io.Opcodes Java Examples
The following examples show how to use
com.android.dx.io.Opcodes.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DecodedInstruction.java From buck with Apache License 2.0 | 6 votes |
/** * Constructs an instance. */ public DecodedInstruction(InstructionCodec format, int opcode, int index, IndexType indexType, int target, long literal) { if (format == null) { throw new NullPointerException("format == null"); } if (!Opcodes.isValidShape(opcode)) { throw new IllegalArgumentException("invalid opcode"); } this.format = format; this.opcode = opcode; this.index = index; this.indexType = indexType; this.target = target; this.literal = literal; }
Example #2
Source File: DecodedInstruction.java From Box with Apache License 2.0 | 6 votes |
/** * Constructs an instance. */ public DecodedInstruction(InstructionCodec format, int opcode, int index, IndexType indexType, int target, long literal) { if (format == null) { throw new NullPointerException("format == null"); } if (!Opcodes.isValidShape(opcode)) { throw new IllegalArgumentException("invalid opcode"); } this.format = format; this.opcode = opcode; this.index = index; this.indexType = indexType; this.target = target; this.literal = literal; }
Example #3
Source File: OutputFinisher.java From Box with Apache License 2.0 | 6 votes |
/** * Attempts to fit the given instruction into a specific opcode, * returning the opcode whose format that the instruction fits * into or {@code null} to indicate that the instruction will need * to be expanded. This fitting process starts with the given * opcode as a first "best guess" and then pessimizes from there * if necessary. * * @param insn {@code non-null;} the instruction in question * @param guess {@code null-ok;} the current guess as to the best * opcode; {@code null} means that no simple opcode fits * @return {@code null-ok;} a possibly-different opcode; either a * {@code non-null} good fit or {@code null} to indicate that no * simple opcode fits */ private Dop findOpcodeForInsn(DalvInsn insn, Dop guess) { /* * Note: The initial guess might be null, meaning that an * earlier call to this method already determined that there * was no possible simple opcode fit. */ while (guess != null) { if (guess.getFormat().isCompatible(insn)) { /* * Don't break out for const_string to generate jumbo version * when option is enabled. */ if (!dexOptions.forceJumbo || guess.getOpcode() != Opcodes.CONST_STRING) { break; } } guess = Dops.getNextOrNull(guess, dexOptions); } return guess; }
Example #4
Source File: Dop.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param opcode {@code Opcodes.isValid();} the opcode value * itself * @param family {@code Opcodes.isValid();} the opcode family * @param nextOpcode {@code Opcodes.isValid();} what opcode (by * number) to try next when attempting to match an opcode to * particular arguments; {@code Opcodes.NO_NEXT} to indicate that * this is the last opcode to try in a particular chain * @param format {@code non-null;} the instruction format * @param hasResult whether the opcode has a result register; if so it * is always the first register */ public Dop(int opcode, int family, int nextOpcode, InsnFormat format, boolean hasResult) { if (!Opcodes.isValidShape(opcode)) { throw new IllegalArgumentException("bogus opcode"); } if (!Opcodes.isValidShape(family)) { throw new IllegalArgumentException("bogus family"); } if (!Opcodes.isValidShape(nextOpcode)) { throw new IllegalArgumentException("bogus nextOpcode"); } if (format == null) { throw new NullPointerException("format == null"); } this.opcode = opcode; this.family = family; this.nextOpcode = nextOpcode; this.format = format; this.hasResult = hasResult; }
Example #5
Source File: Dop.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Gets the opcode for the opposite test of this instance. This is only * valid for opcodes which are in fact tests. * * @return {@code non-null;} the opposite test */ public Dop getOppositeTest() { switch (opcode) { case Opcodes.IF_EQ: return Dops.IF_NE; case Opcodes.IF_NE: return Dops.IF_EQ; case Opcodes.IF_LT: return Dops.IF_GE; case Opcodes.IF_GE: return Dops.IF_LT; case Opcodes.IF_GT: return Dops.IF_LE; case Opcodes.IF_LE: return Dops.IF_GT; case Opcodes.IF_EQZ: return Dops.IF_NEZ; case Opcodes.IF_NEZ: return Dops.IF_EQZ; case Opcodes.IF_LTZ: return Dops.IF_GEZ; case Opcodes.IF_GEZ: return Dops.IF_LTZ; case Opcodes.IF_GTZ: return Dops.IF_LEZ; case Opcodes.IF_LEZ: return Dops.IF_GTZ; } throw new IllegalArgumentException("bogus opcode: " + this); }
Example #6
Source File: Dop.java From Box with Apache License 2.0 | 6 votes |
/** * Gets the opcode for the opposite test of this instance. This is only * valid for opcodes which are in fact tests. * * @return {@code non-null;} the opposite test */ public Dop getOppositeTest() { switch (opcode) { case Opcodes.IF_EQ: return Dops.IF_NE; case Opcodes.IF_NE: return Dops.IF_EQ; case Opcodes.IF_LT: return Dops.IF_GE; case Opcodes.IF_GE: return Dops.IF_LT; case Opcodes.IF_GT: return Dops.IF_LE; case Opcodes.IF_LE: return Dops.IF_GT; case Opcodes.IF_EQZ: return Dops.IF_NEZ; case Opcodes.IF_NEZ: return Dops.IF_EQZ; case Opcodes.IF_LTZ: return Dops.IF_GEZ; case Opcodes.IF_GEZ: return Dops.IF_LTZ; case Opcodes.IF_GTZ: return Dops.IF_LEZ; case Opcodes.IF_LEZ: return Dops.IF_GTZ; } throw new IllegalArgumentException("bogus opcode: " + this); }
Example #7
Source File: Dop.java From Box with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param opcode {@code Opcodes.isValid();} the opcode value * itself * @param family {@code Opcodes.isValid();} the opcode family * @param nextOpcode {@code Opcodes.isValid();} what opcode (by * number) to try next when attempting to match an opcode to * particular arguments; {@code Opcodes.NO_NEXT} to indicate that * this is the last opcode to try in a particular chain * @param format {@code non-null;} the instruction format * @param hasResult whether the opcode has a result register; if so it * is always the first register */ public Dop(int opcode, int family, int nextOpcode, InsnFormat format, boolean hasResult) { if (!Opcodes.isValidShape(opcode)) { throw new IllegalArgumentException("bogus opcode"); } if (!Opcodes.isValidShape(family)) { throw new IllegalArgumentException("bogus family"); } if (!Opcodes.isValidShape(nextOpcode)) { throw new IllegalArgumentException("bogus nextOpcode"); } if (format == null) { throw new NullPointerException("format == null"); } this.opcode = opcode; this.family = family; this.nextOpcode = nextOpcode; this.format = format; this.hasResult = hasResult; }
Example #8
Source File: OutputFinisher.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Attempts to fit the given instruction into a specific opcode, * returning the opcode whose format that the instruction fits * into or {@code null} to indicate that the instruction will need * to be expanded. This fitting process starts with the given * opcode as a first "best guess" and then pessimizes from there * if necessary. * * @param insn {@code non-null;} the instruction in question * @param guess {@code null-ok;} the current guess as to the best * opcode; {@code null} means that no simple opcode fits * @return {@code null-ok;} a possibly-different opcode; either a * {@code non-null} good fit or {@code null} to indicate that no * simple opcode fits */ private Dop findOpcodeForInsn(DalvInsn insn, Dop guess) { /* * Note: The initial guess might be null, meaning that an * earlier call to this method already determined that there * was no possible simple opcode fit. */ while (guess != null) { if (guess.getFormat().isCompatible(insn)) { /* * Don't break out for const_string to generate jumbo version * when option is enabled. */ if (!dexOptions.forceJumbo || guess.getOpcode() != Opcodes.CONST_STRING) { break; } } guess = Dops.getNextOrNull(guess, dexOptions); } return guess; }
Example #9
Source File: DecodedInstruction.java From J2ME-Loader with Apache License 2.0 | 6 votes |
/** * Constructs an instance. */ public DecodedInstruction(InstructionCodec format, int opcode, int index, IndexType indexType, int target, long literal) { if (format == null) { throw new NullPointerException("format == null"); } if (!Opcodes.isValidShape(opcode)) { throw new IllegalArgumentException("invalid opcode"); } this.format = format; this.opcode = opcode; this.index = index; this.indexType = indexType; this.target = target; this.literal = literal; }
Example #10
Source File: DecodedInstruction.java From Box with Apache License 2.0 | 6 votes |
/** * Constructs an instance. */ public DecodedInstruction(InstructionCodec format, int opcode, int index, IndexType indexType, int target, long literal) { if (format == null) { throw new NullPointerException("format == null"); } if (!Opcodes.isValidShape(opcode)) { throw new IllegalArgumentException("invalid opcode"); } this.format = format; this.opcode = opcode; this.index = index; this.indexType = indexType; this.target = target; this.literal = literal; }
Example #11
Source File: Dop.java From buck with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param opcode {@code Opcodes.isValid();} the opcode value * itself * @param family {@code Opcodes.isValid();} the opcode family * @param nextOpcode {@code Opcodes.isValid();} what opcode (by * number) to try next when attempting to match an opcode to * particular arguments; {@code Opcodes.NO_NEXT} to indicate that * this is the last opcode to try in a particular chain * @param format {@code non-null;} the instruction format * @param hasResult whether the opcode has a result register; if so it * is always the first register */ public Dop(int opcode, int family, int nextOpcode, InsnFormat format, boolean hasResult) { if (!Opcodes.isValidShape(opcode)) { throw new IllegalArgumentException("bogus opcode"); } if (!Opcodes.isValidShape(family)) { throw new IllegalArgumentException("bogus family"); } if (!Opcodes.isValidShape(nextOpcode)) { throw new IllegalArgumentException("bogus nextOpcode"); } if (format == null) { throw new NullPointerException("format == null"); } this.opcode = opcode; this.family = family; this.nextOpcode = nextOpcode; this.format = format; this.hasResult = hasResult; }
Example #12
Source File: Dop.java From buck with Apache License 2.0 | 6 votes |
/** * Gets the opcode for the opposite test of this instance. This is only * valid for opcodes which are in fact tests. * * @return {@code non-null;} the opposite test */ public Dop getOppositeTest() { switch (opcode) { case Opcodes.IF_EQ: return Dops.IF_NE; case Opcodes.IF_NE: return Dops.IF_EQ; case Opcodes.IF_LT: return Dops.IF_GE; case Opcodes.IF_GE: return Dops.IF_LT; case Opcodes.IF_GT: return Dops.IF_LE; case Opcodes.IF_LE: return Dops.IF_GT; case Opcodes.IF_EQZ: return Dops.IF_NEZ; case Opcodes.IF_NEZ: return Dops.IF_EQZ; case Opcodes.IF_LTZ: return Dops.IF_GEZ; case Opcodes.IF_GEZ: return Dops.IF_LTZ; case Opcodes.IF_GTZ: return Dops.IF_LEZ; case Opcodes.IF_LEZ: return Dops.IF_GTZ; } throw new IllegalArgumentException("bogus opcode: " + this); }
Example #13
Source File: OutputFinisher.java From buck with Apache License 2.0 | 6 votes |
/** * Attempts to fit the given instruction into a specific opcode, * returning the opcode whose format that the instruction fits * into or {@code null} to indicate that the instruction will need * to be expanded. This fitting process starts with the given * opcode as a first "best guess" and then pessimizes from there * if necessary. * * @param insn {@code non-null;} the instruction in question * @param guess {@code null-ok;} the current guess as to the best * opcode; {@code null} means that no simple opcode fits * @return {@code null-ok;} a possibly-different opcode; either a * {@code non-null} good fit or {@code null} to indicate that no * simple opcode fits */ private Dop findOpcodeForInsn(DalvInsn insn, Dop guess) { /* * Note: The initial guess might be null, meaning that an * earlier call to this method already determined that there * was no possible simple opcode fit. */ while (guess != null) { if (guess.getFormat().isCompatible(insn)) { /* * Don't break out for const_string to generate jumbo version * when option is enabled. */ if (!dexOptions.forceJumbo || guess.getOpcode() != Opcodes.CONST_STRING) { break; } } guess = Dops.getNextOrNull(guess, dexOptions); } return guess; }
Example #14
Source File: OutputFinisher.java From Box with Apache License 2.0 | 6 votes |
/** * Attempts to fit the given instruction into a specific opcode, * returning the opcode whose format that the instruction fits * into or {@code null} to indicate that the instruction will need * to be expanded. This fitting process starts with the given * opcode as a first "best guess" and then pessimizes from there * if necessary. * * @param insn {@code non-null;} the instruction in question * @param guess {@code null-ok;} the current guess as to the best * opcode; {@code null} means that no simple opcode fits * @return {@code null-ok;} a possibly-different opcode; either a * {@code non-null} good fit or {@code null} to indicate that no * simple opcode fits */ private Dop findOpcodeForInsn(DalvInsn insn, Dop guess) { /* * Note: The initial guess might be null, meaning that an * earlier call to this method already determined that there * was no possible simple opcode fit. */ while (guess != null) { if (guess.getFormat().isCompatible(insn)) { /* * Don't break out for const_string to generate jumbo version * when option is enabled. */ if (!dexOptions.forceJumbo || guess.getOpcode() != Opcodes.CONST_STRING) { break; } } guess = Dops.getNextOrNull(guess, dexOptions); } return guess; }
Example #15
Source File: Dop.java From Box with Apache License 2.0 | 6 votes |
/** * Constructs an instance. * * @param opcode {@code Opcodes.isValid();} the opcode value * itself * @param family {@code Opcodes.isValid();} the opcode family * @param nextOpcode {@code Opcodes.isValid();} what opcode (by * number) to try next when attempting to match an opcode to * particular arguments; {@code Opcodes.NO_NEXT} to indicate that * this is the last opcode to try in a particular chain * @param format {@code non-null;} the instruction format * @param hasResult whether the opcode has a result register; if so it * is always the first register */ public Dop(int opcode, int family, int nextOpcode, InsnFormat format, boolean hasResult) { if (!Opcodes.isValidShape(opcode)) { throw new IllegalArgumentException("bogus opcode"); } if (!Opcodes.isValidShape(family)) { throw new IllegalArgumentException("bogus family"); } if (!Opcodes.isValidShape(nextOpcode)) { throw new IllegalArgumentException("bogus nextOpcode"); } if (format == null) { throw new NullPointerException("format == null"); } this.opcode = opcode; this.family = family; this.nextOpcode = nextOpcode; this.format = format; this.hasResult = hasResult; }
Example #16
Source File: Dop.java From Box with Apache License 2.0 | 6 votes |
/** * Gets the opcode for the opposite test of this instance. This is only * valid for opcodes which are in fact tests. * * @return {@code non-null;} the opposite test */ public Dop getOppositeTest() { switch (opcode) { case Opcodes.IF_EQ: return Dops.IF_NE; case Opcodes.IF_NE: return Dops.IF_EQ; case Opcodes.IF_LT: return Dops.IF_GE; case Opcodes.IF_GE: return Dops.IF_LT; case Opcodes.IF_GT: return Dops.IF_LE; case Opcodes.IF_LE: return Dops.IF_GT; case Opcodes.IF_EQZ: return Dops.IF_NEZ; case Opcodes.IF_NEZ: return Dops.IF_EQZ; case Opcodes.IF_LTZ: return Dops.IF_GEZ; case Opcodes.IF_GEZ: return Dops.IF_LTZ; case Opcodes.IF_GTZ: return Dops.IF_LEZ; case Opcodes.IF_LEZ: return Dops.IF_GTZ; } throw new IllegalArgumentException("bogus opcode: " + this); }
Example #17
Source File: InstructionTransformer.java From buck with Apache License 2.0 | 5 votes |
public void visit(DecodedInstruction[] all, DecodedInstruction one) { int typeId = one.getIndex(); int mappedId = indexMap.adjustType(typeId); boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO); jumboCheck(isJumbo, mappedId); mappedInstructions[mappedAt++] = one.withIndex(mappedId); }
Example #18
Source File: InstructionTransformer.java From Box with Apache License 2.0 | 5 votes |
@Override public void visit(DecodedInstruction[] all, DecodedInstruction one) { int methodId = one.getIndex(); int mappedId = indexMap.adjustMethod(methodId); boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO); jumboCheck(isJumbo, mappedId); mappedInstructions[mappedAt++] = one.withIndex(mappedId); }
Example #19
Source File: DecodedInstruction.java From Box with Apache License 2.0 | 5 votes |
/** * Decodes an instruction from the given input source. */ public static DecodedInstruction decode(CodeInput in) throws EOFException { int opcodeUnit = in.read(); int opcode = Opcodes.extractOpcodeFromUnit(opcodeUnit); InstructionCodec format = OpcodeInfo.getFormat(opcode); return format.decode(opcodeUnit, in); }
Example #20
Source File: InstructionTransformer.java From Box with Apache License 2.0 | 5 votes |
@Override public void visit(DecodedInstruction[] all, DecodedInstruction one) { int stringId = one.getIndex(); int mappedId = indexMap.adjustString(stringId); boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO); jumboCheck(isJumbo, mappedId); mappedInstructions[mappedAt++] = one.withIndex(mappedId); }
Example #21
Source File: DecodedInstruction.java From buck with Apache License 2.0 | 5 votes |
/** * Decodes an instruction from the given input source. */ public static DecodedInstruction decode(CodeInput in) throws EOFException { int opcodeUnit = in.read(); int opcode = Opcodes.extractOpcodeFromUnit(opcodeUnit); InstructionCodec format = OpcodeInfo.getFormat(opcode); return format.decode(opcodeUnit, in); }
Example #22
Source File: InstructionTransformer.java From buck with Apache License 2.0 | 5 votes |
public void visit(DecodedInstruction[] all, DecodedInstruction one) { int methodId = one.getIndex(); int mappedId = indexMap.adjustMethod(methodId); boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO); jumboCheck(isJumbo, mappedId); mappedInstructions[mappedAt++] = one.withIndex(mappedId); }
Example #23
Source File: Dops.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * Gets the {@link Dop} for the given opcode value. * * @param opcode {@code Opcodes.MIN_VALUE..Opcodes.MAX_VALUE;} the * opcode value * @return {@code non-null;} the associated opcode instance */ public static Dop get(int opcode) { int idx = opcode - Opcodes.MIN_VALUE; try { Dop result = DOPS[idx]; if (result != null) { return result; } } catch (ArrayIndexOutOfBoundsException ex) { // Fall through. } throw new IllegalArgumentException("bogus opcode"); }
Example #24
Source File: Dops.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * Gets the next {@link Dop} in the instruction fitting chain after the * given instance, if any. * * @param opcode {@code non-null;} the opcode * @param options {@code non-null;} options, used to determine * which opcodes are potentially off-limits * @return {@code null-ok;} the next opcode in the same family, in the * chain of opcodes to try, or {@code null} if the given opcode is * the last in its chain */ public static Dop getNextOrNull(Dop opcode, DexOptions options) { int nextOpcode = opcode.getNextOpcode(); if (nextOpcode == Opcodes.NO_NEXT) { return null; } opcode = get(nextOpcode); return opcode; }
Example #25
Source File: Dops.java From buck with Apache License 2.0 | 5 votes |
/** * Gets the next {@link Dop} in the instruction fitting chain after the * given instance, if any. * * @param opcode {@code non-null;} the opcode * @param options {@code non-null;} options, used to determine * which opcodes are potentially off-limits * @return {@code null-ok;} the next opcode in the same family, in the * chain of opcodes to try, or {@code null} if the given opcode is * the last in its chain */ public static Dop getNextOrNull(Dop opcode, DexOptions options) { int nextOpcode = opcode.getNextOpcode(); if (nextOpcode == Opcodes.NO_NEXT) { return null; } opcode = get(nextOpcode); return opcode; }
Example #26
Source File: InstructionTransformer.java From buck with Apache License 2.0 | 5 votes |
public void visit(DecodedInstruction[] all, DecodedInstruction one) { int fieldId = one.getIndex(); int mappedId = indexMap.adjustField(fieldId); boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO); jumboCheck(isJumbo, mappedId); mappedInstructions[mappedAt++] = one.withIndex(mappedId); }
Example #27
Source File: OddSpacer.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void writeTo(AnnotatedOutput out) { if (codeSize() != 0) { out.writeShort(InsnFormat.codeUnit(Opcodes.NOP, 0)); } }
Example #28
Source File: DecodedInstruction.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * Decodes an instruction from the given input source. */ public static DecodedInstruction decode(CodeInput in) throws EOFException { int opcodeUnit = in.read(); int opcode = Opcodes.extractOpcodeFromUnit(opcodeUnit); InstructionCodec format = OpcodeInfo.getFormat(opcode); return format.decode(opcodeUnit, in); }
Example #29
Source File: InstructionTransformer.java From buck with Apache License 2.0 | 5 votes |
public void visit(DecodedInstruction[] all, DecodedInstruction one) { int stringId = one.getIndex(); int mappedId = indexMap.adjustString(stringId); boolean isJumbo = (one.getOpcode() == Opcodes.CONST_STRING_JUMBO); jumboCheck(isJumbo, mappedId); mappedInstructions[mappedAt++] = one.withIndex(mappedId); }
Example #30
Source File: OddSpacer.java From buck with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void writeTo(AnnotatedOutput out) { if (codeSize() != 0) { out.writeShort(InsnFormat.codeUnit(Opcodes.NOP, 0)); } }