Add oat file generation and tests to build
- Currently builds boot.oat for host and target
and target oat files for art tests.
- Added cross compilation support via --strip-prefix option to dex2oat
- Reduced output to prevent build log spam (Compiler::verbose_)
- Added image roots for recovering important pointers on image load
- Redid JNI stub creation and made the stub array an image root
- Fixed JNI stub test by making JNI stub array executable
- Fixed JNI UnregisterNative to having it reinstall the JNI stub
- Fixed ARM JNI stub to generate PIC code (with irogers)
- Fixed JniCompiler to generate PIC code (with irogers)
- Fixed FindNativeMethod to handle recursive calls
- Finished checkFieldType to use Object::InstanceOf
- Fixed thread unsafe access to ClassLinker::{dex_files_,dex_caches_}
- Added ResolvedMethod variant for use with Method* for context
- Fixed ImageWriter to call FixupMethod
- Fixed ImageWriter to rewrite JNI stub references
- Improved error reporting on lack of ANDROID_DATA dir or art-cache dir
- Fixed Runtime::Start to InitLibraries before creating thread peer
- Implemented Space::IsCondemned to skip spaces loaded from images
- Implemented artFindInterfaceMethodInCache,
allowing interface invocation from managed code
Change-Id: I603e97fa0ac44508ae05a2e47c1cdb4481678d7b
diff --git a/src/compiler.cc b/src/compiler.cc
index fa9867d..8a382f5 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -10,7 +10,7 @@
#include "jni_internal.h"
#include "runtime.h"
-extern bool oatCompileMethod(art::Method*, art::InstructionSet);
+extern bool oatCompileMethod(const art::Compiler& compiler, art::Method*, art::InstructionSet);
namespace art {
@@ -31,7 +31,8 @@
ByteArray* CreateAbstractMethodErrorStub(ThrowAme);
}
-Compiler::Compiler(InstructionSet insns) : instruction_set_(insns), jni_compiler_(insns) {
+Compiler::Compiler(InstructionSet insns) : instruction_set_(insns), jni_compiler_(insns),
+ verbose_(false) {
if (insns == kArm || insns == kThumb2) {
abstract_method_error_stub_ = arm::CreateAbstractMethodErrorStub(&ThrowAbstractMethodError);
} else if (insns == kX86) {
@@ -41,7 +42,15 @@
void Compiler::CompileAll(const ClassLoader* class_loader) {
Resolve(class_loader);
- // TODO add verification step
+ // TODO: add verification step
+
+ // TODO: mark all verified classes initialized if they have no <clinit>
+ ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
+ Class* Class_class = class_linker->FindSystemClass("Ljava/lang/Class;");
+ Method* Class_clinit = Class_class->FindDirectMethod("<clinit>", "()V");
+ CHECK(Class_clinit == NULL);
+ Class_class->SetStatus(Class::kStatusInitialized);
+
Compile(class_loader);
SetCodeAndDirectMethods(class_loader);
}
@@ -49,7 +58,7 @@
void Compiler::CompileOne(Method* method) {
const ClassLoader* class_loader = method->GetDeclaringClass()->GetClassLoader();
Resolve(class_loader);
- // TODO add verification step
+ // TODO: add verification step
CompileMethod(method);
SetCodeAndDirectMethods(class_loader);
}
@@ -131,6 +140,8 @@
void Compiler::CompileMethod(Method* method) {
if (method->IsNative()) {
jni_compiler_.Compile(method);
+ // unregister will install the stub to lookup via dlsym
+ method->UnregisterNative();
} else if (method->IsAbstract()) {
DCHECK(abstract_method_error_stub_ != NULL);
if (instruction_set_ == kX86) {
@@ -140,7 +151,7 @@
method->SetCode(abstract_method_error_stub_, kArm);
}
} else {
- oatCompileMethod(method, kThumb2);
+ oatCompileMethod(*this, method, kThumb2);
}
CHECK(method->GetCode() != NULL);