Add support for the return-void-barrier odex instruction

This commit is contained in:
Ben Gruver
2011-11-19 17:51:58 -08:00
committed by =
parent c8de336727
commit 4a5692f827
8 changed files with 36 additions and 3 deletions

View File

@ -661,6 +661,9 @@ public class MethodAnalyzer {
case RETURN_WIDE:
case RETURN_OBJECT:
return true;
case RETURN_VOID_BARRIER:
analyzeReturnVoidBarrier(analyzedInstruction);
return true;
case CONST_4:
case CONST_16:
case CONST:
@ -1099,7 +1102,7 @@ public class MethodAnalyzer {
}
private void verifyInstruction(AnalyzedInstruction analyzedInstruction) {
private void verifyInstruction(AnalyzedInstruction analyzedInstruction) {
Instruction instruction = analyzedInstruction.instruction;
switch (instruction.opcode) {
@ -1133,6 +1136,7 @@ public class MethodAnalyzer {
verifyMoveException(analyzedInstruction);
return;
case RETURN_VOID:
case RETURN_VOID_BARRIER:
verifyReturnVoid(analyzedInstruction);
return;
case RETURN:
@ -1780,6 +1784,16 @@ public class MethodAnalyzer {
}
}
private void analyzeReturnVoidBarrier(AnalyzedInstruction analyzedInstruction) {
Instruction10x instruction = (Instruction10x)analyzedInstruction.instruction;
Instruction10x deodexedInstruction = new Instruction10x(Opcode.RETURN_VOID);
analyzedInstruction.setDeodexedInstruction(deodexedInstruction);
analyzeInstruction(analyzedInstruction);
}
private void verifyReturnVoid(AnalyzedInstruction analyzedInstruction) {
TypeIdItem returnType = encodedMethod.method.getPrototype().getReturnType();
if (returnType.getTypeDescriptor().charAt(0) != 'V') {

View File

@ -43,7 +43,7 @@ public class Instruction10x extends Instruction {
public Instruction10x(Opcode opcode, byte[] buffer, int bufferIndex) {
super(opcode);
assert buffer[bufferIndex] == opcode.value;
assert (buffer[bufferIndex] & 0xFF) == opcode.value;
assert buffer[bufferIndex + 1] == 0x00;
}

View File

@ -268,6 +268,7 @@ public enum Opcode
EXECUTE_INLINE_RANGE((short)0xef, "execute-inline/range", ReferenceType.none, Format.Format3rmi, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT),
INVOKE_DIRECT_EMPTY((short)0xf0, "invoke-direct-empty", ReferenceType.method, Format.Format35c, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT),
INVOKE_OBJECT_INIT_RANGE((short)0xf0, "invoke-object-init/range", ReferenceType.method, Format.Format3rc, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT),
RETURN_VOID_BARRIER((short)0xf1, "return-void-barrier", ReferenceType.none, Format.Format10x, Opcode.ODEX_ONLY),
IGET_QUICK((short)0xf2, "iget-quick", ReferenceType.none, Format.Format22cs, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_QUICK | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER),
IGET_WIDE_QUICK((short)0xf3, "iget-wide-quick", ReferenceType.none, Format.Format22cs, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_QUICK | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER),
IGET_OBJECT_QUICK((short)0xf4, "iget-object-quick", ReferenceType.none, Format.Format22cs, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_QUICK | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER),
@ -419,6 +420,9 @@ public enum Opcode
IGET_WIDE_VOLATILE, IPUT_WIDE_VOLATILE, SGET_WIDE_VOLATILE, SPUT_WIDE_VOLATILE,
IPUT_OBJECT_VOLATILE, SGET_OBJECT_VOLATILE, SPUT_OBJECT_VOLATILE);
}
if (apiLevel < 11) {
removeOpcodes(RETURN_VOID_BARRIER);
}
if (apiLevel < 14) {
removeOpcodes(CONST_CLASS_JUMBO, CHECK_CAST_JUMBO, INSTANCE_OF_JUMBO, NEW_INSTANCE_JUMBO,
NEW_ARRAY_JUMBO, FILLED_NEW_ARRAY_JUMBO, IGET_JUMBO, IGET_WIDE_JUMBO, IGET_OBJECT_JUMBO,