* thread.c (ruby_thread_stack_overflow): check if the given thread
is during GC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* addr2line.c (follow_debuglink): insert global_debug_dir by using
memmove instead of copying to temporary buffer.
* dln.c (dln_load): use memcpy with the known length instead of
strcpy.
* gc.c (rb_gc_unprotect_logging): use strdup instead of malloc and
strcpy.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Use PRIuSIZE instead of PRIdSIZE. This fixes the exception message shown
on too large xmalloc2. This commit also fixes other incorrect use of
PRIdSIZE in other functions; though most of them are debug print.
* gc.c (heap_extend_pages, get_envparam_size, ruby_malloc_size_overflow,
gc_profile_dump_on): Use PRIuSIZE instead of PRIdSIZE as the passed
value is size_t, not ssize_t.
* iseq.c (get_line_info, rb_iseq_disasm_insn): Ditto.
* sprintf.c (rb_str_format): Ditto.
* thread_win32.c (native_thread_create): Ditto.
* vm.c (get_param): Ditto.
* ext/objspace/objspace_dump.c (dump_append_string_content,
dump_object): Ditto.
* ext/socket/raddrinfo.c (host_str, port_str): Ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
are imemo objects (imemo_env).
* NEWS: describe this change. I believe nobody touch these objects
because there are no method defined.
* vm_core.h: remove the following definitions.
* rb_cEnv decl.
* GetEnvPtr() because Env is no longer T_DATA object.
* vm_core.h (rb_env_t): fix layout for imemo values.
* vm_core.h (vm_assert_env): added.
* vm_core.h (vm_env_new): added.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[Bug #12628]
This patch introduce many changes.
* Introduce concept of "Block Handler (BH)" to represent
passed blocks.
* move rb_control_frame_t::flag to ep[0] (as a special local
variable). This flags represents not only frame type, but also
env flags such as escaped.
* rename `rb_block_t` to `struct rb_block`.
* Make Proc, Binding and RubyVM::Env objects wb-protected.
Check [Bug #12628] for more details.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (run_finalizer): make saved running finalizer state
volatile to ensure not to be clobbered by longjmp.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
I expected to inline this function implicitly at the loop
(ex: marking T_ARRAY objects) but sometimes it remains as
normal call.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (run_finalizer): push and exec tag just once, instead of
protecting for each finalizer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (gc_start_internal, rb_gc_start): set finalizing flag
whenever calling deferred finalizers not to recurse.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
singleton class of the VM object.
Before this patch, we only set mark bit for the VM object and
invoke mark function separately.
[Bug #12583]
* test/ruby/test_gc.rb: add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
allocate memory. This is pointed out by Facebook's Infer.
* gc.c (gc_prof_setup_new_record): ditto.
* regparse.c (parse_regexp): ditto.
* util.c (MALLOC): use xmalloc and xfree like above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
and define CONSTFUNC and PUREFUNC if available.
Note that I don't add those options as default because
it still shows many false-positive (it seems not to consider
longjmp).
* vm_eval.c (stack_check): get rb_thread_t* as an argument
to avoid duplicate call of GET_THREAD().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_eval.c (rb_eval_cmd, rb_catch_obj): use TH_JUMP_TAG with the
same rb_thread_t used for TH_PUSH_TAG, instead of JUMP_TAG with
the current thread global variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
mul overflow efficiently.
* include/ruby/ruby.h (rb_alloc_tmp_buffer2): use rb_mul_size_overflow
and avoid division where it can define DSIZE_T.
* gc.c (xmalloc2_size): moved from ruby.h and use rb_mul_size_overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
avoid duplicated check of size.
* gc.c (ruby_xmalloc2): added to keep separate layers.
* include/ruby/ruby.h (rb_alloc_tmp_buffer2): added to check
the size more statically.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
used by objspace_xmalloc and objspace_xcalloc.
objspace_xmalloc introduces its own check in this commit.
objspace_xcalloc checks with xmalloc2_size (ruby_xmalloc2_size).
* gc.c (objspace_xmalloc0): common xmalloc function.
* gc.c (objspace_xmalloc): introduce its own size check.
* gc.c (objspace_xmalloc2): separated from ruby_xmalloc2 to clarify
the layer who has the responsibility to check the size.
* gc.c (objspace_xrealloc): remove duplicated size check.
* gc.c (ruby_xmalloc2): use objspace_xmalloc2.
* include/ruby/ruby.h (ruby_xmalloc2_size): follow the size limit
as SSIZE_MAX. Note that ISO C says size_t is unsigned integer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO 0.3 -> 0.2
RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO 0.8 -> 0.65
These values are same as Ruby 2.0.0.
This change cause GC counts.
However, generational GC reduced each (minor) GC time and
increase memory locality. So that not so big impact on my
benchmarking results.
(surprizingly, this fix speed up programs on some cases)
You can change these values by environment variables
if you feel wrong.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
And also take an accept_zero flag which allow to accept zero
even if lower_bound is set.
* gc.c (ruby_gc_set_params): fix parameters.
RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO set 0.9 as *lower_bound*, so that
it should be upper_bound.
Set RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO as lower bound.
Also set lower/upper bound of RUBY_GC_HEAP_FREE_SLOTS_GOAL_RATIO to
RUBY_GC_HEAP_FREE_SLOTS_MIN/MAX_RATIO.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Introduce new environement variable
GC_HEAP_FREE_SLOTS_GOAL_RATIO (goal_ratio) to calculate the ratio
of additional memory.
Before this change, we add pages with the following formula
(when free_slots < total_pages * RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO):
next_pages = total_pages * RUBY_GC_HEAP_GROWTH_FACTOR
This addition can allocate too much.
With this change, we increase pages to satisfy the following formula:
next_free_slots = next_total_slots * goal_ratio
where
next_free_slots = free_slots + adding_slots
next_total_slots = total_slots + adding_slots.
If you want to prepare many free slots, increase this ratio.
If this variable is 0, then simply multiply
RUBY_GC_HEAP_GROWTH_FACTOR.
* gc.c (get_envparam_double): enable to accept 0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Before this change, heap_pages_min_slots are calculated at the
beggining sweeping phase. And this value is used at the end of
*next* marking phase.
To simplify it, we use this value at the end of this marking phase.
It means that we don't need to store this value as global state.
Also heap_pages_max_slots is calculated at the begging of sweeping
phase and used at the end of sweeping phase.
To simplify this logic, we introduced new global value
heap_pages_freeable_pages it means extra pages count we can free.
gc_sweep_step() checks this value and moves empty pages to tomb_heap
not more than this value.
Because of this fix, heap_pages_swept_slots is no longer needed.
* gc.c (rb_objspace_t::heap_pages): restruct the objspace global
status.
remove the following fileds
* swept_slots (and heap_pages_swept_slots)
* min_free_slots (and heap_pages_min_free_slots)
* max_free_slots (and heap_pages_max_free_slots)
And add the following filed.
* freeable_pages (and heap_pages_freeable_pages)
* gc.c (heap_pages_free_unused_pages): unlink tomb heap pages
because tomb heap should have only freeable pages.
* gc.c (heap_extend_pages): add parameters for future extension.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RUBY_GC_HEAP_FREE_SLOTS_MIN_RATIO:
allocate additional pages when free slots is lower than
the value (total_slots * (this ratio)).
* RUBY_GC_HEAP_FREE_SLOTS_MAX_RATIO:
allow to free pages when free slots is greater thatn
the value (total_slots * (this ratio)).
Before this change, these values are hard coded.
* gc.c (ruby_gc_params_t): ditto.
* gc.c (ruby_gc_set_params): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (gc_sweep_step): use returned free slots count.
* gc.c (gc_sweep_step): change variable name `next'
to `next_sweep_page'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (tick): Use __builtin_ppc_get_timebase for POWER arch.
[Fix GH-1291]
This gives a little performance improvement
user system total real
Before: 20.870000 0.000000 20.870000 ( 20.893959)
After: 20.720000 0.000000 20.720000 ( 20.733970)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (mark_stack_locations): extract the common part from
mark_current_machine_context and rb_gc_mark_machine_stack.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (rb_objspace_of): macro to get the objspace from a thread.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
because there is a same name (no related) function gc_stat().
Also gc_stat_* are renamed to gc_mode_*,
gc_stat_transition() to gc_mode_transition(),
rb_objspace:🎏:stat is renamed to rb_objspace:🎏:mode.
Change rb_objspace:🎏:mode from 2 bits to 3 bits because VC++
returns negative enum value with 2 bits.
* gc.c (gc_mode): add a macro to access rb_objspace:🎏:mode
with verification code (verification is enabled only on
RGENGC_CHECK_MODE > 0).
* gc.c (gc_mode_set): same macro for setter.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* error.c (rb_assert_failure): assertion with stack dump.
* ruby_assert.h (RUBY_ASSERT): new header for the assertion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e