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

986 Коммитов

Автор SHA1 Сообщение Дата
tmm1 40d7c9c18b gc.c: speed up RGENGC_CHECK_MODE by removing unncessary check
* gc.c (reflist_add): revert changes from r44109. it is unnecessary
  after r44113
* gc.c (allrefs_i): fix whitespace
* gc.c (allrefs_roots_i): fix whitespace

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 06:58:48 +00:00
ko1 1b29c00f00 * gc.c (allrefs_add): push obj only if allrefs table doesn't have
obj.
* gc.c (allrefs_roots_i): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 06:47:15 +00:00
ko1 14979f2161 * gc.c (RGENGC_CHECK_MODE): separate checkers to different modes.
* 2: enable generational bits check (for debugging)
  * 3: enable livness check
  * 4: show all references



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 06:44:35 +00:00
nobu 13dee2481b * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 06:26:05 +00:00
ko1 8d4253f7e1 * gc.c (gc_marks_check): disable GC during checking and
restore malloc_increase info.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 06:21:52 +00:00
tmm1 3705007e7a gc.c: build complete object graph for RGENGC_CHECK_MODE
* gc.c (reflist_add): return 0 if reference already exists
	* gc.c (allrefs_add): return 1 on newly added references
	* gc.c (allrefs_i): follow references to construct complete object
	  graph. before this patch, RGENGC_CHECK could fail to verify some WB
	  miss issues. [Bug #9226] [ruby-core:58959]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 05:46:48 +00:00
nobu 0326725b24 gc.c: check arguments first
* gc.c (wmap_aset): check if both arguments are able to finalize
  before setting finalizers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 05:17:19 +00:00
nobu 9bd802f556 gc.c: fix WeakMap#inspect
* gc.c (wmap_inspect_i): fix key/value order.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 05:02:17 +00:00
tmm1 332decb490 gc.c: fix typo in function name
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44106 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 03:25:28 +00:00
tmm1 7170baa878 objspace_dump.c: include object's gc flags in dump
* ext/objspace/objspace_dump.c (dump_object): include fstring flag on
  strings. include gc flags (old, remembered, wb_protected) on all objects.
* ext/objspace/objspace_dump.c (Init_objspace_dump): initialize lazy
  IDs before first use.
* gc.c (rb_obj_gc_flags): new function to retrieve object flags
* internal.h (RB_OBJ_GC_FLAGS_MAX): maximum flags allowed for one obj
* test/objspace/test_objspace.rb (test_dump_flags): test for above
* test/objspace/test_objspace.rb (test_trace_object_allocations):
  resolve name before dump (for rb_class_path_cached)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10 02:26:09 +00:00
nobu d2cc188ad5 gc.c: ObjectSpace::WeakMap#size
* gc.c (wmap_size): add ObjectSpace::WeakMap#size and #length.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-09 07:13:40 +00:00
tmm1 8f77cfb308 gc.c: promote long-lived NODE_CREF objects to oldgen
* include/ruby/ruby.h: add RGENGC_WB_PROTECTED_NODE_CREF setting
  In a large app, this reduces the size of
  remembered_shady_object_count by 80%. [Bug #9225] [ruby-core:58947]
* gc.c (rb_node_newnode): add FL_WB_PROTECTED flag to NODE_CREF
* class.c (rewrite_cref_stack): insert OBJ_WRITE for NODE_CREF
* iseq.c (set_relation): ditto
* iseq.c (rb_iseq_clone): ditto
* vm_eval.c (rb_yield_refine_block): ditto
* vm_insnhelper.c (vm_cref_push): ditto
* vm_insnhelper.h (COPY_CREF): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 02:28:04 +00:00
charliesome 0aada28159 * gc.c (gc_mark_children): use nd_clss and nd_next for code clarity
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-07 13:01:17 +00:00
ko1 b91e889c34 * gc.c: change oldmalloc meaning.
Increase oldmalloc_increase with malloc_increase
  instead of using obj_memsize_of().
  This change will avoid the danger of memory full without major GC.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 10:27:02 +00:00
ko1 f09058b877 * gc.c (atomic_sub_nounderflow): not 0 but val itself.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 10:09:38 +00:00
ko1 e4720e1118 * gc.c (rb_objspace_alloc, Init_heap): initialize
oldmalloc_increase_limit at Init_heap.
  rb_objspace_alloc() is not called on some platforms.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 09:38:22 +00:00
ko1 2c616737e5 * gc.c (garbage_collect_body): bug fix.
initialize after recording.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-06 09:34:26 +00:00
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