Support for exception throwing.

These changes start to add support for a long jump style of exception throw.
A Context is added to build up the registers that will be loaded by the long
jump from callee saves that are on the stack. Throws are reworked slightly to
give the PC for the frame of the method being looked at, rather than the return
PC (that previously led the trace's PC to be off by a frame). Callee save
support is added to the JNI compiler which then no longer needs to spill
incoming argument registers as it may reuse the callee saves.

Currently the code is lightly tested on ARM and doesn't support
restoring floating point callee save registers.

Also clean up some PIC TODOs.

Change-Id: I9bcef4ab3bf4a9de57d7a5123fb3bb1707ca8921
diff --git a/src/jni_compiler_test.cc b/src/jni_compiler_test.cc
index 20c403c..9328e85 100644
--- a/src/jni_compiler_test.cc
+++ b/src/jni_compiler_test.cc
@@ -53,9 +53,11 @@
     }
     ASSERT_TRUE(jmethod_ != NULL);
 
-    if (native_fnptr) {
+    if (native_fnptr != NULL) {
       JNINativeMethod methods[] = {{method_name, method_sig, native_fnptr}};
       ASSERT_EQ(JNI_OK, env_->RegisterNatives(jklass_, methods, 1));
+    } else {
+      env_->UnregisterNatives(jklass_);
     }
 
     jmethodID constructor = env_->GetMethodID(jklass_, "<init>", "()V");
@@ -233,10 +235,6 @@
 }
 
 TEST_F(JniCompilerTest, CompileAndRunIntObjectObjectMethod) {
-#if !defined(__arm__)
-  UNIMPLEMENTED(WARNING) << "needs X86Assembler::Call(FrameOffset base, Offset offset, ManagedRegister)";
-  return;
-#endif
   SetupForTest(false, "fooIOO",
                "(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
                reinterpret_cast<void*>(&Java_MyClass_fooIOO));
@@ -336,10 +334,6 @@
 
 
 TEST_F(JniCompilerTest, CompileAndRunStaticIntObjectObjectMethod) {
-#if !defined(__arm__)
-  UNIMPLEMENTED(WARNING) << "needs X86Assembler::Call(FrameOffset base, Offset offset, ManagedRegister)";
-  return;
-#endif
   SetupForTest(true, "fooSIOO",
                "(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
                reinterpret_cast<void*>(&Java_MyClass_fooSIOO));
@@ -390,10 +384,6 @@
 }
 
 TEST_F(JniCompilerTest, CompileAndRunStaticSynchronizedIntObjectObjectMethod) {
-#if !defined(__arm__)
-  UNIMPLEMENTED(WARNING) << "needs X86Assembler::Call(FrameOffset base, Offset offset, ManagedRegister)";
-  return;
-#endif
   SetupForTest(true, "fooSSIOO",
                "(ILjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
                reinterpret_cast<void*>(&Java_MyClass_fooSSIOO));
@@ -546,10 +536,6 @@
 }
 
 TEST_F(JniCompilerTest, ReturnGlobalRef) {
-#if !defined(__arm__)
-  UNIMPLEMENTED(WARNING) << "needs X86Assembler::Call(FrameOffset base, Offset offset, ManagedRegister)";
-  return;
-#endif
   SetupForTest(false, "fooO", "(Ljava/lang/Object;)Ljava/lang/Object;",
                reinterpret_cast<void*>(&Java_MyClass_fooO));
   jobject result = env_->CallNonvirtualObjectMethod(jobj_, jklass_, jmethod_, jobj_);