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/thread.cc b/src/thread.cc
index 426677e..d879cea 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -48,33 +48,6 @@
LOG(INFO) << "Info: " << info;
}
-/*
- * TODO: placeholder for a method that can be called by the
- * invoke-interface trampoline to unwind and handle exception. The
- * trampoline will arrange it so that the caller appears to be the
- * callsite of the failed invoke-interface. See comments in
- * compiler/runtime_support.S
- */
-extern "C" void artFailedInvokeInterface() {
- UNIMPLEMENTED(FATAL) << "Unimplemented exception throw";
-}
-
-// TODO: placeholder. See comments in compiler/runtime_support.S
-extern "C" uint64_t artFindInterfaceMethodInCache(uint32_t method_idx,
- Object* this_object , Method* caller_method)
-{
- /*
- * Note: this_object has not yet been null-checked. To match
- * the old-world state, nullcheck this_object and load
- * Class* this_class = this_object->GetClass().
- * See comments and possible thrown exceptions in old-world
- * Interp.cpp:dvmInterpFindInterfaceMethod, and complete with
- * new-world FindVirtualMethodForInterface.
- */
- UNIMPLEMENTED(FATAL) << "Unimplemented invoke interface";
- return 0LL;
-}
-
// TODO: placeholder. This is what generated code will call to throw
void ThrowException(Thread* thread, Throwable* exception) {
/*
@@ -146,6 +119,7 @@
// TODO: placeholder
void StackOverflowFromCode(Method* method) {
+ Thread::Current()->Dump(std::cerr);
//NOTE: to save code space, this handler needs to look up its own Thread*
UNIMPLEMENTED(FATAL) << "Stack overflow: " << PrettyMethod(method);
}
@@ -220,6 +194,38 @@
(char*)&table[4], size_in_bytes);
}
+/*
+ * TODO: placeholder for a method that can be called by the
+ * invoke-interface trampoline to unwind and handle exception. The
+ * trampoline will arrange it so that the caller appears to be the
+ * callsite of the failed invoke-interface. See comments in
+ * runtime_support.S
+ */
+extern "C" void artFailedInvokeInterface() {
+ UNIMPLEMENTED(FATAL) << "Unimplemented exception throw";
+}
+
+// See comments in runtime_support.S
+extern "C" uint64_t artFindInterfaceMethodInCache(uint32_t method_idx,
+ Object* this_object , Method* caller_method)
+{
+ if (this_object == NULL) {
+ ThrowNullPointerFromCode();
+ }
+ ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
+ Method* interface_method = class_linker->ResolveMethod(method_idx, caller_method, false);
+ if (interface_method == NULL) {
+ UNIMPLEMENTED(FATAL) << "Could not resolve interface method. Throw error and unwind";
+ }
+ Method* method = this_object->GetClass()->FindVirtualMethodForInterface(interface_method);
+ const void* code = method->GetCode();
+
+ uint32_t method_uint = reinterpret_cast<uint32_t>(method);
+ uint64_t code_uint = reinterpret_cast<uint32_t>(code);
+ uint64_t result = ((code_uint << 32) | method_uint);
+ return result;
+}
+
// TODO: move to more appropriate location
/*
* Float/double conversion requires clamping to min and max of integer form. If
@@ -251,6 +257,11 @@
return (int64_t)f;
}
+// Return value helper for jobject return types
+static Object* DecodeJObjectInThread(Thread* thread, jobject obj) {
+ return thread->DecodeJObject(obj);
+}
+
void Thread::InitFunctionPointers() {
#if defined(__arm__)
pShlLong = art_shl_long;
@@ -312,6 +323,8 @@
pThrowRuntimeExceptionFromCode = ThrowRuntimeExceptionFromCode;
pThrowInternalErrorFromCode = ThrowInternalErrorFromCode;
pThrowNoSuchMethodFromCode = ThrowNoSuchMethodFromCode;
+ pFindNativeMethod = FindNativeMethod;
+ pDecodeJObjectInThread = DecodeJObjectInThread;
pDebugMe = DebugMe;
}