summaryrefslogtreecommitdiff
path: root/compiler/driver/compiler_driver.cc
diff options
context:
space:
mode:
author Ian Rogers <irogers@google.com> 2013-08-27 23:34:06 -0700
committer Ian Rogers <irogers@google.com> 2013-08-27 23:37:33 -0700
commita436fde2762664a3ecdda5eefcadd20b2e104f59 (patch)
tree22431bc387483220728a3bc99ec7314abce3ad60 /compiler/driver/compiler_driver.cc
parent10cc81056261625902a8a073bafb9f499eec4ff7 (diff)
Handle OOMEs in class linker with grace.
Check for OOMEs and then fail due to them in class loading. Make the compiler driver spot OOMEs during resolution and abort compilation to avoid needless GC thrash then eventual death. Allocate the pre-allocated OOME during Runtime::Init as Runtime::Start isn't called in the context of the compiler/tools. Change-Id: Id72199d0fe82001b5bf22758b3cdc9cc4b8efbb9
Diffstat (limited to 'compiler/driver/compiler_driver.cc')
-rw-r--r--compiler/driver/compiler_driver.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 634d3bc9c0..3368e96139 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -671,7 +671,7 @@ void CompilerDriver::LoadImageClasses(base::TimingLogger& timings)
if (klass.get() == NULL) {
image_classes_->erase(it++);
VLOG(compiler) << "Failed to find class " << descriptor;
- Thread::Current()->ClearException();
+ self->ClearException();
} else {
++it;
}
@@ -1472,7 +1472,7 @@ static void ResolveClassFieldsAndMethods(const ParallelCompilationManager* manag
// Class couldn't be resolved, for example, super-class is in a different dex file. Don't
// attempt to resolve methods and fields when there is no declaring class.
CHECK(soa.Self()->IsExceptionPending());
- Thread::Current()->ClearException();
+ soa.Self()->ClearException();
resolve_fields_and_methods = false;
} else {
resolve_fields_and_methods = manager->GetCompiler()->IsImage();
@@ -1547,7 +1547,14 @@ static void ResolveType(const ParallelCompilationManager* manager, size_t type_i
if (klass == NULL) {
CHECK(soa.Self()->IsExceptionPending());
- Thread::Current()->ClearException();
+ mirror::Throwable* exception = soa.Self()->GetException(NULL);
+ VLOG(compiler) << "Exception during type resolution: " << exception->Dump();
+ if (strcmp(ClassHelper(exception->GetClass()).GetDescriptor(),
+ "Ljava/lang/OutOfMemoryError;") == 0) {
+ // There's little point continuing compilation if the heap is exhausted.
+ LOG(FATAL) << "Out of memory during type resolution for compilation";
+ }
+ soa.Self()->ClearException();
}
}