1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Call FrozenCore.make_shareable

This commit is contained in:
Nobuyoshi Nakada 2020-10-20 17:28:12 +09:00
parent f43c71abe0
commit 65450e8f7d
Notes: git 2020-12-14 19:19:47 +09:00
3 changed files with 11 additions and 6 deletions

View file

@ -10925,12 +10925,14 @@ mark_lvar_used(struct parser_params *p, NODE *rhs)
}
}
extern VALUE rb_mRubyVMFrozenCore;
static NODE *
shareable_constant_value(struct parser_params *p, NODE *value, const YYLTYPE *loc)
{
if (p->ctxt.shareable_constant_value) {
NODE *ractor = NEW_COLON3(rb_intern("Ractor"), loc);
value = NEW_CALL(ractor, rb_intern("make_shareable"),
NODE *fcore = NEW_LIT(rb_mRubyVMFrozenCore, loc);
value = NEW_CALL(fcore, rb_intern("make_shareable"),
NEW_LIST(value, loc), loc);
}
return value;

View file

@ -51,10 +51,6 @@ class Ractor
}
end
def self.make_shareable(obj)
obj.freeze
end
# Multiplex multiple Ractor communications.
#
# r, obj = Ractor.select(r1, r2)

7
vm.c
View file

@ -3176,6 +3176,12 @@ m_core_hash_merge_kwd(VALUE recv, VALUE hash, VALUE kw)
return hash;
}
static VALUE
m_core_make_shareable(VALUE recv, VALUE obj)
{
return rb_obj_freeze(obj);
}
static VALUE
core_hash_merge_kwd(VALUE hash, VALUE kw)
{
@ -3340,6 +3346,7 @@ Init_VM(void)
rb_define_method_id(klass, id_core_raise, f_raise, -1);
rb_define_method_id(klass, idProc, f_proc, 0);
rb_define_method_id(klass, idLambda, f_lambda, 0);
rb_define_method(klass, "make_shareable", m_core_make_shareable, 1);
rb_obj_freeze(fcore);
RBASIC_CLEAR_CLASS(klass);
rb_obj_freeze(klass);