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/assembler_x86.cc b/src/assembler_x86.cc
index 45c0086..892bf76 100644
--- a/src/assembler_x86.cc
+++ b/src/assembler_x86.cc
@@ -134,6 +134,12 @@
   EmitImmediate(imm);
 }
 
+void X86Assembler::movl(const Address& dst, Label* lbl) {
+  AssemblerBuffer::EnsureCapacity ensured(&buffer_);
+  EmitUint8(0xC7);
+  EmitOperand(0, dst);
+  EmitLabel(lbl, dst.length_ + 5);
+}
 
 void X86Assembler::movzxb(Register dst, ByteRegister src) {
   AssemblerBuffer::EnsureCapacity ensured(&buffer_);
@@ -1389,11 +1395,6 @@
   ret();
 }
 
-void X86Assembler::FillFromSpillArea(
-    const std::vector<ManagedRegister>& spill_regs, size_t displacement) {
-  CHECK_EQ(0u, spill_regs.size());  // no spilled regs on x86
-}
-
 void X86Assembler::IncreaseFrameSize(size_t adjust) {
   CHECK(IsAligned(adjust, kStackAlignment));
   addl(ESP, Immediate(-adjust));
@@ -1467,6 +1468,10 @@
   fs()->movl(Address::Absolute(thr_offs), ESP);
 }
 
+void X86Assembler::StoreLabelToThread(ThreadOffset thr_offs, Label* lbl) {
+  fs()->movl(Address::Absolute(thr_offs), lbl);
+}
+
 void X86Assembler::StoreSpanning(FrameOffset dest, ManagedRegister src,
                                  FrameOffset in_off, ManagedRegister scratch) {
   UNIMPLEMENTED(FATAL);  // this case only currently exists for ARM
@@ -1654,19 +1659,11 @@
 }
 
 void X86Assembler::Call(FrameOffset base, Offset offset, ManagedRegister) {
-  // TODO: Needed for:
-  // JniCompilerTest.CompileAndRunIntObjectObjectMethod
-  // JniCompilerTest.CompileAndRunStaticIntObjectObjectMethod
-  // JniCompilerTest.CompileAndRunStaticSynchronizedIntObjectObjectMethod
-  // JniCompilerTest.ReturnGlobalRef
   UNIMPLEMENTED(FATAL);
 }
 
-// TODO: remove this generator of non-PIC code
-void X86Assembler::Call(uintptr_t addr, ManagedRegister mscratch) {
-  Register scratch = mscratch.AsX86().AsCpuRegister();
-  movl(scratch, Immediate(addr));
-  call(scratch);
+void X86Assembler::Call(ThreadOffset offset, ManagedRegister mscratch) {
+  fs()->call(Address::Absolute(offset));
 }
 
 void X86Assembler::GetCurrentThread(ManagedRegister tr) {