Merge "ART: Heap-allocate buffer in space_bitmap when on 64b arch"
diff --git a/runtime/gc/accounting/space_bitmap.cc b/runtime/gc/accounting/space_bitmap.cc
index 8e817e5..3cb8d94 100644
--- a/runtime/gc/accounting/space_bitmap.cc
+++ b/runtime/gc/accounting/space_bitmap.cc
@@ -127,9 +127,17 @@
   }
 
   // TODO: rewrite the callbacks to accept a std::vector<mirror::Object*> rather than a mirror::Object**?
-  const size_t buffer_size = kWordSize * kBitsPerWord;
+  constexpr size_t buffer_size = kWordSize * kBitsPerWord;
+#ifdef __LP64__
+  // Heap-allocate for smaller stack frame.
+  std::unique_ptr<mirror::Object*[]> pointer_buf_ptr(new mirror::Object*[buffer_size]);
+  mirror::Object** pointer_buf = pointer_buf_ptr.get();
+#else
+  // Stack-allocate buffer as it's small enough.
   mirror::Object* pointer_buf[buffer_size];
+#endif
   mirror::Object** pb = &pointer_buf[0];
+
   size_t start = OffsetToIndex(sweep_begin - live_bitmap.heap_begin_);
   size_t end = OffsetToIndex(sweep_end - live_bitmap.heap_begin_ - 1);
   CHECK_LT(end, live_bitmap.Size() / kWordSize);