* array.c (ary_recycle_hash): add RB_GC_GUARD
(rb_ary_diff): remove volatile
[Bug #10369]
The RB_GC_GUARD seems needed for most of the ary_recycle_hash
functions anyways.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h (rb_ary_new_from_args): optimization by expanding
arguments in caller to get rid of va_list if possible.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (ary_new): allocate buffer in heap after new object get
allocated successfully, to get rid of potential memory leak at
object allocation failure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Please refer this ticket for details.
This change also introduces the following changes.
* Remove RGENGC_AGE2_PROMOTION and introduce object age (0 to 3).
Age can be count with FL_PROMOTE0 and FL_PROMOTE1 flags in
RBasic::flags (2 bit). Age == 3 objects become old objects.
* WB_PROTECTED flag in RBasic to WB_UNPROTECTED bitmap.
* LONG_LIVED bitmap to represent living objects while minor GCs
It specifies (1) Old objects and (2) remembered shady objects.
* Introduce rb_objspace_t::marked_objects which counts marked
objects in current marking phase. marking count is needed to
introduce incremental marking.
* rename mark related function and sweep related function to
gc_(marks|sweep)_(start|finish|step|rest|continue).
* rename rgengc_report() to gc_report().
* Add obj_info() function to get cstr of object details.
* Add MEASURE_LINE() macro to measure execution time of specific line.
* and many small fixes.
* include/ruby/ruby.h: add flag USE_RINCGC.
Now USE_RINCGC can be set only with USE_RGENGC.
* include/ruby/ruby.h: introduce FL_PROMOTED0 and add FL_PROMOTED1
to count object age.
* include/ruby/ruby.h: rewrite write barriers for incremental marking.
* debug.c: catch up flag name changes.
* internal.h: add rb_gc_writebarrier_remember() instead of
rb_gc_writebarrier_remember_promoted().
* array.c (ary_memcpy0): use rb_gc_writebarrier_remember().
* array.c (rb_ary_modify): ditto.
* hash.c (rb_hash_keys): ditto.
* hash.c (rb_hash_values): ditto.
* object.c (init_copy): use rb_copy_wb_protected_attribute() because
FL_WB_PROTECTED is moved from RBasic::flags.
* test/objspace/test_objspace.rb: catch up ObjectSpace.dump() changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This function creates internal use only array (which is completely
hided by ObjectSpace.each_object) with filling nil.
Otherwise, it can be incldues strange VALUEs.
* internal.h: added.
* node.h: use rb_ary_tmp_new_fill() for MEMO.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_ary_any_p): the array may be modified in the yielded
block, do not access directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_ary_any_p), hash.c (rb_hash_any_p): optimized
versions. these are bit faster than optimization in
Enumerable#any?.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rcombinate0): remove recursion, by looping with indexes
stored in `p`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rpermute0): remove recursion, by looping with indexes
stored in `p`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_ary_combination): iterate on a shared copy, and use
array of indexes instead of array of chosen objects.
[ruby-core:63149] [Bug #9939]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_ary_permutation): `p` is the array of size `r`, as
commented at permute0(). since `n >= r` here, buffer overflow
never happened, just reduce unnecessary allocation though.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
ARY_SET() is same functionality of RARRAY_ASET(), but
it has an assertion (`ary' doesn't have shared array).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Shared arrays were WB-unprotected object because
sharing array can modify shared array's buffer
if it occupied shared array.
[sharing array (ary)] -> [shared array (shared)] -> <buff>
| A
+---------------------------------------+
write `buff' with WB(ary, &buff[i], obj)
-> if `ary' and `shared' are old, then only `ary'
will be remembered.
-> traverse from `ary'. But `shared' is old, so
that written `obj' is not marked.
It cause WB miss so that shared arrays were WB-unprotected.
(WB-unprotected objects are marked everytime if it is living)
This patch insert WB() for `shared' if it is needed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (ary_reject): may be turned into a shared array during
the given block. [ruby-dev:48101] [Bug #9727]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
array owner is promoted and a shared array is not promoted.
Now, shared array is WB-unprotected so that shared arrays are not
promoted. All objects referred from shared array should be marked
correctly.
[ruby-core:61919] [ruby-trunk - Bug #9718]
* test/ruby/test_array.rb: add a test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
* array.c (rb_ary_initialize): NUM2LONG() may call size.to_int,
ary can be frozen, modified, etc, so recheck after argument
conversion is necessary. [Closes GH-526]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_ary_shuffle_bang, rb_ary_sample): share id_random
instead of no longer used sym_random.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* process.c (rb_execarg_fixup): use RHASH_TBL_RAW and insert write
barriers where appropriate
* vm.c (kwmerge_i): use RHASH_TBL_RAW
* vm.c (HASH_ASET): use rb_hash_aset instead of calling directly into
st_insert
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_ary_or): lhs elements are prefered, so should not
replace with rhs elements.
* test/ruby/test_array.rb (test_OR_in_order): import the test failed
by r43969 from rubyspec/core/array/union_spec.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (rb_hash): detect recursion for all `hash' methods. each
`hash' methods no longer need to use rb_exec_recursive().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): for declaration
argument list of rb_block_call_func.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43910 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
* array.c: reduce use of RARRAY_LEN and ARY_CAPA when object is not
modified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_ary_uniq): use rb_hash_values(), as well as the case no
block is given.
* internal.h: define rb_hash_values() as internal API.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_ary_uniq): set class of the return value to the receiver
class. fix failure in TestArray#test_array_subclass.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_ary_uniq): remove no longer used local variables since
r43194.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
there are not new relations.
* enum.c (enum_sort_by): ditto.
* struct.c (setup_struct): use RARRAY_RAWPTR().
* vm_eval.c (yield_under): ditto.
* ext/pathname/pathname.c (path_entries): use RARRAY_AREF().
* ext/pathname/pathname.c (path_s_glob): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
make it normal object.
* array.c (rb_ary_modify): use RARRAY_PTR_USE() without WB because
there are not new relations.
* array.c (ary_ensure_room_for_unshift): use RARRAY_RAWPTR() because
there are not new relations.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
At least on my environments, I don't see any errors
with many trials. Please tell us if you find any GC bugs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
* array.c (rb_ary_initialize): use ary_memfill().
* array.c (rb_ary_fill): ditto.
* array.c (rb_ary_slice_bang): use RARRAY_RAWPTR() because
this code creates no new references.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Making non-shady shared array causes SEGV (see rubyci).
It seems a bug around shared array.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_ary_modify, ary_make_partial, rb_ary_splice,
rb_ary_replace, rb_ary_eql, rb_ary_compact_bang):
use RARRAY_RAWPTR() instead of RARRAY_PTR().
* array.c (rb_ary_shift): use RARRAY_PTR_USE() without WB because
there are not new relations.
* array.c (ary_ensure_room_for_unshift): ditto.
* array.c (rb_ary_sort_bang): ditto.
* array.c (rb_ary_delete_at): ditto.
* array.c (rb_ary_reverse_m): use RARRAY_RAWPTR() because
there are not new relations.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42072 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
because this operation creates a reference to Qnil.
* array.c (ary_make_shared, rb_ary_store, rb_ary_shift_m,
rb_ary_splice, rb_ary_resize, rb_ary_fill): use ary_mem_clear()
instead of rb_mem_clear().
* array.c (ary_make_shared): use RARRAY_RAWPTR() instead of RARRAY_PTR().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
with write barrier. If ary is promoted, use write barrier correctly.
* array.c (rb_ary_cat, rb_ary_unshift_m, rb_ary_dup,
rb_ary_sort_bang, rb_ary_replace, rb_ary_plus): use ary_memcpy().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
RARRAY_PTR. In this code, there are no "write" operation.
* array.c (rb_ary_equal): ditto.
* array.c (recursive_equal): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
because VALUE is not defined before including ruby/ruby.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e