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

freeze (make shareable) script_lines

This commit is contained in:
Koichi Sasada 2021-09-30 17:30:04 +09:00
parent c7550537f1
commit 7185c00fcc
Notes: git 2021-10-21 16:18:10 +09:00
3 changed files with 9 additions and 2 deletions

View file

@ -6989,6 +6989,7 @@ iseq.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
iseq.$(OBJEXT): $(CCAN_DIR)/list/list.h
iseq.$(OBJEXT): $(CCAN_DIR)/str/str.h
iseq.$(OBJEXT): $(hdrdir)/ruby.h
iseq.$(OBJEXT): $(hdrdir)/ruby/ractor.h
iseq.$(OBJEXT): $(hdrdir)/ruby/ruby.h
iseq.$(OBJEXT): $(top_srcdir)/internal/array.h
iseq.$(OBJEXT): $(top_srcdir)/internal/bits.h

9
iseq.c
View file

@ -39,7 +39,7 @@
#include "vm_core.h"
#include "vm_callinfo.h"
#include "yjit.h"
#include "ruby/ractor.h"
#include "builtin.h"
#include "insns.inc"
#include "insns_info.inc"
@ -617,7 +617,12 @@ prepare_iseq_build(rb_iseq_t *iseq,
ISEQ_ORIGINAL_ISEQ_CLEAR(iseq);
body->variable.flip_count = 0;
RB_OBJ_WRITE(iseq, &body->variable.script_lines, script_lines);
if (NIL_P(script_lines)) {
RB_OBJ_WRITE(iseq, &body->variable.script_lines, Qnil);
}
else {
RB_OBJ_WRITE(iseq, &body->variable.script_lines, rb_ractor_make_shareable(script_lines));
}
ISEQ_COMPILE_DATA_ALLOC(iseq);
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->err_info, err_info);

View file

@ -49,6 +49,7 @@ class TestRubyVM < Test::Unit::TestCase
iseq.each_child{|child|
assert_equal lines, child.script_lines
}
assert lines.frozen?
# don't keep
RubyVM.keep_script_lines = false