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

1219 Коммитов

Автор SHA1 Сообщение Дата
ko1 cb62399d90 * gc.c (atomic_sub_nounderflow): added to simplify atomic sub with
care about underflow.
* gc.c (objspace_malloc_increase): use it.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 08:53:47 +00:00
nobu b9cafaf524 vm_insnhelper.c: rb_get_kwargs
* vm_insnhelper.c (rb_get_kwargs): get keyword argument values from an
  option hash, not only checking keys.
* dir.c (dir_initialize): use rb_get_kwargs.
* gc.c (gc_start_internal): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 08:10:47 +00:00
nobu 761e9c518f gc.c: indent
* gc.c (gc_start_internal): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44032 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 07:47:29 +00:00
ko1 0e20c2afa8 * gc.c (gc_start_internal): do not use rb_gc_start() and rb_gc().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 07:22:25 +00:00
ko1 73d6dc252d * gc.c (gc_start_internal, rb_gc): do not need
heap_pages_free_unused_pages() here.
  It was done in after_sweep().
* gc.c (rb_gc): The reason is now GPR_FLAG_CAPI.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 06:26:02 +00:00
tmm1 e6237c8243 gc.c: add note about experimental nature of new GC.start flags
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 05:32:11 +00:00
tmm1 470c9d844b gc.c: add minor marking and lazy sweeping options to GC.start
* gc.c (gc_start_internal): GC.start() now accepts two optional
  keyword arguments. These can be used to disable full_mark (minor
  mark only) or disable immediate_sweep (use lazy sweep). These new
  options are useful for benchmarking GC behavior, or performing minor
  GC out-of-band.
* test/ruby/test_gc.rb (class TestGc): tests for new options.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 05:11:51 +00:00
nobu 928c99944b * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 12:49:07 +00:00
tmm1 941e36d3db gc.c: [DOC] minor typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 12:34:39 +00:00
ko1 b9cf1033aa * gc.c (gc_info_decode): fix to avoid syntax error on VS2012.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 12:06:59 +00:00
tmm1 4876dd3fb1 gc.c: add GC.latest_gc_info()
* gc.c (struct rb_objspace): rename internal last_collection_flags to
  latest_gc_info
* gc.c (gc_latest_collection_info): add GC.latest_gc_info() with similar
  behavior to GC.stat()
* gc.c (rb_gc_latest_gc_info): new c-api for above
* gc.c (gc_stat_internal): remove :last_collection_flags from GC.stat
* gc.c (gc_profile_decode_flags): remove GC::Profiler.decode_flags
* include/ruby/intern.h (rb_gc_latest_gc_info): export new c-api
* test/ruby/test_gc.rb (class TestGc): test for new behavior
* NEWS: note about new api

* gc.c (gc_stat_internal): raise TypeError on wrong type
* gc.c (gc_stat): fix error message

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 10:30:38 +00:00
ko1 53035271a8 * gc.c: change function names vm_ prefix to objspace_ prefix.
They are objspace_ functionality.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44006 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 08:52:30 +00:00
tmm1 241c1a5459 gc.c: expose GC.stat() to C-api via rb_gc_stat()
* include/ruby/intern.h: add rb_gc_stat() for access to GC.stat
  variables from c-api
* gc.c (rb_gc_stat): new c-api method. accepts either VALUE hash like
  GC.stat, or VALUE symbol key and returns size_t directly. the second
  form is useful to avoid allocations, i.e. for usage inside
  INTERNAL_EVENT_GC tracepoints.
* gc.c (gc_stat): add GC.stat(:key) to return single value instead of hash
* gc.c (gc_stat_internal): helper method to retrieve single or all stat values
* test/ruby/test_gc.rb (class TestGc): test for new behavior
* NEWS: note about this new api

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 07:45:13 +00:00
ko1 cda7250de0 * gc.c (vm_malloc_size): added.
return malloc_usable_size() if possible.
* gc.c (MALLOC_ALLOCATED_SIZE): add new setting macro to enable
  GC.allocated_size.
  If platform supports `malloc_usable_size()' (or similar one),
  GC.allocated_size can be implemented with this function.
  Default is 0.
* gc.c (vm_xmalloc, vm_xrealloc, vm_xfree): use vm_malloc_size()
  to detect collect allocated size.
* gc.c (vm_malloc_increase): refactoring.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 04:54:20 +00:00
tmm1 393b9e65e9 gc.c: split GC_END event into GC_END_MARK and GC_END_SWEEP
* include/ruby/ruby.h: remove INTERNAL_EVENT_GC_END and replace with
  two new events: GC_END_MARK and GC_END_SWEEP
* gc.c (gc_after_sweep): emit GC_END_SWEEP after lazy sweep is done
* gc.c (gc_marks_body): emit GC_END_MARK at end of minor/major mark
* ext/-test-/tracepoint/tracepoint.c (struct tracepoint_track): tests
  for new events.
* test/-ext-/tracepoint/test_tracepoint.rb (class TestTracepointObj):
  ditto.
* NEWS: remove ObjectSpace.after_gc_*_hook. These are only a sample,
  and will be removed before ruby 2.1.
* ext/objspace/gc_hook.c: remove ObjectSpace.after_gc_end_hook=

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 04:26:04 +00:00
nobu c06f12031e gc.c: flush all deferred finalizers
* gc.c (finalize_deferred): flush all deferred finalizers while other
  finalizers can get ready to run newly by lazy sweep.
  [ruby-core:58833] [Bug #9205]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 01:47:12 +00:00
nobu 3e36402e7f gc.c: rb_gc_set_params
* gc.c (rb_gc_set_params): define as separate function.
  RUBY_ALIAS_FUNCTION is for simple alias only, the third parameter
  will be ignored on gcc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 01:16:20 +00:00
tmm1 53e0d4666c gc.c: Load GC tuning settings earlier during boot.
* gc.c (ruby_gc_set_params): Accept safe_level argument so GC tuning
  settings can be applied before rb_safe_level() is available.
* internal.h (rb_gc_set_params): ditto.
* ruby.c (process_options): Apply GC tuning early during boot process
  so boot-time allocations can benefit. This also benefits any code
  loaded in via `ruby -r`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 00:19:13 +00:00
nobu b7c6db94ae gc.c: use malloc_size
* configure.in: check malloc_size() available on BSD.
* gc.c: use malloc_size() with malloc/malloc.h on BSD.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 14:48:20 +00:00
tmm1 084b602d9a * include/ruby/ruby.h (struct RClass): Add wrapper struct around
RClass->m_tbl with serial. This prevents double marking method
  tables, since many classes/modules can share the same method table.
  This improves minor mark time in a large application by 30%.
* internal.h (struct method_table_wrapper): Define new
  wrapper struct with additional serial.
* internal.h (RCLASS_M_TBL_INIT): New macro for initializing method
  table wrapper and st_table.
* method.h (void rb_sweep_method_entry): Rename rb_free_m_table to
  rb_free_m_tbl for consistentcy
* .gdbinit (define rb_method_entry): Update rb_method_entry gdb helper
  for new method table structure.
* class.c: Use RCLASS_M_TBL_WRAPPER and
  RCLASS_M_TBL_INIT macros.
* class.c (rb_include_class_new): Share WRAPPER between module and
  iclass, so serial can prevent double marking.
* eval.c (rb_prepend_module): ditto.
* eval.c (rb_using_refinement): ditto.
* gc.c: Mark and free new wrapper struct.
* gc.c (obj_memsize_of): Count size of additional wrapper struct.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03 08:11:07 +00:00
tmm1 d7009f76ef * gc.c: Expose details about last garbage collection via GC.stat.
* gc.c (gc_stat): Add :last_collection_flags for reason/trigger/type of
  last GC run.
* gc.c (gc_prof_sweep_timer_stop): Record HAVE_FINALIZE GPR even
  without GC_PROFILE_MORE_DETAIL.
* gc.c (gc_profile_flags): Add GC::Profiler.decode_flags to make sense
  of GC.stat[:last_collection_flags]
* test/ruby/test_gc.rb (class TestGc): Test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-28 07:40:35 +00:00
ko1 9e733b9091 * gc.c (gc_mark_stacked_objects): check only when check_mode > 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-27 08:56:48 +00:00
tmm1 0094b7bb68 * gc.c (Init_GC): Add new GC::INTERNAL_CONSTANTS for information about
GC heap/page/slot sizing.
* test/ruby/test_gc.rb (class TestGc): test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-27 06:57:14 +00:00
tmm1 23178d1044 * gc.c (gc_page_sweep): Fix compile warning from last commit.
* hash.c (hash_aset_str): Re-use existing variable to avoid
  unnecessary pointer dereferencing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-27 06:24:37 +00:00
ko1 da65a3d906 * gc.c (gc_page_sweep): disable debug print.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-27 06:13:19 +00:00
ko1 5993c141f1 * gc.c (gc_stat): add new information heap_eden_page_length and
heap_tomb_page_length.
* test/ruby/test_gc.rb: fix to use GC.stat[:heap_eden_page_length]
  instead of GC.stat[:heap_length].
  This test expects `heap_eden_page_length' (used pages size).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-27 06:09:55 +00:00
tmm1 5080a75621 * gc.c: Rename rb_heap_t members:
used -> page_length
    limit -> total_slots

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-27 01:42:25 +00:00
ko1 2bfd722d80 * internal.h: do not use ruby_sized_xrealloc() and ruby_sized_xfree()
if HAVE_MALLOC_USABLE_SIZE (or _WIN32) is defined.
  We don't need these function if malloc_usable_size() is available.
* gc.c: catch up this change.
* gc.c: define HAVE_MALLOC_USABLE_SIZE on _WIN32.
* array.c (ary_resize_capa): do not use ruby_sized_xfree() with
  local variable to avoid "unused local variable" warning.
  This change only has few impact.
* string.c (rb_str_resize): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-25 01:13:31 +00:00
ko1 30e88ca8a7 * gc.c: continue to change OLDSPACE -> OLDMALLOC.
RGENGC_ESTIMATE_OLDSPACE -> RGENGC_ESTIMATE_OLDMALLOC.
* gc.c: add a new major GC reason GPR_FLAG_MAJOR_BY_OLDMALLOC.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43837 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-24 19:49:02 +00:00
ko1 a87eaf88a0 * gc.c: change terminlogy "..._num" to "..._slots" about slot opetaion.
* final_num -> final_slots
  * objspace_live_num() -> objspace_live_slots()
  * objspace_limit_num() -> objspace_limit_slots()
  * objspace_free_num() -> objspace_free_slots()



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-24 19:18:53 +00:00
ko1 f06002208d * gc.c (gc_stat): add internal information.
* heap_swept_slot
  * malloc_increase
  * malloc_limit
  * remembered_shady_object
  * remembered_shady_object_limit
  * old_object
  * old_object_limit
  * oldmalloc_increase
  * oldmalloc_limit
* gc.c (gc_stat): rename names.
  * heap_live_num -> heap_live_slot
  * heap_free_num -> heap_free_slot
  * heap_final_slot -> heap_final_slot
  Quote from RDoc of GC.stat():
    "The contents of the hash are implementation specific and may
    be changed in the future."
