From 5bafb6c596ae140e70aebb2378f81e4273c99058 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Fri, 13 Apr 2018 21:36:51 +0000 Subject: Add write barrier calls for direct marking objects. This commit adds write barriers for objects marked from `rb_iseq_mark`. r62851 introduced direct marking from iseqs to: * keyword arg default values * catch table iseqs * VALUEs embedded in encoded instructions This patch adds missing write barrier calls to those references. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 31 +++++++++++++++++++++++++------ iseq.c | 2 +- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/compile.c b/compile.c index 5415d68..5d37c73 100644 --- a/compile.c +++ b/compile.c @@ -1596,6 +1596,9 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, for (i = 0; i < RARRAY_LEN(default_values); i++) { VALUE dv = RARRAY_AREF(default_values, i); if (dv == complex_mark) dv = Qundef; + if (!SPECIAL_CONST_P(dv)) { + RB_OBJ_WRITTEN(iseq, Qundef, dv); + } dvs[i] = dv; } @@ -2082,6 +2085,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor) rb_hash_rehash(map); freeze_hide_obj(map); generated_iseq[code_index + 1 + j] = map; + RB_OBJ_WRITTEN(iseq, Qundef, map); FL_SET(iseq, ISEQ_MARKABLE_ISEQ); break; } @@ -2094,6 +2098,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor) VALUE v = operands[j]; generated_iseq[code_index + 1 + j] = v; if (!SPECIAL_CONST_P(v)) { + RB_OBJ_WRITTEN(iseq, Qundef, v); FL_SET(iseq, ISEQ_MARKABLE_ISEQ); } break; @@ -2104,6 +2109,7 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor) generated_iseq[code_index + 1 + j] = v; /* to mark ruby object */ if (!SPECIAL_CONST_P(v)) { + RB_OBJ_WRITTEN(iseq, Qundef, v); FL_SET(iseq, ISEQ_MARKABLE_ISEQ); } break; @@ -2280,6 +2286,7 @@ iseq_set_exception_table(rb_iseq_t *iseq) entry->start = label_get_position((LABEL *)(ptr[1] & ~1)); entry->end = label_get_position((LABEL *)(ptr[2] & ~1)); entry->iseq = (rb_iseq_t *)ptr[3]; + RB_OBJ_WRITTEN(iseq, Qundef, entry->iseq); /* stack depth */ if (ptr[4]) { @@ -8478,13 +8485,25 @@ ibf_load_code(const struct ibf_load *load, const rb_iseq_t *iseq, const struct r switch (types[op_index]) { case TS_CDHASH: case TS_VALUE: - code[code_index] = ibf_load_object(load, op); - FL_SET(iseq, ISEQ_MARKABLE_ISEQ); - break; + { + VALUE v = ibf_load_object(load, op); + code[code_index] = v; + if (!SPECIAL_CONST_P(v)) { + RB_OBJ_WRITTEN(iseq, Qundef, v); + FL_SET(iseq, ISEQ_MARKABLE_ISEQ); + } + break; + } case TS_ISEQ: - code[code_index] = (VALUE)ibf_load_iseq(load, (const rb_iseq_t *)op); - FL_SET(iseq, ISEQ_MARKABLE_ISEQ); - break; + { + VALUE v = (VALUE)ibf_load_iseq(load, (const rb_iseq_t *)op); + code[code_index] = v; + if (!SPECIAL_CONST_P(v)) { + RB_OBJ_WRITTEN(iseq, Qundef, v); + FL_SET(iseq, ISEQ_MARKABLE_ISEQ); + } + break; + } case TS_IC: FL_SET(iseq, ISEQ_MARKABLE_ISEQ); case TS_ISE: diff --git a/iseq.c b/iseq.c index 68ad9a3..96ccb56 100644 --- a/iseq.c +++ b/iseq.c @@ -235,7 +235,7 @@ rb_iseq_mark(const rb_iseq_t *iseq) for (j = 0; i < body->param.keyword->num; i++, j++) { VALUE obj = body->param.keyword->default_values[j]; - if (obj != Qundef) { + if (!SPECIAL_CONST_P(obj)) { rb_gc_mark(obj); } } -- cgit v1.1