Stack support for Optimizing compiler

Allows to read/write DEX registers from physical register or stack
location when the method is compiled with the Optimizing compiler.

Required fixing arm and arm64 JNI compiler by saving floating
point registers.

Bug: 18547544
Change-Id: I401579f251d1c0a130f6cf4a93a960cdcd7518f5
diff --git a/runtime/stack_map.h b/runtime/stack_map.h
index fd22361..ec37699 100644
--- a/runtime/stack_map.h
+++ b/runtime/stack_map.h
@@ -104,10 +104,9 @@
         return "in fpu register";
       case kConstant:
         return "as constant";
-      default:
-        LOG(FATAL) << "Invalid location kind " << static_cast<int>(kind);
-        return nullptr;
     }
+    UNREACHABLE();
+    return nullptr;
   }
 
   LocationKind GetLocationKind(uint16_t register_index) const {
@@ -126,6 +125,23 @@
         kFixedSize + sizeof(LocationKind) + register_index * SingleEntrySize());
   }
 
+  int32_t GetStackOffsetInBytes(uint16_t register_index) const {
+    DCHECK(GetLocationKind(register_index) == kInStack);
+    // We currently encode the offset in bytes.
+    return GetValue(register_index);
+  }
+
+  int32_t GetConstant(uint16_t register_index) const {
+    DCHECK(GetLocationKind(register_index) == kConstant);
+    return GetValue(register_index);
+  }
+
+  int32_t GetMachineRegister(uint16_t register_index) const {
+    DCHECK(GetLocationKind(register_index) == kInRegister
+        || GetLocationKind(register_index) == kInFpuRegister);
+    return GetValue(register_index);
+  }
+
   static size_t SingleEntrySize() {
     return sizeof(LocationKind) + sizeof(int32_t);
   }