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

* 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.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2014-07-06 17:20:30 +00:00
parent 2006bfe2f4
commit 7ad35210a3
3 changed files with 29 additions and 13 deletions

View file

@ -1,3 +1,12 @@
Mon Jul 7 02:18:42 2014 Koichi Sasada <ko1@atdot.net>
* 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@atdot.net> Mon Jul 7 00:36:13 2014 Koichi Sasada <ko1@atdot.net>
* gc.c: rename is_dying_object() to is_garbage_object(). * gc.c: rename is_dying_object() to is_garbage_object().

View file

@ -763,7 +763,7 @@ sprintf.$(OBJEXT): {$(VPATH)}sprintf.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
st.$(OBJEXT): {$(VPATH)}st.c $(RUBY_H_INCLUDES) st.$(OBJEXT): {$(VPATH)}st.c $(RUBY_H_INCLUDES)
strftime.$(OBJEXT): {$(VPATH)}strftime.c $(RUBY_H_INCLUDES) \ strftime.$(OBJEXT): {$(VPATH)}strftime.c $(RUBY_H_INCLUDES) \
{$(VPATH)}timev.h $(ENCODING_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) {$(VPATH)}regex.h $(ENCODING_H_INCLUDES) {$(VPATH)}internal.h $(PROBES_H_INCLUDES)
struct.$(OBJEXT): {$(VPATH)}struct.c $(RUBY_H_INCLUDES) {$(VPATH)}internal.h struct.$(OBJEXT): {$(VPATH)}struct.c $(RUBY_H_INCLUDES) {$(VPATH)}internal.h
thread.$(OBJEXT): {$(VPATH)}thread.c {$(VPATH)}eval_intern.h \ thread.$(OBJEXT): {$(VPATH)}thread.c {$(VPATH)}eval_intern.h \

View file

@ -16,6 +16,7 @@
#include "ruby/encoding.h" #include "ruby/encoding.h"
#include "internal.h" #include "internal.h"
#include "probes.h" #include "probes.h"
#include "gc.h"
#include <assert.h> #include <assert.h>
#define BEG(no) (regs->beg[(no)]) #define BEG(no) (regs->beg[(no)])
@ -191,22 +192,28 @@ fstr_update_callback(st_data_t *key, st_data_t *value, st_data_t arg, int existi
if (existing) { if (existing) {
/* because of lazy sweep, str may be unmarked already and swept /* because of lazy sweep, str may be unmarked already and swept
* at next time */ * at next time */
rb_gc_resurrect(*fstr = *key);
if (rb_objspace_garbage_object_p(str)) {
goto create_new_fstr;
}
*fstr = str;
return ST_STOP; 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);
}
else { else {
str = rb_str_new_frozen(str); if (STR_SHARED_P(str)) { /* str should not be shared */
} create_new_fstr:
RBASIC(str)->flags |= RSTRING_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; *key = *value = *fstr = str;
return ST_CONTINUE; return ST_CONTINUE;
}
} }
VALUE VALUE