summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2019-09-12 15:02:23 -0700
committerAaron Patterson <tenderlove@ruby-lang.org>2019-09-26 13:56:41 -0700
commit451776f13d24b0121b2bdfbe4eaafe7c74069c72 (patch)
treeb81f65e0147ad71200a8c639a3cc418da7c12a1b /compile.c
parentdd1e047fcb2a6429dd960b38a9ce03f86bb828fa (diff)
Pass in arena to allocator
This is so we can configure a new arena later
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c14
1 files 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)
{