summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 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<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 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 <typename T>
friend class ScopedArenaAllocatorAdapter;