ruby-changes:50940
From: tenderlove <ko1@a...>
Date: Sat, 14 Apr 2018 06:36:57 +0900 (JST)
Subject: [ruby-changes:50940] tenderlove:r63147 (trunk): Add write barrier calls for direct marking objects.
tenderlove 2018-04-14 06:36:51 +0900 (Sat, 14 Apr 2018) New Revision: 63147 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63147 Log: 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. Modified files: trunk/compile.c trunk/iseq.c Index: compile.c =================================================================== --- compile.c (revision 63146) +++ compile.c (revision 63147) @@ -1596,6 +1596,9 @@ iseq_set_arguments_keywords(rb_iseq_t *i https://github.com/ruby/ruby/blob/trunk/compile.c#L1596 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_ https://github.com/ruby/ruby/blob/trunk/compile.c#L2085 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_ https://github.com/ruby/ruby/blob/trunk/compile.c#L2098 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_ https://github.com/ruby/ruby/blob/trunk/compile.c#L2109 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 https://github.com/ruby/ruby/blob/trunk/compile.c#L2286 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 *loa https://github.com/ruby/ruby/blob/trunk/compile.c#L8485 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: Index: iseq.c =================================================================== --- iseq.c (revision 63146) +++ iseq.c (revision 63147) @@ -235,7 +235,7 @@ rb_iseq_mark(const rb_iseq_t *iseq) https://github.com/ruby/ruby/blob/trunk/iseq.c#L235 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); } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/