Propagate the narrowed type for an if-nez after an instance-of

This commit is contained in:
Ben Gruver 2016-04-23 11:07:41 -07:00
parent 7fd5f88caf
commit 9802cf3428

View File

@ -1176,7 +1176,7 @@ public class MethodAnalyzer {
AnalyzedInstruction nextAnalyzedInstruction = analyzedInstructions.valueAt(instructionIndex + 1);
Instruction nextInstruction = nextAnalyzedInstruction.instruction;
if (nextInstruction.getOpcode() == Opcode.IF_EQZ) {
if (nextInstruction.getOpcode() == Opcode.IF_EQZ || nextInstruction.getOpcode() == Opcode.IF_NEZ) {
if (((Instruction21t)nextInstruction).getRegisterA() == analyzedInstruction.getDestinationRegister()) {
Reference reference = ((Instruction22c)analyzedInstruction.getInstruction()).getReference();
RegisterType registerType = RegisterType.getRegisterType(classPath, (TypeReference)reference);
@ -1201,9 +1201,16 @@ public class MethodAnalyzer {
}
if (override) {
overridePredecessorRegisterTypeAndPropagateChanges(
analyzedInstructions.valueAt(instructionIndex + 2), nextAnalyzedInstruction,
objectRegister, registerType);
AnalyzedInstruction branchStartInstruction;
if (nextInstruction.getOpcode() == Opcode.IF_EQZ) {
branchStartInstruction = analyzedInstructions.valueAt(instructionIndex + 2);
} else {
int nextAddress = getInstructionAddress(nextAnalyzedInstruction) +
((Instruction21t)nextInstruction).getCodeOffset();
branchStartInstruction = analyzedInstructions.get(nextAddress);
}
overridePredecessorRegisterTypeAndPropagateChanges(branchStartInstruction,
nextAnalyzedInstruction, objectRegister, registerType);
}
}
}