aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-17 20:38:02 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-17 20:38:02 +0000
commit1e98a25e9fff7e4c9c858f67c9ca7c6b9ee793f8 (patch)
tree4aa59e06f3e1f3f5e480834c1339665dd4a03df2 /string.c
parentce8eeb84c3a9dd66d797e9e179371ea3e4422cf9 (diff)
downloadruby-1e98a25e9fff7e4c9c858f67c9ca7c6b9ee793f8.tar.gz
* string.c: introduce STR_FAKESTR to show string is FAKESTR or not.
* string.c (STR_SET_SHARED): ignore FAKESTR because only Ruby objects can use write barrier. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/string.c b/string.c
index 9419e31115..68fcfc2852 100644
--- a/string.c
+++ b/string.c
@@ -52,9 +52,22 @@ static VALUE rb_str_clear(VALUE str);
VALUE rb_cString;
VALUE rb_cSymbol;
+/* FLAGS of RString
+ *
+ * 1: RSTRING_NOEMBED
+ * 2: STR_SHARED (== ELTS_SHARED)
+ * 2-6: RSTRING_EMBED_LEN (5 bits == 32)
+ * 7: STR_TMPLOCK
+ * 8-9: ENC_CODERANGE (2 bits)
+ * 10-16: ENCODING (7 bits == 128)
+ * 18: STR_NOFREE
+ * 19: STR_FAKESTR
+ */
+
#define RUBY_MAX_CHAR_LEN 16
#define STR_TMPLOCK FL_USER7
#define STR_NOFREE FL_USER18
+#define STR_FAKESTR FL_USER19
#define STR_SET_NOEMBED(str) do {\
FL_SET((str), STR_NOEMBED);\
@@ -120,8 +133,10 @@ VALUE rb_cSymbol;
} while (0)
#define STR_SET_SHARED(str, shared_str) do { \
- RB_OBJ_WRITE((str), &RSTRING(str)->as.heap.aux.shared, (shared_str)); \
- FL_SET((str), STR_SHARED); \
+ if (!FL_TEST(str, STR_FAKESTR)) { \
+ RB_OBJ_WRITE((str), &RSTRING(str)->as.heap.aux.shared, (shared_str)); \
+ FL_SET((str), STR_SHARED); \
+ } \
} while (0)
#define STR_HEAP_PTR(str) (RSTRING(str)->as.heap.ptr)
@@ -262,7 +277,7 @@ rb_fstring(VALUE str)
static VALUE
setup_fake_str(struct RString *fake_str, const char *name, long len, int encidx)
{
- fake_str->basic.flags = T_STRING|RSTRING_NOEMBED|STR_NOFREE;
+ fake_str->basic.flags = T_STRING|RSTRING_NOEMBED|STR_NOFREE|STR_FAKESTR;
/* SHARED to be allocated by the callback */
ENCODING_SET_INLINED((VALUE)fake_str, encidx);