diff options
author | nari <nari@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-03-26 04:57:47 +0000 |
---|---|---|
committer | nari <nari@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-03-26 04:57:47 +0000 |
commit | 90b70738427567dc065ad75b32fa932b280c304a (patch) | |
tree | c123b148394a08abcb0ecebcb407a251388af33b /gc.c | |
parent | 2bf56dededed9d4c376893f783aa5b4300b08495 (diff) | |
download | ruby-90b70738427567dc065ad75b32fa932b280c304a.tar.gz |
* parse.y: support Symbol GC. [ruby-trunk Feature #9634]
See this ticket about Symbol GC.
* include/ruby/ruby.h:
Declare few functions.
* rb_sym2id: almost same as old SYM2ID but support dynamic symbols.
* rb_id2sym: almost same as old ID2SYM but support dynamic symbols.
* rb_sym2str: almost same as `rb_id2str(SYM2ID(sym))` but not
pin down a dynamic symbol.
Declare a new struct.
* struct RSymbol: represents a dynamic symbol as object in
Ruby's heaps.
Add few macros.
* STATIC_SYM_P: check a static symbol.
* DYNAMIC_SYM_P: check a dynamic symbol.
* RSYMBOL: cast to RSymbol
* gc.c: declare RSymbol. support T_SYMBOL.
* internal.h: Declare few functions.
* rb_gc_free_dsymbol: free up a dynamic symbol. GC call this
function at a sweep phase.
* rb_str_dynamic_intern: convert a string to a dynamic symbol.
* rb_check_id_without_pindown: not pinning function.
* rb_sym2id_without_pindown: ditto.
* rb_check_id_cstr_without_pindown: ditto.
* string.c (Init_String): String#intern and String#to_sym use
rb_str_dynamic_intern.
* template/id.h.tmpl: use LSB of ID as a flag for determining a
static symbol, so we shift left other ruby_id_types.
* string.c: use rb_sym2str instead `rb_id2str(SYM2ID(sym))` to
avoid pinning.
* load.c: use xx_without_pindown function at creating temporary ID
to avoid pinning.
* object.c: ditto.
* sprintf.c: ditto.
* struct.c: ditto.
* thread.c: ditto.
* variable.c: ditto.
* vm_method.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -354,6 +354,7 @@ typedef struct RVALUE { struct RMatch match; struct RRational rational; struct RComplex complex; + struct RSymbol symbol; struct { struct RBasic basic; VALUE v1; @@ -1652,6 +1653,12 @@ obj_free(rb_objspace_t *objspace, VALUE obj) } break; + case T_SYMBOL: + { + rb_gc_free_dsymbol(obj); + } + break; + default: rb_bug("gc_sweep(): unknown data type 0x%x(%p) 0x%"PRIxVALUE, BUILTIN_TYPE(obj), (void*)obj, RBASIC(obj)->flags); @@ -2393,7 +2400,7 @@ rb_obj_id(VALUE obj) * 24 if 32-bit, double is 8-byte aligned * 40 if 64-bit */ - if (SYMBOL_P(obj)) { + if (STATIC_SYM_P(obj)) { return (SYM2ID(obj) * sizeof(RVALUE) + (4 << 2)) | FIXNUM_FLAG; } else if (FLONUM_P(obj)) { @@ -2499,6 +2506,7 @@ obj_memsize_of(VALUE obj, int use_tdata) break; case T_FLOAT: + case T_SYMBOL: break; case T_BIGNUM: @@ -3918,6 +3926,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr) case T_FLOAT: case T_BIGNUM: + case T_SYMBOL: break; case T_MATCH: |