From 00d878c62a7ab728f776306aa4d87843ac091104 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sat, 4 Jan 2014 14:34:49 -0800 Subject: [PATCH] Fixing arena chunk reuse. --- src/alloy/arena.cc | 3 ++- src/alloy/hir/hir_builder.cc | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/alloy/arena.cc b/src/alloy/arena.cc index 1649771dd..fe08f8c31 100644 --- a/src/alloy/arena.cc +++ b/src/alloy/arena.cc @@ -45,13 +45,14 @@ void Arena::DebugFill() { void* Arena::Alloc(size_t size) { if (active_chunk_) { - if (active_chunk_->capacity - active_chunk_->offset < size) { + if (active_chunk_->capacity - active_chunk_->offset < size + 4096) { Chunk* next = active_chunk_->next; if (!next) { XEASSERT(size < chunk_size_); // need to support larger chunks next = new Chunk(chunk_size_); active_chunk_->next = next; } + next->offset = 0; active_chunk_ = next; } } else { diff --git a/src/alloy/hir/hir_builder.cc b/src/alloy/hir/hir_builder.cc index c147ae0fc..43fa9e116 100644 --- a/src/alloy/hir/hir_builder.cc +++ b/src/alloy/hir/hir_builder.cc @@ -72,6 +72,7 @@ int HIRBuilder::Finalize() { // Sometimes VC++ generates functions with bl at the end even if they // will never return. Just add a return to satisfy things. XELOGW("Fall-through out of the function."); + Trap(); Return(); current_block_ = NULL; break;