summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2019-08-29 15:22:41 -0700
committerAaron Patterson <tenderlove@ruby-lang.org>2019-09-05 10:13:49 -0700
commit581fcde0884e493206b04b3e6b7a069b941dfe46 (patch)
treef72f598a18bc148909871c1fc1cc64c0a2eb7276 /parse.y
parent70d3596a4a2ef023243bf4805ce2a9cd6fdc0487 (diff)
downloadruby-581fcde0884e493206b04b3e6b7a069b941dfe46.tar.gz
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).
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y13
1 files changed, 12 insertions, 1 deletions
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;
}