ruby-changes:34644
From: ko1 <ko1@a...>
Date: Mon, 7 Jul 2014 02:20:35 +0900 (JST)
Subject: [ruby-changes:34644] ko1:r46727 (trunk): * string.c (fstr_update_callback): do not use rb_gc_resurrect()
ko1 2014-07-07 02:20:30 +0900 (Mon, 07 Jul 2014) New Revision: 46727 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46727 Log: * string.c (fstr_update_callback): do not use rb_gc_resurrect() any more. Make new frozen string and replace with garbage frozen string. * common.mk: use gc.h from string.c. Modified files: trunk/ChangeLog trunk/common.mk trunk/string.c Index: ChangeLog =================================================================== --- ChangeLog (revision 46726) +++ ChangeLog (revision 46727) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Jul 7 02:18:42 2014 Koichi Sasada <ko1@a...> + + * string.c (fstr_update_callback): do not use rb_gc_resurrect() + any more. + + Make new frozen string and replace with garbage frozen string. + + * common.mk: use gc.h from string.c. + Mon Jul 7 00:36:13 2014 Koichi Sasada <ko1@a...> * gc.c: rename is_dying_object() to is_garbage_object(). Index: string.c =================================================================== --- string.c (revision 46726) +++ string.c (revision 46727) @@ -16,6 +16,7 @@ https://github.com/ruby/ruby/blob/trunk/string.c#L16 #include "ruby/encoding.h" #include "internal.h" #include "probes.h" +#include "gc.h" #include <assert.h> #define BEG(no) (regs->beg[(no)]) @@ -191,22 +192,28 @@ fstr_update_callback(st_data_t *key, st_ https://github.com/ruby/ruby/blob/trunk/string.c#L192 if (existing) { /* because of lazy sweep, str may be unmarked already and swept * at next time */ - rb_gc_resurrect(*fstr = *key); - return ST_STOP; - } - if (STR_SHARED_P(str)) { - /* str should not be shared */ - str = rb_enc_str_new(RSTRING_PTR(str), RSTRING_LEN(str), STR_ENC_GET(str)); - OBJ_FREEZE(str); + if (rb_objspace_garbage_object_p(str)) { + goto create_new_fstr; + } + + *fstr = str; + return ST_STOP; } else { - str = rb_str_new_frozen(str); - } - RBASIC(str)->flags |= RSTRING_FSTR; + if (STR_SHARED_P(str)) { /* str should not be shared */ + create_new_fstr: + str = rb_enc_str_new(RSTRING_PTR(str), RSTRING_LEN(str), STR_ENC_GET(str)); + OBJ_FREEZE(str); + } + else { + str = rb_str_new_frozen(str); + } + RBASIC(str)->flags |= RSTRING_FSTR; - *key = *value = *fstr = str; - return ST_CONTINUE; + *key = *value = *fstr = str; + return ST_CONTINUE; + } } VALUE Index: common.mk =================================================================== --- common.mk (revision 46726) +++ common.mk (revision 46727) @@ -763,7 +763,7 @@ sprintf.$(OBJEXT): {$(VPATH)}sprintf.c $ https://github.com/ruby/ruby/blob/trunk/common.mk#L763 st.$(OBJEXT): {$(VPATH)}st.c $(RUBY_H_INCLUDES) strftime.$(OBJEXT): {$(VPATH)}strftime.c $(RUBY_H_INCLUDES) \ {$(VPATH)}timev.h $(ENCODING_H_INCLUDES) -string.$(OBJEXT): {$(VPATH)}string.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \ +string.$(OBJEXT): {$(VPATH)}string.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h {$(VPATH)}gc.h \ {$(VPATH)}regex.h $(ENCODING_H_INCLUDES) {$(VPATH)}internal.h $(PROBES_H_INCLUDES) struct.$(OBJEXT): {$(VPATH)}struct.c $(RUBY_H_INCLUDES) {$(VPATH)}internal.h thread.$(OBJEXT): {$(VPATH)}thread.c {$(VPATH)}eval_intern.h \ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/