summaryrefslogtreecommitdiff
path: root/array.c
AgeCommit message (Collapse)Author
2014-09-22array.c: GC guardnobu
* array.c (rb_ary_splice): prevent replacing array from GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-21* array.c: use rb_equal_opt() for performance improvement.glass
[ruby-core:64954] [Feature #10227] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-08* gc.c: add incremental GC algorithm. [Feature #10137]ko1
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
2014-08-15* array.c (rb_ary_tmp_new): added.ko1
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
2014-07-18array.c: array may be modified in the blocknobu
* 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
2014-07-18optimized any? methodsnobu
* 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
2014-07-11* array.c: Clarify documentation for Array#insert.hsbt
[ruby-core:62934] [Bug #9901] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-18constify parametersnobu
* include/ruby/intern.h: constify `argv` parameters. * include/ruby/ruby.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-14array.c: non-recursive rcombinate0nobu
* 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
2014-06-14array.c: non-recursive rpermute0nobu
* 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
2014-06-14array.c: non-recursive permute0nobu
* array.c (permute0): remove recursion, by looping with indexes stored in `p`. [ruby-core:63103] [Bug #9932] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-14array.c: combinate0nobu
* array.c (combinate0): extract. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-13array.c: combination on a shared copynobu
* 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
2014-06-13array.c: yield_indexed_valuesnobu
* array.c (yield_indexed_values): extract from permute0(), rpermute0(), and rcombinate0(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-13array.c: fix array sizenobu
* 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
2014-05-24* array.c: [DOC] Clarify default argument for Array.new.zzak
By @Elffers [Fixes GH-610] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-24* array.c: [DOC] Add more documents to shuffle! and shuffle.hsbt
Contributed by @JuanitoFatas [ci skip][fix GH-612] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-20use predefined IDsnobu
* array.c (rb_ary_equal), hash.c (hash_equal): use predefined IDs, `to_ary` and `to_hash` respectively. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-11* array.c (ARY_SET): added.ko1
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
2014-04-11* array.c: make shared arrays WB-protected objects.ko1
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
2014-04-11array.c: maybe shared arraynobu
* 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
2014-04-10* array.c (rb_ary_modify): remember shared array owner if a sharedko1
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
2014-03-14[DOC] add links to `Object#hash`nobu
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
2014-02-06array.c: comment why rb_ary_modify is needed twicenobu
* 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
2014-01-09* array.c: rdoc clarification for <=>marcandre
* file.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-06array.c: return first unique element in Array#uniqtmm1
* array.c (ary_add_hash): Fix consistency issue between Array#uniq and Array#uniq! [Bug #9340] [ruby-core:59457] * test/ruby/test_array.rb (class TestArray): regression test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-01* array.c (rb_ary_zip): use ALLOCV_N() instead of ALLOCA_N().glass
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-23* array.c: Have to_h raise on elements that are not key-value pairs [#9239]marcandre
* enum.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-20* include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN intoko1
RB_OBJ_WRITE and RB_OBJ_WRITTEN. * array.c, class.c, compile.c, hash.c, internal.h, iseq.c, proc.c, process.c, re.c, string.c, variable.c, vm.c, vm_eval.c, vm_insnhelper.c, vm_insnhelper.h, vm_method.c: catch up this change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44299 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-13* array.c: fix comment to remove the word "shady".ko1
* variable.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-11* array.c: More doc examples for Array#{map|collect}{!} using both formsmarcandre
* enum.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-10array.c, hash.c: add saltnobu
* array.c (rb_ary_hash): add salt to differentiate false and empty array. [ruby-core:58993] [Bug #9231] * hash.c (rb_any_hash, rb_hash_hash): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08array.c: id_randomnobu
* 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
2013-12-08* array.c (rb_ary_shuffle_bang, rb_ary_sample): rename local variables.ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44065 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08* array.c (rb_ary_shuffle_bang, rb_ary_sample): checkktsj
unknown keywords. * test/ruby/test_array.rb (test_shuffle, test_sample): tests for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08* array.c (rb_ary_or): use RHASH_TBL_RAW instead of RHASH_TBLcharliesome
* 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
2013-12-05array.c: prefer lhs elementsnobu
* 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
2013-12-03hash.c: detect recursion for allnobu
* 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
2013-12-03* array.c (rb_ary_uniq_bang): remove duplicate code.glass
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-03* array.c (ary_add_hash): set and return values because string keysglass
will be frozen. [ruby-core:58809] [Bug #9202] * array.c (rb_ary_uniq_bang): ditto. * array.c (rb_ary_or): ditto. * array.c (rb_ary_uniq): ditto. * test/ruby/test_array.rb: tests for above. The patch is from normalperson (Eric Wong). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29ruby/ruby.h: RB_BLOCK_CALL_FUNC_ARGLISTnobu
* 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
2013-11-29array.c, enum.c, range.c: rb_block_call_func compatiblenobu
* array.c (take_i), range.c (first_i): make rb_block_call_func compatible. * enum.c (collect_all, DEFINE_ENUMFUNCS): add blockarg. * enum.c ({min,max,minmax,chunk,slicebefore}_ii): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29ruby/ruby.h: add blockarg to rb_block_call_funcnobu
* include/ruby/ruby.h (rb_block_call_func): add blockarg. block function can take block argument, e.g., proc {|&blockarg| ...}. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-26should not ignore the rest of recursive constructsnobu
* array.c (rb_ary_hash): should not ignore the rest of recursive constructs. * hash.c (rb_hash_hash): ditto. * range.c (range_hash): ditto. * struct.c (rb_struct_hash): ditto. * test/-ext-/test_recursion.rb (TestRecursion): separate from test/ruby/test_thread.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-25* internal.h: do not use ruby_sized_xrealloc() and ruby_sized_xfree()ko1
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-07* array.c: [DOC] Add note about negative indices in Array overviewzzak
By @ckaenzig [Fixes GH-427] https://github.com/ruby/ruby/pull/427 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-07* array.c (rb_ary_shuffle_bang): use RARRAY_PTR_USE() without WBglass
because there are not new relations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-07* array.c (rb_ary_sample): use rb_ary_dup().glass
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-06* array.c (rb_ary_shift_m): use RARRAY_PTR_USE() without WB becauseglass
there are not new relations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-06* array.c (rb_ary_reverse): use RARRAY_PTR_USE().glass
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e