summaryrefslogtreecommitdiff
path: root/runtime/entrypoints/entrypoint_utils.cc
diff options
context:
space:
mode:
author Brian Carlstrom <bdc@google.com> 2014-09-10 23:10:47 -0700
committer Brian Carlstrom <bdc@google.com> 2014-09-11 12:09:40 -0700
commit3437531f515d84609fa43baaec32a0d1cc0e3fe0 (patch)
tree2331d63b2299babe5adb7240e7864695eb4bb34d /runtime/entrypoints/entrypoint_utils.cc
parent967e1a56df7675c8d38d411736fc081039f1a9f9 (diff)
Use WellKnownClasses in ThrowStackOverflowError to reduce changes of further stack overflow
Bug: 17463118 (cherry picked from commit bfc2b98a3cf7a9d580f2477e54aabded5004fd26) Change-Id: Iea04bb7f6c4daa9cbdb8ee6ce8ddcbeb9f05aa3d
Diffstat (limited to 'runtime/entrypoints/entrypoint_utils.cc')
-rw-r--r--runtime/entrypoints/entrypoint_utils.cc59
1 files changed, 29 insertions, 30 deletions
diff --git a/runtime/entrypoints/entrypoint_utils.cc b/runtime/entrypoints/entrypoint_utils.cc
index d834d4d115..a78c2c005b 100644
--- a/runtime/entrypoints/entrypoint_utils.cc
+++ b/runtime/entrypoints/entrypoint_utils.cc
@@ -33,8 +33,10 @@
namespace art {
-static inline mirror::Class* CheckFilledNewArrayAlloc(uint32_t type_idx, mirror::ArtMethod* referrer,
- int32_t component_count, Thread* self,
+static inline mirror::Class* CheckFilledNewArrayAlloc(uint32_t type_idx,
+ mirror::ArtMethod* referrer,
+ int32_t component_count,
+ Thread* self,
bool access_check)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
if (UNLIKELY(component_count < 0)) {
@@ -56,9 +58,10 @@ static inline mirror::Class* CheckFilledNewArrayAlloc(uint32_t type_idx, mirror:
} else {
ThrowLocation throw_location = self->GetCurrentLocationForThrow();
DCHECK(throw_location.GetMethod() == referrer);
- self->ThrowNewExceptionF(throw_location, "Ljava/lang/InternalError;",
- "Found type %s; filled-new-array not implemented for anything but 'int'",
- PrettyDescriptor(klass).c_str());
+ self->ThrowNewExceptionF(
+ throw_location, "Ljava/lang/InternalError;",
+ "Found type %s; filled-new-array not implemented for anything but 'int'",
+ PrettyDescriptor(klass).c_str());
}
return nullptr; // Failure
}
@@ -92,8 +95,10 @@ mirror::Array* CheckAndAllocArrayFromCode(uint32_t type_idx, mirror::ArtMethod*
}
// Helper function to allocate array for FILLED_NEW_ARRAY.
-mirror::Array* CheckAndAllocArrayFromCodeInstrumented(uint32_t type_idx, mirror::ArtMethod* referrer,
- int32_t component_count, Thread* self,
+mirror::Array* CheckAndAllocArrayFromCodeInstrumented(uint32_t type_idx,
+ mirror::ArtMethod* referrer,
+ int32_t component_count,
+ Thread* self,
bool access_check,
gc::AllocatorType /* allocator_type */) {
mirror::Class* klass = CheckFilledNewArrayAlloc(type_idx, referrer, component_count, self,
@@ -144,24 +149,19 @@ void ThrowStackOverflowError(Thread* self) {
// TODO: Use String::FromModifiedUTF...?
ScopedLocalRef<jstring> s(env, env->NewStringUTF(msg.c_str()));
if (s.get() != nullptr) {
- jfieldID detail_message_id = env->GetFieldID(WellKnownClasses::java_lang_Throwable,
- "detailMessage", "Ljava/lang/String;");
- env->SetObjectField(exc.get(), detail_message_id, s.get());
+ env->SetObjectField(exc.get(), WellKnownClasses::java_lang_Throwable_detailMessage, s.get());
// cause.
- jfieldID cause_id = env->GetFieldID(WellKnownClasses::java_lang_Throwable,
- "cause", "Ljava/lang/Throwable;");
- env->SetObjectField(exc.get(), cause_id, exc.get());
+ env->SetObjectField(exc.get(), WellKnownClasses::java_lang_Throwable_cause, exc.get());
// suppressedExceptions.
- jfieldID emptylist_id = env->GetStaticFieldID(WellKnownClasses::java_util_Collections,
- "EMPTY_LIST", "Ljava/util/List;");
ScopedLocalRef<jobject> emptylist(env, env->GetStaticObjectField(
- WellKnownClasses::java_util_Collections, emptylist_id));
+ WellKnownClasses::java_util_Collections,
+ WellKnownClasses::java_util_Collections_EMPTY_LIST));
CHECK(emptylist.get() != nullptr);
- jfieldID suppressed_id = env->GetFieldID(WellKnownClasses::java_lang_Throwable,
- "suppressedExceptions", "Ljava/util/List;");
- env->SetObjectField(exc.get(), suppressed_id, emptylist.get());
+ env->SetObjectField(exc.get(),
+ WellKnownClasses::java_lang_Throwable_suppressedExceptions,
+ emptylist.get());
// stackState is set as result of fillInStackTrace. fillInStackTrace calls
// nativeFillInStackTrace.
@@ -171,19 +171,17 @@ void ThrowStackOverflowError(Thread* self) {
stack_state_val.reset(soa.Self()->CreateInternalStackTrace<false>(soa));
}
if (stack_state_val.get() != nullptr) {
- jfieldID stackstateID = env->GetFieldID(WellKnownClasses::java_lang_Throwable,
- "stackState", "Ljava/lang/Object;");
- env->SetObjectField(exc.get(), stackstateID, stack_state_val.get());
+ env->SetObjectField(exc.get(),
+ WellKnownClasses::java_lang_Throwable_stackState,
+ stack_state_val.get());
// stackTrace.
- jfieldID stack_trace_elem_id = env->GetStaticFieldID(
- WellKnownClasses::libcore_util_EmptyArray, "STACK_TRACE_ELEMENT",
- "[Ljava/lang/StackTraceElement;");
ScopedLocalRef<jobject> stack_trace_elem(env, env->GetStaticObjectField(
- WellKnownClasses::libcore_util_EmptyArray, stack_trace_elem_id));
- jfieldID stacktrace_id = env->GetFieldID(
- WellKnownClasses::java_lang_Throwable, "stackTrace", "[Ljava/lang/StackTraceElement;");
- env->SetObjectField(exc.get(), stacktrace_id, stack_trace_elem.get());
+ WellKnownClasses::libcore_util_EmptyArray,
+ WellKnownClasses::libcore_util_EmptyArray_STACK_TRACE_ELEMENT));
+ env->SetObjectField(exc.get(),
+ WellKnownClasses::java_lang_Throwable_stackTrace,
+ stack_trace_elem.get());
// Throw the exception.
ThrowLocation throw_location = self->GetCurrentLocationForThrow();
@@ -326,7 +324,8 @@ JValue InvokeProxyInvocationHandler(ScopedObjectAccessAlreadyRunnable& soa, cons
}
}
CHECK_NE(throws_index, -1);
- mirror::ObjectArray<mirror::Class>* declared_exceptions = proxy_class->GetThrows()->Get(throws_index);
+ mirror::ObjectArray<mirror::Class>* declared_exceptions =
+ proxy_class->GetThrows()->Get(throws_index);
mirror::Class* exception_class = exception->GetClass();
bool declares_exception = false;
for (int i = 0; i < declared_exceptions->GetLength() && !declares_exception; i++) {