зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
c5f50296b4
Коммит
52bd0d1900
14
node.c
14
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);
|
||||
}
|
||||
|
|
1
node.h
1
node.h
|
@ -474,7 +474,6 @@ typedef struct rb_ast_body_struct {
|
|||
typedef struct rb_ast_struct {
|
||||
VALUE flags;
|
||||
node_buffer_t *node_buffer;
|
||||
VALUE mark_ary;
|
||||
rb_ast_body_t body;
|
||||
} rb_ast_t;
|
||||
rb_ast_t *rb_ast_new(void);
|
||||
|
|
Загрузка…
Ссылка в новой задаче