aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--common.mk2
-rw-r--r--string.c31
3 files changed, 29 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index ad4b15b734..fd133d4394 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* gc.c: rename is_dying_object() to is_garbage_object().
diff --git a/common.mk b/common.mk
index 42dfe1ab56..ec2844aa00 100644
--- a/common.mk
+++ b/common.mk
@@ -763,7 +763,7 @@ sprintf.$(OBJEXT): {$(VPATH)}sprintf.c $(RUBY_H_INCLUDES) {$(VPATH)}re.h \
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 \
diff --git a/string.c b/string.c
index e9d342bc69..1a46f467ad 100644
--- a/string.c
+++ b/string.c
@@ -16,6 +16,7 @@
#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_data_t *value, st_data_t arg, int existi
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