Interpret class initializers when building image.
We initialize all image classes with the interpreter if they have a
class/static initializer.
Black list classes whose initializers need access to on device native
code. If such classes are added to the image classes they will fail when
they attempt to enter JNI code. A number of "intrinsic" style JNI
routines are special cased to allow more than just trivial class
initializers to run.
Add a lock for initialization in the compiler to serialize the execution
of class initializers and avoid deadlock.
Remove InSourceSpace from image writer (cruft) and teach the image writer
to fix up referent fields in references.
Fix bugs in the interprerter and implement filled-new-array.
Factor some VM code to more easily share between the interpreter and
JNI entry points.
Change-Id: I6bb811dea84f1b82260b1a4e73ac7412179c0b41
diff --git a/src/heap.cc b/src/heap.cc
index cf13eae..d12d20e 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -1984,11 +1984,14 @@
void Heap::EnqueueClearedReferences(Object** cleared) {
DCHECK(cleared != NULL);
if (*cleared != NULL) {
- ScopedObjectAccess soa(Thread::Current());
- JValue args[1];
- args[0].SetL(*cleared);
- soa.DecodeMethod(WellKnownClasses::java_lang_ref_ReferenceQueue_add)->Invoke(soa.Self(), NULL,
- args, NULL);
+ // When a runtime isn't started there are no reference queues to care about so ignore.
+ if (LIKELY(Runtime::Current()->IsStarted())) {
+ ScopedObjectAccess soa(Thread::Current());
+ JValue args[1];
+ args[0].SetL(*cleared);
+ soa.DecodeMethod(WellKnownClasses::java_lang_ref_ReferenceQueue_add)->Invoke(soa.Self(), NULL,
+ args, NULL);
+ }
*cleared = NULL;
}
}