Add tests for Thumb2RelativePatcher.

Also make the thumb2/arm64 thunk allocation precise instead
of eagerly allocating thunk space. This allows the calls to
use the maximum positive offset.

Change-Id: Ifa95b0bb00bd73eeab0c2905d21e2f3078f4b0a8
diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc
index d2a0f4f..e15890f 100644
--- a/compiler/oat_writer.cc
+++ b/compiler/oat_writer.cc
@@ -357,7 +357,8 @@
   bool EndClass() {
     OatDexMethodVisitor::EndClass();
     if (oat_class_index_ == writer_->oat_classes_.size()) {
-      offset_ = writer_->relative_patcher_->ReserveSpace(offset_, nullptr);
+      offset_ = writer_->relative_patcher_->ReserveSpace(offset_, nullptr,
+                                                         MethodReference(nullptr, 0u));
     }
     return true;
   }
@@ -384,7 +385,8 @@
         quick_code_offset = lb->second;
         deduped = true;
       } else {
-        offset_ = writer_->relative_patcher_->ReserveSpace(offset_, compiled_method);
+        offset_ = writer_->relative_patcher_->ReserveSpace(
+            offset_, compiled_method, MethodReference(dex_file_, it.GetMemberIndex()));
         offset_ = compiled_method->AlignCode(offset_);
         DCHECK_ALIGNED_PARAM(offset_,
                              GetInstructionSetAlignment(compiled_method->GetInstructionSet()));