summaryrefslogtreecommitdiffstats
path: root/runtime/interpreter
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2015-03-05 10:40:17 +0000
committerNicolas Geoffray <ngeoffray@google.com>2015-03-09 10:09:33 +0000
commit14691c5e786e8c2c5734f687e4c96217340771be (patch)
tree7c2156671b323c70ffdd1d48d5e2f1d1de79c5fc /runtime/interpreter
parent3d7d2af4c6502b771b032ee9bf3ab30e78f9c60d (diff)
downloadart-14691c5e786e8c2c5734f687e4c96217340771be.zip
art-14691c5e786e8c2c5734f687e4c96217340771be.tar.gz
art-14691c5e786e8c2c5734f687e4c96217340771be.tar.bz2
Compute the right catch location for the debugger.
Also remove tls ThrowLocation, it is not needed anymore. Change-Id: I78fddf09ce968ca475e39c17fa76d699c589c8d9
Diffstat (limited to 'runtime/interpreter')
-rw-r--r--runtime/interpreter/interpreter_common.cc84
-rw-r--r--runtime/interpreter/interpreter_goto_table_impl.cc4
-rw-r--r--runtime/interpreter/interpreter_switch_impl.cc4
3 files changed, 9 insertions, 83 deletions
diff --git a/runtime/interpreter/interpreter_common.cc b/runtime/interpreter/interpreter_common.cc
index 754602f..3f09bd3 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();
}
@@ -936,7 +862,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 37324ea..f1ab747 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 2f85587..dceed47 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;