aboutsummaryrefslogtreecommitdiffstats
path: root/symbol.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-09 16:19:13 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-09 16:19:13 +0000
commit96815f1ebe945a802ca2e35a1bb6e3b564339732 (patch)
tree6ab8921694d8207b6758823f3a38157701cfb3c7 /symbol.c
parent996ff90744d79b60ef40a03d16bc185e64d1b5af (diff)
downloadruby-96815f1ebe945a802ca2e35a1bb6e3b564339732.tar.gz
* symbol.c: remove rb_gc_mark_symbols().
fstrings refered by static symbols and pinned dynamic symbols are registerd by rb_gc_register_mark_object(). frstring refered by dynamic symbols (not pinned symbols) are refered from global_symbols.dsymbol_fstr_hash (Hash object). Note that fstrings refered from dynamic symbols must live loger than symbol objects themselves because rb_gc_free_dsymbol() uses fstring to remove from symbol tables. This is why we can not mark fstrings from dynamic symbols. This technique reduces root objects for GC marking. * gc.c (gc_mark_roots): ditto. * internal.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'symbol.c')
-rw-r--r--symbol.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/symbol.c b/symbol.c
index 338c6e9d28..342768b8fb 100644
--- a/symbol.c
+++ b/symbol.c
@@ -59,7 +59,7 @@ static struct symbols {
ID last_id;
st_table *str_id;
st_table *id_str;
- int minor_marked;
+ VALUE dsymbol_fstr_hash;
} global_symbols = {tLAST_TOKEN};
static const struct st_hash_type symhash = {
@@ -70,21 +70,17 @@ static const struct st_hash_type symhash = {
void
Init_sym(void)
{
+ VALUE dsym_fstrs = rb_hash_new();
+ global_symbols.dsymbol_fstr_hash = dsym_fstrs;
+ rb_gc_register_mark_object(dsym_fstrs);
+ rb_obj_hide(dsym_fstrs);
+
global_symbols.str_id = st_init_table_with_size(&symhash, 1000);
global_symbols.id_str = st_init_numtable_with_size(1000);
Init_id();
}
-void
-rb_gc_mark_symbols(int full_mark)
-{
- if (full_mark || global_symbols.minor_marked == 0) {
- rb_mark_tbl(global_symbols.id_str);
- if (!full_mark) global_symbols.minor_marked = 1;
- }
-}
-
static ID attrsetname_to_attr(VALUE name);
static int lookup_id_str(ID id, st_data_t *data);
@@ -316,7 +312,8 @@ register_static_symid_str(ID id, VALUE str)
st_add_direct(global_symbols.str_id, (st_data_t)str, id);
st_add_direct(global_symbols.id_str, id, (st_data_t)str);
- global_symbols.minor_marked = 0;
+ rb_gc_register_mark_object(str);
+
return id;
}
@@ -384,7 +381,7 @@ dsymbol_alloc(const VALUE klass, const VALUE str, rb_encoding * const enc)
st_add_direct(global_symbols.str_id, (st_data_t)str, (st_data_t)dsym);
st_add_direct(global_symbols.id_str, (ID)dsym, (st_data_t)str);
- global_symbols.minor_marked = 0;
+ rb_hash_aset(global_symbols.dsymbol_fstr_hash, str, Qtrue);
if (RUBY_DTRACE_SYMBOL_CREATE_ENABLED()) {
RUBY_DTRACE_SYMBOL_CREATE(RSTRING_PTR(RSYMBOL(dsym)->fstr), rb_sourcefile(), rb_sourceline());
@@ -419,11 +416,14 @@ dsymbol_pindown(VALUE sym)
must_be_dynamic_symbol(sym);
if (UNLIKELY(SYMBOL_PINNED_P(sym) == 0)) {
+ VALUE fstr = RSYMBOL(sym)->fstr;
sym = dsymbol_check(sym);
FL_SET(sym, SYMBOL_PINNED);
/* make it permanent object */
rb_gc_register_mark_object(sym);
+ rb_gc_register_mark_object(fstr);
+ rb_hash_delete(global_symbols.dsymbol_fstr_hash, fstr);
}
return (ID)sym;