Various fixes to the interpreter. First 23 run-test tests pass.
- Factored out code to throw stack overflow error into its own method.
- Increased kStackOverflowReservedBytes to 10kB to support interpreter.
- Reordered return type checks to prevent type resolution with an
exception pending.
- Fixed field checks so they pass if the field is static or the object
is the declaring class.
- Suppressed using the interpreter for proxy methods.
Change-Id: Ide73ec928ab0aa7b31229c4e69679a35dd948e43
diff --git a/src/runtime_support.cc b/src/runtime_support.cc
index 7ee1960..92c5e3a 100644
--- a/src/runtime_support.cc
+++ b/src/runtime_support.cc
@@ -343,4 +343,28 @@
return klass;
}
+void ThrowStackOverflowError(Thread* self) {
+ CHECK(!self->IsHandlingStackOverflow()) << "Recursive stack overflow.";
+ // Remove extra entry pushed onto second stack during method tracing.
+ if (Runtime::Current()->IsMethodTracingActive()) {
+ InstrumentationMethodUnwindFromCode(self);
+ }
+ self->SetStackEndForStackOverflow(); // Allow space on the stack for constructor to execute.
+ JNIEnvExt* env = self->GetJniEnv();
+ std::string msg("stack size ");
+ msg += PrettySize(self->GetStackSize());
+ // Use low-level JNI routine and pre-baked error class to avoid class linking operations that
+ // would consume more stack.
+ int rc = ::art::ThrowNewException(env, WellKnownClasses::java_lang_StackOverflowError,
+ msg.c_str(), NULL);
+ if (rc != JNI_OK) {
+ // TODO: ThrowNewException failed presumably because of an OOME, we continue to throw the OOME
+ // or die in the CHECK below. We may want to throw a pre-baked StackOverflowError
+ // instead.
+ LOG(ERROR) << "Couldn't throw new StackOverflowError because JNI ThrowNew failed.";
+ CHECK(self->IsExceptionPending());
+ }
+ self->ResetDefaultStackEnd(); // Return to default stack size.
+}
+
} // namespace art