ART: Mark deallocated arena memory as inaccessible.

Mark arena and scoped arena memory freed by allocator
adapters as inaccessible. This can help catch accesses to
old storage of a container, for example the old data of an
ArenaVector<> that's been resized.

Together with debug-mode enforcement of destruction of all
scoped arena containers, this provides strong verification
of their memory usage. However, this does not apply to the
normal (non-scoped) arena memory held by arena containers
as they are typically not destroyed if they are themselves
located in the arena. ArenaBitVector memory, whether in
normal or scoped arena, isn't marked either.

Change-Id: I4d2a80fedf7ceb7d4ce24ee8e7bcd53513171388
diff --git a/runtime/base/scoped_arena_allocator.h b/runtime/base/scoped_arena_allocator.h
index ca514e4..4f51370 100644
--- a/runtime/base/scoped_arena_allocator.h
+++ b/runtime/base/scoped_arena_allocator.h
@@ -32,11 +32,16 @@
 class ScopedArenaAllocatorAdapter;
 
 // Holds a list of Arenas for use by ScopedArenaAllocator stack.
-class ArenaStack : private DebugStackRefCounter {
+class ArenaStack : private DebugStackRefCounter, private ArenaAllocatorMemoryTool {
  public:
   explicit ArenaStack(ArenaPool* arena_pool);
   ~ArenaStack();
 
+  using ArenaAllocatorMemoryTool::IsRunningOnMemoryTool;
+  using ArenaAllocatorMemoryTool::MakeDefined;
+  using ArenaAllocatorMemoryTool::MakeUndefined;
+  using ArenaAllocatorMemoryTool::MakeInaccessible;
+
   void Reset();
 
   size_t PeakBytesAllocated() {
@@ -64,8 +69,8 @@
 
   // Private - access via ScopedArenaAllocator or ScopedArenaAllocatorAdapter.
   void* Alloc(size_t bytes, ArenaAllocKind kind) ALWAYS_INLINE {
-    if (UNLIKELY(is_running_on_memory_tool_)) {
-      return AllocValgrind(bytes, kind);
+    if (UNLIKELY(IsRunningOnMemoryTool())) {
+      return AllocWithMemoryTool(bytes, kind);
     }
     size_t rounded_bytes = RoundUp(bytes, 8);
     uint8_t* ptr = top_ptr_;
@@ -80,7 +85,7 @@
   uint8_t* AllocateFromNextArena(size_t rounded_bytes);
   void UpdatePeakStatsAndRestore(const ArenaAllocatorStats& restore_stats);
   void UpdateBytesAllocated();
-  void* AllocValgrind(size_t bytes, ArenaAllocKind kind);
+  void* AllocWithMemoryTool(size_t bytes, ArenaAllocKind kind);
 
   StatsAndPool stats_and_pool_;
   Arena* bottom_arena_;
@@ -88,8 +93,6 @@
   uint8_t* top_ptr_;
   uint8_t* top_end_;
 
-  const bool is_running_on_memory_tool_;
-
   friend class ScopedArenaAllocator;
   template <typename T>
   friend class ScopedArenaAllocatorAdapter;