From 65450e8f7daf59ca64a12ff1da0efdc0f4280dc1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 20 Oct 2020 17:28:12 +0900 Subject: [PATCH] Call FrozenCore.make_shareable --- parse.y | 6 ++++-- ractor.rb | 4 ---- vm.c | 7 +++++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/parse.y b/parse.y index da66c5637a..de3a8a8183 100644 --- a/parse.y +++ b/parse.y @@ -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; diff --git a/ractor.rb b/ractor.rb index 0867f1a9d1..ca09aee7be 100644 --- a/ractor.rb +++ b/ractor.rb @@ -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) diff --git a/vm.c b/vm.c index c6f3344130..8ced733d5f 100644 --- a/vm.c +++ b/vm.c @@ -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);