summaryrefslogtreecommitdiffstats
path: root/compiler/utils
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2014-10-10 15:39:11 +0100
committerVladimir Marko <vmarko@google.com>2014-10-10 15:40:01 +0100
commit3d2ec35be5aadecc9d2bbd80394929ba3b36a4bf (patch)
treee007e66d240f12782361e998719901145508243f /compiler/utils
parentacfbbd4df2fc1c79a7102587bebf398f95b5e5de (diff)
downloadart-3d2ec35be5aadecc9d2bbd80394929ba3b36a4bf.zip
art-3d2ec35be5aadecc9d2bbd80394929ba3b36a4bf.tar.gz
art-3d2ec35be5aadecc9d2bbd80394929ba3b36a4bf.tar.bz2
Fix ScopedArenaAllocator::Reset() for Create()d allocators.
Change-Id: I88cbb329911ed489768772218b49b6f1756ffd86
Diffstat (limited to 'compiler/utils')
-rw-r--r--compiler/utils/scoped_arena_allocator.cc10
-rw-r--r--compiler/utils/scoped_arena_allocator.h2
2 files changed, 11 insertions, 1 deletions
diff --git a/compiler/utils/scoped_arena_allocator.cc b/compiler/utils/scoped_arena_allocator.cc
index aeb2f76..2616150 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<uint8_t*>(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 62ea330..523f158 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 <typename T>
friend class ScopedArenaAllocatorAdapter;