Allocate shadow frames in interpreter on stack instead of on heap.

Instead of using new, the shadow frames are allocated using alloca.

Change-Id: Idc92fbccf1fe7589ace7b97811b21a5c67c97fd2
diff --git a/src/stack.h b/src/stack.h
index d6ff9c6..1b4d285 100644
--- a/src/stack.h
+++ b/src/stack.h
@@ -58,13 +58,23 @@
 //  - JNI - just VRegs, but where every VReg holds a reference.
 class ShadowFrame {
  public:
-  // Create ShadowFrame for interpreter.
+  // Compute size of ShadowFrame in bytes.
+  static size_t ComputeSize(uint32_t num_vregs) {
+    return sizeof(ShadowFrame) + (sizeof(uint32_t) * num_vregs) +
+           (sizeof(mirror::Object*) * num_vregs);
+  }
+
+  // Create ShadowFrame in heap for deoptimization.
   static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link,
                              mirror::AbstractMethod* method, uint32_t dex_pc) {
-    size_t sz = sizeof(ShadowFrame) +
-                (sizeof(uint32_t) * num_vregs) +
-                (sizeof(mirror::Object*) * num_vregs);
-    uint8_t* memory = new uint8_t[sz];
+    uint8_t* memory = new uint8_t[ComputeSize(num_vregs)];
+    ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true);
+    return sf;
+  }
+
+  // Create ShadowFrame for interpreter using provided memory.
+  static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link,
+                             mirror::AbstractMethod* method, uint32_t dex_pc, void* memory) {
     ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true);
     return sf;
   }