From d84daa56faaed7c1028ee0e7a21f53e1707e7074 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 14 Oct 2022 15:54:09 +0900 Subject: [PATCH] mruby-struct/struct.c (mrb_struct_modify): remove the write barrier. Instead of calling write barriers (mrb_write_barrier) in the function, call field write barriers (mrb_field_write_barrier_value) from the individual functions. --- mrbgems/mruby-struct/src/struct.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mrbgems/mruby-struct/src/struct.c b/mrbgems/mruby-struct/src/struct.c index 69376f602..fc93d8a92 100644 --- a/mrbgems/mruby-struct/src/struct.c +++ b/mrbgems/mruby-struct/src/struct.c @@ -75,12 +75,7 @@ mrb_struct_s_members_m(mrb_state *mrb, mrb_value klass) return ary; } -static void -mrb_struct_modify(mrb_state *mrb, mrb_value strct) -{ - mrb_check_frozen(mrb, mrb_basic_ptr(strct)); - mrb_write_barrier(mrb, mrb_basic_ptr(strct)); -} +#define mrb_struct_modify(mrb,s) mrb_check_frozen((mrb), mrb_basic_ptr(s)) /* 15.2.18.4.6 */ /* @@ -154,6 +149,7 @@ mrb_struct_set_m(mrb_state *mrb, mrb_value obj) } else { ptr[i] = val; + mrb_field_write_barrier_value(mrb, mrb_basic_ptr(obj), val); } return val; } @@ -437,6 +433,7 @@ mrb_struct_aset_sym(mrb_state *mrb, mrb_value s, mrb_sym id, mrb_value val) if (mrb_symbol(ptr_members[i]) == id) { mrb_struct_modify(mrb, s); ptr[i] = val; + mrb_field_write_barrier_value(mrb, mrb_basic_ptr(s), val); return val; } } @@ -494,6 +491,7 @@ mrb_struct_aset(mrb_state *mrb, mrb_value s) "offset %i too large for struct(size:%i)", i, RSTRUCT_LEN(s)); } mrb_struct_modify(mrb, s); + mrb_field_write_barrier_value(mrb, mrb_basic_ptr(s), val); return RSTRUCT_PTR(s)[i] = val; }