API change in StackVisitor::GetVReg*.

- Remove GetVReg() and SetVReg() that were expecting to always succeed.
- Change Quick-only methods to take a FromQuickCode suffix.
- Change deopt to use dead values when GetVReg does not succeed:
  the optimizing compiler will not have a location for uninitialized
  Dex registers and potentially dead registers.

Change-Id: Ida05773a97aff8aa69e0caf42ea961f80f854b77
diff --git a/runtime/stack.cc b/runtime/stack.cc
index b8ca21e..47b85ad 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -137,7 +137,11 @@
       return nullptr;
     } else {
       uint16_t reg = code_item->registers_size_ - code_item->ins_size_;
-      return reinterpret_cast<mirror::Object*>(GetVReg(m, reg, kReferenceVReg));
+      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 " << PrettyMethod(m);
+      return reinterpret_cast<mirror::Object*>(value);
     }
   }
 }
@@ -181,8 +185,8 @@
     const DexFile::CodeItem* code_item = m->GetCodeItem();
     DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be NULL or how would we compile
                                                       // its instructions?
-    *val = *GetVRegAddr(cur_quick_frame_, code_item, frame_info.CoreSpillMask(),
-                        frame_info.FpSpillMask(), frame_info.FrameSizeInBytes(), vreg);
+    *val = *GetVRegAddrFromQuickCode(cur_quick_frame_, code_item, frame_info.CoreSpillMask(),
+                                     frame_info.FpSpillMask(), frame_info.FrameSizeInBytes(), vreg);
     return true;
   }
 }
@@ -291,8 +295,9 @@
     const DexFile::CodeItem* code_item = m->GetCodeItem();
     DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be NULL or how would we compile
                                                       // its instructions?
-    uint32_t* addr = GetVRegAddr(cur_quick_frame_, code_item, frame_info.CoreSpillMask(),
-                                 frame_info.FpSpillMask(), frame_info.FrameSizeInBytes(), vreg);
+    uint32_t* addr = GetVRegAddrFromQuickCode(
+        cur_quick_frame_, code_item, frame_info.CoreSpillMask(),
+        frame_info.FpSpillMask(), frame_info.FrameSizeInBytes(), vreg);
     *val = *reinterpret_cast<uint64_t*>(addr);
     return true;
   }
@@ -365,8 +370,9 @@
     const DexFile::CodeItem* code_item = m->GetCodeItem();
     DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be NULL or how would we compile
                                                       // its instructions?
-    uint32_t* addr = GetVRegAddr(cur_quick_frame_, code_item, frame_info.CoreSpillMask(),
-                                 frame_info.FpSpillMask(), frame_info.FrameSizeInBytes(), vreg);
+    uint32_t* addr = GetVRegAddrFromQuickCode(
+        cur_quick_frame_, code_item, frame_info.CoreSpillMask(),
+        frame_info.FpSpillMask(), frame_info.FrameSizeInBytes(), vreg);
     *addr = new_value;
     return true;
   }
@@ -494,8 +500,9 @@
     const DexFile::CodeItem* code_item = m->GetCodeItem();
     DCHECK(code_item != nullptr) << PrettyMethod(m);  // Can't be NULL or how would we compile
                                                       // its instructions?
-    uint32_t* addr = GetVRegAddr(cur_quick_frame_, code_item, frame_info.CoreSpillMask(),
-                                 frame_info.FpSpillMask(), frame_info.FrameSizeInBytes(), vreg);
+    uint32_t* addr = GetVRegAddrFromQuickCode(
+        cur_quick_frame_, code_item, frame_info.CoreSpillMask(),
+        frame_info.FpSpillMask(), frame_info.FrameSizeInBytes(), vreg);
     *reinterpret_cast<uint64_t*>(addr) = new_value;
     return true;
   }