From 451776f13d24b0121b2bdfbe4eaafe7c74069c72 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 12 Sep 2019 15:02:23 -0700 Subject: Pass in arena to allocator This is so we can configure a new arena later --- compile.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/compile.c b/compile.c index 51b7b9fc3c..ccd2c37674 100644 --- a/compile.c +++ b/compile.c @@ -841,11 +841,10 @@ calc_padding(void *ptr, size_t size) #endif /* STRICT_ALIGNMENT */ static void * -compile_data_alloc(rb_iseq_t *iseq, size_t size) +compile_data_alloc_with_arena(struct iseq_compile_data_storage **arena, size_t size) { void *ptr = 0; - struct iseq_compile_data_storage *storage = - ISEQ_COMPILE_DATA(iseq)->storage_current; + struct iseq_compile_data_storage *storage = *arena; #ifdef STRICT_ALIGNMENT size_t padding = calc_padding((void *)&storage->buff[storage->pos], size); #else @@ -862,7 +861,7 @@ compile_data_alloc(rb_iseq_t *iseq, size_t size) } storage->next = (void *)ALLOC_N(char, alloc_size + offsetof(struct iseq_compile_data_storage, buff)); - storage = ISEQ_COMPILE_DATA(iseq)->storage_current = storage->next; + storage = *arena = storage->next; storage->next = 0; storage->pos = 0; storage->size = alloc_size; @@ -880,6 +879,13 @@ compile_data_alloc(rb_iseq_t *iseq, size_t size) return ptr; } +static void * +compile_data_alloc(rb_iseq_t *iseq, size_t size) +{ + struct iseq_compile_data_storage ** arena = &ISEQ_COMPILE_DATA(iseq)->storage_current; + return compile_data_alloc_with_arena(arena, size); +} + static INSN * compile_data_alloc_insn(rb_iseq_t *iseq) { -- cgit v1.2.3