mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
996ff90744
commit
96815f1ebe
4 changed files with 33 additions and 22 deletions
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
||||||
|
Thu Jul 10 01:09:57 2014 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
Thu Jul 10 00:24:18 2014 Naohisa Goto <ngotogenome@gmail.com>
|
Thu Jul 10 00:24:18 2014 Naohisa Goto <ngotogenome@gmail.com>
|
||||||
|
|
||||||
* common.mk (DTRACE_DEPENDENT_OBJS): fix build failure on Solaris
|
* common.mk (DTRACE_DEPENDENT_OBJS): fix build failure on Solaris
|
||||||
|
|
9
gc.c
9
gc.c
|
@ -4230,15 +4230,6 @@ gc_mark_roots(rb_objspace_t *objspace, int full_mark, const char **categoryp)
|
||||||
MARK_CHECKPOINT("machine_context");
|
MARK_CHECKPOINT("machine_context");
|
||||||
mark_current_machine_context(objspace, th);
|
mark_current_machine_context(objspace, th);
|
||||||
|
|
||||||
MARK_CHECKPOINT("symbols");
|
|
||||||
#if USE_RGENGC
|
|
||||||
objspace->rgengc.parent_object_is_old = TRUE;
|
|
||||||
rb_gc_mark_symbols(full_mark);
|
|
||||||
objspace->rgengc.parent_object_is_old = FALSE;
|
|
||||||
#else
|
|
||||||
rb_gc_mark_symbols(full_mark);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MARK_CHECKPOINT("encodings");
|
MARK_CHECKPOINT("encodings");
|
||||||
rb_gc_mark_encodings();
|
rb_gc_mark_encodings();
|
||||||
|
|
||||||
|
|
|
@ -805,7 +805,6 @@ int rb_is_attrset_name(VALUE name);
|
||||||
int rb_is_local_name(VALUE name);
|
int rb_is_local_name(VALUE name);
|
||||||
int rb_is_method_name(VALUE name);
|
int rb_is_method_name(VALUE name);
|
||||||
int rb_is_junk_name(VALUE name);
|
int rb_is_junk_name(VALUE name);
|
||||||
void rb_gc_mark_symbols(int full_mark);
|
|
||||||
ID rb_make_internal_id(void);
|
ID rb_make_internal_id(void);
|
||||||
void rb_gc_free_dsymbol(VALUE);
|
void rb_gc_free_dsymbol(VALUE);
|
||||||
VALUE rb_str_dynamic_intern(VALUE);
|
VALUE rb_str_dynamic_intern(VALUE);
|
||||||
|
|
24
symbol.c
24
symbol.c
|
@ -59,7 +59,7 @@ static struct symbols {
|
||||||
ID last_id;
|
ID last_id;
|
||||||
st_table *str_id;
|
st_table *str_id;
|
||||||
st_table *id_str;
|
st_table *id_str;
|
||||||
int minor_marked;
|
VALUE dsymbol_fstr_hash;
|
||||||
} global_symbols = {tLAST_TOKEN};
|
} global_symbols = {tLAST_TOKEN};
|
||||||
|
|
||||||
static const struct st_hash_type symhash = {
|
static const struct st_hash_type symhash = {
|
||||||
|
@ -70,21 +70,17 @@ static const struct st_hash_type symhash = {
|
||||||
void
|
void
|
||||||
Init_sym(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.str_id = st_init_table_with_size(&symhash, 1000);
|
||||||
global_symbols.id_str = st_init_numtable_with_size(1000);
|
global_symbols.id_str = st_init_numtable_with_size(1000);
|
||||||
|
|
||||||
Init_id();
|
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 ID attrsetname_to_attr(VALUE name);
|
||||||
static int lookup_id_str(ID id, st_data_t *data);
|
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.str_id, (st_data_t)str, id);
|
||||||
st_add_direct(global_symbols.id_str, id, (st_data_t)str);
|
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;
|
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.str_id, (st_data_t)str, (st_data_t)dsym);
|
||||||
st_add_direct(global_symbols.id_str, (ID)dsym, (st_data_t)str);
|
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()) {
|
if (RUBY_DTRACE_SYMBOL_CREATE_ENABLED()) {
|
||||||
RUBY_DTRACE_SYMBOL_CREATE(RSTRING_PTR(RSYMBOL(dsym)->fstr), rb_sourcefile(), rb_sourceline());
|
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);
|
must_be_dynamic_symbol(sym);
|
||||||
|
|
||||||
if (UNLIKELY(SYMBOL_PINNED_P(sym) == 0)) {
|
if (UNLIKELY(SYMBOL_PINNED_P(sym) == 0)) {
|
||||||
|
VALUE fstr = RSYMBOL(sym)->fstr;
|
||||||
sym = dsymbol_check(sym);
|
sym = dsymbol_check(sym);
|
||||||
FL_SET(sym, SYMBOL_PINNED);
|
FL_SET(sym, SYMBOL_PINNED);
|
||||||
|
|
||||||
/* make it permanent object */
|
/* make it permanent object */
|
||||||
rb_gc_register_mark_object(sym);
|
rb_gc_register_mark_object(sym);
|
||||||
|
rb_gc_register_mark_object(fstr);
|
||||||
|
rb_hash_delete(global_symbols.dsymbol_fstr_hash, fstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ID)sym;
|
return (ID)sym;
|
||||||
|
|
Loading…
Add table
Reference in a new issue