diff options
| author | 2016-01-04 15:32:43 -0800 | |
|---|---|---|
| committer | 2016-01-05 08:16:06 -0800 | |
| commit | 103992b9171fac9eceb2fe4015ab04f544b9c559 (patch) | |
| tree | 0e21aeb48e11130f9bfe1c1c42202ba715e30cb6 /runtime/entrypoints/entrypoint_utils.cc | |
| parent | 376a6f3dbae7b71a6fc2c339ec416d3407277308 (diff) | |
ART: Move ThrowStackOverflowError to common_throws
This should really be in common_throws considering all the callers.
Change-Id: I410c07cbf5659f216d44597530cb85f99740f320
Diffstat (limited to 'runtime/entrypoints/entrypoint_utils.cc')
| -rw-r--r-- | runtime/entrypoints/entrypoint_utils.cc | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc index 915d9ab5e7..b5a55bfa44 100644 --- a/runtime/entrypoints/entrypoint_utils.cc +++ b/runtime/entrypoints/entrypoint_utils.cc @@ -33,7 +33,6 @@ #include "oat_quick_method_header.h" #include "reflection.h" #include "scoped_thread_state_change.h" -#include "ScopedLocalRef.h" #include "well_known_classes.h" namespace art { @@ -120,102 +119,6 @@ mirror::Array* CheckAndAllocArrayFromCodeInstrumented(uint32_t type_idx, heap->GetCurrentAllocator()); } -void ThrowStackOverflowError(Thread* self) { - if (self->IsHandlingStackOverflow()) { - LOG(ERROR) << "Recursive stack overflow."; - // We don't fail here because SetStackEndForStackOverflow will print better diagnostics. - } - - self->SetStackEndForStackOverflow(); // Allow space on the stack for constructor to execute. - JNIEnvExt* env = self->GetJniEnv(); - std::string msg("stack size "); - msg += PrettySize(self->GetStackSize()); - - // Avoid running Java code for exception initialization. - // TODO: Checks to make this a bit less brittle. - - std::string error_msg; - - // Allocate an uninitialized object. - ScopedLocalRef<jobject> exc(env, - env->AllocObject(WellKnownClasses::java_lang_StackOverflowError)); - if (exc.get() != nullptr) { - // "Initialize". - // StackOverflowError -> VirtualMachineError -> Error -> Throwable -> Object. - // Only Throwable has "custom" fields: - // String detailMessage. - // Throwable cause (= this). - // List<Throwable> suppressedExceptions (= Collections.emptyList()). - // Object stackState; - // StackTraceElement[] stackTrace; - // Only Throwable has a non-empty constructor: - // this.stackTrace = EmptyArray.STACK_TRACE_ELEMENT; - // fillInStackTrace(); - - // detailMessage. - // TODO: Use String::FromModifiedUTF...? - ScopedLocalRef<jstring> s(env, env->NewStringUTF(msg.c_str())); - if (s.get() != nullptr) { - env->SetObjectField(exc.get(), WellKnownClasses::java_lang_Throwable_detailMessage, s.get()); - - // cause. - env->SetObjectField(exc.get(), WellKnownClasses::java_lang_Throwable_cause, exc.get()); - - // suppressedExceptions. - ScopedLocalRef<jobject> emptylist(env, env->GetStaticObjectField( - WellKnownClasses::java_util_Collections, - WellKnownClasses::java_util_Collections_EMPTY_LIST)); - CHECK(emptylist.get() != nullptr); - env->SetObjectField(exc.get(), - WellKnownClasses::java_lang_Throwable_suppressedExceptions, - emptylist.get()); - - // stackState is set as result of fillInStackTrace. fillInStackTrace calls - // nativeFillInStackTrace. - ScopedLocalRef<jobject> stack_state_val(env, nullptr); - { - ScopedObjectAccessUnchecked soa(env); - stack_state_val.reset(soa.Self()->CreateInternalStackTrace<false>(soa)); - } - if (stack_state_val.get() != nullptr) { - env->SetObjectField(exc.get(), - WellKnownClasses::java_lang_Throwable_stackState, - stack_state_val.get()); - - // stackTrace. - ScopedLocalRef<jobject> stack_trace_elem(env, env->GetStaticObjectField( - WellKnownClasses::libcore_util_EmptyArray, - WellKnownClasses::libcore_util_EmptyArray_STACK_TRACE_ELEMENT)); - env->SetObjectField(exc.get(), - WellKnownClasses::java_lang_Throwable_stackTrace, - stack_trace_elem.get()); - } else { - error_msg = "Could not create stack trace."; - } - // Throw the exception. - self->SetException(reinterpret_cast<mirror::Throwable*>(self->DecodeJObject(exc.get()))); - } else { - // Could not allocate a string object. - error_msg = "Couldn't throw new StackOverflowError because JNI NewStringUTF failed."; - } - } else { - error_msg = "Could not allocate StackOverflowError object."; - } - - if (!error_msg.empty()) { - LOG(WARNING) << error_msg; - CHECK(self->IsExceptionPending()); - } - - bool explicit_overflow_check = Runtime::Current()->ExplicitStackOverflowChecks(); - self->ResetDefaultStackEnd(); // Return to default stack size. - - // And restore protection if implicit checks are on. - if (!explicit_overflow_check) { - self->ProtectStack(); - } -} - void CheckReferenceResult(mirror::Object* o, Thread* self) { if (o == nullptr) { return; |