aboutsummaryrefslogtreecommitdiffstats
path: root/hash.c
Commit message (Collapse)AuthorAgeFilesLines
...
* hash.c: fix return valuenobu2014-12-191-3/+10
| | | | | | | * hash.c (hash_equal): prefer true than the result of implicit conversion from int returned by rb_eql() to VALUE. [Fix GH-789] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Gather declarations in non-header files.akr2014-11-181-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Include ruby.h and ruby/encoding.h to beakr2014-11-151-3/+1
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (gc_stat_internal): add compatible layer.ko12014-11-141-1/+1
| | | | | | | | | | | | | | | | | | | | | From Ruby 2.2, keys of GC.stat are changed [Feature #9924]. To provide compatible layer, GC.stat add a default_proc (if default_proc of given Hash object is not set). At first use of this compatible layer of interpreter process, show a warning message like that: program: GC.stat[:total_allocated_object] warning message: "warning: GC.stat keys were changed from Ruby 2.1. In this case, you refer to obsolete `total_allocated_object' (new key is `total_allocated_objects'). Please check <https://bugs.ruby-lang.org/issues/9924> for more information." Pleaes correct my English message :) * hash.c (rb_hash_set_default_proc): export (in internal). * internal.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * rewrite method/block parameter fitting logic to optimizeko12014-11-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | keyword arguments/parameters and a splat argument. [Feature #10440] (Details are described in this ticket) Most of complex part is moved to vm_args.c. Now, ISeq#to_a does not catch up new instruction format. * vm_core.h: change iseq data structures. * introduce rb_call_info_kw_arg_t to represent keyword arguments. * add rb_call_info_t::kw_arg. * rename rb_iseq_t::arg_post_len to rb_iseq_t::arg_post_num. * rename rb_iseq_t::arg_keywords to arg_keyword_num. * rename rb_iseq_t::arg_keyword to rb_iseq_t::arg_keyword_bits. to represent keyword bitmap parameter index. This bitmap parameter shows that which keyword parameters are given or not given (0 for given). It is refered by `checkkeyword' instruction described bellow. * rename rb_iseq_t::arg_keyword_check to rb_iseq_t::arg_keyword_rest to represent keyword rest parameter index. * add rb_iseq_t::arg_keyword_default_values to represent default keyword values. * rename VM_CALL_ARGS_SKIP_SETUP to VM_CALL_ARGS_SIMPLE to represent (ci->flag & (SPLAT|BLOCKARG)) && ci->blockiseq == NULL && ci->kw_arg == NULL. * vm_insnhelper.c, vm_args.c: rewrite with refactoring. * rewrite splat argument code. * rewrite keyword arguments/parameters code. * merge method and block parameter fitting code into one code base. * vm.c, vm_eval.c: catch up these changes. * compile.c (new_callinfo): callinfo requires kw_arg parameter. * compile.c (compile_array_): check the last argument Hash object or not. If Hash object and all keys are Symbol literals, they are compiled to keyword arguments. * insns.def (checkkeyword): add new instruction. This instruction check the availability of corresponding keyword. For example, a method "def foo k1: 'v1'; end" is cimpiled to the following instructions. 0000 checkkeyword 2, 0 # check k1 is given. 0003 branchif 9 # if given, jump to address #9 0005 putstring "v1" 0007 setlocal_OP__WC__0 3 # k1 = 'v1' 0009 trace 8 0011 putnil 0012 trace 16 0014 leave * insns.def (opt_send_simple): removed and add new instruction "opt_send_without_block". * parse.y (new_args_tail_gen): reorder variables. Before this patch, a method "def foo(k1: 1, kr1:, k2: 2, **krest, &b)" has parameter variables "k1, kr1, k2, &b, internal_id, krest", but this patch reorders to "kr1, k1, k2, internal_id, krest, &b". (locate a block variable at last) * parse.y (vtable_pop): added. This function remove latest `n' variables from vtable. * iseq.c: catch up iseq data changes. * proc.c: ditto. * class.c (keyword_error): export as rb_keyword_error(). * common.mk: depend vm_args.c for vm.o. * hash.c (rb_hash_has_key): export. * internal.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: rb_hash_delete does not call the blocknobu2014-10-231-7/+7
| | | | | | | * hash.c (rb_hash_delete): now does not call the block given to the current method. [ruby-core:65861] [Bug #10413] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (rb_any_hash): remove unnecessary dsym checknormal2014-10-091-1/+1
| | | | | | | | gcc (Debian 4.7.2-5) 4.7.2 on x86 generates smaller code this way, as it does not seem to be able to reuse the result of SPECIAL_CONST_P. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* protoize no-arguments functionsnobu2014-09-301-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: [DOC] fix for Hash#store docsnobu2014-09-131-1/+2
| | | | | | | | | * hash.c (rb_hash_aset): fix misleading example which may suggest that Hash.store will return self instead of value - Hash#store is returning value and update itself, as well as Hash#[]=. [Fix GH-715] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c: add incremental GC algorithm. [Feature #10137]ko12014-09-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* optimized any? methodsnobu2014-07-181-0/+48
| | | | | | | | * 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
* * hash.c (ruby_setenv): Fix TestEnv#test_aset failure on Solaris 9.ngoto2014-07-101-5/+21
| | | | | | | | | When name contains '=', ruby_setenv raises Errno::EINVAL. That is the same behavior as Solaris 10. NULL check for malloc return value is also added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: use rb_check_aritynobu2014-07-021-8/+12
| | | | | | | | * hash.c (rb_hash_initialize, rb_hash_fetch_m, rb_hash_default): use rb_check_arity over rb_scan_args. (env_fetch): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: fix memory leaknobu2014-06-261-2/+3
| | | | | | | * hash.c (env_shift): fix memory leak on Windows, free environment strings block always. [ruby-dev:48332] [Bug #9983] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: fix memory leaknobu2014-06-251-11/+9
| | | | | | | | * hash.c (env_select): fix memory leak and crash on Windows, make keys array first instead of iterating on envrion directly. [ruby-dev:48325] [Bug #9978] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: fix dangling pointernobu2014-06-251-3/+5
| | | | | | | * hash.c (env_name): also store a coerced string to get rid of a dangling pointer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: fix memory leaknobu2014-06-251-2/+5
| | | | | | | | * hash.c (ruby_setenv): fix memory leak on Windows, free environment strings block after check for the size. [ruby-dev:48323] [Bug #9977] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: env_namenobu2014-06-251-34/+27
| | | | | | | * hash.c (get_env_ptr, env_name): extract check for bad environment variable name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: prohibit tainted stringsnobu2014-06-251-5/+9
| | | | | | | | * hash.c (env_aset, env_has_key, env_assoc, env_has_value), (env_rassoc, env_key): prohibit tainted strings if $SAFE is non-zero. [Bug #9976] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: unused functions on non-Windowsnobu2014-06-241-2/+0
| | | | | | | * hash.c (invalid_envname, check_envname): not used on platforms other than Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: env_str_transcodenobu2014-06-241-6/+11
| | | | | | | * hash.c (env_str_transcode): convert with replacing invalid/undef characters, on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: replace undefnobu2014-06-241-3/+6
| | | | | | | * hash.c (env_str_new, env_path_str_new): replace invalid or undefined conversions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: frozen PATH envnobu2014-06-241-13/+16
| | | | | | | * hash.c (env_path_str_new): make PATH environment variable string, to be frozen. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h (struct RHash): no longer. [Feature #9889]shyouhei2014-06-231-3/+13
| | | | | | | | | | | | | | | | | | | | * include/ruby/ruby.h (RHASH): ditto. * include/ruby/ruby.h (RHASH_ITER_LEV): deprecated. Will be deleted later. * include/ruby/ruby.h (RHASH_IFNONE): ditto. * internal.h (struct RHash): moved here. * internal.h (RHASH): ditto. * hash.c (rb_hash_iter_lev): do not use this. * hash.c (rb_hash_ifnone): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use predefined IDsnobu2014-05-201-1/+1
| | | | | | | * 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
* hash.c: make rb_hash_keys externnobu2014-05-071-1/+1
| | | | | | * hash.c (rb_hash_keys): make an internal public function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: use ID_SCOPE_SHIFTnobu2014-03-231-1/+2
| | | | | | | * hash.c (rb_any_hash): use ID_SCOPE_SHIFT instead of magic number. [Feature #9425] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: use power-of-two sizes to avoid slow modulo opsnormal2014-03-221-0/+1
| | | | | | | | | | | | | | | | | | * st.c (hash_pos): use bitwise AND to avoid slow modulo op (new_size): power-of-two sizes for hash_pos change (st_numhash): adjust for common keys due to lack of prime modulo [Feature #9425] * hash.c (rb_any_hash): right shift for symbols * benchmark/bm_hash_aref_miss.rb: added to show improvement * benchmark/bm_hash_aref_sym_long.rb: ditto * benchmark/bm_hash_aref_str.rb: ditto * benchmark/bm_hash_aref_sym.rb: ditto * benchmark/bm_hash_ident_num.rb: added to prevent regression * benchmark/bm_hash_ident_obj.rb: ditto * benchmark/bm_hash_ident_str.rb: ditto * benchmark/bm_hash_ident_sym.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] add links to `Object#hash`nobu2014-03-141-0/+2
| | | | | | | 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
* class.c: do nothing if copying selfnobu2014-02-211-0/+2
| | | | | | | | * class.c (rb_mod_init_copy): do nothing if copying self. [ruby-dev:47989] [Bug #9535] * hash.c (rb_hash_initialize_copy): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * hash.c (rb_hash_flatten): fix behavior of flatten(0).glass2014-02-201-3/+10
| | | | | | | | | [ruby-dev:47988] [Bug #9533] * test/ruby/test_array.rb: test for above. patch is from Takeshi Sasaki. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * hash.c (rb_hash_flatten): fix behavior of flatten(-1).glass2014-02-201-5/+9
| | | | | | | | [ruby-dev:47988] [Bug #9533] * test/ruby/test_array.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* insns.def: add opt path for Hash#[] and Hash#[]= used with str literal keystmm12014-01-101-1/+1
| | | | | | | | | | | | | | * insns.def (opt_aref_with): new instruction to optimize Hash#[], removing any allocation overhead when used with a string literal key. Patch by normalperson (Eric Wong). [ruby-core:59640] [Bug #9382] * insns.def (opt_aset_with): new instruction to optimize Hash#[]= * compile.c (iseq_compile_each): compiler shortcuts for new instructions * hash.c (static VALUE rb_hash_compare_by_id_p): fix documentation for Hash#compare_by_identity to reflect frozen string sharing * test/ruby/test_hash.rb (class TestHash): test for new behavior git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * hash.c (rb_objid_hash): should return `long'. brushup r44534.usa2014-01-091-4/+3
| | | | | | | * object.c (rb_obj_hash): follow above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * hash.c (rb_any_hash): should treat the return value of rb_objid_hash()usa2014-01-091-1/+2
| | | | | | | | as `long', because ruby assumes the object id of an object is `long'. this fixes test failures on mswin64 introduced at r44525. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* object.c: hash value from objid with saltnobu2014-01-081-3/+12
| | | | | | | | | * hash.c (rb_objid_hash): return hash value from object ID with a salt, extract from rb_any_hash(). * object.c (rb_obj_hash): return same value as rb_any_hash(). fix r44125. [ruby-core:59638] [Bug #9381] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * hash.c (rb_hash_keys): make rb_hash_keys() static.glass2014-01-011-1/+1
| | | | | | | | | | it is no longer used from array.c since r43969. the patch is from normalperson (Eric Wong). [ruby-core:59449] [Feature #9336] * internal.h: remove definition of rb_hash_keys(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: remove dead codenobu2013-12-261-26/+1
| | | | | | | * hash.c (rb_hash_reject): remove dead code for the deprecated behavior. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: no extra states copynobu2013-12-261-1/+1
| | | | | | | * hash.c (HASH_REJECT_COPY_EXTRA_STATES): turn off the old behavior, copying extra states by accident. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: extra statesnobu2013-12-241-1/+1
| | | | | | | * hash.c (rb_hash_reject): use words "extra states". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: fix infinite loopnobu2013-12-231-0/+1
| | | | | | | * hash.c (has_extra_methods): traverse ancestors, and fix infinite loop. [Bug #9275] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: fix commit missnobu2013-12-231-3/+3
| | | | | | | * hash.c (HAS_EXTRA_STATES): remove extra parenthesis. [Bug #9275] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: reduce warningnobu2013-12-231-2/+13
| | | | | | | * hash.c (HAS_EXTRA_STATES): warn extra states only when something differ. [ruby-core:59254] [Bug #9275] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: rewordnobu2013-12-231-10/+9
| | | | | | | * hash.c (HAS_EXTRA_STATES, rb_hash_reject): use words "extra states". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/ruby.h: rename OBJ_WRITE and OBJ_WRITTEN intoko12013-12-201-3/+3
| | | | | | | | | | | | 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
* hash.c: revertnobu2013-12-171-1/+1
| | | | | | | | * hash.c (rb_hash_reject): revert to deprecated behavior, with warnings, due to compatibility for HashWithDifferentAccess. [ruby-core:59154] [Bug #9223] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: add warningsnobu2013-12-171-12/+31
| | | | | | * hash.c (rb_hash_reject): warn attributes in detail more. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: typonobu2013-12-161-1/+1
| | | | | | * hash.c (rb_hash_reject): fix typo in macro name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: warnings in rb_hash_rejectnobu2013-12-161-4/+30
| | | | | | | | * hash.c (rb_hash_dup_empty): split from rb_hash_dup. * hash.c (rb_hash_reject): add warnings (currently suppressed). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: refactor loopnobu2013-12-161-9/+3
| | | | | | * hash.c (rb_hash): rewrite with while instead of goto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e