Thumb2: Fix EmitJumpTables() to extend buffer only if needed.
Bug: 28256882
Change-Id: I15227535c0fcb73c04b0b05160852c4b1bebee49
diff --git a/compiler/utils/assembler.cc b/compiler/utils/assembler.cc
index c2aa574..e6c3a18 100644
--- a/compiler/utils/assembler.cc
+++ b/compiler/utils/assembler.cc
@@ -47,7 +47,7 @@
AssemblerBuffer::AssemblerBuffer(ArenaAllocator* arena)
: arena_(arena) {
static const size_t kInitialBufferCapacity = 4 * KB;
- contents_ = arena_->AllocArray<uint8_t>(kInitialBufferCapacity);
+ contents_ = arena_->AllocArray<uint8_t>(kInitialBufferCapacity, kArenaAllocAssembler);
cursor_ = contents_;
limit_ = ComputeLimit(contents_, kInitialBufferCapacity);
fixup_ = nullptr;
@@ -94,6 +94,7 @@
void AssemblerBuffer::ExtendCapacity(size_t min_capacity) {
size_t old_size = Size();
size_t old_capacity = Capacity();
+ DCHECK_GT(min_capacity, old_capacity);
size_t new_capacity = std::min(old_capacity * 2, old_capacity + 1 * MB);
new_capacity = std::max(new_capacity, min_capacity);