diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2015-03-09 10:11:03 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-03-09 10:11:03 +0000 |
commit | 5c9d8f0d2948c2b4fe4258f96e3598ad5b8fa23b (patch) | |
tree | 7510031e119cf981cdb6aafc5e5c2299aa06590d /runtime/interpreter | |
parent | 3dd536ffd7e8f82e4587964545b272acbd61d68e (diff) | |
parent | 14691c5e786e8c2c5734f687e4c96217340771be (diff) | |
download | art-5c9d8f0d2948c2b4fe4258f96e3598ad5b8fa23b.tar.gz art-5c9d8f0d2948c2b4fe4258f96e3598ad5b8fa23b.tar.bz2 art-5c9d8f0d2948c2b4fe4258f96e3598ad5b8fa23b.zip |
Merge "Compute the right catch location for the debugger."
Diffstat (limited to 'runtime/interpreter')
-rw-r--r-- | runtime/interpreter/interpreter_common.cc | 84 | ||||
-rw-r--r-- | runtime/interpreter/interpreter_goto_table_impl.cc | 4 | ||||
-rw-r--r-- | runtime/interpreter/interpreter_switch_impl.cc | 4 |
3 files changed, 9 insertions, 83 deletions
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc index 82d412c505..e6e647cbd9 100644 --- a/runtime/interpreter/interpreter_common.cc +++ b/runtime/interpreter/interpreter_common.cc @@ -413,90 +413,16 @@ EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL(Primitive::kPrimNot) // iput-objec #undef EXPLICIT_DO_IPUT_QUICK_ALL_TEMPLATE_DECL #undef EXPLICIT_DO_IPUT_QUICK_TEMPLATE_DECL -/** - * Finds the location where this exception will be caught. We search until we reach either the top - * frame or a native frame, in which cases this exception is considered uncaught. - */ -class CatchLocationFinder : public StackVisitor { - public: - explicit CatchLocationFinder(Thread* self, Handle<mirror::Throwable>* exception) - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) - : StackVisitor(self, nullptr), self_(self), handle_scope_(self), exception_(exception), - catch_method_(handle_scope_.NewHandle<mirror::ArtMethod>(nullptr)), - catch_dex_pc_(DexFile::kDexNoIndex), clear_exception_(false) { - } - - bool VisitFrame() OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - mirror::ArtMethod* method = GetMethod(); - if (method == nullptr) { - return true; - } - if (method->IsRuntimeMethod()) { - // Ignore callee save method. - DCHECK(method->IsCalleeSaveMethod()); - return true; - } - if (method->IsNative()) { - return false; // End stack walk. - } - DCHECK(!method->IsNative()); - uint32_t dex_pc = GetDexPc(); - if (dex_pc != DexFile::kDexNoIndex) { - uint32_t found_dex_pc; - { - StackHandleScope<3> hs(self_); - Handle<mirror::Class> exception_class(hs.NewHandle((*exception_)->GetClass())); - Handle<mirror::ArtMethod> h_method(hs.NewHandle(method)); - found_dex_pc = mirror::ArtMethod::FindCatchBlock(h_method, exception_class, dex_pc, - &clear_exception_); - } - if (found_dex_pc != DexFile::kDexNoIndex) { - catch_method_.Assign(method); - catch_dex_pc_ = found_dex_pc; - return false; // End stack walk. - } - } - return true; // Continue stack walk. - } - - ArtMethod* GetCatchMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return catch_method_.Get(); - } - - uint32_t GetCatchDexPc() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return catch_dex_pc_; - } - - bool NeedClearException() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return clear_exception_; - } - - private: - Thread* const self_; - StackHandleScope<1> handle_scope_; - Handle<mirror::Throwable>* exception_; - MutableHandle<mirror::ArtMethod> catch_method_; - uint32_t catch_dex_pc_; - bool clear_exception_; - - - DISALLOW_COPY_AND_ASSIGN(CatchLocationFinder); -}; - uint32_t FindNextInstructionFollowingException(Thread* self, ShadowFrame& shadow_frame, uint32_t dex_pc, const instrumentation::Instrumentation* instrumentation) { self->VerifyStack(); - ThrowLocation throw_location; StackHandleScope<3> hs(self); - Handle<mirror::Throwable> exception(hs.NewHandle(self->GetException(&throw_location))); + Handle<mirror::Throwable> exception(hs.NewHandle(self->GetException())); if (instrumentation->HasExceptionCaughtListeners() && self->IsExceptionThrownByCurrentMethod(exception.Get())) { - CatchLocationFinder clf(self, &exception); - clf.WalkStack(false); - instrumentation->ExceptionCaughtEvent(self, throw_location, clf.GetCatchMethod(), - clf.GetCatchDexPc(), exception.Get()); + instrumentation->ExceptionCaughtEvent(self, exception.Get()); } bool clear_exception = false; uint32_t found_dex_pc; @@ -848,7 +774,7 @@ static void CheckExceptionGenerateClassNotFound(Thread* self) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { if (self->IsExceptionPending()) { // If it is not an InternalError, wrap it. - std::string type(PrettyTypeOf(self->GetException(nullptr))); + std::string type(PrettyTypeOf(self->GetException())); if (type != "java.lang.InternalError") { self->ThrowNewWrappedException(self->GetCurrentLocationForThrow(), "Ljava/lang/ClassNotFoundException;", @@ -903,7 +829,7 @@ static void UnstartedRuntimeInvoke(Thread* self, const DexFile::CodeItem* code_ // This might have an error pending. But semantics are to just return null. if (self->IsExceptionPending()) { // If it is an InternalError, keep it. See CheckExceptionGenerateClassNotFound. - std::string type(PrettyTypeOf(self->GetException(nullptr))); + std::string type(PrettyTypeOf(self->GetException())); if (type != "java.lang.InternalError") { self->ClearException(); } @@ -938,7 +864,7 @@ static void UnstartedRuntimeInvoke(Thread* self, const DexFile::CodeItem* code_ if (!ok) { std::string error_msg = StringPrintf("Failed in Class.newInstance for '%s' with %s", PrettyClass(h_klass.Get()).c_str(), - PrettyTypeOf(self->GetException(nullptr)).c_str()); + PrettyTypeOf(self->GetException()).c_str()); self->ThrowNewWrappedException(self->GetCurrentLocationForThrow(), "Ljava/lang/InternalError;", error_msg.c_str()); diff --git a/runtime/interpreter/interpreter_goto_table_impl.cc b/runtime/interpreter/interpreter_goto_table_impl.cc index 37324eac82..f1ab7477ef 100644 --- a/runtime/interpreter/interpreter_goto_table_impl.cc +++ b/runtime/interpreter/interpreter_goto_table_impl.cc @@ -244,7 +244,7 @@ JValue ExecuteGotoImpl(Thread* self, const DexFile::CodeItem* code_item, ShadowF HANDLE_INSTRUCTION_END(); HANDLE_INSTRUCTION_START(MOVE_EXCEPTION) { - Throwable* exception = self->GetException(nullptr); + Throwable* exception = self->GetException(); DCHECK(exception != nullptr) << "No pending exception on MOVE_EXCEPTION instruction"; shadow_frame.SetVRegReference(inst->VRegA_11x(inst_data), exception); self->ClearException(); @@ -605,7 +605,7 @@ JValue ExecuteGotoImpl(Thread* self, const DexFile::CodeItem* code_item, ShadowF "Throwing '%s' that is not instance of Throwable", exception->GetClass()->GetDescriptor(&temp)); } else { - self->SetException(shadow_frame.GetCurrentLocationForThrow(), exception->AsThrowable()); + self->SetException(exception->AsThrowable()); } HANDLE_PENDING_EXCEPTION(); } diff --git a/runtime/interpreter/interpreter_switch_impl.cc b/runtime/interpreter/interpreter_switch_impl.cc index 2f85587604..dceed47169 100644 --- a/runtime/interpreter/interpreter_switch_impl.cc +++ b/runtime/interpreter/interpreter_switch_impl.cc @@ -163,7 +163,7 @@ JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item, break; case Instruction::MOVE_EXCEPTION: { PREAMBLE(); - Throwable* exception = self->GetException(nullptr); + Throwable* exception = self->GetException(); DCHECK(exception != nullptr) << "No pending exception on MOVE_EXCEPTION instruction"; shadow_frame.SetVRegReference(inst->VRegA_11x(inst_data), exception); self->ClearException(); @@ -515,7 +515,7 @@ JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item, "Throwing '%s' that is not instance of Throwable", exception->GetClass()->GetDescriptor(&temp)); } else { - self->SetException(shadow_frame.GetCurrentLocationForThrow(), exception->AsThrowable()); + self->SetException(exception->AsThrowable()); } HANDLE_PENDING_EXCEPTION(); break; |