summaryrefslogtreecommitdiff
path: root/array.c
AgeCommit message (Collapse)Author
2013-05-26* hash.c (rb_hash_tbl_raw), internal.h: added.ko1
Returns st_table without shading hash. * array.c: use rb_hash_tbl_raw() for read-only purpose. * compile.c (iseq_compile_each): ditto. * gc.c (count_objects): ditto. * insns.def: ditto. * process.c: ditto. * thread.c (clear_coverage): ditto. * vm_insnhelper.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* gc.c: support RGENGC. [ruby-trunk - Feature #8339]ko1
See this ticet about RGENGC. * gc.c: Add several flags: * RGENGC_DEBUG: if >0, then prints debug information. * RGENGC_CHECK_MODE: if >0, add assertions. * RGENGC_PROFILE: if >0, add profiling features. check GC.stat and GC::Profiler. * include/ruby/ruby.h: disable RGENGC by default (USE_RGENGC == 0). * array.c: add write barriers for T_ARRAY and generate sunny objects. * include/ruby/ruby.h (RARRAY_PTR_USE): added. Use this macro if you want to access raw pointers. If you modify the contents which pointer pointed, then you need to care write barrier. * bignum.c, marshal.c, random.c: generate T_BIGNUM sunny objects. * complex.c, include/ruby/ruby.h: add write barriers for T_COMPLEX and generate sunny objects. * rational.c (nurat_s_new_internal), include/ruby/ruby.h: add write barriers for T_RATIONAL and generate sunny objects. * internal.h: add write barriers for RBasic::klass. * numeric.c (rb_float_new_in_heap): generate sunny T_FLOAT objects. * object.c (rb_class_allocate_instance), range.c: generate sunny T_OBJECT objects. * string.c: add write barriers for T_STRING and generate sunny objects. * variable.c: add write barriers for ivars. * vm_insnhelper.c (vm_setivar): ditto. * include/ruby/ruby.h, debug.c: use two flags FL_WB_PROTECTED and FL_OLDGEN. * node.h (NODE_FL_CREF_PUSHED_BY_EVAL, NODE_FL_CREF_OMOD_SHARED): move flag bits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* include/ruby/ruby.h: constify RBasic::klass and addko1
RBASIC_CLASS(obj) macro which returns a class of `obj'. This change is a part of RGENGC branch [ruby-trunk - Feature #8339]. * object.c: add new function rb_obj_reveal(). This function reveal interal (hidden) object by rb_obj_hide(). Note that do not change class before and after hiding. Only permitted example is: klass = RBASIC_CLASS(obj); rb_obj_hide(obj); .... rb_obj_reveal(obj, klass); TODO: API design. rb_obj_reveal() should be replaced with others. TODO: modify constified variables using cast may be harmful for compiler's analysis and optimizaton. Any idea to prohibt inserting RBasic::klass directly? If rename RBasic::klass and force to use RBASIC_CLASS(obj), then all codes such as `RBASIC(obj)->klass' will be compilation error. Is it acceptable? (We have similar experience at Ruby 1.9, for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)". * internal.h: add some macros. * RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal object. * RBASIC_SET_CLASS(obj, cls) set RBasic::klass. * RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS without write barrier (planned). * RCLASS_SET_SUPER(a, b) set super class of a. * array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c, file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c, parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c, string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c: Use above macros and functions to access RBasic::klass. * ext/coverage/coverage.c, ext/readline/readline.c, ext/socket/ancdata.c, ext/socket/init.c, * ext/zlib/zlib.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13* *.c, parse.y, insns.def: use RARRAY_AREF/ASET macroko1
instead of using RARRAY_PTR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24* array.c: Improve rdoc for eql?marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24* array.c: Fix documentation for Array#index and #replace aliaseszzak
Based on a patch by @phiggins [Fixes GH-282] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-22enhanced Array#delete_if docs by johnnymugshsbt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-13* array.c: rdoc tweak for include?marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-12* array.c: Document synonymous methods, by windwiny [GH-277]zzak
* bignum.c: ditto * complex.c: ditto * dir.c: ditto * encoding.c: ditto * enumerator.c: ditto * numeric.c: ditto * proc.c: ditto * re.c: ditto * string.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-09* internal.h (MUL_OVERFLOW_SIGNED_INTEGER_P): New macro.akr
(MUL_OVERFLOW_FIXNUM_P): Ditto. (MUL_OVERFLOW_LONG_P): Ditto. * array.c (rb_ary_product): Don't overflow on signed integer multiplication. * numeric.c (fix_mul): Ditto. (int_pow): Ditto. * rational.c (f_imul): Ditto. * insns.def (opt_mult): Ditto. * thread.c (sleep_timeval): Don't overflow on signed integer addition. * bignum.c (rb_int2big): Don't overflow on signed integer negation. (rb_big2ulong): Ditto. (rb_big2long): Ditto. (rb_big2ull): Ditto. (rb_big2ll): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-04reduce overhead of TYPEnobu
* array.c (ary_join_1): reduce overhead of TYPE(). * eval.c (rb_frozen_class_p, rb_mod_{append,prepend}_features): ditto. * string.c (rb_to_id): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-23* array.c (take_items): honor encoding of class name.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39882 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-23vm_eval.c: preserve passed_blocknobu
* vm_eval.c (check_funcall_respond_to): preserve passed_block, which is modified in vm_call0_body() via vm_call0(), and caused a bug of rb_check_funcall() by false negative result of rb_block_given_p(). re-fix [ruby-core:53650] [Bug #8153]. [ruby-core:53653] [Bug #8154] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-22* array.c: Avoid zip bug by not using obsolete rb_check_block_call [Bug #8153]marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-17* array.c: Typo in Array#delete by Timo Sand [GH fixes #258]zzak
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-17* array.c: fix rdoc. [ruby-core:53485] [ruby-trunk - Bug #8108]ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-01* array.c: typo in comment patch by Nami-Doc [Github fixes #253]zzak
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23* array.c: Fix rdoc for flatten!marcandre
* hash.c: Correct rdoc for reject! git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23* array.c: Document #<=> return values and formattingzzak
* bignum.c: ditto * file.c: ditto * object.c: ditto * numeric.c: ditto * rational.c: ditto * string.c: ditto * time.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-23* array.c (rb_ary_diff, rb_ary_and, rb_ary_or): Document return orderzzak
[RubySpec #7803 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-19* array.c: Fix typo in class documentationeregon
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-19* object.c: rdoc formatting for Kernel#Array()zzak
* array.c: Add rdoc for Array() method to Creating Arrays section git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-08* array.c (rb_ary_dup): reverted r39004. see [Bug #7768], and theusa
release manager finailly decided to revert it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-01* array.c (rb_ary_dup): make returned array the same class as the originalcharliesome
array [Bug #7768] [ruby-core:51792] * test/ruby/test_array.rb (class TestArray): add test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-30* array.c (rb_ary_bsearch): Fix r38986 (typo) [Bug #7726]marcandre
* range.c (range_bsearch): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-30* array.c (rb_ary_bsearch): Fix r38986 (missing whitespace)marcandre
* range.c (range_bsearch): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-30* array.c (rb_ary_bsearch): Raise TypeError on bad return from blockmarcandre
* range.c (range_bsearch): ditto * test/ruby/test_array.rb (class): Test for above * test/ruby/test_range.rb (class): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-30* array.c (rb_ary_bsearch): Return enumerator if no block [#7725]marcandre
* range.c (range_bsearch): ditto * test/ruby/test_array.rb: Test for above * test/ruby/test_range.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-29* array.c: Improve documentation abouteregon
comparison by hash for concerned methods. [ruby-core:51266] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-24* enum.c (enum_zip): Fix error messagemarcandre
* array.c (take_items): Same, for Array#zip [Bug #7706] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29adjust stylenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02* array.c, enum.c, insns.def, io.c, numeric.c, parse.y, process.c,ko1
range.c: use prepared IDs. A patch from charliesome (Charlie Somerville). [Bug #7495] * common.mk: add dependency to id.h. * common.mk: replace ID_H_INCLUDES with id.h. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-01adjust style.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26* array.c: Fix rdoc for Array#delete [#7437]marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-25array.c: refactoring of rb_ary_delete_same()shirosaki
* array.c (ary_resize_smaller): new function to resize array. * array.c (rb_ary_delete): refactoring to extract a function. * array.c (rb_ary_delete_same): refactoring. It renames function, reduces duplicated code and removes unused code. * gc.c (wmap_final_func): follow the above change. * internal.h (rb_ary_delete_same): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-25* array.c: fixes for the updated documentation in r35858:eregon
Typos and #take/#drop accept to take/drop 0 elements. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24Fix WeakRef finalizeshirosaki
* array.c (rb_ary_delete_same_obj): new function for WeakRef. This deletes same objects as item argument in the array. * internal.h (rb_ary_delete_same_obj): add a declaration. * gc.c (wmap_final_func): remove WeakRef object reference from the array. rb_ary_delete() is not usable because it uses rb_equal() to compare object references. * gc.c (wmap_finalize): remove recycled object references from weak map hash properly. How to get object reference from object id was wrong. st_delete() doesn't work properly if key and value arguments are same. The key of obj2wmap is referenced object and the value of obj2wmap is WeakRef array. * gc.c (wmap_aset): obj2wmap should contain WeakRef array in the definition. * test/test_weakref.rb (TestWeakRef#test_not_reference_different_object, TestWeakRef#test_weakref_finalize): add tests for above. [ruby-core:49044] [Bug #7304] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24Fix Segmentation fault at TestArray#test_arefshirosaki
* array.c (rb_ary_aref): fix Segmentation fault at TestArray#test_aref on x64 mingw. Variable argument of rb_scan_args() should be a pointer (VALUE *), but 0 of variable argument seems not equal to null pointer on x64 mingw. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-22Fix cache validity check of requireshirosaki
* array.c (rb_ary_shared_with_p): fix cache validity check. If #pop or #shift has been called against $: or $", the array will be still shared with the snapshot. We check array length for cache validity. [ruby-core:49518] [Bug #7383] * test/ruby/test_require.rb (TestRequire#test_require_with_array_pop, TestRequire#test_require_with_array_shift): add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20* array.c (rb_get_values_at): Improve rdocmarcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20* array.c (rb_ary_bsearch): fix rdoc bug (O(n log n) -> O(log n)).mame
Patch by Charlie Somerville. [ruby-core:49661] [Bug #7409] * range.c (range_bsearch): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-15* range.c (range_bsearch): fix some bugs: a documentation bug, a wrongmame
condition, missed break in switch/case, and workaround for GCC optimization. See [ruby-core:49364] in detail. A great patch from Heesob Park. [Bug #7352] [Feature #4766] * array.c (rb_ary_bsearch): fix similar bug (missed break). * test/ruby/test_range.rb: add two test cases for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-14* array.c (rb_ary_bsearch): add Array#bsearch for binary search.mame
[ruby-core:36390] [Feature #4766] * test/ruby/test_array.rb: add a test for above. * range.c (range_bsearch): add Range#bsearch for binary search. [ruby-core:36390] [Feature #4766] * test/ruby/test_range.rb: add a test for above * NEWS: added the two new methods. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-12* probes.d: add DTrace probe declarations. [ruby-core:27448]tenderlove
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe. * compile.c (rb_insns_name): allowing DTrace probes to access instruction sequence name. * Makefile.in: translate probes.d file to appropriate header file. * common.mk: declare dependencies on the DTrace header. * configure.in: add a test for existence of DTrace. * eval.c (setup_exception): add a probe for when an exception is raised. * gc.c: Add DTrace probes for mark begin and end, and sweep begin and end. * hash.c (empty_hash_alloc): Add a probe for hash allocation. * insns.def: Add probes for function entry and return. * internal.h: function declaration for compile.c change. * load.c (rb_f_load): add probes for `load` entry and exit, require entry and exit, and wrapping search_required for load path search. * object.c (rb_obj_alloc): added a probe for general object creation. * parse.y (yycompile0): added a probe around parse and compile phase. * string.c (empty_str_alloc, str_new): DTrace probes for string allocation. * test/dtrace/*: tests for DTrace probes. * vm.c (vm_invoke_proc): add probes for function return on exception raise, hash create, and instruction sequence execution. * vm_core.h: add probe declarations for function entry and exit. * vm_dump.c: add probes header file. * vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on function entry and return. * vm_exec.c: expose instruction number to instruction name function. * vm_insnshelper.c: add function entry and exit probes for cfunc methods. * vm_insnhelper.h: vm usage information is always collected, so uncomment the functions. 12 19:14:50 2012 Akinori MUSHA <knu@iDaemons.org> * configure.in (isinf, isnan): isinf() and isnan() are macros on DragonFly which cannot be found by AC_REPLACE_FUNCS(). This workaround enforces the fact that they exist on DragonFly. 12 15:59:38 2012 Shugo Maeda <shugo@ruby-lang.org> * vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo), vm_insnhelper.c (vm_search_method): revert r37616 because it's too slow. [ruby-dev:46477] * test/ruby/test_refinement.rb (test_inline_method_cache): skip the test until the bug is fixed efficiently. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09* array.c (rb_ary_splice): fix r37583 doesn't condier the case whennaruse
beg > array length. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09array.c: speedup Array#unshift by using space in shared arraynobu
* array.c: speedup Array#unshift by using space in shared array. [Feature #6638] - when array owns its shared array (ARY_SHARED_NUM == 1), and there is enough space then try unshift values directly into shared array. - when resulting array is big (~>64 items) then make it shared with enough room for future #unshifts, and then insert into shared array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37584 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09array.c: use shared array in rb_ary_slicenobu
* array.c (rb_ary_splice): use shared array in rb_ary_slice. [Feature #6638] - use ary_ensure_room_for_push when rb_ary_slice used to add at the end of array, cause rb_ary_concat use rb_ary_slice. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09array.c: make array really suitable for queuenobu
* array.c (ary_ensure_room_for_push): make array really suitable for queue. [Feature #6638] when array is shared (which happens after Array#shift), and ARY_SHARED_NUM == 1 (which is very often when array used as queue), then make rb_ary_push push directly into shared array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37582 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09array.c: steal shared array's container when ARY_SHARED_NUM == 1nobu
* array.c (rb_ary_modify): steal shared array's container when ARY_SHARED_NUM == 1. [Feature #6638] - Do not allocate new memory in rb_ary_modify when ARY_SHARED_NUM == 1 and length almost same. - Store ARY_CAPA instead of RARRAY_LEN in ary_make_shared, to make it useful. - Fix rb_ary_sort_bang accordantly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-07* array.c: Fix mistake in rdoc of Array#uniq.marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e