Skip to content

Commit

Permalink
Pass in arena to allocator
Browse files Browse the repository at this point in the history
This is so we can configure a new arena later
  • Loading branch information
tenderlove committed Sep 26, 2019
1 parent dd1e047 commit 451776f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions compile.c
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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)
{
Expand Down

0 comments on commit 451776f

Please sign in to comment.