OSDN Git Service

ART: Fix underflow in codegen
authorAndreas Gampe <agampe@google.com>
Sun, 26 Feb 2017 22:10:28 +0000 (14:10 -0800)
committerAndreas Gampe <agampe@google.com>
Sun, 26 Feb 2017 22:12:02 +0000 (14:12 -0800)
Check for count == 0 first before accessing non-existent stack map.

Test: m ART_TEST_JIT=true test-art-host
Test: m ART_TEST_JIT=true test-art-host-run-test-913-heaps
Change-Id: Id4cad8e791d731147860b8a9a0d90cc893cc6972

compiler/optimizing/code_generator.cc

index 8dd423f..424b850 100644 (file)
@@ -861,8 +861,11 @@ void CodeGenerator::RecordPcInfo(HInstruction* instruction,
 bool CodeGenerator::HasStackMapAtCurrentPc() {
   uint32_t pc = GetAssembler()->CodeSize();
   size_t count = stack_map_stream_.GetNumberOfStackMaps();
+  if (count == 0) {
+    return false;
+  }
   CodeOffset native_pc_offset = stack_map_stream_.GetStackMap(count - 1).native_pc_code_offset;
-  return (count > 0) && (native_pc_offset.Uint32Value(GetInstructionSet()) == pc);
+  return (native_pc_offset.Uint32Value(GetInstructionSet()) == pc);
 }
 
 void CodeGenerator::MaybeRecordNativeDebugInfo(HInstruction* instruction,