diff options
author | Jeff Hao <jeffhao@google.com> | 2014-04-23 00:16:15 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-04-23 00:16:15 +0000 |
commit | a08ec9b372d4f5e918b3d68499fbd1731180cd98 (patch) | |
tree | 4c21e507ec2b2ca36011313d9a40d151e23f6193 /runtime | |
parent | 4af159bfcc66c6e90a2aee4a2035a996a399e7ed (diff) | |
parent | aa961918da5142220029da2809287e0dd537a5d7 (diff) | |
download | art-a08ec9b372d4f5e918b3d68499fbd1731180cd98.zip art-a08ec9b372d4f5e918b3d68499fbd1731180cd98.tar.gz art-a08ec9b372d4f5e918b3d68499fbd1731180cd98.tar.bz2 |
Merge "Fix FindCatchBlock to work in -Xverify:none mode."
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/catch_block_stack_visitor.cc | 4 | ||||
-rw-r--r-- | runtime/catch_block_stack_visitor.h | 2 | ||||
-rw-r--r-- | runtime/interpreter/interpreter_common.h | 3 | ||||
-rw-r--r-- | runtime/mirror/art_method.cc | 21 | ||||
-rw-r--r-- | runtime/mirror/art_method.h | 3 |
5 files changed, 23 insertions, 10 deletions
diff --git a/runtime/catch_block_stack_visitor.cc b/runtime/catch_block_stack_visitor.cc index f9acffb..410fff9 100644 --- a/runtime/catch_block_stack_visitor.cc +++ b/runtime/catch_block_stack_visitor.cc @@ -53,7 +53,9 @@ bool CatchBlockStackVisitor::HandleTryItems(mirror::ArtMethod* method) { } if (dex_pc != DexFile::kDexNoIndex) { bool clear_exception = false; - uint32_t found_dex_pc = method->FindCatchBlock(to_find_, dex_pc, &clear_exception); + SirtRef<mirror::Class> sirt_method_to_find(Thread::Current(), to_find_); + uint32_t found_dex_pc = method->FindCatchBlock(sirt_method_to_find, dex_pc, &clear_exception); + to_find_ = sirt_method_to_find.get(); catch_finder_->SetClearException(clear_exception); if (found_dex_pc != DexFile::kDexNoIndex) { catch_finder_->SetHandlerDexPc(found_dex_pc); diff --git a/runtime/catch_block_stack_visitor.h b/runtime/catch_block_stack_visitor.h index 175ad7d..ce67e27 100644 --- a/runtime/catch_block_stack_visitor.h +++ b/runtime/catch_block_stack_visitor.h @@ -45,7 +45,7 @@ class CatchBlockStackVisitor : public StackVisitor { Thread* const self_; const bool is_deoptimization_; // The type of the exception catch block to find. - mirror::Class* const to_find_; + mirror::Class* to_find_; CatchFinder* const catch_finder_; // Number of native methods passed in crawl (equates to number of SIRTs to pop) uint32_t native_method_count_; diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h index 21eeafa..65bdf0e 100644 --- a/runtime/interpreter/interpreter_common.h +++ b/runtime/interpreter/interpreter_common.h @@ -498,7 +498,8 @@ static inline uint32_t FindNextInstructionFollowingException(Thread* self, ThrowLocation throw_location; mirror::Throwable* exception = self->GetException(&throw_location); bool clear_exception = false; - uint32_t found_dex_pc = shadow_frame.GetMethod()->FindCatchBlock(exception->GetClass(), dex_pc, + SirtRef<mirror::Class> exception_class(self, exception->GetClass()); + uint32_t found_dex_pc = shadow_frame.GetMethod()->FindCatchBlock(exception_class, dex_pc, &clear_exception); if (found_dex_pc == DexFile::kDexNoIndex) { instrumentation->MethodUnwindEvent(self, this_object, diff --git a/runtime/mirror/art_method.cc b/runtime/mirror/art_method.cc index c998346..f3303a8 100644 --- a/runtime/mirror/art_method.cc +++ b/runtime/mirror/art_method.cc @@ -230,10 +230,15 @@ uintptr_t ArtMethod::ToNativePc(const uint32_t dex_pc) { return 0; } -uint32_t ArtMethod::FindCatchBlock(Class* exception_type, uint32_t dex_pc, +uint32_t ArtMethod::FindCatchBlock(SirtRef<Class>& exception_type, uint32_t dex_pc, bool* has_no_move_exception) { MethodHelper mh(this); const DexFile::CodeItem* code_item = mh.GetCodeItem(); + // Set aside the exception while we resolve its type. + Thread* self = Thread::Current(); + ThrowLocation throw_location; + SirtRef<mirror::Throwable> exception(self, self->GetException(&throw_location)); + self->ClearException(); // Default to handler not found. uint32_t found_dex_pc = DexFile::kDexNoIndex; // Iterate over the catch handlers associated with dex_pc. @@ -245,21 +250,25 @@ uint32_t ArtMethod::FindCatchBlock(Class* exception_type, uint32_t dex_pc, break; } // Does this catch exception type apply? - Class* iter_exception_type = mh.GetDexCacheResolvedType(iter_type_idx); - if (iter_exception_type == NULL) { - // The verifier should take care of resolving all exception classes early + Class* iter_exception_type = mh.GetClassFromTypeIdx(iter_type_idx); + if (exception_type.get() == nullptr) { + self->ClearException(); LOG(WARNING) << "Unresolved exception class when finding catch block: " << mh.GetTypeDescriptorFromTypeIdx(iter_type_idx); - } else if (iter_exception_type->IsAssignableFrom(exception_type)) { + } else if (iter_exception_type->IsAssignableFrom(exception_type.get())) { found_dex_pc = it.GetHandlerAddress(); break; } } if (found_dex_pc != DexFile::kDexNoIndex) { const Instruction* first_catch_instr = - Instruction::At(&mh.GetCodeItem()->insns_[found_dex_pc]); + Instruction::At(&code_item->insns_[found_dex_pc]); *has_no_move_exception = (first_catch_instr->Opcode() != Instruction::MOVE_EXCEPTION); } + // Put the exception back. + if (exception.get() != nullptr) { + self->SetException(throw_location, exception.get()); + } return found_dex_pc; } diff --git a/runtime/mirror/art_method.h b/runtime/mirror/art_method.h index fd5ac19..38e44be 100644 --- a/runtime/mirror/art_method.h +++ b/runtime/mirror/art_method.h @@ -418,7 +418,8 @@ class MANAGED ArtMethod : public Object { // Find the catch block for the given exception type and dex_pc. When a catch block is found, // indicates whether the found catch block is responsible for clearing the exception or whether // a move-exception instruction is present. - uint32_t FindCatchBlock(Class* exception_type, uint32_t dex_pc, bool* has_no_move_exception) + uint32_t FindCatchBlock(SirtRef<Class>& exception_type, uint32_t dex_pc, + bool* has_no_move_exception) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); static void SetClass(Class* java_lang_reflect_ArtMethod); |