ART: Enforce arena alignment in Realloc
Enforce the expected alignment in Realloc when the given buffer
can be expanded.
Add debug checks to prove alignment guarantees.
Change-Id: I7dbaf3ca0896f714cff07ff08f067a7c088a6c8d
Test: m test-art-host
diff --git a/runtime/base/arena_allocator.cc b/runtime/base/arena_allocator.cc
index b84e29f..aeb990c 100644
--- a/runtime/base/arena_allocator.cc
+++ b/runtime/base/arena_allocator.cc
@@ -163,6 +163,7 @@
MallocArena::MallocArena(size_t size) {
memory_ = reinterpret_cast<uint8_t*>(calloc(1, size));
CHECK(memory_ != nullptr); // Abort on OOM.
+ DCHECK_ALIGNED(memory_, ArenaAllocator::kAlignment);
size_ = size;
}
@@ -370,6 +371,7 @@
arena_head_ = new_arena;
// Update our internal data structures.
begin_ = new_arena->Begin();
+ DCHECK_ALIGNED(begin_, kAlignment);
ptr_ = begin_ + bytes;
end_ = new_arena->End();
}