From 423d2a3dcbb260b020efb5da59f784c9f02accbf Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Thu, 12 Sep 2013 17:33:56 -0700 Subject: Add support for changing roots through the root visitor callback. Needed for copying collectors. Change-Id: Icc4a342a57e0cfb79587edb02ef8c85e08808877 --- runtime/stack.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'runtime/stack.h') diff --git a/runtime/stack.h b/runtime/stack.h index 8ecf8f0..bd29ceb 100644 --- a/runtime/stack.h +++ b/runtime/stack.h @@ -150,7 +150,12 @@ class ShadowFrame { mirror::Object* GetVRegReference(size_t i) const { DCHECK_LT(i, NumberOfVRegs()); if (HasReferenceArray()) { - return References()[i]; + mirror::Object* ref = References()[i]; + // If the vreg reference is not equal to the vreg then the vreg reference is stale. + if (reinterpret_cast(ref) != vregs_[i]) { + return nullptr; + } + return ref; } else { const uint32_t* vreg = &vregs_[i]; return *reinterpret_cast(vreg); @@ -459,13 +464,14 @@ class StackVisitor { uintptr_t GetGPR(uint32_t reg) const; void SetGPR(uint32_t reg, uintptr_t value); - uint32_t GetVReg(mirror::ArtMethod** cur_quick_frame, const DexFile::CodeItem* code_item, + // This is a fast-path for getting/setting values in a quick frame. + uint32_t* GetVRegAddr(mirror::ArtMethod** cur_quick_frame, const DexFile::CodeItem* code_item, uint32_t core_spills, uint32_t fp_spills, size_t frame_size, uint16_t vreg) const { int offset = GetVRegOffset(code_item, core_spills, fp_spills, frame_size, vreg); DCHECK_EQ(cur_quick_frame, GetCurrentQuickFrame()); byte* vreg_addr = reinterpret_cast(cur_quick_frame) + offset; - return *reinterpret_cast(vreg_addr); + return reinterpret_cast(vreg_addr); } uintptr_t GetReturnPc() const; -- cgit v1.1