diff options
author | 2018-05-22 15:33:48 +0100 | |
---|---|---|
committer | 2018-05-23 13:48:31 +0100 | |
commit | 6ec2a1bf1cbecf17546df780dd0ad769042e1874 (patch) | |
tree | 09f7430f020e04dc892ff2c2152bb773cd45c0dd /runtime/interpreter/interpreter_common.cc | |
parent | 2d3065e6ca0bd707bc998b7d260bb8e8ec07cf87 (diff) |
ObjPtr<>-ify UnstartedRuntime, fix 2 stale reference uses.
Test: Rely on TreeHugger.
Bug: 31113334
Change-Id: I35f76c3e3b94dfca18dbe67aba065a1270f4e5ee
Diffstat (limited to 'runtime/interpreter/interpreter_common.cc')
-rw-r--r-- | runtime/interpreter/interpreter_common.cc | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc index 5a50ec5586..708a7884fa 100644 --- a/runtime/interpreter/interpreter_common.cc +++ b/runtime/interpreter/interpreter_common.cc @@ -34,6 +34,7 @@ #include "mirror/var_handle.h" #include "reflection-inl.h" #include "reflection.h" +#include "shadow_frame-inl.h" #include "stack.h" #include "thread-inl.h" #include "transaction.h" @@ -1428,6 +1429,24 @@ bool DoInvokeCustom(Thread* self, } } +// Assign register 'src_reg' from shadow_frame to register 'dest_reg' into new_shadow_frame. +static inline void AssignRegister(ShadowFrame* new_shadow_frame, const ShadowFrame& shadow_frame, + size_t dest_reg, size_t src_reg) + REQUIRES_SHARED(Locks::mutator_lock_) { + // Uint required, so that sign extension does not make this wrong on 64b systems + uint32_t src_value = shadow_frame.GetVReg(src_reg); + ObjPtr<mirror::Object> o = shadow_frame.GetVRegReference<kVerifyNone>(src_reg); + + // If both register locations contains the same value, the register probably holds a reference. + // Note: As an optimization, non-moving collectors leave a stale reference value + // in the references array even after the original vreg was overwritten to a non-reference. + if (src_value == reinterpret_cast<uintptr_t>(o.Ptr())) { + new_shadow_frame->SetVRegReference(dest_reg, o); + } else { + new_shadow_frame->SetVReg(dest_reg, src_value); + } +} + template <bool is_range> inline void CopyRegisters(ShadowFrame& caller_frame, ShadowFrame* callee_frame, @@ -1612,7 +1631,7 @@ static inline bool DoCallCommon(ArtMethod* called_method, return false; } } - new_shadow_frame->SetVRegReference(dest_reg, o.Ptr()); + new_shadow_frame->SetVRegReference(dest_reg, o); break; } // Handle doubles and longs. 2 consecutive virtual register slots. |