From 3d2ec35be5aadecc9d2bbd80394929ba3b36a4bf Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 10 Oct 2014 15:39:11 +0100 Subject: Fix ScopedArenaAllocator::Reset() for Create()d allocators. Change-Id: I88cbb329911ed489768772218b49b6f1756ffd86 --- compiler/utils/scoped_arena_allocator.cc | 10 +++++++++- compiler/utils/scoped_arena_allocator.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'compiler/utils') diff --git a/compiler/utils/scoped_arena_allocator.cc b/compiler/utils/scoped_arena_allocator.cc index aeb2f768dd..26161501b3 100644 --- a/compiler/utils/scoped_arena_allocator.cc +++ b/compiler/utils/scoped_arena_allocator.cc @@ -115,10 +115,18 @@ ScopedArenaAllocator::ScopedArenaAllocator(ArenaStack* arena_stack) } ScopedArenaAllocator::~ScopedArenaAllocator() { - Reset(); + DoReset(); } void ScopedArenaAllocator::Reset() { + DoReset(); + // If this allocator was Create()d, we need to move the arena_stack_->top_ptr_ past *this. + if (mark_ptr_ == reinterpret_cast(this)) { + arena_stack_->top_ptr_ = mark_ptr_ + RoundUp(sizeof(ScopedArenaAllocator), 8); + } +} + +void ScopedArenaAllocator::DoReset() { DebugStackReference::CheckTop(); DebugStackRefCounter::CheckNoRefs(); arena_stack_->UpdatePeakStatsAndRestore(*this); diff --git a/compiler/utils/scoped_arena_allocator.h b/compiler/utils/scoped_arena_allocator.h index 62ea3302a3..523f158969 100644 --- a/compiler/utils/scoped_arena_allocator.h +++ b/compiler/utils/scoped_arena_allocator.h @@ -132,6 +132,8 @@ class ScopedArenaAllocator uint8_t* mark_ptr_; uint8_t* mark_end_; + void DoReset(); + template friend class ScopedArenaAllocatorAdapter; -- cgit v1.2.3-59-g8ed1b