From 581fcde0884e493206b04b3e6b7a069b941dfe46 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 29 Aug 2019 15:22:41 -0700 Subject: Directly mark node objects instead of using a mark array This patch changes the AST mark function so that it will walk through nodes in the NODE buffer marking Ruby objects rather than using a mark array to guarantee liveness. The reason I want to do this is so that when compaction happens on major GCs, node objects will have their references pinned (or possibly we can update them correctly). --- parse.y | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index 63d8f53c1d..3cf485d55a 100644 --- a/parse.y +++ b/parse.y @@ -299,7 +299,7 @@ struct parser_params { }; #define new_tmpbuf() \ - (rb_imemo_tmpbuf_t *)add_mark_object(p, rb_imemo_tmpbuf_auto_free_pointer(NULL)) + (rb_imemo_tmpbuf_t *)add_tmpbuf_mark_object(p, rb_imemo_tmpbuf_auto_free_pointer(NULL)) #define intern_cstr(n,l,en) rb_intern3(n,l,en) @@ -337,6 +337,13 @@ rb_discard_node(struct parser_params *p, NODE *n) { rb_ast_delete_node(p->ast, n); } + +static inline VALUE +add_tmpbuf_mark_object(struct parser_params *p, VALUE obj) +{ + rb_ast_add_mark_object(p->ast, obj); + return obj; +} #endif static inline VALUE @@ -347,7 +354,11 @@ add_mark_object(struct parser_params *p, VALUE obj) && !RB_TYPE_P(obj, T_NODE) /* Ripper jumbles NODE objects and other objects... */ #endif ) { +#ifdef RIPPER rb_ast_add_mark_object(p->ast, obj); +#else + RB_OBJ_WRITTEN(p->ast, Qundef, obj); +#endif } return obj; } -- cgit v1.2.3