[前][次][番号順一覧][スレッド一覧]

ruby-changes:57565

From: Aaron <ko1@a...>
Date: Fri, 6 Sep 2019 02:14:17 +0900 (JST)
Subject: [ruby-changes:57565] 64817a7cfd (master): Mark some tmpbufs via node objects

https://git.ruby-lang.org/ruby.git/commit/?id=64817a7cfd

From 64817a7cfd4a258b45356e6da8fbdd0040b3231b Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Tue, 3 Sep 2019 14:01:07 -0700
Subject: Mark some tmpbufs via node objects

This way we don't need to add the tmpbufs to a Ruby array for marking

diff --git a/node.c b/node.c
index 61926ad..8a519f2 100644
--- a/node.c
+++ b/node.c
@@ -1225,6 +1225,9 @@ mark_ast_value(void *ctx, NODE * node) https://github.com/ruby/ruby/blob/trunk/node.c#L1225
         case NODE_DXSTR:
         case NODE_DREGX:
         case NODE_DSYM:
+        case NODE_ARGS:
+        case NODE_FOR:
+        case NODE_ARYPTN:
             rb_gc_mark(node->nd_lit);
             break;
     }
diff --git a/parse.y b/parse.y
index 3cf485d..08bedd2 100644
--- a/parse.y
+++ b/parse.y
@@ -2797,10 +2797,10 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2797
 			ID id = internal_id(p);
 			NODE *m = NEW_ARGS_AUX(0, 0, &NULL_LOC);
 			NODE *args, *scope, *internal_var = NEW_DVAR(id, &@2);
-			rb_imemo_tmpbuf_t *tmpbuf = new_tmpbuf();
 			ID *tbl = ALLOC_N(ID, 2);
+			VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer(tbl);
+                        RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf);
 			tbl[0] = 1 /* length of local var table */; tbl[1] = id /* internal id */;
-			tmpbuf->ptr = (VALUE *)tbl;
 
 			switch (nd_type($2)) {
 			  case NODE_LASGN:
@@ -2821,6 +2821,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2821
 			args = new_args(p, m, 0, id, 0, new_args_tail(p, 0, 0, 0, &@2), &@2);
 			scope = NEW_NODE(NODE_SCOPE, tbl, $5, args, &@$);
 			$$ = NEW_FOR($4, scope, &@$);
+                        $$->nd_lit = tmpbuf;
 			fixpos($$, $2);
 		    /*% %*/
 		    /*% ripper: for!($2, $4, $5) %*/
@@ -11136,11 +11137,11 @@ new_args_tail(struct parser_params *p, NODE *kw_args, ID kw_rest_arg, ID block, https://github.com/ruby/ruby/blob/trunk/parse.y#L11137
     int saved_line = p->ruby_sourceline;
     struct rb_args_info *args;
     NODE *node;
-    rb_imemo_tmpbuf_t *tmpbuf = new_tmpbuf();
 
     args = ZALLOC(struct rb_args_info);
-    tmpbuf->ptr = (VALUE *)args;
-    node = NEW_NODE(NODE_ARGS, 0, 0, args, &NULL_LOC);
+    VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer(args);
+    RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf);
+    node = NEW_NODE(NODE_ARGS, tmpbuf, 0, args, &NULL_LOC);
     if (p->error_p) return node;
 
     args->block_arg      = block;
@@ -11245,11 +11246,11 @@ new_array_pattern_tail(struct parser_params *p, NODE *pre_args, int has_rest, ID https://github.com/ruby/ruby/blob/trunk/parse.y#L11246
     int saved_line = p->ruby_sourceline;
     struct rb_ary_pattern_info *apinfo;
     NODE *node;
-    rb_imemo_tmpbuf_t *tmpbuf = new_tmpbuf();
 
     apinfo = ZALLOC(struct rb_ary_pattern_info);
-    tmpbuf->ptr = (VALUE *)apinfo;
-    node = NEW_NODE(NODE_ARYPTN, 0, 0, apinfo, loc);
+    VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer(apinfo);
+    node = NEW_NODE(NODE_ARYPTN, tmpbuf, 0, apinfo, loc);
+    RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf);
 
     apinfo->pre_args = pre_args;
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]