Consider DATA objects without a mark function as protected
It's not uncommon for simple binding to wrap structs without any Ruby object references. Hence with no `mark` function. Might as well mark them as protected by a write barrier.
This commit is contained in:
parent
8623c81220
commit
6e4c242130
Notes:
git
2023-02-07 10:49:20 +00:00
5
gc.c
5
gc.c
@ -3110,7 +3110,7 @@ rb_data_object_wrap(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FU
|
||||
{
|
||||
RUBY_ASSERT_ALWAYS(dfree != (RUBY_DATA_FUNC)1);
|
||||
if (klass) rb_data_object_check(klass);
|
||||
return newobj_of(klass, T_DATA, (VALUE)dmark, (VALUE)dfree, (VALUE)datap, FALSE, sizeof(struct RTypedData));
|
||||
return newobj_of(klass, T_DATA, (VALUE)dmark, (VALUE)dfree, (VALUE)datap, !dmark, sizeof(struct RTypedData));
|
||||
}
|
||||
|
||||
VALUE
|
||||
@ -3126,7 +3126,8 @@ rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *type)
|
||||
{
|
||||
RBIMPL_NONNULL_ARG(type);
|
||||
if (klass) rb_data_object_check(klass);
|
||||
return newobj_of(klass, T_DATA, (VALUE)type, (VALUE)1, (VALUE)datap, type->flags & RUBY_FL_WB_PROTECTED, sizeof(struct RTypedData));
|
||||
bool wb_protected = (type->flags & RUBY_FL_WB_PROTECTED) || !type->function.dmark;
|
||||
return newobj_of(klass, T_DATA, (VALUE)type, (VALUE)1, (VALUE)datap, wb_protected, sizeof(struct RTypedData));
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
Loading…
x
Reference in New Issue
Block a user