aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2020-10-01 21:02:05 +0900
committernagachika <nagachika@ruby-lang.org>2020-10-01 21:02:05 +0900
commitb35bfa6abb7760e4323a4341dff840f59ddcfde1 (patch)
treef99c71873c8d91e0388040e1858e0de5b203a25e /parse.y
parent811b2b0df5e670ad8db7951191232ce3f5b0d978 (diff)
downloadruby-b35bfa6abb7760e4323a4341dff840f59ddcfde1.tar.gz
merge revision(s) 35ba2783fe6b3316a6bbc6f00bf975ad7185d6e0,e8edc34f0abe176b24975a1fed1f2c3782f0a252: [Backport #16807]
Use a linked list to eliminate imemo tmp bufs for managing local tables This patch changes local table memory to be managed by a linked list rather than via the garbage collector. It reduces allocations from the GC and also fixes a use-after-free bug in the concurrent-with-sweep compactor I'm working on. Remove unused struct member I accidentally added this in 35ba2783fe6b3316a6bbc6f00bf975ad7185d6e0, and it's making the size of RVALUE be too big. I'm sorry! orz
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y12
1 files changed, 2 insertions, 10 deletions
diff --git a/parse.y b/parse.y
index 54515f9002..0fd0c46114 100644
--- a/parse.y
+++ b/parse.y
@@ -2872,11 +2872,9 @@ primary : literal
ID id = internal_id(p);
NODE *m = NEW_ARGS_AUX(0, 0, &NULL_LOC);
NODE *args, *scope, *internal_var = NEW_DVAR(id, &@2);
- VALUE tmpbuf = rb_imemo_tmpbuf_auto_free_pointer();
ID *tbl = ALLOC_N(ID, 3);
- rb_imemo_tmpbuf_set_ptr(tmpbuf, tbl);
tbl[0] = 1 /* length of local var table */; tbl[1] = id /* internal id */;
- tbl[2] = tmpbuf;
+ rb_ast_add_local_table(p->ast, tbl);
switch (nd_type($2)) {
case NODE_LASGN:
@@ -2896,7 +2894,6 @@ primary : literal
/* {|*internal_id| <m> = internal_id; ... } */
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, &@$);
- RB_OBJ_WRITTEN(p->ast, Qnil, tmpbuf);
$$ = NEW_FOR($4, scope, &@$);
fixpos($$, $2);
/*% %*/
@@ -11825,12 +11822,9 @@ local_tbl(struct parser_params *p)
int cnt = cnt_args + cnt_vars;
int i, j;
ID *buf;
- VALUE tbl = 0;
if (cnt <= 0) return 0;
- tbl = rb_imemo_tmpbuf_auto_free_pointer();
buf = ALLOC_N(ID, cnt + 2);
- rb_imemo_tmpbuf_set_ptr(tbl, buf);
MEMCPY(buf+1, p->lvtbl->args->tbl, ID, cnt_args);
/* remove IDs duplicated to warn shadowing */
for (i = 0, j = cnt_args+1; i < cnt_vars; ++i) {
@@ -11841,11 +11835,9 @@ local_tbl(struct parser_params *p)
}
if (--j < cnt) {
REALLOC_N(buf, ID, (cnt = j) + 2);
- rb_imemo_tmpbuf_set_ptr(tbl, buf);
}
buf[0] = cnt;
- buf[cnt + 1] = (ID)tbl;
- RB_OBJ_WRITTEN(p->ast, Qnil, tbl);
+ rb_ast_add_local_table(p->ast, buf);
return buf;
}