Skip to content

Commit

Permalink
Introduce a secondary arena
Browse files Browse the repository at this point in the history
We'll scan the secondary arena during GC mark. So, we should only
allocate "markable" instruction linked list nodes out of the secondary
arena.
  • Loading branch information
tenderlove committed Sep 26, 2019
1 parent bd017c6 commit 3cd8f76
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compile.c
Expand Up @@ -882,7 +882,7 @@ compile_data_alloc_with_arena(struct iseq_compile_data_storage **arena, size_t s
static void *
compile_data_alloc(rb_iseq_t *iseq, size_t size)
{
struct iseq_compile_data_storage ** arena = &ISEQ_COMPILE_DATA(iseq)->storage_current;
struct iseq_compile_data_storage ** arena = &ISEQ_COMPILE_DATA(iseq)->node.storage_current;
return compile_data_alloc_with_arena(arena, size);
}

Expand Down
8 changes: 5 additions & 3 deletions iseq.c
Expand Up @@ -75,7 +75,8 @@ static void
compile_data_free(struct iseq_compile_data *compile_data)
{
if (compile_data) {
free_arena(compile_data->storage_head);
free_arena(compile_data->node.storage_head);
free_arena(compile_data->insn.storage_head);
if (compile_data->ivar_cache_table) {
rb_id_table_free(compile_data->ivar_cache_table);
}
Expand Down Expand Up @@ -420,7 +421,7 @@ rb_iseq_memsize(const rb_iseq_t *iseq)

size += sizeof(struct iseq_compile_data);

cur = compile_data->storage_head;
cur = compile_data->node.storage_head;
while (cur) {
size += cur->size + offsetof(struct iseq_compile_data_storage, buff);
cur = cur->next;
Expand Down Expand Up @@ -558,7 +559,8 @@ prepare_iseq_build(rb_iseq_t *iseq,
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->mark_ary, rb_ary_tmp_new(3));
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, Qnil);

ISEQ_COMPILE_DATA(iseq)->storage_head = ISEQ_COMPILE_DATA(iseq)->storage_current = new_arena();
ISEQ_COMPILE_DATA(iseq)->node.storage_head = ISEQ_COMPILE_DATA(iseq)->node.storage_current = new_arena();
ISEQ_COMPILE_DATA(iseq)->insn.storage_head = ISEQ_COMPILE_DATA(iseq)->insn.storage_current = new_arena();
ISEQ_COMPILE_DATA(iseq)->option = option;

ISEQ_COMPILE_DATA(iseq)->ivar_cache_table = NULL;
Expand Down
10 changes: 8 additions & 2 deletions iseq.h
Expand Up @@ -99,8 +99,14 @@ struct iseq_compile_data {
struct iseq_label_data *redo_label;
const rb_iseq_t *current_block;
struct iseq_compile_data_ensure_node_stack *ensure_node_stack;
struct iseq_compile_data_storage *storage_head;
struct iseq_compile_data_storage *storage_current;
struct {
struct iseq_compile_data_storage *storage_head;
struct iseq_compile_data_storage *storage_current;
} node;
struct {
struct iseq_compile_data_storage *storage_head;
struct iseq_compile_data_storage *storage_current;
} insn;
int loopval_popped; /* used by NODE_BREAK */
int last_line;
int label_no;
Expand Down

0 comments on commit 3cd8f76

Please sign in to comment.