Граф коммитов

1256 Коммитов

Автор SHA1 Сообщение Дата
nobu bb10a21346 ruby.h: deprecate plain Data
* include/ruby/ruby.h (rb_data_object_alloc_deprecated): deprecate
  Data_Make_Struct and Data_Wrap_Struct.  [EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-27 01:28:47 +00:00
nobu e5a3c25a69 compile.c, gc.c: suppress warnings
* compile.c (iseq_compile_each): suppress implicit conversion
  warning by old apple gcc 4.2.

* gc.c (RVALUE_FLAGS_AGE, heap_page_allocate): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-14 01:56:53 +00:00
ko1 8c6c9c46d8 * vm.c (rb_vm_register_special_exception): make new function to
make and register special exceptions.
* vm.c (rb_vm_mark): do not need to mark special exceptions
  because they are registerd by rb_gc_register_mark_object().
* eval.c (Init_eval): use rb_vm_register_special_exception().
* gc.c (Init_GC): ditto.
* proc.c (Init_Proc): ditto.
* thread.c (Init_Thread): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-11 10:53:48 +00:00
ko1 c653db51b0 * gc.c (rb_gc_mark_values): added.
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
2014-09-11 10:34:09 +00:00
ko1 51101947bb * gc.c (gc_mark_ptr): rename to gc_mark_set.
* gc.c (gc_mark): add gc_mark_ptr() to skip is_markable_object()
  check. gc_mark_maybe() can use gc_mark_ptr() directly because
  passed pointer is checked by is_pointer_to_heap().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-11 10:23:36 +00:00
ko1 970d8cb613 * include/ruby/ruby.h, gc.c: add new internal events
RUBY_INTERNAL_EVENT_GC_ENTER and
  RUBY_INTERNAL_EVENT_GC_EXIT.
  When invoking GC process, GC_ENTER event is called.
  When exiting from GC process, GC_EXIT event is called.
  Incremental GC (incremental marking and lazy sweep) can call
  these events many times.
  For example (minor marking):
  (1) GC_ENTER
  - (2) GC_START (minor GC)
    (minor marking)
  - (3) GC_END_MARK
    (start lazy sweep)
  (4) GC_EXIT
    (ruby process)
  (5) GC_ENTER
    (lazy sweep)
  (6) GC_EXIT
    (ruby process)
    (... repeat (5), (6))
  (7) GC_ENTER
      (finish lazy sweep)
    - (8) GC_END_SWEEP
  (9) GC_EXIT
  2nd example (incremental major marking):
  (1) GC_ENTER
  - (2) GC_START (minor GC)
    (start incremental marking)
  (3) GC_EXIT
    (ruby process)
  (4) GC_ENTER
    (incremental marking)
  (5) GC_EXIT
     (ruby process)
     (... repeat (4), (5))
  (6) GC_ENTER
    (finish incremental marking)
  - (7) GC_END_MARK
    (start lazy sweep)
  (8) GC_EXIT
    (ruby process)
  (9) GC_ENTER
    (lazy sweep)
  (10) GC_EXIT
    (ruby process)
    (... repeat (9), (10))
  (11) GC_ENTER
    (finish lazy marking)
  - (12) GC_STOP_SWEEP
  (13) GC_EXIT
  Thease internal events enable to measure GC pause time completely.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-11 08:46:59 +00:00
ko1 cc3088ea51 * include/ruby/ruby.h: freeze nil/true/false.
* gc.c (should_be_finalizable): check frozen after checkin FL_ABLE.
* object.c (rb_obj_taint): check
  OBJ_TAINTABLE(obj).
* object.c (rb_obj_freeze): remove immediate_frozen_tbl
   because all of immediate values are frozen. YAY!
* object.c (rb_obj_frozen_p): ditto.
* test/ruby/test_eval.rb: skip instance_variable_set for
  frozen objects.
* test/ruby/test_weakmap.rb: check ArgumentError instead of
  RuntimeError.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-11 05:37:32 +00:00
nobu 24974c0ea1 gc.c: preserve encoding
* gc.c (should_be_callable): preserve encoding of class name in
  error messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10 08:22:03 +00:00
ko1 c1b05c53b7 * gc.c (gc_stat): update rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10 02:59:46 +00:00
ko1 52c41f1e8f * gc.c (gc_stat_internal): rename:
* malloc_increase -> malloc_increase_bytes
  * malloc_limit -> malloc_increase_bytes_limit
  * oldmalloc_increase -> oldmalloc_increase_bytes
  * oldmalloc_limit -> oldmalloc_increase_bytes_limit
  ref: [Feature #9924]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10 02:53:11 +00:00
ko1 ed729d3986 * gc.c (gc_stat_internal): rename `heap_used' to `heap_allocated_pages'.
ref: [Feature #9924]
* test/ruby/test_gc.rb: add constraints test for gc stat information.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10 02:47:05 +00:00
ko1 6b398398b9 * gc.c (gc_stat_internal): rename:
* remembered_shady_object -> remembered_wb_unprotected_objects
  * remembered_shady_object_limit -> remembered_wb_unprotected_objects_limit
  * old_object -> old_objects
  * old_object_limit -> old_objects_limit
  ref: [Feature #9924]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10 02:35:17 +00:00
ko1 2d581d6c2a * gc.c (gc_stat_internal): support:
* total_allocated_pages
  * total_freed_pages
  ref: [Feature #9924]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10 02:13:41 +00:00
ko1 6c6254274f * gc.c (objspace_total_slot): rename objspace_available_slots.
* gc.c (objspace_live_slot, objspace_free_slot): rename
  ..._slot() to ..._slots().
* gc.c (objspace_free_slot): should subtract heap_pages_final_slots.
* gc.c (gc_stat_internal):
  * add `heap_available_slots' field
  * rename heap_live_slot to heap_live_slots
  * rename heap_free_slot to heap_free_slots
  ref: [Feature #9924]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-10 01:42:09 +00:00
ko1 6b4a7aa2a6 * gc.c: refactoring for RGENGC_PROFILE > 0.
* rename rb_objspace_t::profile::..._count
    to rb_objspace_t::profile::total_..._count
  * rename promote_infant_types to promote_types
* gc.c (gc_remember_unprotected): count remembered shady objects here.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 22:32:09 +00:00
nagachika 9aacc92bc9 * gc.c (init_mark_stack): MEMZERO() receive type as 2nd argument instead
of size.
  Coverity Scan found this bug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47483 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 18:23:11 +00:00
kazu 5623c00f4b s/stressfull/stressful/g
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 13:09:14 +00:00
ko1 9b6bc26f87 * gc.c: rename rb_objspace_t::marked_objects to marked_slots.
* gc.c (gc_marks_start): should be clear first.
* gc.c (gc_marks_start): remembered shady objects are also marked.
* gc.c (gc_stat_internal): add heap_marked_slots.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 10:55:18 +00:00
ko1 97fef1cdfb * gc.c: rename
* total_allocated_object_num -> total_allocated_objects
  * total_allocated_object_num_at_gc_start -> total_allocated_objects_at_gc_start
  * total_freed_object_num -> total_freed_objects
* gc.c (gc_stat_internal):
  * rename total_allocated_object -> total_allocated_objects
  * rename total_freed_object -> total_freed_objects



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 10:01:18 +00:00
ko1 727497607c * gc.c (gc_stat_internal): fix symbol names
* heap_final_slot -> heap_final_slots
  * heap_swept_slot -> heap_swept_slots



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 09:53:47 +00:00
ko1 8ee9071cbe * gc.c (rb_objspace_t::heap_pages): rename field names:
* used -> allocated_pages
  * increment -> allocatable_pages
  * length -> sorted_length
  And remove unused `limt' field.
* gc.c: rename macros:
  * heap_pages_used -> heap_allocated_pages
  * heap_pages_length -> heap_pages_sorted_length
  * heap_pages_increment -> heap_allocatable_pages
* gc.c (gc_stat_internal): fix symbol names
  ref: [Feature #9924]
  https://docs.google.com/spreadsheets/d/11Ua4uBr6o0k-nORrZLEIIUkHJ9JRzRR0NyZfrhEEnc8/edit?usp=sharing
  Yellow color fields in this table are changed.
* test/ruby/test_gc.rb: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 09:33:52 +00:00
nobu eb7a7801bf gc.c: fix typos
* gc.c (gc_stat_transition): fix typos.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47470 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 06:39:08 +00:00
ko1 886e27995b * gc.c: continue layout changing.
newobj_of() also touch:
  (4) increment total_allocated_object_num
  (5) check hook_events
  And gather fields related to marking phase.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 06:00:57 +00:00
ko1 15e4903cba * gc.c: fix layout of rb_objsapce_t to improve cache locality.
newobj_of() accesses:
  (1) rb_objspace_t::flags
  (2) rb_objspace_t::eden_heap::freelist
  (3) and rb_objspace_t::eden_heap::free_pages if freelist is NULL.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 05:24:42 +00:00
ko1 3238a4a729 * gc.c: move rb_objspace_t:🎏:gc_stressfull after during_gc
to make accesssing both parameters easy.
* gc.c (heap_get_freeobj): add LIKELY() hint.
* gc.c (heap_get_freeobj_from_next_freepage): ditto.
* gc.c (newobj_of): check both parameters at once for exceptional
  case.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 05:12:15 +00:00
ko1 ddac04d2c2 * gc.c: add rb_objspace_t:🎏:gc_stressfull and
ruby_gc_stressfull macro.
  Rename objspace->gc_stress to objspace->gc_stress_mode.
  If objspace->gc_stress_mode is true (!nil and !false) then
  ruby_gc_stressfull becomes TRUE.
  ruby_gc_stressfull will speedup newobj_of() slightly.
* gc.c: initialize ruby_gc_stress(full|_mode) by gc_params.gc_stress
  even if ENABLE_VM_OBJSPACE is false.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 04:56:55 +00:00
ko1 0c391a55d3 * gc.c: remvoe ruby_disable_gc_stress and add ruby_disable_gc
to speed-up newobj_of().
* gc.c (ready_to_gc): check ruby_disable_gc.
* signal.c: use ruby_disable_gc.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 04:12:14 +00:00
ko1 335ca560de * gc.c: rename gc_stat entries and check stat transition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 03:13:25 +00:00
ko1 71990d0ed1 * gc.c (gc_sweep_rest): remove wrong modification of during_gc flag.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 03:07:46 +00:00
nobu ce71cfaa42 * gc.c (rb_objspace_t::profile): reduce padding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 02:59:08 +00:00
ko1 c5e13c3270 * gc.c: pack boolean values into rb_objspace_t::flags with bit fields
to improve cache locality.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-09 02:45:21 +00:00
svn c6da45b74c * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-08 04:11:16 +00:00
ko1 123eeb1c1a * gc.c: add incremental GC algorithm. [Feature #10137]
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
2014-09-08 04:11:00 +00:00
ktsj 6bce41b3b7 * gc.c (obj_memsize_of): don't calculate memsize of T_NODE
when called from check_gen_consistency. It fixes segmentation
  fault on RGENGC_CHECK_MODE >= 1 introduced by r47188.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-17 10:51:33 +00:00
nobu a669514e63 node.h: extract NODE functions from gc.c
* node.h (rb_gc_free_node, rb_node_memsize, rb_gc_mark_node):
  extract functions for NODE from obj_free(), obj_memsize_of(),
  gc_mark_children() in gc.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-16 01:53:10 +00:00
nobu 85691b9578 gc.c: memsize of T_NODE
* gc.c (obj_memsize_of): fix size of T_NODE and comments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-15 03:00:31 +00:00
ko1 2cb8ee942c * gc.c: remove unused macros.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-30 06:24:05 +00:00
normal 48a2b96d2b introduce ZALLOC{,_N} to replace ALLOC{,_N}+MEMZERO use
Using calloc where possible reduces code and binary sizes.

* include/ruby/ruby.h (ZALLOC, ZALLOC_N): implement
  (Data_Make_Struct, TypedData_Make_Struct):
  ZALLOC replaces ALLOC+memset
* compile.c (iseq_seq_sequence): ZALLOC_N replaces ALLOC_N+MEMZERO
* cont.c (fiber_t_alloc): ZALLOC replaces ALLOC+MEMZERO
* io.c (rb_io_reopen): ditto
* iseq.c (prepare_iseq_build): ditto
* parse.y (new_args_tail_gen, parser_new, ripper_s_allocate): ditto
* re.c (match_alloc): ditto
* variable.c (rb_const_set): ditto
* ext/socket/raddrinfo.c (get_addrinfo): ditto
* ext/strscan/strscan.c (strscan_s_allocate): ditto
* gc.c (rb_objspace_alloc): calloc replaces malloc+MEMZERO

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-25 21:34:35 +00:00
ko1 41929aa6b6 * gc.c: change objspace::rgengc::parent_object_is_old (boolean)
to objspace::rgengc::parent_object (VALUE).
  Use Qfalse or RVALUE pointer instead of FALSE and TRUE.
* gc.c (gc_marks_body): should clear parent_object just before
  gc_mark_roots() because there are no parents objects
  for root objects.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-25 05:12:06 +00:00
ko1 61a2893457 * gc.c (rb_gc_writebarrier_remember_promoted): should remember only
OLD objects on RGENGC_AGE2_PROMOTION.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-25 04:47:48 +00:00
ko1 009bf7be44 * gc.c (gc_mark_stacked_objects): fix error message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-25 04:43:09 +00:00
ko1 c90cd20cc4 * gc.c: fix major GC flags.
* add GPR_FLAG_MAJOR_BY_FORCE, which indicates
    major GC by METHOD, CAPI and so on (see GC_BY).
  * remove GPR_FLAG_MAJOR_BY_RESCAN because not used.
  * remove GPR_FLAG_MAJOR_BY_STRESS, use FORCE instead.
* test/ruby/test_gc.rb: catch up.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-24 11:13:19 +00:00
ko1 88722e6a5d * gc.c (gc_mark_roots): call rb_vm_mark directly.
* vm.c: remove mark function for RubyVM object because
  RubyVM object marked manually.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-16 09:06:52 +00:00
nobu ef3ff64933 gc.c: fix typo
* gc.c (global_list): fix typo, capital 'L'.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-10 03:24:17 +00:00
ko1 96815f1ebe * 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
2014-07-09 16:19:13 +00:00
ko1 2e225e2c8b * gc.c: revert miss-commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-07 03:46:15 +00:00
ko1 2c551e4715 * parse.y: need to use updated (re-created) symbols.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-07 03:42:42 +00:00
ko1 2006bfe2f4 * gc.c: rename is_dying_object() to is_garbage_object().
* gc.h: rb_objspace_garbage_object_p() as an exported function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-06 15:42:14 +00:00
ko1 094949cb0a * gc.c (is_dying_object): fix missed condition.
* gc.c (is_live_object): move frequent path first.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-06 12:33:12 +00:00
ko1 38943e80d6 * gc.c: rename is_dead_object() to is_dying_object().
This function is not opposite against is_live_object()
  because is_dying_object() does *not* check object type.
* gc.c (is_dying_object): change condition.
* gc.c (is_live_object): use T_NONE instead of 0.
* gc.c (rb_objspace_dying_object_p): added.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-06 12:02:57 +00:00
ko1 a617afc643 * gc.c (rb_gc_register_mark_object): change data structure.
From single array, to array of arrays. Each array only has 1024
  entries.
* vm.c (Init_vm_objects): change default capa from 1 to 128.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-06 04:42:35 +00:00
nobu 876bfc6b4e Init functions don't need ID caches
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-03 03:38:10 +00:00
ko1 41fe524857 * gc.c (gc_heap_lazy_sweep): simplify logic.
* gc.c (gc_page_sweep): return TRUE if empty slots are available.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-02 06:47:10 +00:00
nobu 1d0fbdb92e gc.c: freeze GC::OPTS
* gc.c (Init_GC): freeze GC::OPTS.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-30 14:59:46 +00:00
ko1 51ae29a3cb * gc.c (gc_stat_internal): return size_t value instead of VALUE
and remove `out' parameter.
* gc.c: add braces for `if' statements.
* gc.c (gc_stat_internal): fix comment.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-30 07:46:57 +00:00
ko1 4369806ff0 * gc.c: support `USE_RGENGC == 0'.
* test/ruby/test_gc.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46622 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-30 06:14:37 +00:00
nobu e99ee55abc constify parameters
* include/ruby/intern.h: constify `argv` parameters.

* include/ruby/ruby.h: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18 06:16:39 +00:00
ko1 b905ac81a0 * gc.c (obj_memsize_of): memsize_of(T_ZOMBIE) returns 0, not a rb_bug.
ObjectSpace.count_objects_size() uses memsize_of(T_ZOMBIE).
  This bug introduced at r46348.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-17 03:27:26 +00:00
ko1 c8c9952066 * gc.c: invoke GC before memory allocation (xmalloc/xrealloc)
when GC.stress = true.
  [Bug #9859]
* test/ruby/test_gc.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-10 16:55:32 +00:00
ko1 5b2a745810 * gc.c: change full GC timing to keep lower memory usage.
Extend heap only at
  (1) after major GC
  or
  (2) after several (two times, at current) minor GC
  Details in https://bugs.ruby-lang.org/issues/9607#note-9
  [Bug #9607]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-09 11:43:23 +00:00
nobu 029fd365df gc.c: fix typo
* gc.c (gcdebug_sentinel): fix typo, "sentinel" not "sential".
  [fix GH-634]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-09 07:01:44 +00:00
ko1 72a77c25e5 * gc.c (gc_page_sweep): refactoring.
* gc.c (gc_page_sweep): should not set, but add final_slots into
  sweep_page->final_slots.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46356 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-05 07:14:53 +00:00
ko1 0e3debf15b * gc.c (obj_free): check also FL_PROMOTED bit by RVALUE_OLD_P().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-05 01:05:07 +00:00
ko1 2f73dbd084 * gc.c: introduce RZombie to manage zombie objects.
Rewrite finalizing logics with this type.
* gc.c (gc_verify_internal_consistency): verify zombie (finalizing)
  objects count.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-04 13:33:20 +00:00
ko1 7ad125d7d2 * gc.c (rb_objspace_free): should not rest_sweep() here.
Some data structures are already freed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-03 10:17:18 +00:00
ko1 29bee7e8ea revert r46332 because RVALUE_OLD_P() returns int by r46334
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-03 09:13:39 +00:00
ko1 75604b077e * gc.c (rb_gc_call_finalizer_at_exit): add
gc_verify_internal_consistency() when RGENGC_CHECK_MODE >= 2.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-03 09:02:21 +00:00
ko1 2e437f8b45 * gc.c: change the counting method for young objects.
clear counter at the beggining of every GC and
  count promoted (infant->young) objects.
  Some promotions (infant->young) are transition of promoting to old
  objects. We should not count such promotions.
  With this technique, we don't need to check young objects
  at obj_free().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-03 09:00:53 +00:00
ko1 9d71a0ae33 * gc.c: add verifying counters code in gc_verify_internal_consistency().
gc_verify_internal_consistency() counts all
  - live objects
  - young objects (if age2 promotion)
  - old objects
  in all pages and compares with objspace managing counters.
* gc.c (gc_after_sweep): do gc_verify_internal_consistency()
  when RGENGC_CHECK_MODE >= 2.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-03 07:50:23 +00:00
nobu b259791072 gc.c: int for simple predicates
* gc.c: use int for simple predicate functions instead of VALUE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-03 07:44:19 +00:00
ko1 3d42f2295d * gc.c (rb_gc_force_recycle): we only need to know the result (0/1)
of RVALUE_OLD_P(). clang fails to compile it because is_old is
  `int' but RVALUE_OLD_P() returns VALUE.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-03 07:37:44 +00:00
ko1 e7d8c473c1 * gc.c (objspace_live_slot): live slot count should not include final
slot (contains T_ZOMBIE) count.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-03 04:19:21 +00:00
ko1 a0bbf948b5 * gc.c (obj_free): fix spacing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-03 04:03:55 +00:00
ko1 58390617ef * gc.c (check_gen_consistency): fix error message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-03 04:00:18 +00:00
ko1 baff4dfef9 * gc.c: count old/young objects more correctly.
* gc.c (RVALUE_DEMOTE_FROM_OLD): decrement old object count.
* gc.c (RVALUE_DEMOTE_FROM_YOUNG): decrement young object count.
* gc.c (rb_gc_resurrect): increment old object count.
* gc.c (gc_marks_body): should not add old object count.
  This code is completely my misunderstanding.
* gc.c (rb_gc_force_recycle): decrement young or old object count
  correctly.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-03 03:55:04 +00:00
normal fae18c95be remove empty rb_gc_mark_parser function
* parse.y (rb_gc_mark_parser): remove, empty since r8758
* internal.h: ditto, not usable from extensions since 2.0.0
* gc.c (gc_mark_roots): remove checkpoint for parser

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-29 19:49:22 +00:00
nobu e434a3f280 gc.c: fix typo
* gc.c (objspace_malloc_increase): fix typo.
  "increase" not "incraese".

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-24 06:20:34 +00:00
normal 688b4cb74c gc.c (rb_free_m_tbl): mark function as static
* gc.c (rb_free_m_tbl): mark function as static
* method.h (rb_free_m_tbl): remove prototype

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-22 20:17:48 +00:00
naruse 3d6ecd45c7 fix type
struct RVALUE.file is const char*.
struct RVALUE.line is int.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18 11:02:43 +00:00
ko1 a86d454538 * gc.c (gc_marks, gc_marks_body): increase the counter of young objects
at the major GC because AGE2Promotion changes all old objects into
  young objects at major GC.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-16 08:41:06 +00:00
ko1 be5ed87c2f * gc.c (gc_before_sweep): heap_pages_swept_slots should contains
heap_pages_increment.
  For example, GC by exceeding malloc_limit can remain
  heap_pages_increment.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-16 08:38:04 +00:00
nobu 27082c9dfa * gc.c (heap_extend_pages): fix indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-15 10:53:40 +00:00
ko1 bceb547077 * gc.c (garbage_collect_body): move gc_heap_prepare_minimum_pages()
from gc_sweep().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-15 09:58:21 +00:00
ko1 8d81c976aa * gc.c (heap_extend_pages): calculate next growing heap size.
* gc.c (heap_set_increment): accept addition pages instead of
  minimum pages.
* gc.c (gc_after_sweep): use heap_etend_pages().
* gc.c (gc_heap_prepare_minimum_pages): add only 1 page.
* gc.c (heap_ready_to_gc): add only 1 page.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-15 09:54:49 +00:00
ko1 28a180ed2f * gc.c: introduce macros to remove magic number.
GC_HEAP_FREE_SLOTS_MIN_RATIO = 0.3: guarantee minimum empty slots
                                      ratio after sweep.
  GC_HEAP_FREE_SLOTS_MAX_RATIO = 0.8: allow to free pages 0.2 (= 1-0.8)
                                      of current existing slots.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-15 09:43:18 +00:00
ko1 1b03f51f82 * gc.c: enable RGENGC_AGE2_PROMOTION.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-14 09:04:27 +00:00
ko1 b4d9f9ca1d * gc.c (rgengc_rememberset_mark): promote remembered object earlier.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-14 09:03:17 +00:00
ko1 8be5c76f06 * gc.c: count young object correctly and show it in GC.stat
on RGENGC_AGE2_PROMOTION.
* gc.c (RVALUE_PROMOTE_YOUNG): decrement young object count on
  YOUNG->OLD.
* gc.c (obj_free): decrement young object count when young object
  freed.
* gc.c (gc_marks): should not clear young object count.
* gc.c (gc_stat_internal): GC.stat :young_object information.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-12 10:57:11 +00:00
nobu d4d045850b gc.c: fix argument types for st_foreach
* gc.c ({free,mark}_{method,const}_entry_i): fix argument types as
  st_data_t for st_foreach().

* gc.c (rgengc_unprotect_logging_exit_func_i): add third argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 15:43:37 +00:00
nari ca319081ce * gc.c (gc_after_sweep): suppress unnecessary expanding heap.
Tomb heap pages are freed pages here, so expanding heap is
  not required.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-30 10:58:45 +00:00
nari ec0cfc3a31 * gc.c: This argument must be a pointer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-28 08:46:36 +00:00
nari 6ee891d6a7 * gc.c: Fix typos. These are undefined variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-28 08:46:33 +00:00
ko1 d32ad2efca * gc.c (objspace_malloc_increase): don't cause GC by malloc_increase
when memop type is MEMOP_TYPE_REALLOC.
  GC at realloc is not well maintained.
  We need a time to make it safe.
  [ruby-dev:48117]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-21 23:37:18 +00:00
nobu 5890cb9d2d gc.c: full mark after malloc/realloc
* gc.c (objspace_malloc_increase): run full mark if 0x04 bit is
  set in ruby_gc_stress.  [ruby-core:62103] [Feature #9761]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-21 21:54:17 +00:00
nobu a633ed2812 gc.c: GC.stress after realloc
* gc.c (objspace_malloc_increase): run GC after realloc not only
  malloc and calloc by GC.stress.  [ruby-core:62103] [Feature #9761]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-21 21:53:48 +00:00
nobu 6f3bd427e7 gc.c: fixnum GC stress
* gc.c (garbage_collect_body): name magic numbers.

* gc.c (gc_stress_set): GC.stress accepts not only boolean but
  also Fixnum.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-21 00:39:43 +00:00
normal 1d2d053bda gc.c: drop special case for big hash/array
* gc.c (rb_gc_writebarrier): drop special case for big hash/array
  [Bug #9518]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-19 21:24:45 +00:00
nobu be116626dd gc.c: suppress a warning
* gc.c (get_envparam_size): suppress a warning by char-subscripts.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-17 08:24:10 +00:00
nobu 4b86cf6e98 gc.c: no newline to rb_bug
* gc.c: no newline in messages for rb_bug, it outputs a newline
  after the message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-11 01:31:06 +00:00
ko1 be51200785 * gc.c (gc_verify_internal_consistency): move lines and enable
allrefs_dump() on RGENGC_CHECK_MODE >= 4.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-10 10:01:16 +00:00
ko1 ddffb9bb9b * gc.c (rb_gc_writebarrier_unprotect_promoted): disable to dump debug
message when RGENGC_CHECK_MODE == 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-10 05:41:41 +00:00
nobu 4a0e3ccf28 gc.c: check rgengc_report argument
* gc.c (rgengc_report): use __VA_ARGS__ if possible.

* gc.c (rgengc_report_body): check argument.

* gc.c (heap_page_allocate): fix missing argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-10 03:40:34 +00:00
nobu 04de1d7dfe gc.c: do nothing unless USE_RGENGC
* gc.c (gc_verify_internal_consistency): always do nothing unless
  USE_RGENGC is set, no local variable needed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-10 03:40:32 +00:00
nobu 1a00d07619 gc.c: adjust indent
* gc.c (RVALUE_DEMOTE_FROM_YOUNG, RVALUE_DEMOTE_FROM_OLD): adjust
  indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-10 03:40:30 +00:00
akr 3f05ee0f42 Add comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-09 14:32:01 +00:00
akr 8a8221e69d * gc.c (mark_current_machine_context): Call SET_STACK_END.
This reverts a hunk of r40703 by ko1.
  This fixes [ruby-dev:48098] [Bug #9717].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-09 14:30:46 +00:00
ko1 bdf4eb0615 * gc.c: rename `RGENGC_THREEGEN' to `RGENGC_AGE2_PROMOTION'.
* gc.c (rgengc_rememberset_mark): don't promote, but remain in
  remember set for infant objects.
* gc.c (RVALUE_PROMOTE_INFANT, RVALUE_PROMOTE_YOUNG): count numbers
  in these functions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-08 13:36:02 +00:00
ko1 37067ed905 * gc.c, gc.h (rb_objspace_each_objects_without_setup):
Add a new (hidden) C-API to iterate objspace snapshot.
  This API is not safe to call any C-APIs in a given callback
  function. Be careful to use this C-API.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-02 11:59:50 +00:00
nobu a92374677c gc.c: avoid inadvertent pin-down
* gc.c (gc_info_decode): get rid of inadvertent dynamic symbol
  pin-down, and preserve encoding in error messages.  also should
  not use RSTRING_PTR macro on function calls.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-30 21:55:59 +00:00
ko1 835186a322 * gc.c (gc_before_sweep): cap `malloc_limit' to
gc_params.malloc_limit_max.  It can grow and grow with such case:
    `loop{"a" * (1024 ** 2)}'
  [Bug #9687]
  This issue is pointed by Tim Robertson.
  http://www.omniref.com/blog/blog/2014/03/27/ruby-garbage-collection-still-not-ready-for-production/



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-29 04:37:06 +00:00
nari 90b7073842 * 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
2014-03-26 04:57:47 +00:00
hsbt 23d790e46f gc.c: Fix up default GC params by @csfrancis [fix GH-556]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-24 05:28:03 +00:00
zzak 27b9d591a5 * gc.c: [DOC] Fix call-seq for GC.start by @jasonrclark [Fixes GH-572]
https://github.com/ruby/ruby/pull/572 [ci skip]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-21 07:33:03 +00:00
ko1 3e20c50d50 * gc.c (objspace_malloc_increase): should not invoke
garbage_collect_with_gvl() here on non-ruby threads.
  Should just ignore the malloc_increase.
  This issue is pointed by Eric Wong [ruby-core:61519].



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-20 08:05:35 +00:00
normal f5c2e89cd4 gc.c (objspace_xcalloc): fix GC accounting
This hopefully works on all platforms with malloc_usable_size.
This may also trigger bugs in places which did not expect GC, too;
so maybe some existing code will need RB_GC_GUARD.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-15 23:06:32 +00:00
nobu 1b9ff04f65 object.c: [DOC] merge rdoc
* gc.c (rb_obj_id): remove unused rdoc.

* object.c (rb_obj_hash): [DOC] merge unused rdoc from rb_obj_id()
  in gc.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-15 00:08:24 +00:00
nobu fc23374f06 [DOC] add links to `Object#hash`
add links to `Object#hash` to each #`hash` methods rdocs.
[Fixes GH-567]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-14 01:27:43 +00:00
normal 44f58afa75 gc.c: simplify condition
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-01 10:08:10 +00:00
normal 8b5fddab28 gc.c: fix build for testing w/o RGenGC
* gc.c (ruby_gc_set_params): fix building without RGenGC

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-01 07:15:07 +00:00
nobu cc216f9aae adjust indent and style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27 07:10:14 +00:00
ko1 8467d86f8a * gc.c (heap_pages_free_unused_pages): check tomb page availability
at first.
  And return immediately if we don't touch sorted list any more.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-26 09:46:45 +00:00
nobu c0ea69d544 gc.c: suppress warnings
* gc.c (gc_marks): cast explicitly to suppress warnings by VC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-22 02:56:55 +00:00
normal 08252d18a3 gc.c: RB_GC_GUARD should be robust enough for any compiler
* include/ruby/ruby.h (RB_GC_GUARD):
  use rb_gc_guarded_ptr_val on non-GCC/MSC
* gc.c (rb_gc_guarded_ptr_val): rename and adjust argument.
  RB_GC_GUARD should be robust enough for any compiler.
  [ruby-core:60816] [Bug #7805]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-20 23:45:55 +00:00
ko1 1aebaf7355 * gc.c (get_envparam_double): fix a warning message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-17 03:33:03 +00:00
ko1 3ee0444955 * gc.c: introduce new environment variable
"RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR" to control major/minor GC
  frequency.
  Do full GC when the number of old objects is more than R * N
  where R is this factor and
                N is the number of old objects just after last full GC.
* test/ruby/test_gc.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-17 03:27:13 +00:00
akr 3c99764bcd * internal.h: Rename macro names: RBIGNUM_FOO to BIGNUM_FOO.
(BIGNUM_EMBED_LEN_NUMBITS): Renamed from RBIGNUM_EMBED_LEN_NUMBITS.
  (BIGNUM_EMBED_LEN_MAX): Renamed from RBIGNUM_EMBED_LEN_MAX.
  (BIGNUM_SIGN_BIT): Renamed from RBIGNUM_SIGN_BIT.
  (BIGNUM_SIGN): Renamed from RBIGNUM_SIGN.
  (BIGNUM_SET_SIGN): Renamed from RBIGNUM_SET_SIGN.
  (BIGNUM_POSITIVE_P): Renamed from RBIGNUM_POSITIVE_P.
  (BIGNUM_NEGATIVE_P): Renamed from RBIGNUM_NEGATIVE_P.
  (BIGNUM_EMBED_FLAG): Renamed from RBIGNUM_EMBED_FLAG.
  (BIGNUM_EMBED_LEN_MASK): Renamed from RBIGNUM_EMBED_LEN_MASK.
  (BIGNUM_EMBED_LEN_SHIFT): Renamed from RBIGNUM_EMBED_LEN_SHIFT.
  (BIGNUM_LEN): Renamed from RBIGNUM_LEN.
  (RBIGNUM_DIGITS): Renamed from RBIGNUM_DIGITS.
  (BIGNUM_LENINT): Renamed from RBIGNUM_LENINT.

* bignum.c: Follow the above change.

* gc.c: Ditto.

* marshal.c: Ditto.

* math.c: Ditto.

* numeric.c: Ditto.

* random.c: Ditto.

* rational.c: Ditto.

* sprintf.c: Ditto.

* ext/-test-/bignum/bigzero.c: Ditto.

* ext/-test-/bignum/intpack.c: Ditto.

* ext/bigdecimal/bigdecimal.c: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-15 21:17:34 +00:00
akr 6f8b0e9bb0 * include/ruby/intern.h,
include/ruby/io.h,
  include/ruby/ruby.h,
  include/ruby/win32.h,
  include/ruby/backward/rubysig.h,
  bignum.c,
  gc.c,
  io.c,
  process.c,
  safe.c,
  struct.c,
  thread.c,
  ext/socket/rubysocket.h,
  ext/-test-/old_thread_select: Remove deprecated definitions
  [ruby-core:60581] [Feature #9502]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-14 15:16:31 +00:00
nobu aff08cfcd7 gc.c: unit suffix
* gc.c (get_envparam_size): accept unit suffix 'k', 'm', and 'g'.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-14 05:04:07 +00:00
ko1 c6f2c9383f * gc.c, gc.h (rb_objspace_marked_object_p): added.
This function *ONLY* works just after marking phase,
  before any sweeping.
  This function is highly depending current GC implementation
  and can be removed future version.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-08 07:03:43 +00:00
nobu 5fe0030d02 gc.c: ignore empty strings
* gc.c (get_envparam_size, get_envparam_double): silently ignore empty
  strings, without any warnings regardless $VERBOSE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-07 02:02:58 +00:00
nobu 9ba0b76fb3 gc.c: revert return
* gc.c (get_envparam_size): revert `return` statement removed by
  accident.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-07 01:59:16 +00:00
nobu 38b57c2915 gc.c: use size_t
* gc.c (ruby_gc_params_t, get_envparam_size): use size_t for
  integer environment parameters for sizes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-07 01:54:26 +00:00
nobu d4bbc2d776 gc.c: check numeric string
* gc.c (get_envparam_int, get_envparam_double): check invalid string
  as numeric.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-06 11:49:14 +00:00
ko1 b31c66f7af * gc.c (get_envparam_int): correct warning messsages.
* gc.c (get_envparam_double): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-06 06:28:40 +00:00
ko1 cb410ff932 * gc.c (get_envparam_int): don't accept a value equals to lowerbound
(changed by last commit) because "" or "foo" (not a number) strings
  are parsed as 0. They should be rejected.
* gc.c (get_envparam_double): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-06 06:26:01 +00:00
ko1 f167bc403d * gc.c (ruby_gc_set_params): if RUBY_GC_OLDMALLOC_LIMIT is provided,
then set objspace->rgengc.oldmalloc_increase_limit.
  Without this fix, the env variable RUBY_GC_OLDMALLOC_LIMIT
  does not work.
* gc.c (get_envparam_int): accept a value equals to lowerbounds.
* gc.c (get_envparam_double): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-06 00:04:14 +00:00
ko1 906e88e376 * gc.c (gc_mark_children): STR_ASSOC is no longer available.
Reported by @nagachika.
  http://d.hatena.ne.jp/nagachika/20140204



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05 02:49:41 +00:00
nobu 628f75b752 vm_core.h: rb_thread_struct::machine
* vm_core.h (rb_thread_struct): aggregate cpu stuff into a struct,
  so that a debugger can show its content at once.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-28 06:09:58 +00:00
hsbt 689755a1ad * gc.c: fix typo by @windwiny [fix GH-506]
*  proc.c: ditto
*  variable.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-19 05:43:28 +00:00
tmm1 9bfaeffd53 gc.c: fix doc typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-10 04:13:04 +00:00
marcandre e5839862e4 * gc.c: Oups, symbols are immediates too
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-09 17:49:31 +00:00
marcandre 705f9a7e80 * gc.c: Supplement object_id's rdoc for immediate and frozen string litterals
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-09 17:34:39 +00:00
marcandre cc366241ce * gc.c: Fix and remove outdated rdoc for object_id
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-09 17:34:27 +00:00
ko1 94e870b000 * gc.c (ruby_gc_set_params): don't show obsolete warnings for
RUBY_FREE_MIN/RUBY_HEAP_MIN_SLOTS if
  RUBY_GC_HEAP_FREE_SLOTS/RUBY_GC_HEAP_INIT_SLOTS are given.
  [Bug #9276]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-21 19:11:12 +00:00
ko1 0a8c1142b0 * gc.c (heap_get_freeobj): improve hot path performance.
* gc.c (heap_get_freeobj_from_next_freepage): replace with
  heap_get_freepage(). It returns freeobj instead of freepage.
  This is not on hot path.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-19 05:04:55 +00:00
ko1 9797647e25 * gc.c (newobj_of): don't need to RBASIC_SET_CLASS() which includes WB
here because created obj is always YOUNG/INFANT.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-19 01:51:16 +00:00
tmm1 3f8deb966c gc.c: remove redundant freelist assignment
* gc.c (heap_get_freeobj): remove redundant assignment. heap->freelist
  is set after the while() loop already.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-18 18:11:54 +00:00
ko1 d767adf990 * gc.c (garbage_collect_body): lazy_sweep setting should work
without USE_RGENGC.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-18 15:27:41 +00:00
ko1 a0a1d0f268 * gc.c (gc_profile_dump_major_reason): fix this function because major_reason
can be OR of multiple reasons.
* gc.c (gc_profile_dump_on): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-18 14:34:23 +00:00
ko1 661cf78bef * gc.c (gc_profile_record_get): should return an empty array
when profiling is active.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44277 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-18 08:04:08 +00:00