summaryrefslogtreecommitdiff
path: root/node.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-22 10:38:55 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-22 10:38:55 +0000
commit52bd0d190042f739a80e76f43e7ef3cbc8ae0969 (patch)
tree706e2ea3a9a8b2d0b9e0714661a412e52377cd74 /node.c
parentc5f50296b412436e6d03d459b43eae16e6fdbbf5 (diff)
node.h (rb_ast_t): move its field mark_ary to node_buffer_t
I want to add a new field to rb_ast_t whose size is restricted because it is an imemo. This change makes one room in rb_ast_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'node.c')
-rw-r--r--node.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/node.c b/node.c
index 2f626cacfd..7c5e1397e6 100644
--- a/node.c
+++ b/node.c
@@ -1058,6 +1058,7 @@ struct node_buffer_struct {
long idx, len;
node_buffer_elem_t *head;
node_buffer_elem_t *last;
+ VALUE mark_ary;
};
static node_buffer_t *
@@ -1068,6 +1069,7 @@ rb_node_buffer_new(void)
nb->len = 16;
nb->head = nb->last = (node_buffer_elem_t*) &nb[1];
nb->head->next = NULL;
+ nb->mark_ary = rb_ary_tmp_new(0);
return nb;
}
@@ -1111,13 +1113,17 @@ rb_ast_delete_node(rb_ast_t *ast, NODE *n)
rb_ast_t *
rb_ast_new(void)
{
- return (rb_ast_t *)rb_imemo_new(imemo_ast, rb_ary_tmp_new(0), 0, 0, (VALUE)rb_node_buffer_new());
+ node_buffer_t *nb = rb_node_buffer_new();
+ VALUE mark_ary = nb->mark_ary;
+ rb_ast_t *ast = (rb_ast_t *)rb_imemo_new(imemo_ast, 0, 0, 0, (VALUE)nb);
+ RB_GC_GUARD(mark_ary);
+ return ast;
}
void
rb_ast_mark(rb_ast_t *ast)
{
- if (ast->node_buffer) rb_gc_mark(ast->mark_ary);
+ if (ast->node_buffer) rb_gc_mark(ast->node_buffer->mark_ary);
}
void
@@ -1133,11 +1139,11 @@ void
rb_ast_dispose(rb_ast_t *ast)
{
rb_ast_free(ast);
- RB_OBJ_WRITE(ast, &ast->mark_ary, Qnil);
+ if (ast->node_buffer) RB_OBJ_WRITE(ast, &ast->node_buffer->mark_ary, Qnil);
}
void
rb_ast_add_mark_object(rb_ast_t *ast, VALUE obj)
{
- rb_ary_push(ast->mark_ary, obj);
+ rb_ary_push(ast->node_buffer->mark_ary, obj);
}