From 52bd0d190042f739a80e76f43e7ef3cbc8ae0969 Mon Sep 17 00:00:00 2001 From: mame Date: Wed, 22 Aug 2018 10:38:55 +0000 Subject: 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 --- node.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'node.c') 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); } -- cgit v1.2.3