* test/ruby/test_gc.rb: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-24 19:08:33 +00:00
ko1 c1382f3ab5 * gc.c: change terminology OLDSPACE -> OLDMALLOC.
(oldspace -> oldmalloc for variable names)
  OLDSPACE is confusing because it is not includes slots.
  To more clearly, rename such as (oldspace_limit -> oldmalloc_limit).
  It is clear that it measures (estimates) malloc()'ed size.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43833 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-24 18:13:48 +00:00
nagachika 81f4262e6b * ChangeLog: fix a typo at r43744.
* gc.c (is_mark_stack_empty): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-23 15:35:04 +00:00
ko1 dbe9e6a5f8 * gc.c: fix gloval variable name.
Now we have following environments (and related variable names).
  * RUBY_GC_HEAP_INIT_SLOTS
  * RUBY_GC_HEAP_FREE_SLOTS
  * RUBY_GC_HEAP_GROWTH_FACTOR (new from 2.1)
  * RUBY_GC_HEAP_GROWTH_MAX_SLOTS (new from 2.1)
  * obsolete
    * RUBY_FREE_MIN       -> RUBY_GC_HEAP_FREE_SLOTS (from 2.1)
    * RUBY_HEAP_MIN_SLOTS -> RUBY_GC_HEAP_INIT_SLOTS (from 2.1)
  * RUBY_GC_MALLOC_LIMIT
  * RUBY_GC_MALLOC_LIMIT_MAX (new from 2.1)
  * RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR (new from 2.1)
  * RUBY_GC_OLDSPACE_LIMIT (new from 2.1)
  * RUBY_GC_OLDSPACE_LIMIT_MAX (new from 2.1)
  * RUBY_GC_OLDSPACE_LIMIT_GROWTH_FACTOR (new from 2.1)
