This function is similar to rb_gc_mark_locations(), but not
conservertive.
* internal.h: ditto.
* vm.c (env_mark): use rb_gc_mark_values() because env values should
be Ruby VALUEs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Please refer this ticket for details.
This change also introduces the following changes.
* Remove RGENGC_AGE2_PROMOTION and introduce object age (0 to 3).
Age can be count with FL_PROMOTE0 and FL_PROMOTE1 flags in
RBasic::flags (2 bit). Age == 3 objects become old objects.
* WB_PROTECTED flag in RBasic to WB_UNPROTECTED bitmap.
* LONG_LIVED bitmap to represent living objects while minor GCs
It specifies (1) Old objects and (2) remembered shady objects.
* Introduce rb_objspace_t::marked_objects which counts marked
objects in current marking phase. marking count is needed to
introduce incremental marking.
* rename mark related function and sweep related function to
gc_(marks|sweep)_(start|finish|step|rest|continue).
* rename rgengc_report() to gc_report().
* Add obj_info() function to get cstr of object details.
* Add MEASURE_LINE() macro to measure execution time of specific line.
* and many small fixes.
* include/ruby/ruby.h: add flag USE_RINCGC.
Now USE_RINCGC can be set only with USE_RGENGC.
* include/ruby/ruby.h: introduce FL_PROMOTED0 and add FL_PROMOTED1
to count object age.
* include/ruby/ruby.h: rewrite write barriers for incremental marking.
* debug.c: catch up flag name changes.
* internal.h: add rb_gc_writebarrier_remember() instead of
rb_gc_writebarrier_remember_promoted().
* array.c (ary_memcpy0): use rb_gc_writebarrier_remember().
* array.c (rb_ary_modify): ditto.
* hash.c (rb_hash_keys): ditto.
* hash.c (rb_hash_values): ditto.
* object.c (init_copy): use rb_copy_wb_protected_attribute() because
FL_WB_PROTECTED is moved from RBasic::flags.
* test/objspace/test_objspace.rb: catch up ObjectSpace.dump() changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (WARN_UNUSED_RESULT): warn unused result by gcc 3.4
or later.
* symbol.c: declare some functions with WARN_UNUSED_RESULT.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_setup_fake_str): setup fake string from C pointer,
length, and encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This function creates internal use only array (which is completely
hided by ObjectSpace.each_object) with filling nil.
Otherwise, it can be incldues strange VALUEs.
* internal.h: added.
* node.h: use rb_ary_tmp_new_fill() for MEMO.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.h (RSYMBOL): move macros for Symbol from internal.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (rb_to_symbol): new function to convert an object to a
symbol.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
exposing IDs from collectable symbols.
[Bug #10014]
Now, rb_check_id() returns 0 if corresponding symbol is
pinned dynamic symbol.
There is remaining intern_cstr_without_pindown(), it can return
IDs from collectable symbols. We must be careful to use it
(only used in parse.y). I think it should be removed if
it does not have impact for performance.
* parse.y:
add:
* STATIC_SYM2ID()
* STATIC_ID2SYM()
rename:
* rb_pin_dynamic_symbol() -> dsymbol_pindown()
* internal.h:
remove:
* rb_check_id_without_pindown()
* rb_sym2id_without_pindown()
add:
* rb_check_symbol()
* rb_check_symbol_cstr()
* load.c: use rb_check_id() or rb_check_id_cstr().
* object.c: ditto.
* struct.c: ditto.
* thread.c: ditto.
* vm_method.c: ditto.
* string.c (sym_find): use only rb_check_symbol().
* sprintf.c (rb_str_format): use rb_check_symbol_cstr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* object.c (rb_obj_copy_ivar): extract function to copy instance
variables only for T_OBJECT from init_copy.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This is too new to be a compatibility problem.
* include/ruby/ruby.h: Hide Symbol internals.
(struct RSymbol): moved to internal.h
(RSYMBOL): ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (rb_hash_keys): make an internal public function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* object.c (rb_class_search_ancestor): return ancestor class or
iclass if inherited.
* object.c (rb_obj_is_kind_of, rb_class_inherited_p): share
function to search the ancestor.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* string.c (sym_to_proc), proc.c (rb_block_clear_env_self): clear
caller's self which is useless, so that it can get collected.
[Fixes GH-592]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (rb_id_attrget): new function to convert setter ID to
getter ID.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* re.c (match_regexp): set regexp for MatchData from string.
* re.c (rb_backref_set_string): create MatchData from string and
set backref.
* string.c (rb_pat_search, rb_str_sub, rb_str_sub_bang, str_gsub),
(scan_once, rb_str_scan, rb_str_partition): use rb_str_index
instead of rb_reg_search() when pattern is a String. based on
the patch by Sam Rawlins <sam.rawlins@gmail.com> [Fixes GH-579]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
* internal.h: add prototype for rb_reg_search0
* re.c: rename rb_reg_search to rb_reg_search0, add set_backref_str
argument to allow callers to indicate that they don't require the
backref string to be allocated
* string.c: don't allocate backref str if replacement string is provided
Closes GH-578. [Bug #9676] [ruby-core:61682]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45414 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* marshal.c (to_be_skipped_id): ignore anonymous attributes.
* pack.c (Init_pack): use anonymous ID so that associated objects
do not appear in the packed result.
* parse.y (rb_make_internal_id): return an anonymous ID for
internal use.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
By r44804, string objects can not have STR_ASSOC flag.
* internal.h: ditto.
* ext/objspace/objspace_dump.c (dump_object): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
The patch base by drkaes (Stefan Kaes).
[Bug #9321]
* variable.c (rb_mod_const_missing): use rb_vm_pop_cfunc_frame()
instead of rb_frame_pop().
* vm_eval.c (raise_method_missing): ditto.
* vm_eval.c (rb_iterate): ditto.
* internal.h (rb_vm_pop_cfunc_frame): add decl.
* test/ruby/test_settracefunc.rb: add tests.
provided by drkaes (Stefan Kaes).
* vm.c, eval.c, include/ruby/intern.h (rb_frame_pop):
move definition of rb_frame_pop() and deprecate it.
It doesn't care about `return' events.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
it is no longer used from array.c since r43969.
the patch is from normalperson (Eric Wong).
[ruby-core:59449] [Feature #9336]
* internal.h: remove definition of rb_hash_keys().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (struct RClass): add super, remove iv_index_tbl.
since RCLASS_SUPER() is commonly used inside while loops, we move it
back inside struct RClass to improve cache hits. this provides a
small improvement (1%) in hotspots like rb_obj_is_kind_of()
* internal.h (struct rb_classext_struct): remove super, add
iv_index_table
* internal.h (RCLASS_SUPER): update for new location
* internal.h (RCLASS_SET_SUPER): ditto
* internal.h (RCLASS_IV_INDEX_TBL): ditto
* object.c (rb_class_get_superclass): ditto
* include/ruby/backward/classext.h (RCLASS_SUPER): ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e