diff options
| author | 2018-10-10 16:09:43 +0100 | |
|---|---|---|
| committer | 2018-10-12 10:07:41 +0100 | |
| commit | 4cbfadc29b4ba89b32fa6eb55a287db78d12a45c (patch) | |
| tree | 70cd681c4326ab8cf034da6c0fb0fef222cd67b1 /runtime/stack.cc | |
| parent | a48eb7e0690187618d2824a7d9b5601e7f5cdf80 (diff) | |
Remove CHECK that GetThis() must always work.
Ensures GetVReg of a reference on compiled code checks that the
value is indeed a reference from the stack maps.
bug: 116683601
bug: 117452149
Test: 686-get-this
Change-Id: I3a370c45786a4892c7888491bec6d5ae64672f6c
Diffstat (limited to 'runtime/stack.cc')
| -rw-r--r-- | runtime/stack.cc | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/runtime/stack.cc b/runtime/stack.cc index eb9c661d18..25939d2f2c 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -139,9 +139,9 @@ mirror::Object* StackVisitor::GetThisObject() const { } else { uint16_t reg = accessor.RegistersSize() - accessor.InsSize(); uint32_t value = 0; - bool success = GetVReg(m, reg, kReferenceVReg, &value); - // We currently always guarantee the `this` object is live throughout the method. - CHECK(success) << "Failed to read the this object in " << ArtMethod::PrettyMethod(m); + if (!GetVReg(m, reg, kReferenceVReg, &value)) { + return nullptr; + } return reinterpret_cast<mirror::Object*>(value); } } @@ -223,20 +223,39 @@ bool StackVisitor::GetVRegFromOptimizedCode(ArtMethod* m, uint16_t vreg, VRegKin switch (location_kind) { case DexRegisterLocation::Kind::kInStack: { const int32_t offset = dex_register_map[vreg].GetStackOffsetInBytes(); + BitMemoryRegion stack_mask = code_info.GetStackMaskOf(stack_map); + if (kind == kReferenceVReg && !stack_mask.LoadBit(offset / kFrameSlotSize)) { + return false; + } const uint8_t* addr = reinterpret_cast<const uint8_t*>(cur_quick_frame_) + offset; *val = *reinterpret_cast<const uint32_t*>(addr); return true; } - case DexRegisterLocation::Kind::kInRegister: + case DexRegisterLocation::Kind::kInRegister: { + uint32_t register_mask = code_info.GetRegisterMaskOf(stack_map); + uint32_t reg = dex_register_map[vreg].GetMachineRegister(); + if (kind == kReferenceVReg && !(register_mask & (1 << reg))) { + return false; + } + return GetRegisterIfAccessible(reg, kind, val); + } case DexRegisterLocation::Kind::kInRegisterHigh: case DexRegisterLocation::Kind::kInFpuRegister: case DexRegisterLocation::Kind::kInFpuRegisterHigh: { + if (kind == kReferenceVReg) { + return false; + } uint32_t reg = dex_register_map[vreg].GetMachineRegister(); return GetRegisterIfAccessible(reg, kind, val); } - case DexRegisterLocation::Kind::kConstant: - *val = dex_register_map[vreg].GetConstant(); + case DexRegisterLocation::Kind::kConstant: { + uint32_t result = dex_register_map[vreg].GetConstant(); + if (kind == kReferenceVReg && result != 0) { + return false; + } + *val = result; return true; + } case DexRegisterLocation::Kind::kNone: return false; default: |