From bfd9a4378eacaf2dc2bbe05ad48c5164fc93c9fe Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Wed, 21 May 2014 17:43:44 -0700 Subject: Change MethodHelper to use a Handle. Added ConstHandle to help prevent errors where you modify the value stored in the handle of the caller. Also fixed compaction bugs related to not knowing MethodHelper::GetReturnType can resolve types. This bug was present in interpreter RETURN_OBJECT. Bug: 13077697 Change-Id: I71f964d4d810ab4debda1a09bc968af8f3c874a3 --- runtime/interpreter/interpreter_switch_impl.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'runtime/interpreter/interpreter_switch_impl.cc') diff --git a/runtime/interpreter/interpreter_switch_impl.cc b/runtime/interpreter/interpreter_switch_impl.cc index d592a53e1d..a43fad365e 100644 --- a/runtime/interpreter/interpreter_switch_impl.cc +++ b/runtime/interpreter/interpreter_switch_impl.cc @@ -244,11 +244,14 @@ JValue ExecuteSwitchImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem if (UNLIKELY(self->TestAllFlags())) { CheckSuspend(self); } - Object* obj_result = shadow_frame.GetVRegReference(inst->VRegA_11x(inst_data)); - result.SetJ(0); - result.SetL(obj_result); + const size_t ref_idx = inst->VRegA_11x(inst_data); + Object* obj_result = shadow_frame.GetVRegReference(ref_idx); if (do_assignability_check && obj_result != NULL) { - Class* return_type = MethodHelper(shadow_frame.GetMethod()).GetReturnType(); + StackHandleScope<1> hs(self); + MethodHelper mhs(hs.NewHandle(shadow_frame.GetMethod())); + Class* return_type = mhs.GetReturnType(); + // Re-load since it might have moved. + obj_result = shadow_frame.GetVRegReference(ref_idx); if (return_type == NULL) { // Return the pending exception. HANDLE_PENDING_EXCEPTION(); @@ -263,6 +266,7 @@ JValue ExecuteSwitchImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem HANDLE_PENDING_EXCEPTION(); } } + result.SetL(obj_result); if (UNLIKELY(instrumentation->HasMethodExitListeners())) { instrumentation->MethodExitEvent(self, shadow_frame.GetThisObject(code_item->ins_size_), shadow_frame.GetMethod(), inst->GetDexPc(insns), -- cgit v1.2.3-59-g8ed1b