OSDN Git Service

An argument is handled incorrectly for add-int/lit8 during optimization phase
authornikolay serdjuk <nikolay.y.serdjuk@intel.com>
Tue, 25 Mar 2014 05:21:29 +0000 (12:21 +0700)
committernikolay serdjuk <nikolay.y.serdjuk@intel.com>
Tue, 25 Mar 2014 05:21:29 +0000 (12:21 +0700)
Dalvik instruction 'add-int/lit8' stores a constant in the third parameter.
But during optimization phase the compiler reads the constant from the
second parameter. This is incorrect because it leads to wrong decision that
no array bound checks are needed in our test case. As a consequence it
fails with SIGSEGV because of accessing elements which are beyond the bounds.

Change-Id: I653892514934046d31a9e4d206d9d95ebb6267ab
Signed-off-by: nikolay serdjuk <nikolay.y.serdjuk@intel.com>
compiler/dex/local_value_numbering.cc

index 45167a8..8dbc2bb 100644 (file)
@@ -482,9 +482,9 @@ uint16_t LocalValueNumbering::GetValueNumber(MIR* mir) {
     case Instruction::SHL_INT_LIT8:
     case Instruction::SHR_INT_LIT8:
     case Instruction::USHR_INT_LIT8: {
-        // Same as res = op + 2 operands, except use vB as operand 2
+        // Same as res = op + 2 operands, except use vC as operand 2
         uint16_t operand1 = GetOperandValue(mir->ssa_rep->uses[0]);
-        uint16_t operand2 = LookupValue(Instruction::CONST, mir->dalvikInsn.vB, 0, 0);
+        uint16_t operand2 = LookupValue(Instruction::CONST, mir->dalvikInsn.vC, 0, 0);
         res = LookupValue(opcode, operand1, operand2, NO_VALUE);
         SetOperandValue(mir->ssa_rep->defs[0], res);
       }