add links to `Object#hash` to each #`hash` methods rdocs.
[Fixes GH-567]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
at first.
And return immediately if we don't touch sorted list any more.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45182 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (RB_GC_GUARD):
use rb_gc_guarded_ptr_val on non-GCC/MSC
* gc.c (rb_gc_guarded_ptr_val): rename and adjust argument.
RB_GC_GUARD should be robust enough for any compiler.
[ruby-core:60816] [Bug #7805]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
"RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR" to control major/minor GC
frequency.
Do full GC when the number of old objects is more than R * N
where R is this factor and
N is the number of old objects just after last full GC.
* test/ruby/test_gc.rb: add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This function *ONLY* works just after marking phase,
before any sweeping.
This function is highly depending current GC implementation
and can be removed future version.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (ruby_gc_params_t, get_envparam_size): use size_t for
integer environment parameters for sizes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
(changed by last commit) because "" or "foo" (not a number) strings
are parsed as 0. They should be rejected.
* gc.c (get_envparam_double): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
then set objspace->rgengc.oldmalloc_increase_limit.
Without this fix, the env variable RUBY_GC_OLDMALLOC_LIMIT
does not work.
* gc.c (get_envparam_int): accept a value equals to lowerbounds.
* gc.c (get_envparam_double): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_core.h (rb_thread_struct): aggregate cpu stuff into a struct,
so that a debugger can show its content at once.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RUBY_FREE_MIN/RUBY_HEAP_MIN_SLOTS if
RUBY_GC_HEAP_FREE_SLOTS/RUBY_GC_HEAP_INIT_SLOTS are given.
[Bug #9276]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (heap_get_freeobj_from_next_freepage): replace with
heap_get_freepage(). It returns freeobj instead of freepage.
This is not on hot path.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (heap_get_freeobj): remove redundant assignment. heap->freelist
is set after the while() loop already.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
can be OR of multiple reasons.
* gc.c (gc_profile_dump_on): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c: check objspace->profile.current_record before inserting
profiling record by new macro gc_prof_enabled().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44276 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (gc_finalize_deferred_register): define in prototype style,
instead of old K&R style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
internal data structure.
Now this method only checks geneartion (old/young) consistency.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (gc_info_decode): Use :major_by=>:nofree as fallback reason
when other trigger conditions are present.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (wmap_mark): disable deletion of dead objects by default,
so that WeakMap can be non-shady.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (wmap_keys): return keys for live objects only, like as
wmap_values.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (wmap_aset): use st_update instead of st_lookup and
st_insert.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* 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
* 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
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
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
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
* 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
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
* 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
* 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
* 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
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
* 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
* 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
* 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
* 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
* 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
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
* 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
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
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
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