Spill possibly reference holding registers for runtime calls.

Live references may be in registers when we crawl a stack for GC during
a runtime call. Whilst an exception won't occur we need to save the
callee save registers into the frame so the stack crawl can find their
values. Create variants of the callee save method to save just the
registers that are necessary.

Change-Id: I6fa479bffcbc333fe846f9bd3ef2e626e0209ed9
diff --git a/src/common_test.h b/src/common_test.h
index 72701d9..84b97e9 100644
--- a/src/common_test.h
+++ b/src/common_test.h
@@ -127,23 +127,29 @@
     ASSERT_TRUE(runtime_.get() != NULL);
     class_linker_ = runtime_->GetClassLinker();
 
+    InstructionSet instruction_set = kNone;
 #if defined(__i386__)
-    InstructionSet insns = kX86;
+    instruction_set = kX86;
 #elif defined(__arm__)
-    InstructionSet insns = kThumb2;
-#else
-    InstructionSet insns = kNone;
+    instruction_set = kThumb2;
 #endif
-    runtime_->SetJniStubArray(JniCompiler::CreateJniStub(insns));
-    runtime_->SetAbstractMethodErrorStubArray(Compiler::CreateAbstractMethodErrorStub(insns));
-    runtime_->SetCalleeSaveMethod(runtime_->CreateCalleeSaveMethod(insns));
-    for (int i=0; i < Runtime::kMaxTrampolineMethodType; i++) {
+    runtime_->SetJniStubArray(JniCompiler::CreateJniStub(instruction_set));
+    runtime_->SetAbstractMethodErrorStubArray(Compiler::CreateAbstractMethodErrorStub(instruction_set));
+    for (int i=0; i < Runtime::kLastTrampolineMethodType; i++) {
       Runtime::TrampolineType type = Runtime::TrampolineType(i);
       if (!runtime_->HasResolutionStubArray(type)) {
-        runtime_->SetResolutionStubArray(Compiler::CreateResolutionStub(insns, type), type);
+        runtime_->SetResolutionStubArray(
+            Compiler::CreateResolutionStub(instruction_set, type), type);
       }
     }
-    compiler_.reset(new Compiler(insns));
+    for (int i=0; i < Runtime::kLastCalleeSaveType; i++) {
+      Runtime::CalleeSaveType type = Runtime::CalleeSaveType(i);
+      if (!runtime_->HasCalleeSaveMethod(type)) {
+        runtime_->SetCalleeSaveMethod(
+            runtime_->CreateCalleeSaveMethod(instruction_set, type), type);
+      }
+    }
+    compiler_.reset(new Compiler(instruction_set));
 
     Heap::VerifyHeap();  // Check for heap corruption before the test
   }