* test/ruby/test_gc.rb: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-23 03:33:10 +00:00
tmm1 3d5bf44cd8 * gc.c: Rename heap_pages_swept_num to heap_pages_swept_slots to clarify meaning (number of slots, not pages).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-22 23:50:08 +00:00
nobu d87a084929 * gc.c (RUBY_ALIAS_FUNCTION_VOID): fix compile error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-22 07:56:29 +00:00
ko1 c91ec25d19 * gc.c (heap_set_increment): accept minumum additional page number.
* gc.c (gc_after_sweep): allocate pages to allocate at least
   RUBY_HEAP_MIN_SLOTS.
   [Bug #9137]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-22 07:40:27 +00:00
nari 9d2f54b3e9 * include/ruby/intern.h (rb_gc_set_params): Deprecate
rb_gc_set_params because it's only used in ruby internal.

* internal.h (ruby_gc_set_params): Declare rb_gc_set_params's
  alias function.

* gc.c: ditto.

* ruby.c: use ruby_gc_set_params.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-22 07:26:55 +00:00
ko1 a6ca9f9fce * vm.c (ruby_vm_destruct): do not use ruby_xfree() after freeing
objspace.
* gc.c (ruby_mimfree): added. It is similar to ruby_mimmalloc().
* internal.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-22 01:38:08 +00:00
naruse 215a7da2a6 * gc.c: fix build failure on FreeBSD introduced by r43763.
malloc_usable_size() is defined by malloc_np.h on FreeBSD.

* configure.in: check malloc.h and malloc_np.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-22 00:05:34 +00:00
ko1 b1529a30e0 * gc.c: RGENGC_CHECK_MODE should be 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 13:34:38 +00:00
nobu d1d737ae57 * gc.c: needs malloc.h if malloc_usable_size() is available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 11:41:16 +00:00
nobu 1a2997b299 gc.c: malloc_usable_size
* gc.c (malloc_usable_size): use _msize() on Windows.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 09:52:09 +00:00
nobu 4305eb8e6c gc.c: malloc_usable_size
* gc.c (vm_xrealloc, vm_xfree): use malloc_usable_size() to obtain old
  size if available.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 09:49:05 +00:00
ko1 20fa0c26c9 * gc.c: rename initial_xxx variables to gc_params.xxx.
They are not only used initial values.
  Chikanaga-san: Congratulations on RubyPrize!



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 08:50:40 +00:00
nobu a638a44b48 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 08:21:05 +00:00
ko1 047cdaca14 * gc.c: enable "RGENGC_ESTIMATE_OLDSPACE" option as default.
Without this option, some application consumes huge memory.
  (and there are only a few performance down)
  Introduced new environment variables:
  * RUBY_GC_HEAP_OLDSPACE (default 16MB)
  * RUBY_GC_HEAP_OLDSPACE_MAX (default 128 MB)
  * RUBY_GC_HEAP_OLDSPACE_GROWTH_FACTOR (default 1.2)
* gc.c (initial_malloc_limit): rename to initial_malloc_limit_min.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 08:20:34 +00:00
ko1 5d1d1ed258 * gc.c (gc_marks_check): do not dump all refs.
* gc.c (allrefs_dump_i): fix output format.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 05:07:04 +00:00
nobu 42a8a2cbe7 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 05:01:05 +00:00
ko1 4c9d6d801b * gc.c: change RGENGC_CHECK_MODE (>= 2) logic.
Basically, make an object graph of all of living objects before and
  after marking and check status.
  [Before marking: check WB sanity]
  If there is a non-old object `obj' pointed from old object
  (`parent') then `parent' or `obj' should be remembered.
  [After marking: check marking miss]
  Traversible objects with the object graph should be marked.
  (However, this alert about objects pointed by machine context
   can be false positive. We only display alert.)
  [Implementation memo]
  objspace_allrefs() creates an object graph.
  The object graph is represented by st_table, key is object (VALUE)
  and value is referring objects. Referring objects are stored by
  "struct reflist".
* gc.c (init_mark_stack): do not use push_mark_stack_chunk() at init.
  This pre-allocation causes failure on is_mark_stask_empty()
  without any pushing.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-21 04:57:37 +00:00
ko1 2127b9cfc7 * gc.c (heap_is_swept_object): use heap_page::before_sweep flag.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-19 09:52:52 +00:00
ko1 2d00e739ef * gc.c (rb_objspace_reachable_objects_from_root): do major marking.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-19 09:50:14 +00:00
ko1 301223df95 * gc.c (rb_gc_resurrect): added.
rb_fstring() used rb_gc_mark() to avoid freeing used string.
  However, rb_gc_mark() set mark bit *and* pushes mark_stack.
  rb_gc_resurrect() does only set mark bit if it is before sweeping.
* string.c (rb_fstring): use rb_gc_resurrect.
* internal.h: add decl.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-19 09:48:47 +00:00
ktsj 711a069e0f * gc.c (rb_gcdebug_print_obj_condition): catch up recent changes
to compile on GC_DEBUG.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-10 14:50:13 +00:00
nobu 24537e1b1c gc.c: finalizer functions
* gc.c (rb_define_finalizer, rb_undefine_finalizer): rename and export
  finalizer functions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 23:03:11 +00:00
ko1 9782d219f3 * gc.c (vm_malloc_increase): sweep immediately on GC due to malloc().
To reduce memory usage, sweep as soon as possible.
  This behavior is same as Ruby 2.0.0 and before.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 16:35:54 +00:00
nobu 3fdff0501a gc.c: private call
* gc.c (should_be_callable): allow private call since rb_eval_cmd
  calls even private methods.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 15:36:46 +00:00
nobu 7a330ba230 gc.c: should_be_callable
* gc.c (should_be_callable): extract duplicate code.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 15:34:30 +00:00
tarui 5d663cc2d3 * gc.c (gc_page_sweep, rgengc_rememberset_mark): Refactoring.
Get bitmaps directly.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 00:23:02 +00:00
tarui ead9dbae1f * gc.c (RVALUE_PROMOTE_INFANT): Refactoring. Remove duplicated nonsense
code.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 00:17:23 +00:00
tarui 76a3e71cfd * gc.c (gc_marks_test): Bugfix. Fix a struct member name for build
with RGENGC_CHECK_MODE.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 00:05:27 +00:00
tarui 0f091bbfb4 * gc.c : Add GC_PROFILE_DETAIL_MEMORY option.
If GC_PROFILE_MORE_DETAIL && GC_PROFILE_DETAIL_MEMORY,
	  maxrss, minflt and majflt are added to each profile record.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-08 23:59:20 +00:00
nobu 1062dcf4df gc.c: use switch for alternative BUILTIN_TYPE
* gc.c (rb_objspace_call_finalizer): BUILTIN_TYPE is alternative,
  T_DATA object (Thread, Mutex, Fiber) cannot be T_FILE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-07 18:10:33 +00:00
ko1 bc31909366 * gc.c (vm_malloc_increase): check GVL before gc_rest_sweep().
vm_malloc_increase() can be called without GVL.
  However, gc_rest_sweep() assumes acquiring GVL.
  To avoid this problem, check GVL before gc_rest_sweep().
  [Bug #9090]
  This workaround introduces possibility to set malloc_limit as
  wrong value (*1). However, this may be rare case. So I commit it.
  *1: Without rest_sweep() here, gc_rest_sweep() can decrease
      malloc_increase due to ruby_sized_xfree().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-07 18:03:12 +00:00
ko1 a6698bc676 * gc.c: modify malloc_limit strategy.
* fix default vaues:
    GC_MALLOC_LIMIT_GROWTH_FACTOR
    GC_MALLOC_LIMIT: 8MB -> 16MB
    GC_MALLOC_LIMIT_MAX: 384MB -> 32MB
  * algorithm of malloc_limit increment.
    if (malloc_increase < malloc_limit) {
      next_malloc_limit = malloc_limit * factor
      if (malloc_limit > malloc_limit_max) {
        malloc_limit = malloc_increase
      }
    }
    This algorithm change malloc_limit from
    16MB -> 32MB slowly.
    If malloc_limit exceeds malloc_limit_max, then
    increase with malloc_increase.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-07 10:45:01 +00:00
tarui 01a7e7893b * gc.c (gc_before_sweep): Change algorithm of malloc_limit to
conservative for closing to memory consumption of ruby 2.0.

	* gc.c (GC_MALLOC_LIMIT, GC_MALLOC_LIMIT_GROWTH_FACTOR):
	  Adjust parameters for new algorithm.

	Example: make gcbench-rdoc on a pc
                              time       maxrss
	2.0.0p343             285.27     281853952
	trunk before patch    207.19     690405376
	trunk after patch     211.59     312500224


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-06 12:36:34 +00:00
ko1 3db0e56472 * gc.c: define RGENGC_ESTIMATE_OLDSPACE == 0 if USE_RGENGC is 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-06 00:14:26 +00:00
ko1 8c6157e048 * gc.c (Init_GC): add GC::OPTS to show options.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-05 22:13:51 +00:00
tarui 3ce802b79c * gc.c (is_live_object): A hidden object may be a live object.
[ruby-dev:47788] [Bug #9072]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-05 11:15:21 +00:00
nobu 8a9dff36c3 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-05 07:48:31 +00:00
ko1 d1674ef67b * gc.c: add support to estimate increase of oldspace memory usage.
This is another approach to solve an issue discussed at r43530.
  This feature is diabled as default.
  This feature measures an increment of memory consuption by oldgen
  objects. It measures memory consumption for each objects when
  the object is promoted. However, measurement of memory consumption
  is not accurate now. So that this measurement is `estimation'.
  To implement this feature, move memsize_of() function from
  ext/objspace/objspace.c and expose rb_obj_memsize_of().
  Some memsize() functions for T_DATA (T_TYPEDDATA) have problem to
  measure memory size, so that we ignores T_DATA objects now.
  For example, some functions skip NULL check for pointer.
  The macro RGENGC_ESTIMATE_OLDSPACE enables/disables this feature,
  and turned off as default.
  We need to compare 3gen GC and this feature carefully.
  (it is possible to enable both feature)
  We need a help to compare them.
* internal.h: expose rb_obj_memsize_of().
* ext/objspace/objspace.c: use rb_obj_memsize_of() function.
* cont.c (fiber_memsize): fix to check NULL.
* variable.c (autoload_memsize): ditto.
* vm.c (vm_memsize): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-05 04:51:01 +00:00
ko1 5ba523967e * gc.c (GC_MALLOC_LIMIT_MAX): fix default value 512MB -> 384MB.
512MB is huge.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-04 19:04:06 +00:00
ko1 325d2cfcdf * gc.c: add 3gen GC patch, but disabled as default.
RGenGC is designed as 2 generational GC, young and old generation.
  Young objects will be promoted to old objects after one GC.
  Old objects are not collect until major (full) GC.
  The issue of this approach is some objects can promoted as old
  objects accidentally and not freed until major GC.
  Major GC is not frequently so short-lived but accidentally becoming
  old objects are not freed.
  For example, the program "loop{Array.new(1_000_000)}" consumes huge
  memories because short lived objects (an array which has 1M
  elements) are promoted while GC and they are not freed before major
  GC.
  To solve this problem, generational GC with more generations
  technique is known. This patch implements three generations gen GC.
  At first, newly created objects are "Infant" objects.
  After surviving one GC, "Infant" objects are promoted to "Young"
  objects.
  "Young" objects are promoted to "Old" objects after surviving
  next GC.
  "Infant" and "Young" objects are collected if it is not marked
  while minor GC. So that this technique solves this problem.
  Representation of generations:
  * Infant: !FL_PROMOTED and !oldgen_bitmap [00]
  * Young :  FL_PROMOTED and !oldgen_bitmap [10]
  * Old   :  FL_PROMOTED and  oldgen_bitmap [11]
  The macro "RGENGC_THREEGEN" enables/disables this feature, and
  turned off as default because there are several problems.
  (1) Failed sometimes (Heisenbugs).
  (2) Performance down.
      Especially on write barriers. We need to detect Young or Old
      object by oldgen_bitmap. It is slower than checking flags.
  To evaluate this feature on more applications, I commit this patch.
  Reports are very welcome.
  This patch includes some refactoring (renaming names, etc).
* include/ruby/ruby.h: catch up 3gen GC.
* .gdbinit: fix to show a prompt "[PROMOTED]" for promoted objects.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-04 18:59:33 +00:00
ko1 42bd731dc5 * include/ruby/ruby.h: rename FL_OLDGEN to FL_PROMOTED.
This flag represents that "this object is promoted at least once."
* gc.c, debug.c, object.c: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-04 15:04:10 +00:00
nobu b9ed44e7c7 gc.c: use boolean
* gc.c (obj_free): use free_immediately as boolean.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-03 12:40:29 +00:00
nobu 3b320b782f gc.c: suppress warning
* gc.c (obj_free): suppress a false shorten-64-to-32 warning,
  RUBY_TYPED_FREE_IMMEDIATELY never exceed the limit of int.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-03 01:37:22 +00:00
nobu 541dac0b9b gc.c: mark live objects only
* gc.c (wmap_mark_map): mark live objects only, but delete zombies.
  [ruby-dev:47787] [Bug #9069]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01 14:24:34 +00:00
tarui 21a58208f1 * gc.c (struct heap_page, gc_page_sweep, gc_sweep): Refactoring for
performance. Add before_sweep condition to heap_page structure.

	* gc.c (rb_gc_force_recycle): Use before_sweep member.

	* gc.c (heap_is_before_sweep, is_before_sweep): Remove. They has not
	  already been used.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01 13:47:39 +00:00
tarui 3705b07014 * gc.c (make_deferred): Refactoring. Collect codes which should be
atomic.

	* gc.c (make_io_deferred, obj_free, rb_objspace_call_finalizer,
	  gc_page_sweep): Correspond to the above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01 13:22:54 +00:00
tarui 1726b516d0 * gc.c (typedef struct rb_objspace): Refactoring. Move some members
into profile member.

	* gc.c (newobj_of): Correspond to the above.

	* gc.c (finalize_list): Ditto.

	* gc.c (objspace_live_num): Ditto.

	* gc.c (gc_page_sweep): Ditto.

	* gc.c (rb_gc_force_recycle): Ditto.

	* gc.c (garbage_collect_body): Ditto.

	* gc.c (rb_gc_count): Ditto.

	* gc.c (gc_stat): Ditto.

	* gc.c (gc_prof_set_heap_info): Ditto.

	* gc.c (gc_profile_dump_on): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01 12:49:49 +00:00
nobu 21ea356a42 gc.c: zombie is not alive
* gc.c (is_live_object): finalizer may not run because of lazy-sweep.
  [ruby-dev:47786] [Bug #9069]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-01 08:25:34 +00:00
ko1 c5e08b764e * add RUBY_TYPED_FREE_IMMEDIATELY to data types which only use
safe functions during garbage collection such as xfree().
  On default, T_DATA objects are freed at same points as fianlizers.
  This approach protects issues such as reported by [ruby-dev:35578].
  However, freeing T_DATA objects immediately helps heap usage.
  Most of T_DATA (in other words, most of dfree functions) are safe.
  However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default
  for safety.
* cont.c: ditto.
* dir.c: ditto.
* encoding.c: ditto.
* enumerator.c: ditto.
* error.c: ditto.
* file.c: ditto.
* gc.c: ditto.
* io.c: ditto.
* iseq.c: ditto.
* marshal.c: ditto.
* parse.y: ditto.
* proc.c: ditto.
* process.c: ditto.
* random.c: ditto.
* thread.c: ditto.
* time.c: ditto.
* transcode.c: ditto.
* variable.c: ditto.
* vm.c: ditto.
* vm_backtrace.c: ditto.
* vm_trace.c: ditto.
* ext/bigdecimal/bigdecimal.c: ditto.
* ext/objspace/objspace.c: ditto.
* ext/stringio/stringio.c: ditto.
* ext/strscan/strscan.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 11:16:54 +00:00
ko1 52811ab159 * include/ruby/ruby.h: introduce new flags for T_TYPEDDATA.
* RUBY_TYPED_FREE_IMMEDIATELY: free the data given by DATA_PTR()
    with dfree function immediately.  Otherwise (default), the data
    freed at finalizaton point.
  * RUBY_TYPED_WB_PROTECTED: make this object with FL_WB_PROTECT
    (not shady).
* gc.c (obj_free): support RUBY_TYPED_FREE_IMMEDIATELY.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 09:42:45 +00:00
ko1 5aa527fade * gc.c (vm_malloc_increase): decrease it more carefully.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 07:49:43 +00:00
ko1 97f0de6d90 * gc.c (heap_page_resurrect): return a page in tomb heap even if
freelist is NULL.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 07:25:45 +00:00
tmm1 29dbed183e * gc.c (gc_profile_total_time): fix off-by-one error in GC::Profiler.total_time.
* test/ruby/test_gc.rb (class TestGc): test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 02:11:26 +00:00
ktsj ad367a256e * gc.c: catch up recent changes to compile on GC_DEBUG,
RGENGC_CHECK_MODE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-26 10:42:07 +00:00
ko1 b848aad5bf * gc.c (gc_profile_dump_on): use "Page" terminology.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-26 05:35:43 +00:00
ko1 d03912898e * gc.c (gc_sweep, gc_heap_lazy_sweep): fix measurement code.
We only need one sweep time measurement without lazy sweep.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-26 04:31:10 +00:00
ko1 286d567bbf * gc.c: tuning parameters.
* gc.c (GC_MALLOC_LIMIT): change default value to 16MB.
* gc.c (GC_MALLOC_LIMIT_GROWTH_FACTOR): change default value to 2.0.
* gc.c (gc_before_sweep): change decrease ratio of `malloc_limit'
  from 1/4 to 1/10.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-26 02:46:30 +00:00
ko1 6c458aec30 * gc.c (vm_malloc_increase): do gc_rest_sweep() before GC.
gc_rest_sweep() can reduce malloc_increase, so try it before GC.
  Otherwise, malloc_increase can be less than malloc_limit at
  gc_before_sweep(). This means that re-calculation of malloc_limit
  may be wrong value.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-26 02:34:23 +00:00
tarui 59735e2c61 * gc.c (gc_before_heap_sweep): Restructure code to mean clearly.
heap->freelist is connected to end of list.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-25 21:37:39 +00:00
ko1 98feb2b9bf * gc.c (gc_before_heap_sweep): fix freelist management.
After rb_gc_force_recycle() for a object blonging to heap->freelist,
  `heap->using_page->freelist' is not null.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-25 19:09:14 +00:00
tmm1 b906f0ed17 * gc.c: add new initial_growth_max tuning parameter. [ruby-core:57928] [Bug #9035]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 22:47:29 +00:00
tmm1 dd117ea118 * gc.c: Rename free_min to min_free_slots and free_min_page to max_free_slots. The algorithm for heap growth is:
if (swept_slots < min_free_slots) pages++
    if (swept_slots > max_free_slots) pages--

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 15:05:22 +00:00
ko1 602241142f * gc.c: move increment from heap to heap_pages.
Share `increment' information with heaps.
* gc.c: change ratio of heap_pages_free_min_page
  to 0.80.
  This change means slow down page freeing speed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 10:16:01 +00:00
ko1 99c4e43d6a * gc.c (heap_pages_free_unused_pages): cast to (int) for size_t
variable `i'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 08:52:38 +00:00
ko1 69d787ff6d * gc.c: introduce tomb heap.
Tomb heap is where zombie objects and ghost (freed slot) lived in.
  Separate from other heaps (now there is only eden heap) at sweeping
  helps freeing pages more efficiently.
  Before this patch, even if there is an empty page at former phase
  of sweeping, we can't free it.
  Algorithm:
    (1) Sweeping all pages in a heap and move empty pages from the
        heap to tomb_heap.
    (2) Check all exsisting pages and free a page
        if all slots of this page are empty and
           there is enough empty slots (checking by swept_num)
  To introduce this pach, there are several tuning of GC parameters.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 08:48:54 +00:00
ko1 29ffa2c273 * gc.c (gc_prof_sweep_timer_stop): catch up recent changes
to compile on GC_PROFILE_MORE_DETAIL=1.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-23 05:22:10 +00:00
ko1 3d85d6edb5 * gc.c (Init_heap): move logics from heap_pages_init() and remove
heap_pages_init().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-22 10:54:44 +00:00
ko1 d6fe84b6f3 * gc.c: allow multiple heaps.
Now, objects are managed by page. And a set of pages is called heap.
  This commit supports multiple heaps in the object space.
  * Functions heap_* and rb_heap_t manages heap data structure.
  * Functions heap_page_* and struct heap_page manage page data
    strcuture.
  * Functions heap_pagse_* and struct rb_objspace_t::heap_pages
    maintains all pages.
    For example, pagaes are allocated from the heap_pages.
  See https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/GC_design
  and https://bugs.ruby-lang.org/attachments/4015/data-heap_structure_with_multiple_heaps.png
  for more deitals.
  Now, there is only one heap called `eden', which is a space for all
  new generated objects.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-22 10:28:31 +00:00
ko1 f5b15f0e3f * vm_trace.c: exterminate Zombies.
There is a bug that T_ZOMBIE objects are not collected.
  Because there is a pass to miss finalizer postponed job
  with multi-threading. This patch solve this issue.
* vm_trace.c (rb_postponed_job_register_one): set
  RUBY_VM_SET_POSTPONED_JOB_INTERRUPT(th) if another same job
  is registered.
  There is a possibility to remain a postponed job without
  interrupt flag.
* vm_trace.c (rb_postponed_job_register_one): check interrupt
  carefully.
* vm_trace.c (rb_postponed_job_register_one): use additional space
  to avoid buffer full.
* gc.c (gc_finalize_deferred_register): check failure.
* thread.c (rb_threadptr_execute_interrupts): check
  `postponed_job_interrupt' immediately.  There is a possibility
  to miss this flag.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-22 06:24:54 +00:00
nobu 6bf78ee633 gc.c: fix arity
* gc.c (Init_GC): fix arity of key? method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18 23:50:13 +00:00
ko1 14c08fdb88 * gc.c: fix rb_objspace_t.
* make "struct heap" and move most of variables
    in rb_objspace_t::heap.
  * rename rb_objspace_t::heap::sorted to
     rb_objspace_t::heap_sorted_pages
     and make a macro heap_sorted_pages.
  * rename rb_objspace_t::heap::range to
     rb_objspace_t::heap_range and rename macros
     lomem/himem to heap_lomem/heap_himem.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18 23:33:55 +00:00
nobu ffcf1df1b5 * gc.c (wmap_inspect_i): fix inspect format.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18 07:06:43 +00:00
nobu 24b97da7ef * gc.c (wmap_inspect_i): fix callback argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18 07:04:42 +00:00
nobu 936b96e9b7 gc.c: ObjectSpace::WeakMap inspection and iteration methods
* gc.c (wmap_inspect, wmap_each, wmap_each_key, wmap_each_value),
  (wmap_keys, wmap_values): add inspection and iteration methods to
  ObjectSpace::WeakMap for debug.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18 06:59:14 +00:00
nobu e12799fd31 gc.c: ObjectSpace::WeakMap#key?
* gc.c (wmap_each_i): add ObjectSpace::WeakMap#key? method.

* lib/weakref.rb (WeakRef#weakref_alive): use above method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18 06:59:12 +00:00
ko1 b443d83a77 * gc.c: change terminology of heap.
Change "slot" to "page". "Slot" is a space of RVALUE.
  1. "Heap" consists of a set of "heap_page"s (pages).
  2. Each "heap_page" has "heap_page_body".
  3. "heap_page_body" has RVALUE (a.k.a. "slot") spaces.
  4. "sorted" is a sorted array of "heap_page"s, sorted
  by address of heap_page_body (for "is_pointer_to_heap").
  See https://bugs.ruby-lang.org/attachments/4008/data-heap_structure.png.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-18 06:33:36 +00:00
ko1 ee4da732e3 * gc.c (CALC_EXACT_MALLOC_SIZE_CHECK_OLD_SIZE): introduced.
This macro enable checker compare with allocated memory and
  declared old_size of sized_xfree and sized_xrealloc.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-17 09:51:41 +00:00
ko1 76b06555d0 * gc.c, internal.h: rename ruby_xsizefree/realloc to
rb_sized_free/realloc.
* array.c: catch up these changes.
* string.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-17 08:41:23 +00:00
ko1 8ac4f421e1 * gc.c, internal.h: add new internal memory mangement functions.
* void *ruby_xsizedrealloc(void *ptr, size_t new_size, size_t old_size)
* void ruby_xsizedfree(void *x, size_t size)
  These functions acccept additional size parameter to calculate more
  accurate malloc_increase parameter which control GC timing.
  [Feature #8985]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-17 07:57:03 +00:00
ko1 82d06c5ade * gc.c (objspace_each_objects): do not skip empty RVALUEs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-16 20:41:49 +00:00
tmm1 2370e623c4 * gc.c (gc_mark_roots): rename roots to be categories instead of function names.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-15 22:33:36 +00:00
nobu 4d94977775 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-15 13:12:03 +00:00
ko1 f241016825 * gc.h (rb_objspace_reachable_objects_from_root): added.
This API provides information which objects are root objects.
  `category' shows what kind of root objects.
* gc.c (gc_mark_roots): separate from gc_marks_body().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-15 10:22:33 +00:00
ko1 52c1331763 * class.c, variable.c, gc.c (rb_class_tbl): removed.
* vm.c, vm_core.h (rb_vm_add_root_module): added to register as a
  defined root module or class.
  This guard helps mark miss from defined classes/modules they are
  only refered from C's global variables in C-exts.
  Basically, it is extension's bug.
  Register to hash object VM has.
  Marking a hash objects allows generational GC supports.
* gc.c (RGENGC_PRINT_TICK): disable (revert).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 18:27:18 +00:00
ko1 9d70a17541 revert r43259 because it is possible to mark miss classes defined in C-exts. Thanks charliesome.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 18:03:43 +00:00
ko1 7aecb95637 * class.c, variable.c, gc.c (rb_class_tbl): removed.
rb_class_tbl is no longer used.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 17:33:44 +00:00
ko1 432834dd35 * gc.c: use terminology `full_mark' instead of `minor_gc'
in mark functions.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 12:00:35 +00:00
ko1 f6fcb9cc94 * gc.c: use __GNUC__ instead of __GCC__.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 11:46:42 +00:00
ko1 f44b0e5b4f * gc.c, parse.y: support generational Symbol relatetd marking.
Each symbols has String objects respectively to represent
  Symbols.
  These objects are marked only when:
* full marking
* new symbols are added
  This hack reduce symbols (related strings) marking time.
  For example, on my Linux environment, the following code
  "20_000_000.times{''}"
  with 40k symbols (similar symbol number on Rails 3.2.14 app,
  @jugyo tells me) boosts, from 7.3sec to 4.2sec.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 11:45:38 +00:00
tmm1 8d9e3cd9c6 gc.c: rename heap.free_num to heap.swept_num
* gc.c: rename heap.free_num as heap.swept_num to clarify meaning and
  avoid confusion with objspace_free_num().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-04 10:52:25 +00:00
tmm1 907a03fee5 gc.c: add objspace_free_num and make GC.stat[:heap_free_num] use it
* gc.c (objspace_free_num): new method for available/free slots on
	  heap. [ruby-core:57633] [Bug #8983]
	* gc.c (gc_stat): change heap_free_num definition to use new method.
	* test/ruby/test_gc.rb: test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-04 10:05:40 +00:00
tmm1 a24705cfa5 gc.c: add rb_objspace.limit
* gc.c: add rb_objspace.limit to keep accurate count of total heap
	  slots [ruby-core:57633] [Bug #8983]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-04 10:05:37 +00:00
ko1 fa105e6c20 * gc.c: define gc_profile_record::allocated_size if
CALC_EXACT_MALLOC_SIZE is true.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-03 09:03:06 +00:00
ko1 8c0033a7b6 * gc.c: relax GC condition due to malloc_limit.
* gc.c (GC_MALLOC_LIMIT_MAX): change default value
  (256MB -> 512MB) and permit zero to ignore max value.
* gc.c (vm_malloc_increase, vm_xrealloc): do not cause GC on realloc.
* gc.c (gc_before_sweep): change debug messages.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-02 09:56:04 +00:00
nobu 6a1a08c945 gc.c: suppress warnings
* gc.c (gc_before_sweep): use PRIuSIZE instead of "%zu" directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43094 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-30 08:06:20 +00:00
ko1 1d90d0ced9 * gc.c (rb_gc_disable): do rest_sweep() before disable GC.
This fix may solve a failure of
  TestTracepointObj#test_tracks_objspace_events
  [test/-ext-/tracepoint/test_tracepoint.rb:43].



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43092 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-30 02:20:28 +00:00
ko1 2c0d74b708 * gc.c: add two GC tuning environment variables.
RUBY_GC_MALLOC_LIMIT_MAX and RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR.
  See r43067 for details.
* gc.c (rb_gc_set_params): refactoring. And change verbose notation.
  Mostly duplicated functions get_envparam_int/double is not cool.
  Please rewrite it.
* test/ruby/test_gc.rb: fix a test for this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-27 09:36:48 +00:00
ko1 a31ff891a1 * gc.c (GC_MALLOC_LIMIT): 8,000,000 -> 8 * 1,024 * 1,024.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-27 08:45:45 +00:00
ko1 78a49728b2 * gc.c (gc_before_sweep): cast to size_t to suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-27 08:20:19 +00:00
ko1 752cc234f6 * gc.c: add some fine-grained profiling codes to tuning marking phase.
If you enable RGENGC_PRINT_TICK to 1, then profiling results by RDTSC
  (on x86/amd64 environment) are printed at last.
  Thanks Yoshii-san.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-27 08:12:31 +00:00
ko1 f365cd2c9a * gc.c: simplify threshold of GC caused by malloc_increase.
Now, malloc_limit is increased/decreased by mysterious logic.
  This fix simplify malloc_limit increase/decrease logic such as:
  if (malloc_increase > malloc_limit) /* so many malloc */
  malloc_limit += malloc_limit * (GC_MALLOC_LIMIT_FACTOR-1);
  else
  malloc_limit -= malloc_limit * (GC_MALLOC_LIMIT_FACTOR-1)/4;
  Default value of GC_MALLOC_LIMIT_FACTOR is 1.8.
  malloc_limit is bounded by GC_MALLOC_LIMIT_MAX (256MB by default).
  This logic runs at before_sweeep(). So there are no effect from
  caused by lazy sweep. And we can remove malloc_increase2.
* gc.c (HEAP_MIN_SLOTS, FREE_MIN, HEAP_GROWTH_FACTOR): rename to
  GC_HEAP_MIN_SLOTS, GC_FREE_MIN, GC_HEAP_GROWTH_FACTOR respectively.
  Check them by `#ifndef' so you can specify these values outside gc.c.
* gc.c (ruby_gc_params_t): add initial_malloc_limit_factor and
  initial_malloc_limit_max.
* gc.c (vm_malloc_prepare, vm_xrealloc): use vm_malloc_increase to
  add and check malloc_increase.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-27 08:01:14 +00:00
nobu 4190cdddbb * gc.c (vm_xrealloc): use TRY_WITH_GC().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-26 07:22:43 +00:00
naruse 165ebcb467 Fix compilation on gcc 4.6
if __has_feature is not defined, it can't compile

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43048 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-26 06:06:19 +00:00
nobu 2bf5be1db5 gc.c: disable AddressSanitizer
* gc.c (mark_locations_array): disable AddressSanitizer.  based on a
  patch by halfie (Ruby Guy) at [ruby-core:57372].
  [ruby-core:56155] [Bug #8680]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-26 05:46:52 +00:00
nobu 89919f4e08 gc.c: atomical add
* gc.c (gc_before_sweep, gc_after_sweep): add to increase2 atomically.

* gc.c (gc_marks): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-26 02:31:26 +00:00
ko1 dc626dbab3 * include/ruby/ruby.h: rename RARRAY_RAWPTR() to RARRAY_CONST_PTR().
RARRAY_RAWPTR(ary) returns (const VALUE *) type pointer and
  usecase of this macro is not acquire raw pointer, but acquire
  read-only pointer. So we rename to better name.
  RSTRUCT_RAWPTR() is also renamed to RSTRUCT_CONST_PTR()
  (I expect that nobody use it).
* array.c, compile.c, cont.c, enumerator.c, gc.c, proc.c, random.c,
  string.c, struct.c, thread.c, vm_eval.c, vm_insnhelper.c:
  catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 08:24:34 +00:00
charliesome 4cf9b6694f * gc.c (free_method_cache_entry_i): unused function
* gc.c (rb_free_mc_table): ditto

* internal.h (method_cache_entry_t): unused struct

* vm_method.c (verify_method_cache): remove unused variable

* vm_method.c (rb_method_entry): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-24 05:09:57 +00:00
charliesome f088828106 * class.c (class_alloc): remove mc_tbl
* gc.c (obj_free): ditto

* internal.h (struct rb_classext_struct): ditto

* method.h (rb_method_entry): remove ent param

* vm_method.c: restore the global method cache. Per class cache tables
  turned out to be far too slow.

  [ruby-core:57289] [Bug #8930]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-24 05:02:13 +00:00
nobu eeb39e0152 vm.c: prototype
* vm.c (rb_next_class_sequence): use ANSI style definition and
  prorotype declaration, instead of old-K&R style.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 07:18:24 +00:00
charliesome 2f522b9cc6 * class.c, compile.c, eval.c, gc.h, insns.def, internal.h, method.h,
variable.c, vm.c, vm_core.c, vm_insnhelper.c, vm_insnhelper.h,
  vm_method.c: Implement class hierarchy method cache invalidation.

  [ruby-core:55053] [Feature #8426] [GH-387]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 05:25:06 +00:00
ko1 c4fe526011 * gc.c (gc_profile_clear): do rest_sweep() before clearing
profile.current_record.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-27 02:49:08 +00:00
akr 873dd9bc45 * gc.c (getrusage_time): Fallback clock_gettime to getrusage when
clock_gettime fails.
  Reported by Eric Saxby.  [ruby-core:56762] [Bug #8805]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-21 08:34:48 +00:00
ko1 326bf140b4 * gc.c (rb_gcdebug_print_obj_condition): add printing information.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-20 17:32:18 +00:00
ko1 21ecf88ce0 * gc.c: fix around GC_DEBUG.
* gc.c (RVALUE::line): should be VALUE. On some environment
  (such as mswin64), `int' introduces alignment mismatch.
* gc.c (newobj_of): add an assertion to check VALUE alignment.
* gc.c (aligned_malloc): `&' is low priority than `=='.
* gc.c: define GC_DEBUG everytime and use it as value 0 or 1.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-19 12:00:51 +00:00
ktsj 04f0de74dd * error.c, file.c, gc.c, hash.c, thread.c, variable.c, vm_eval.c, bin/erb:
$SAFE=4 is obsolete.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-18 10:36:51 +00:00
ko1 5cd2fb2ebb * gc.c (gc_lazy_sweep): remove heap_increment() here because heap_inc
may be 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15 08:46:53 +00:00
tarui da3d79d203 * gc.c (gc_marks_test): inhibit gc for st's operation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-12 14:09:34 +00:00
akr 25336fa7c1 * bignum.c (rb_big_realloc): Use VALGRIND_MAKE_MEM_UNDEFINED to
declare undefined memory area.
  (bignew_1): Ditto.

* internal.h (VALGRIND_MAKE_MEM_DEFINED): Moved from gc.c
  (VALGRIND_MAKE_MEM_UNDEFINED): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-06 03:26:34 +00:00
ko1 33ebcb0538 * array.c, gc.c: move ary_unprotect_logging() into
rb_gc_unprotect_logging() which is general version
* include/ruby/ruby.h: add USE_RGENGC_LOGGING_WB_UNPROTECT
  to enable.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-24 09:42:43 +00:00
ko1 3742192919 * gc.c (gc_before_sweep): fix spacing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 07:15:34 +00:00
ko1 511e155e24 * gc.c (heap_get_freeobj): clear slot->freelist here.
This means that this slot doesn't have any free objects.
  And store this slot with objspace->heap.using_slot.
* gc.c (gc_before_sweep): restore objspace->freelist
  into objspace->heap.using_slot->freelist.
  This means that using_slot has free objects which are
  pointed from objspace->freelist.
* gc.c (gc_slot_sweep): do not need to clear slot->freelist.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-23 07:02:44 +00:00
ko1 4132ac3762 * gc.c (gc_slot_sweep): need to add empty RVALUE as freeobj.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-22 01:10:46 +00:00
nobu db16068ce0 gc.c: suppress warning
* gc.c (heap_assign_slot): suppress implicit conversion warning.
  delta is not greater than sizeof(RVALUE).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 13:31:03 +00:00
ko1 79d557ffcd * gc.c: declare type_name() at the beggining of file.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 13:00:23 +00:00
ko1 344835a754 * gc.c, internal.h (rb_gc_writebarrier_remember_promoted): add a new
function to remember an specified object. This api is only
  experimental (strongly depend on WB/rgengc strategy).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-19 06:11:09 +00:00
ko1 5c088cf703 * gc.c: rename gc related functions with prefix "gc_".
* before_gc_sweep() -> gc_before_sweep().
* after_gc_sweep()  -> gc_after_sweep().
* lazy_sweep()      -> gc_lazy_sweep().
* rest_sweep()      -> gc_rest_sweep().
* slot_sweep()      -> gc_slot_sweep().
* gc.c: rename a heap management function with prefix "heap_".
* get_freeobj() -> heap_get_freeobj().
* gc.c: rename markable_object_p() to is_markable_object().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 23:19:38 +00:00
ko1 a3b6aeba68 * gc.c: rename heap management functions with prefix "heap_".
* allocate_sorted_array() -> heap_allocate_sorted_array().
* slot_add_freeobj()      -> heap_slot_add_freeobj().
* assign_heap_slot()      -> heap_assign_slot().
* add_heap_slots()        -> heap_add_slots().
* init_heap()             -> heap_init().
* set_heap_increment()    -> heap_set_increment().
* gc.c (initial_expand_heap): inlined in rb_gc_set_params().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 08:25:11 +00:00
ko1 caa14925cc * gc.c: catch up last changes for debugging/checking mode.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 07:01:19 +00:00
ko1 9860c846d0 * gc.c (rb_objspace_free): free slot itself.
* gc.c (objspace_each_objects): fix condition.
  Use slot->body instead of slot.
* gc.c (count_objects): use "slot" variable.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 06:52:13 +00:00
ko1 fa014681d5 * gc.c (unlink_heap_slot): fix memory leak.
free slot itself at free_heap_slot().
  Reproduce-able code is here:
  N1 = 100_000; N2 = 1_000_000
  N1.times{ary = []; N2.times{ary << ''}}
  Maybe this problem is remaining in Ruby 2.0.0.
* gc.c (unlink_heap_slot): remove not working code.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 06:24:22 +00:00
ko1 79d9c8ac72 * gc.c: re-design the heap structure.
(1) The heap is consists of a set of slots.
  (2) Each "slot" has a "slot_body".
  slot::start and slot::limit specify RVALUE beginning address
  and number of RVALUE in a "slot_body".
  (3) "slot_body" contains a pointer to slot (slot_body::header::slot)
  and an array of RVALUE.
  (4) heap::sorted is an array of "slots", sorted by an address of
  slot::body.
  See https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/GC_design
  for more details (figure).
* gc.c: Avoid "heaps" terminology. It is ambiguous.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 05:55:39 +00:00
ko1 fd92050515 * gc.c: fix heaps_header and heaps_slot to reduce memory consumption.
(1) move heaps_header::start and limit to  heaps_slot.
  (2) remove heaps_header::end which can be calculated by start+limit.
* gc.c: catch up above change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-17 04:34:57 +00:00
ko1 a97c3b7585 * gc.c: slim a path of newobj_of().
* gc.c (objspace): add a new field objspace::freelist, which contains
  available RVALUEs.
* gc.c (newobj_of): simply call new function `get_freeobj()'.
  get_freeobj() returns objspace::freelist. If  objspace::freelist
  is not available, refill objspace::freelist with a slot pointed by
  objspace::heap::free_slots.
* gc.c (before_gc_sweep): clear objspace::freelist.
* gc.c (slot_sweep): clear slot::freelist.
* gc.c (heaps_prepare_freeslot): renamed to heaps_prepare_freeslot.
* gc.c (unlink_free_heap_slot): remove unused function.
* gc.c (rb_free_const_table): remove unused function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 10:29:31 +00:00
ko1 ed621c001e * gc.c (link_free_heap_slot): removed.
* gc.c (slot_sweep): use `heaps_add_freeslot' instead of
  `link_free_heap_slot'.
* gc.c (assign_heap_slot): use local variable `slot' instead of
  `heaps'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 08:46:15 +00:00
ko1 73ee1676b0 * gc.c (assign_heap_slot): refactoring variable names.
* gc.c (slot_add_freeobj): added.
* gc.c (heaps_add_freeslot): added.
* gc.c (finalize_list, rb_gc_force_recycle, slot_sweep): use
  `slot_add_freeobj' instead of modifying linked list directly.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 08:32:32 +00:00
ko1 e8ee0a24dc * gc.c (lazy_sweep): refactoring.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 07:33:48 +00:00
ko1 53bdcbed86 revert last commit because it fails test-all.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 06:10:56 +00:00
ko1 3cd6fe3254 * gc.c (after_gc_sweep): refactoring code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 06:00:55 +00:00
kou 7b52f3a722 * gc.c (is_before_sweep): Add a missing space before a parenthesis.
* gc.c (rb_gc_force_recycle): Add a missing space around a parenthesis.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-26 14:13:20 +00:00
tarui b0993c733f * gc.c (is_before_sweep): Add new helper function that check the object
is before sweep?
	* gc.c (rb_gc_force_recycle): Have to clear mark bit if object's slot
	  already ready to mainor sweep.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41633 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 16:20:39 +00:00
ko1 ab0a003183 * gc.c: fix oldgen/remembered_shady counting algorithm.
* gc.c (rgengc_check_shady): increment
  `objspace->rgengc.remembered_shady_object_count' here.
* gc.c (rgengc_remember): return FALSE if obj is already remembered.
* gc.c (rgengc_rememberset_mark): make it void.
* gc.c (gc_mark_children): fix to double counting oldgen_object_count
  at minor GC.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-25 03:24:07 +00:00
nobu 5ac5740733 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-24 16:01:06 +00:00
tarui 606d2d354d * gc.c (typedef struct rb_objspace): Change members for monitor objects.
* gc.c (gc_marks_test): Check all WriteBarrier Errors and track them in obj-tree.
	* gc.c (rgengc_check_shady): Ditto.
	* gc.c (gc_marks): Move 2 funtion calls to gc_marks_test for test initialize.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-24 15:57:16 +00:00
nobu 5332d81283 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-23 23:01:06 +00:00
tarui 9694416c06 * gc.c (after_gc_sweep): Have to record malloc info before reset.
* gc.c (gc_prof_timer_start): Pick out part of new record creation as gc_prof_setup_new_record.
	* gc.c (gc_prof_set_malloc_info): Move point of recording allocation size to front of mark.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-23 22:58:01 +00:00
ko1 982fee4fcc * include/ruby/ruby.h, gc.c: rename macros and functions:
OBJ_WB_GIVEUP() -> OBJ_WB_UNPROTECT(),
  rb_obj_wb_giveup() -> rb_obj_wb_unprotect(),
  rb_gc_giveup_promoted_writebarrier() ->
  rb_gc_writebarrier_unprotect_promoted(),
* class.c, eval.c, hash.c: use OBJ_WB_UNPROTECT().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 21:54:10 +00:00
ko1 d73b9320cc * gc.c (rgengc_check_shady): add new WB miss checking
on RGENGC_CHECK_MODE >= 2.

    (1) Save bitmaps before marking
    (2) Run full marking
    (3) On each traceable object,
      (a) object        was not oldgen (== newly or shady object) &&
      (b) parent object was     oldgen &&
      (c) parent object was not remembered &&
      (d) object        was not rememberd
      then, it should be WB miss.

  This idea of this checker is by Masaya Tarui <tarui@ruby-lang.org>.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-22 06:43:30 +00:00
ko1 a59e629868 * gc.c (gc_prof_set_heap_info, after_gc_sweep): call
gc_prof_set_heap_info() just after sweeping to calculate
  live object number correctly.
  (live object number = total generated number (before marking) -
                        total freed number (after sweeping))
* gc.c (gc_marks): record `oldgen_object_count' into current profile`
  record directly.
* gc.c (rgengc_rememberset_mark): same for remembered_normal_objects
  and remembered_shady_objects.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 22:29:09 +00:00
ko1 dbd8f3ac03 * gc.c (rb_objspace::profile): rename rb_objspace::profile::record to
records (because it points a set of records) and add a field
  rb_objspace::profile::current_record to point a current profiling
  record.
* gc.c: use above fields.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 21:51:41 +00:00
ko1 b4f907ea29 * gc.c (rb_gc_giveup_promoted_writebarrier): remove `rest_sweep()'
because all of remembered objects are called for gc_mark_children().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 21:08:38 +00:00
ko1 7396fbb0b5 * gc.c (rgengc_rememberset_mark): call gc_mark_children() for
remembered objects directly instead of pushing on the mark stack.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 20:10:03 +00:00
ko1 671c196384 * gc.c (slot_sweep_body): rename to slot_sweep().
No need to separate major/minor GC.
* gc.c (gc_setup_mark_bits): remove gc_clear_mark_bits() and unify to
  this function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 19:42:04 +00:00
ko1 a27c48f69e * gc.c (check_bitmap_consistency): add to check flag and bitmap consistency.
Use this function in several places.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 19:36:48 +00:00
nobu 15c4b821a1 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 12:36:06 +00:00
tarui 913e65448d * gc.c (typedef enum): Introdule flags of major gc reason.
* gc.c (garbage_collect_body): Ditto.
	* gc.c (gc_profile_flags): Ditto.
	* gc.c (gc_profile_dump_on): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 12:31:13 +00:00
ko1 79d3385e9d * gc.c (allocate_sorted_heaps): remove unused variable `add'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 12:12:57 +00:00
ko1 508b255b9a * include/ruby/ruby.h: constify RArray::as::ary and RArray::heap::ptr.
Use RARRAY_ASET() or RARRAY_PTR_USE() to modify Array objects.
* array.c, gc.c: catch up above changes.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 11:53:33 +00:00
ko1 6a1101f23e * include/ruby/ruby.h: support write barrier protection for T_STRUCT.
Introduce the following C APIs:
  * RSTRUCT_RAWPTR(st) returns pointer (do WB on your risk).
    The type of returned pointer is (const VALUE *).
  * RSTRUCT_GET(st, idx) returns idx-th value of struct.
  * RSTRUCT_SET(st, idx, v) set idx-th value by v with WB.
  And
  * RSTRUCT_PTR(st) returns pointer with shady operation.
    The type of returned pointer is (VALUE *).
* struct.c, re.c, gc.c, marshal.c: rewrite with above APIs.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 11:22:18 +00:00
ko1 ab084f4063 * gc.c (gc_sweep): profile sweep time correctly when LAZY_SWEEP is
disabled.
* gc.c (gc_marks_test): store oldgen count and shady count
  before test marking and restore them after marking.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 06:29:30 +00:00
ko1 ac9413893a * gc.c: enable lazy sweep (commit miss).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 06:08:07 +00:00
ko1 dfc4cc0196 revert last commit (operation miss).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 06:04:29 +00:00
ko1 8398719020 * gc.c: fix to use total_allocated_object_num and heaps_used
at the GC time for profiler.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 05:55:05 +00:00
ko1 e35f127403 * gc.c: fix to use total_allocated_object_num and heaps_used
at the GC time for profiler.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 05:17:40 +00:00
ko1 4a113cd3cb * gc.c: RGENGC_CHECK_MODE should be 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 03:36:40 +00:00
ko1 b21bf8f94b * gc.c (gc_marks_body): fix to get `th' in this function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 02:20:10 +00:00
ko1 7986e98394 * gc.c (heaps_header/heaps_slot): embed bitmaps into heaps_slot.
no need to maintain allocation/free bitmaps.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 01:26:50 +00:00
ko1 caf923fa6a * gc.c (slot_sweep_body): add counters at a time.
* gc.c (gc_profile_dump_on): fix line break position.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-21 00:24:14 +00:00
tarui 4b18db6a2f * gc.c: refactoring bitmaps. introduce bits_t type and some Consts.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 23:15:18 +00:00
ko1 8b80ce3a53 * gc.c: fix to support USE_RGENGC == 0 (disable RGenGC).
If USE_RGENGC==0, it caused compilation error.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 23:10:34 +00:00
tarui fcd5cc93c9 * gc.c (lazy_sweep): Use is_lazy_sweeping()
* gc.c (rest_sweep): Ditto.
	* gc.c (gc_prepare_free_objects): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 23:08:30 +00:00
nobu 2c79a46764 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 22:41:07 +00:00
ko1 8ab7d0e4c3 * gc.c (gc_profile_record::oldgen_objects): added.
* gc.c (gc_profile_dump_on): print the following infomation:
* Living object counts
* Free object counts
  If RGENGC_PROFILE > 0 then
* Oldgen object counts
* Remembered normal object counts
* Remembered shady object counts



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 22:38:08 +00:00
ko1 d1c518d416 * gc.c (gc_prof_sweep_timer_stop): accumulate sweep time only when
record->gc_time > 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 20:39:20 +00:00
ko1 bf017de1f3 * gc.c (rgengc_rememberset_mark): record
(1) normal objects count in remember set
  (2) shady objects count in remember set
  each GC timing.
* gc.c (gc_profile_record_get): enable to access above information
  and REMOVING_OBJECTS, EMPTY_OBJECTS.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 12:20:27 +00:00
nobu 16f36b6322 gc.c: adjust indent
* gc.c (gc_marks): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41463 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-20 00:29:13 +00:00
tarui 88927b04ae * gc.c (rb_gc_writebarrier): give up rescan A and register B directly
if A has huge number of children.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 22:48:03 +00:00
ko1 65ad154e2a * gc.c (gc_profile_total_time): check objspace->profile.next_index > 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41456 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 21:21:16 +00:00
ko1 efc53c496e * gc.c (gc_prof_sweep_timer_start): fix merge miss.
* gc.c (GC_PROFILE_MORE_DETAIL): set it 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 20:49:28 +00:00
ko1 6622ab2049 * gc.c: Accumulate sweep time to GC time.
Now [GC time] is [mark time] + [sweep time] + [misc].
  ([GC time] >= [mark time] + [sweep time])
* gc.c (gc_prof_sweep_slot_timer_start/stop): rename to
  gc_prof_sweep_timer_start/stop and locate at lazy_sweep().
* gc.c (elapsed_time_from): add a utility function.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 20:43:33 +00:00
ko1 21b0705c18 * gc.c (gc_marks): fix wrong option. FALSE means major/full GC.
It should be TRUE (minor marking).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 20:09:59 +00:00
nobu a30d9f9e1e gc.c: refine macros
* gc.c (MARKED_IN_BITMAP, FL_TEST2): return boolean value since always
  used as boolean value.
* gc.c (MARK_IN_BITMAP, CLEAR_IN_BITMAP): evaluate bits once.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 16:07:41 +00:00
nobu 67edbe19ee gc.c: gc_stress is a VALUE
* gc.c (ruby_initial_gc_stress_ptr): now gc_stress is a VALUE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 16:01:16 +00:00
nagachika 291c1bc314 * gc.c (gc_free_stored_bitmaps): fix indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 15:27:58 +00:00
ko1 ce7c13ef4d * gc.c (RVALUE_PROMOTED): fix type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41437 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 15:06:27 +00:00
ko1 50214475a9 * gc.c (garbage_collect_test): rewrite checking code.
When RGENGC_CHECK_MODE >= 2, all minor marking, run normal minor
  marking *and* major/full marking. After that, compare the results
  and shows BUG if a object living with major/full marking but dead
  with minor marking.
  After detecting bugs, print references information.
  (RGENGC_CHECK_MODE == 2, show references to dead object)
  (RGENGC_CHECK_MODE == 3, show all references)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 14:59:35 +00:00
ko1 745263abb9 * gc.c (RVALUE_PROMOTED): check consistency between oldgen flag and
oldgen bitmap if RGENGC_CHECK_MODE > 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 14:34:11 +00:00
ko1 a1acb395a2 * gc.c (rb_gc_force_recycle): clear oldgen bitmap, too.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 14:30:13 +00:00
kazu 28945ea146 * gc.c (gc_stress_get): GC.stress can be Fixnum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 11:53:07 +00:00
ko1 9b47ec04a8 * include/ruby/ruby.h (struct rb_data_type_struct), gc.c: add
rb_data_type_struct::flags. Now, this flags is passed
  at T_DATA object creation. You can specify FL_WB_PROTECTED
  on this flag.
* iseq.c: making non-shady iseq objects.
* class.c, compile.c, proc.c, vm.c: add WB for iseq objects.
* vm_core.h, iseq.h: constify fields to detect WB insertion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 06:26:01 +00:00
nobu 541bdd29ba gc.c: more info
* gc.c (gc_mark_children): show more info for broken object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-19 06:11:15 +00:00
ko1 97dd259df5 * gc.c (garbage_collect_body): use FIX2INT for ruby_gc_stress.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 22:49:19 +00:00
ko1 bfac961bed * gc.c (rb_objspace::gc_stress): int -> VALUE to store Fixnum object.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 22:45:41 +00:00
ko1 d879849b6e * gc.c (make_deferred): clear flags to T_ZOMBIE.
* gc.c (slot_sweep_body): fix indent.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 22:26:57 +00:00
ko1 54d04073d7 * gc.c (rgengc_remember): fix output level.
* gc.c (rgengc_rememberset_mark): fix to output clear count.
  (shady_object_count + clear_count = count of remembered objects)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 22:12:39 +00:00
ko1 65791846a6 * gc.c (rgengc_remember): check T_NONE and T_ZOMBIE
if RGENGC_CHECK_MODE > 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 22:07:09 +00:00
ko1 5455b7e72e * gc.c (RGENGC_CHECK_MODE): add new check mode `3'.
In this mode, show all references if there is
  a miss-corrected object.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 22:04:30 +00:00
ko1 81ed2d3c4a * gc.c (gc_stress_set): add special option of GC.stress.
`GC.stress=(flag)' accepts integer to control behavior of GC.
  See code for details. Of course, this feature is only for MRI.
  You can debug RGenGC (WB) using `GC.stress = 1'.
  Using this option, do minor marking at all possible places.
  GC::STRESS_MINOR_MARK = 1 and GC::STRESS_LAZY_SWEEP = 2
  seem good to add.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 21:35:40 +00:00
tarui 0a3f79310f * gc.c (gc_profile_record_flag): reason seems like one-hot encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 13:37:09 +00:00
zzak 62de1e66f7 * gc.c: Rename rb_mObSpace -> rb_mObjSpace
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 12:59:02 +00:00
ko1 1d7966f5b4 * gc.c (gc_stat): add `generated_normal_object_count_types' for
RGENGC_PROFILE >= 2.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 02:27:37 +00:00
ko1 17cd5ac4af * gc.c (gc_mark_maybe): check to skip T_NONE.
* gc.c (markable_object_p): do not need to check (flags == 0) here.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 02:17:59 +00:00
ko1 7a460d2d1d * gc.c (gc_mark_children): don't need to care about T_ZOMBIE here.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-17 19:21:36 +00:00
eregon 089dd1a1ca * gc.c (ObjectSpace): is a module not a class.
* ext/objspace/objspace.c: try to include overview in rdoc,
  see #8537.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-17 08:44:56 +00:00
eregon abfcded30c * gc.c: fix example of ObjectSpace.define_finalizer in overview
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-17 08:39:39 +00:00
ko1 17be9e9719 * gc.c (gc_mark_maybe): added. check `is_pointer_to_heap()' and
type is not T_ZOMBE.
* gc.c: use `gc_mark_maybe()'. T_ZOMBIE objects should not be pushed
  to the mark stack.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-17 02:54:25 +00:00
tarui 3a0a69fec4 * gc.c: Fixup around GC by MALLOC.
Add allocate size to malloc_increase before GC 
	  for updating limit in after_gc_sweep.
	  Reset malloc_increase into garbage_collect() 
	  for preventing GC again soon.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-15 20:53:01 +00:00
tarui 994ed8dbd5 * gc.c : add some colums to more detail profile.
new colums: Allocated size, Prepare Time, Removing Objects, Empty Objects


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-15 20:18:11 +00:00
tarui 6477616c3b * gc.c (gc_prof_timer_stop): Merge function codes of GC_PROFILE_MORE_DETAIL and !GC_PROFILE_MORE_DETAIL.
* gc.c (gc_prof_mark_timer_start): Ditto. 
	* gc.c (gc_prof_mark_timer_stop): Ditto.
	* gc.c (gc_prof_sweep_slot_timer_start): Ditto.
	* gc.c (gc_prof_sweep_slot_timer_stop): Ditto.
	* gc.c (gc_prof_set_malloc_info): Ditto.
	* gc.c (gc_prof_set_heap_info): Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-15 17:06:15 +00:00
shugo 1f828497d1 * safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4.  $SAFE=4 is now obsolete.
  [ruby-core:55222] [Feature #8468]

* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
  Kernel#untrusted?, untrust, and trust are now deprecated.
  Their behavior is same as tainted?, taint, and untaint,
  respectively.

* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
  and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
  respectively.

* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
  ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
  ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
  ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
  ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
  ext/socket/socket.c, ext/socket/udpsocket.c,
  ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
  ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
  load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
  safe.c, string.c, thread.c, transcode.c, variable.c,
  vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
  $SAFE=4.

* test/dl/test_dl2.rb, test/erb/test_erb.rb,
  test/readline/test_readline.rb,
  test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
  test/ruby/test_array.rb, test/ruby/test_dir.rb,
  test/ruby/test_encoding.rb, test/ruby/test_env.rb,
  test/ruby/test_eval.rb, test/ruby/test_exception.rb,
  test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
  test/ruby/test_io.rb, test/ruby/test_method.rb,
  test/ruby/test_module.rb, test/ruby/test_object.rb,
  test/ruby/test_pack.rb, test/ruby/test_rand.rb,
  test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
  test/ruby/test_struct.rb, test/ruby/test_thread.rb,
  test/ruby/test_time.rb: remove tests for $SAFE=4.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 14:20:51 +00:00
ko1 a8aaf13392 * gc.c (rgengc_remember): permit promoted object.
(rb_gc_writebarrier -> remember)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 08:21:08 +00:00
ko1 a03ac78b2c * gc.c (RVALUE_PROMOTE): fix parameter name (`x' to `obj')
and make it inline function (like RVALUE_PROMOTE).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 08:15:31 +00:00
ko1 dd96561f76 * gc.c (wmap_mark): check allocation of `w->obj2wmap'.
(no-allocation `w->obj2wmap' will be NULL pointer reference)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-10 07:12:14 +00:00
akr bd15d4ca78 * internal.h (numberof): Gathered from various files.
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
  load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
  error.c, ruby.c: Remove the definitions of numberof.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 10:01:19 +00:00
naruse b309a3698d * gc.c (before_gc_sweep): noinline can also avoid the segv instead of
-O0 of r41084. this way is expected less slow.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 04:25:20 +00:00
nobu 83db393e48 adjust style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:52:42 +00:00
nobu 0b87f8d4cf * gc.c (gc_clear_slot_bits): used only if no RGenGC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:49:53 +00:00
nobu 432321d780 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41129 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:36:07 +00:00
tarui f37d0629af * gc.c: use oldgen bitmap as initial mark bitmap when mijor gc.
so can skip oldgen bitmap check around mark & sweep.
	* gc.c (slot_sweep_body): change scan algorithm for performance:
	  from object's pointer base to bitmap one.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:32:57 +00:00
tarui 1f23dca967 * gc.c: introduce oldgen bitmap for preparing performance tuning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:28:03 +00:00
tarui 5a06ae3bf9 * gc.c (MARKED_IN_BITMAP, MARK_IN_BITMAP, CLEAR_IN_BITMAP): bring
bitmap macros in one place, and introduce BITMAP_BIT.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 02:25:19 +00:00
ko1 e7dfa869c0 * gc.c: remove "Sunny" terminology.
"Sunny" doesn't mean antonym of "Shady" (questionable, doubtful, etc).
  Instead of "Suuny", use "non-shady" or "normal".



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 01:17:19 +00:00
tarui 3a17a592da * gc.c (gc_mark): get rid of pushing useless objests.
* gc.c (rgengc_rememberset_mark): bypass gc_mark() in order to push
	  sunny old object at minor gc.
	* gc.c (gc_mark_children): move sunny old check to gc_mark().
	* gc.c (rgengc_check_shady): remove DEMOTE that already unnecessary.
	* gc.c (rb_gc_writebarrier): ditto.
	  
	  change sunny old check point in order to save mark stack and
	  remove unnatural rest_sweep & demote.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05 16:15:26 +00:00
nobu 2b78c32561 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05 16:01:05 +00:00
tarui 5d10f35142 * gc.c (rgengc_rememberset_mark): change scan algorithm for performance:
from object's pointer base to bitmap one.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05 15:57:12 +00:00
nobu 3fb267e501 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05 06:36:06 +00:00
naruse c0089b4d10 use attribute is more simple way for r41083
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41084 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05 06:31:43 +00:00
naruse 77857bfc87 * gc.c (before_gc_sweep): don't optimize it to avoid segv on Ubuntu
10.04 gcc 4.4.
  http://u32.rubyci.org/~chkbuild/ruby-trunk/log/20130527T190301Z.diff.html.gz

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-05 06:27:43 +00:00
ko1 6e19585ac7 * gc.c (gc_profile_enable): rest_sweep() to finish last GC.
Profiling record is allocated at first of marking phase.
  Enable at lazy sweeping may cause an error (SEGV).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-29 15:10:28 +00:00
ko1 b01c4ddfce * gc.c (gc_stat): remove wrong rest_sweep().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27 17:57:08 +00:00
ko1 8a81b54a2b * gc.c (garbage_collect_body): fix GC_ENABLE_LAZY_SWEEP condition.
* gc.c (GC_NOTIFY): move debug print location and use stderr instead
  of stdout.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27 17:46:20 +00:00
ko1 e4c58251b7 * include/ruby/ruby.h, gc.c: add new internal event
RUBY_INTERNAL_EVENT_GC_END. This event invokes at the end of
  after_sweep().
  Time chart with lazy sweep is here:
  (1) Kick RUBY_INTERNAL_EVENT_GC_START
  (2) [gc_marks()]
  (3) [lazy_sweep()]
  (4) [... run Ruby program (mutator) with lazy_sweep() ...]
  (5) [after_sweep()]
  (6) Kick RUBY_INTERNAL_EVENT_GC_END
  (7) [... run Ruby program (mutator), and go to (1) ...]
* ext/-test-/tracepoint/tracepoint.c,
  test/-ext-/tracepoint/test_tracepoint.rb: modify a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27 15:40:27 +00:00
ko1 f0b6cb6fc7 * include/ruby/ruby.h: rename RUBY_INTERNAL_EVENT_FREE to
RUBY_INTERNAL_EVENT_FREEOBJ.
* ext/-test-/tracepoint/tracepoint.c,
  ext/objspace/object_tracing.c,
  gc.c, vm_trace.c: catch up this change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27 10:28:25 +00:00
ko1 050dd10d6f * ext/objspace/objspace.c: support ObjectSpace.trace_object_allocations.
Read the following test to know HOWTO.
  This feature is a sample of RUBY_INTERNAL_EVENT.
* test/objspace/test_objspace.rb: add a test.
* ext/objspace/object_tracing.c: ditto.
* gc.c (rb_gc_count): add. THis function returns GC count.
* internal.h: add decl. of rb_gc_count(). Same as `GC.count'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27 10:01:45 +00:00
ko1 680f0b5ba4 * include/ruby/ruby.h, gc.c, vm_trace.c: add internal events.
* RUBY_INTERNAL_EVENT_NEWOBJ: object created.
* RUBY_INTERNAL_EVENT_FREE: object freeed.
* RUBY_INTERNAL_EVENT_GC_START: GC started.
  And rename `RUBY_EVENT_SWITCH' to `RUBY_INTERNAL_EVENT_SWITCH'.
  Internal events can not invoke any Ruby program because the tracing
  timing may be critical (under huge restriction).
  These events can be hooked only by C-extensions.
  We recommend to use rb_potponed_job_register() API to call Ruby
  program safely.
  This change is mostly written by Aman Gupta (tmm1).
  https://bugs.ruby-lang.org/issues/8107#note-12
  [Feature #8107]
* include/ruby/debug.h, vm_trace.c: added two new APIs.
* rb_tracearg_event_flag() returns rb_event_flag_t of this event.
* rb_tracearg_object() returns created/freeed object.
* ext/-test-/tracepoint/extconf.rb,
  ext/-test-/tracepoint/tracepoint.c,
  test/-ext-/tracepoint/test_tracepoint.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-27 00:21:02 +00:00
ko1 e2793a908e * include/ruby/debug.h, vm_trace.c: add rb_postponed_job API.
Postponed jobs are registered with this API. Registered jobs
  are invoked at `ruby-running-safe-point' as soon as possible.
  This timing is completely same as finalizer timing.
  There are two APIs:
* rb_postponed_job_register(flags, func, data): register a
  postponed job with data. flags are reserved.
* rb_postponed_job_register_one(flags, func, data): same as
  `rb_postponed_job_register', but only one `func' job is
  registered (skip if `func' is already registered).
  This change is mostly written by Aman Gupta (tmm1).
  https://bugs.ruby-lang.org/issues/8107#note-15
  [Feature #8107]
* gc.c: use postponed job API for finalizer.
* common.mk: add dependency from vm_trace.c to debug.h.
* ext/-test-/postponed_job/extconf.rb, postponed_job.c,
  test/-ext-/postponed_job/test_postponed_job.rb: add a test.
* thread.c: implement postponed API.
* vm_core.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 21:30:44 +00:00
ko1 767debf92e * gc.c (gc_stat): collect promote_operation_count and
types (RGENGC_PROFILE >= 2).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 17:27:42 +00:00
ko1 ca2ca7d32b * gc.c (gc_stat): collect shade_operation_count,
remembered_sunny_object_count and remembered_shady_object_count
  for each types when RGENGC_PROFILE >= 2.
  They are informative for optimization.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 16:43:21 +00:00
ko1 c4c821a7d7 * hash.c (rb_hash_tbl_raw), internal.h: added.
Returns st_table without shading hash.
* array.c: use rb_hash_tbl_raw() for read-only purpose.
* compile.c (iseq_compile_each): ditto.
* gc.c (count_objects): ditto.
* insns.def: ditto.
* process.c: ditto.
* thread.c (clear_coverage): ditto.
* vm_insnhelper.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-26 16:19:04 +00:00
ko1 7b5a42f0fa * gc.c (after_gc_sweep): reduce full GC timing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40924 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-25 08:11:04 +00:00
ko1 f38a063090 * gc.c: do major/full GC when:
* number of oldgen object is biggger than twice of
  number of oldgen object at last full GC.
* number of remembered shady object is bigger than twice of
  number of remembered shady object at last full GC.
* number of oldgen object and remembered shady object is bigger
  than half of total object space.
  (please fix my English!)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-24 10:21:04 +00:00
ko1 b84f7fda07 * gc.c (after_gc_sweep, garbage_collect_body): do major GC (full GC)
before extending heaps.
  TODO: do major GC when there are many old (promoted) objects.
* gc.c (after_gc_sweep): remove TODO comments.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-24 06:52:38 +00:00
nobu 699e06a884 gc.c: revert r40898
* gc.c (gc_profile_dump_on): revert r40898.  ok to show the record
  accumulating while lazy_sweep().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-23 08:22:05 +00:00
nobu 95170c704c * gc.c: do not dump the last record
* gc.c (gc_profile_dump_on): do not dump the last record, for some
  reason.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-23 07:58:06 +00:00
nobu 11650a6ab9 gc.c: use size_t and no header if next_index == 0
* gc.c (gc_profile_dump_on): use size_t to get rid of overflow and
  show the header when next_index > 0, instead of next_index != 1.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-22 07:50:20 +00:00
ko1 5aece50163 * gc.c (gc_prepare_free_objects, rest_sweep, lazy_sweep): fix position
of `during_gc' setting.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-22 05:21:06 +00:00
ko1 9e64703ec8 * gc.c (garbage_collect): all GC is start from garbage_collect()
(or garbage_collect_body()). `garbage_collect()' accept additional
  two parameters `full_mark' and `immediate_sweep'.
  If `full_mark' is TRUE, then force it full gc (major gc), otherwise,
  it depends on status of object space. Now, it will be minor gc.
  If `immediate_sweep' is TRUE, then disable lazy sweep.
  To allocate free memory, `full_mark' and `immediate_sweep' should be
  TRUE. Otherwise, they should be FALSE.
* gc.c (gc_prepare_free_objects): use `garbage_collect_body()'.
* gc.c (slot_sweep, before_gc_sweep, after_gc_sweep): add logging code.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-21 23:09:22 +00:00
ko1 51d586c64e * gc.c: remove gc_profile_record::is_marked. always true.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-21 08:21:59 +00:00
ko1 9578bb7831 * gc.c: fix to collect additional information for GC::Profiler.
* major/minor GC
* trigger reason of GC
* gc.c (gc_profile_dump_on): change reporting format with
  added information.
* gc.c (gc_profile_record_get): return added information by
  :GC_FLAGS => array.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-21 08:19:07 +00:00
ko1 2e011442e5 * gc.c: GC::Profiler's sweeping time is accumulated all slot
sweeping time. At lazy GC, GC::Profiler makes new record entry
  for each lazy_sweep(). In this change, accumulating all
  slot_sweep() time.
  And change indentation.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-21 07:52:03 +00:00
ko1 3f2cb86ef3 * gc.c (gc_profile_dump_on): `count' should be (int) because it
can be negative number.
  And use pointer for `record' (don't copy).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-21 07:27:32 +00:00
nobu baa65ad108 gc.c: rb_gc_guarded_ptr
* gc.c (rb_gc_guarded_ptr): unoptimize on other compilers than gcc and
  msvc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-17 08:35:26 +00:00
ko1 e213a7228f * gc.c (rb_node_newnode): use newobj_of() instead of rb_newobj().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-15 18:07:12 +00:00
ko1 f1ccdf98ca * gc.c (newobj): rename to `newobj_of' and accept additional
three parameters v1, v2, v3. newobj_of() do OBJSETUP() and
  fill values with v1, v2, v3.
* gc.c (rb_data_object_alloc, rb_data_typed_object_alloc):
  use newobj_of().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-15 10:26:22 +00:00
ko1 4a9ec30601 * gc.c: add an additional RGENGC_PROFILE mode (2).
Profiling result can be check by GC.stat.
* gc.c (type_name): separate from obj_type_name().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-15 08:07:30 +00:00
nobu bb5212d395 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-14 01:54:48 +00:00
ko1 4f401816ff * gc.c: support RGENGC. [ruby-trunk - Feature #8339]
See this ticet about RGENGC.
* gc.c: Add several flags:
* RGENGC_DEBUG: if >0, then prints debug information.
* RGENGC_CHECK_MODE: if >0, add assertions.
* RGENGC_PROFILE: if >0, add profiling features.
  check GC.stat and GC::Profiler.
* include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0).
* array.c: add write barriers for T_ARRAY and generate sunny objects.
* include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if
  you want to access raw pointers. If you modify the contents which
  pointer pointed, then you need to care write barrier.
* bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects.
* complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX
  and generate sunny objects.
* rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write
  barriers for T_RATIONAL and generate sunny objects.
* internal.h: add write barriers for RBasic::klass.
* numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects.
* object.c (rb_class_allocate_instance), range.c:
  generate sunny T_OBJECT objects.
* string.c: add write barriers for T_STRING and generate sunny objects.
* variable.c: add write barriers for ivars.
* vm_insnhelper.c (vm_setivar): ditto.
* include/ruby/ruby.h, debug.c: use two flags
  FL_WB_PROTECTED and FL_OLDGEN.
* node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED):
  move flag bits.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 18:07:47 +00:00
ko1 7958c71ee5 * gc.c: remove rb_objspace_t::marked_num.
We can use `objspace_live_num()' instead of removed `marked_num'
  if it is after `after_gc_sweep()' function call.
* gc.c (after_gc_sweep): use objspace_live_num() instead of removed
  rb_objspace_t::marked_num.
* gc.c (gc_mark_ptr, gc_marks): remove rb_objspace_t::marked_num code.
* gc.c (gc_prepare_free_objects): do not call set_heaps_increment()
  with checking objspace->heap.marked_num. At this point, we only
  need to check availability of free-cell.
* gc.c (gc_prepare_free_objects):
* gc.c (lazy_sweep): call after_gc_sweep() if there are no sweep_able entry.
* gc.c (rest_sweep, gc_prepare_free_objects): remove after_gc_sweep() call.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 17:02:50 +00:00
ko1 b597df707e * gc.c: disable GC_PROFILE_MORE_DETAIL (fix last commit).
* gc.c (gc_prof_set_malloc_info): fix "objspace->heap.live_num" to
  "objspace_live_num(objspace)". There is no such member variable.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 16:52:49 +00:00
ko1 7d0a90e9b4 * gc.c: refactoring GC::Profiler.
* gc.c (gc_prof_sweep_timer_start/stop): removed because
  they doesn't support lazy sweep.
* gc.c (gc_prof_sweep_slot_timer_start/stop): added.
  redefine `sweeping time' to accumulated time of all of
  slot_sweep().
* gc.c (rb_objspace_t::profile::count): renamed to
  rb_objspace_t::profile::next_index. `counter' seems ambiguous.
  increment it when next record is acquired.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 16:34:25 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00
ko1 8ac05ae500 * gc.c (rb_data_object_alloc): check klass only if klass is not 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 06:25:33 +00:00
ko1 925c936bb1 * gc.c (rb_data_object_alloc, rb_data_typed_object_alloc):
use NEWOBJ_OF() instead of NEWOBJ().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 06:03:00 +00:00
nobu ae422dda78 gc.c: _aligned_malloc
* gc.c (aligned_malloc): declare _aligned_malloc() prototype for old VC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-30 21:08:30 +00:00
nobu b4a2e268ea gc.c: fix compile error
* gc.c (gc_prepare_free_objects): fix compile error.  there should be
  free objects when new slot is added.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-24 05:13:54 +00:00
nari e54daddac4 * gc.c (GC_ENABLE_LAZY_SWEEP): new macro to switch lazy sweeping
for debugging. [Feature #8024] [ruby-dev:47135]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-24 04:53:44 +00:00
nari 3ad60679e3 * gc.c: We have no chance to expand the heap when lazy sweeping is
restricted. So collecting is often invoked if there is not
  enough free space in the heap. Try to expand heap when this is
  the case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-24 04:20:32 +00:00