mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
ce8eeb84c3
commit
1e98a25e9f
2 changed files with 25 additions and 3 deletions
|
@ -1,3 +1,10 @@
|
|||
Wed Mar 18 05:34:32 2015 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* 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.
|
||||
|
||||
Tue Mar 17 18:59:16 2015 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* include/ruby/ruby.h: use rb_gc_writebrrier() simply.
|
||||
|
|
21
string.c
21
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue