Fix compiler class initialization to properly deal with super classes
Also moving active parts of compiler_test to be oat tests including
IntMath and Invoke. Added an interface invocation test case to Invoke
test. Changed Compiler to CHECK that it is not used once the
Runtime::IsStarted, forcing some jni_compiler_test to have two phases,
one for compiling before Runtime::Start and one for JNI operations
after the Runtime::IsStarted.
Finally, fixed Class::CanPutArrayElementFromCode by removing
CanPutArrayElement and calling IsAssignableFrom directly.
Change-Id: I52ca4dbc0e02db65f274ccc3ca7468dce365a44e
diff --git a/src/compiler.cc b/src/compiler.cc
index 017861f..4d7ad19 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -24,6 +24,7 @@
Compiler::Compiler(InstructionSet insns) : instruction_set_(insns), jni_compiler_(insns),
verbose_(false) {
+ CHECK(!Runtime::Current()->IsStarted());
if (insns == kArm || insns == kThumb2) {
abstract_method_error_stub_ = arm::CreateAbstractMethodErrorStub();
} else if (insns == kX86) {
@@ -32,6 +33,7 @@
}
void Compiler::CompileAll(const ClassLoader* class_loader) {
+ DCHECK(!Runtime::Current()->IsStarted());
Resolve(class_loader);
Verify(class_loader);
InitializeClassesWithoutClinit(class_loader);
@@ -40,6 +42,7 @@
}
void Compiler::CompileOne(Method* method) {
+ DCHECK(!Runtime::Current()->IsStarted());
const ClassLoader* class_loader = method->GetDeclaringClass()->GetClassLoader();
Resolve(class_loader);
Verify(class_loader);
@@ -124,19 +127,7 @@
const DexFile::ClassDef& class_def = dex_file.GetClassDef(class_def_index);
const char* descriptor = dex_file.GetClassDescriptor(class_def);
Class* klass = class_linker->FindClass(descriptor, class_loader);
- CHECK(klass != NULL);
- if (klass->IsInitialized()) {
- continue;
- }
- CHECK(klass->IsVerified() || klass->IsErroneous());
- if (!klass->IsVerified()) {
- continue;
- }
- Method* clinit = klass->FindDirectMethod("<clinit>", "()V");
- if (clinit != NULL) {
- continue;
- }
- klass->SetStatus(Class::kStatusInitialized);
+ class_linker->EnsureInitialized(klass, false);
}
DexCache* dex_cache = class_linker->FindDexCache(dex_file);