aboutsummaryrefslogtreecommitdiffstats
path: root/st.c
Commit message (Collapse)AuthorAgeFilesLines
* st.c: fix collision statistics [ci skip]nobu2016-03-301-6/+4
| | | | | | | | * st.c (stat_col): get rid of NaN. * st.c (collision_check): define before used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* disable unaligned word accessnobu2016-01-151-0/+4
| | | | | | | * include/ruby/defines.h, st.c: disable unaligned word access with gcc 6 or later. [Bug #11831] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: constify st_table* in private functionsnormal2015-07-291-5/+9
| | | | | | | | | | | | | | | | | | Minor size reduction on 32-bit x86: text data bss dec hex filename 13742 24 0 13766 35c6 st.o 14166 24 0 14190 376e st-orig.o Public API change to be proposed separately. * st.c (find_entry): constify st_table* (find_packed_index_from): ditto (find_packed_index): ditto (get_keys): ditto (get_values): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: fix arguments order to comparenobu2015-07-241-5/+5
| | | | | | | | * st.c (EQUAL, st_delete_safe): fix arguments order to compare function, searching key is the first and stored key is the second always. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c: get rid of VC++'s warnings of C4700 (uninitialized localusa2015-07-021-7/+7
| | | | | | | | | variable used). I think that these are wrong, but should shut them up. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: use ccan linked-list (try 3)normal2015-06-291-162/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This improves the bm_vm2_bighash benchmark significantly by removing branches during insert, but slows down anything requiring iteration with the more complex loop termination checking. Speedup ratio of 1.10 - 1.20 is typical for the vm2_bighash benchmark. v3 - st_head calculates list_head address in two steps to avoid a bug in old gcc 4.4 (Debian 4.4.7-2) bug which incorrectly warned with: warning: dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules * include/ruby/st.h (struct st_table): hide struct list_head * st.c (struct st_table_entry): adjust struct (head, tail): remove shortcut macros (st_head): new wrapper function (st_init_table_with_size): adjust to new struct and API (st_clear): ditto (add_direct): ditto (unpack_entries): ditto (rehash): ditto (st_copy): ditto (remove_entry): ditto (st_shift): ditto (st_foreach_check): ditto (st_foreach): ditto (get_keys): ditto (get_values): ditto (st_values_check): ditto (st_reverse_foreach_check): ditto (unused) (st_reverse_foreach): ditto (unused) [ruby-core:69726] [Misc #10278] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "st.c: use ccan linked-list (try 2)"normal2015-06-261-120/+162
| | | | | | | | This reverts commit r51044 Still getting failure notices from ko1's CI machine. ref: g3qkqn git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: use ccan linked-list (try 2)normal2015-06-261-162/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This improves the bm_vm2_bighash benchmark significantly by removing branches during insert, but slows down anything requiring iteration with the more complex loop termination checking. Speedup ratio of 1.10 - 1.20 is typical for the vm2_bighash benchmark. * include/ruby/st.h (struct st_table): hide struct list_head * st.c (struct st_table_entry): adjust struct (head, tail): remove shortcut macros (st_head): new wrapper function (st_init_table_with_size): adjust to new struct and API (st_clear): ditto (add_direct): ditto (unpack_entries): ditto (rehash): ditto (st_copy): ditto (remove_entry): ditto (st_shift): ditto (st_foreach_check): ditto (st_foreach): ditto (get_keys): ditto (get_values): ditto (st_values_check): ditto (st_reverse_foreach_check): ditto (unused) (st_reverse_foreach): ditto (unused) [ruby-core:69726] [Misc #10278] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: include ccan/list/list.h to test buildnormal2015-06-261-0/+1
| | | | | | | | | | | | I suspect the build failures with r51034 ("st.c: use ccan linked-list") on ko1's CI machine was due to me forgetting to update common.mk :x Lets see what happens when I only include ccan/list/list.h Will followup with appropriate reverts or reinstating the rest of r51034 along with a common.mk update as I watch CI build. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert r51034 "st.c: use ccan linked-list"normal2015-06-251-121/+162
| | | | | | | | | | | | | | | | | | | | | | | | | Maybe this will stop mysterious CI failures from ko1@sasada-8core: リビジョン 51034 です。 make[1]: ディレクトリ `/mnt/sdb1/ruby/build' に入ります ../trunk/revision.h unchanged make[1]: ディレクトリ `/mnt/sdb1/ruby/build' から出ます make[1]: ディレクトリ `/mnt/sdb1/ruby/build' に入ります config.guess already exists config.sub already exists generating ../trunk/ext/ripper/ripper.c make[2]: ディレクトリ `/mnt/sdb1/ruby/trunk/ext/ripper' に入ります extracting ripper.y from ../../parse.y id.h not found in ["../.."] make[2]: *** [ripper.y] エラー 1 make[2]: ディレクトリ `/mnt/sdb1/ruby/trunk/ext/ripper' から出ます make[1]: *** [../trunk/ext/ripper/ripper.c] エラー 2 make[1]: ディレクトリ `/mnt/sdb1/ruby/build' から出ます make: [up] エラー 2 (無視されました) make: *** [.rbconfig.time] セグメンテーション違反です Command exited with non-zero status 2 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: use ccan linked-listnormal2015-06-251-162/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This improves the bm_vm2_bighash benchmark significantly by removing branches during insert, but slows down anything requiring iteration with the more complex loop termination checking. Speedup ratio of 1.10 - 1.20 is typical for the vm2_bighash benchmark. * include/ruby/st.h (struct st_table): hide struct list_head * st.c (struct st_table_entry): adjust struct (head, tail): remove shortcut macros (st_head): new wrapper function (st_init_table_with_size): adjust to new struct and API (st_clear): ditto (add_direct): ditto (unpack_entries): ditto (rehash): ditto (st_copy): ditto (remove_entry): ditto (st_shift): ditto (st_foreach_check): ditto (st_foreach): ditto (get_keys): ditto (get_values): ditto (st_values_check): ditto (st_reverse_foreach_check): ditto (unused) (st_reverse_foreach): ditto (unused) [ruby-core:69726] [Misc #10278] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c: move Hash specific functionsnobu2015-01-231-22/+2
| | | | | | | | | | | | | * hash.c (rb_ident_hash): move compare_by_identity specific function from st.c. * hash.c (rb_ident_hash_new): ditto from thread.c. * st.c (st_numhash): remove ruby's Hash specific implementation. * thread.c (recursive_list_access): use rb_ident_hash_new(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix flonum hashing regression from r45384normal2015-01-221-0/+9
| | | | | | | | | | * st.c (st_numhash): mix float value for flonum * hash.c (rb_any_hash): ditto * benchmark/bm_hash_aref_flo.rb: new benchmark * benchmark/bm_hash_ident_flo.rb: ditto [Bug #10761] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Include ruby.h and ruby/encoding.h to beakr2014-11-151-1/+0
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: STATIC_ASSERTnobu2014-11-131-3/+6
| | | | | | * st.c: include "internal.h" for STATIC_ASSERT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: update st_reverse_foreachnobu2014-10-041-29/+111
| | | | | | * st.c (st_reverse_foreach): update as st_foreach(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c (new_size): use next_pow2 functionnormal2014-10-021-4/+21
| | | | | | | | | | | | | | | | | | | Reduces object size slightly on x86-64: text data bss dec hex filename 2782359 22400 71880 2876639 2be4df ruby.orig 2781831 22400 71880 2876111 2be2cf ruby.pow2 And on 32-bit x86: text data bss dec hex filename 2814751 12100 30552 2857403 2b99bb ruby.orig 2814051 12100 30552 2856703 2b96ff ruby.pow2 This is not a performance-critical function, but the smaller icache footprint seems worth it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c (do_hash_bin): unused macro.nari2014-09-211-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c (numberof): unused. internal.h has same macro.nari2014-09-211-2/+0
| | | | | | * node.c (F_CUSTOM2): unused. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* UNALIGNED_WORD_ACCESS on ppc64nobu2014-07-231-0/+1
| | | | | | | | | | * include/ruby/defines.h, siphash.c, st.c (UNALIGNED_WORD_ACCESS): add PowerPC64 too, which is capable to access unaligned words. patched by Gustavo Frederico Temple Pedrosa in [ruby-core:63937]. [Feature #10081] * regint.h (PLATFORM_UNALIGNED_WORD_ACCESS): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46915 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: fix uninitialized variablenobu2014-07-061-3/+3
| | | | | | | * st.c (st_update): old_key is uninitialized by jump to the label unpacked. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: remove equality checksnobu2014-07-061-12/+0
| | | | | | | * st.c (st_update): remove equality checks, callers should ensure the equality, otherwise the behavior is undefined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: re-calc hash_val before addingnobu2014-07-061-0/+2
| | | | | | | | * st.c (st_update): re-calculate hash_val before adding if key was changed, otherwise cannot access the newly added element if it has different hash value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: update the key too if changednobu2014-07-061-0/+18
| | | | | | | * st.c (st_update): fix a bug that the key was not updated even if it was changed by the callback function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* configure.in, missing.h: jemalloc manglingnobu2014-06-051-0/+4
| | | | | | | | | | | | * configure.in (with-jemalloc): also check for header, for ABIs which JEMALLOC_MANGLE is needed, i.e., Mach-O and PE-COFF platforms. [ruby-core:62939] [Feature #9113] * include/ruby/missing.h: include alternative malloc header to replace memory management functions. * dln.c, io.c, parse.y, st.c: undef malloc family before re-definition to suppress warnings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c (st_foreach_check): chnage start point of search at checktarui2014-04-201-5/+11
| | | | | | | from top to current. [ruby-dev:48047] [Bug #9646] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c (st_init_table_with_size): update commentnormal2014-03-311-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: use power-of-two sizes to avoid slow modulo opsnormal2014-03-221-57/+17
| | | | | | | | | | | | | | | | | | * 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
* * st.c (st_update): remove unnecessary assignmentnormal2014-03-141-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c (st_foreach): fix type of hash. not st_data_t but st_index_t.tarui2014-03-041-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: hash_posnobu2014-01-181-20/+21
| | | | | | * st.c (hash_pos): extract mapping hash values to hash bins index. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: tweaked commentduerst2013-12-051-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c: add st_values() and st_values_check().glass2013-11-281-0/+41
| | | | | | | | | * include/ruby/st.h: add prototypes for above. * hash.c (rb_hash_values): use st_values_check() for performance improvement if VALUE and st_data_t are compatible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c (st_keys): fix not to use Qundef in st.c.glass2013-11-281-7/+19
| | | | | | | | * include/ruby/st.h: define modified prototype. * hash.c (rb_hash_keys): use modified st_keys(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c (st_keys): define st_keys(). it writes each key to buffer.glass2013-11-271-0/+29
| | | | | | | | | | | | | * hash.c (rb_hash_keys): use st_keys() for performance improvement if st_data_t and VALUE are compatible. * st.h: define macro ST_DATA_COMPATIBLE_P() to predicate whether st_data_t and passed type are compatible. * configure.in: check existence of builtin function to use in ST_DATA_COMPATIBLE_P(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c, st.c: fix for ST_CHECKnobu2013-11-141-5/+5
| | | | | | | | * hash.c (foreach_safe_i, hash_foreach_iter): deal with error detected by ST_CHECK. * st.c (st_foreach_check): call with non-error argument in normal case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: revert st_keysnobu2013-10-101-31/+0
| | | | | | * st.c: revert st_keys() at r43238. VALUE cannot be in st.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43243 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c (st_keys): define st_keys() for performance improvement ofglass2013-10-101-0/+31
| | | | | | | | | | Hash#keys and Array#uniq. * st.h: ditto. * hash.c (rb_hash_keys): use st_keys(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c (st_locale_insensitive_strcasecmp): Renamed from st_strcasecmp.akr2013-07-161-3/+3
| | | | | | | | | | | | (st_locale_insensitive_strncasecmp): Renamed from st_strncasecmp. * include/ruby/st.h: Follow above changes. * include/ruby/ruby.h: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * configure.in: revert r42008. strcasecmp() uses the current locale.glass2013-07-161-2/+0
| | | | | | | | * include/ruby/ruby.h: ditto. * st.c (st_strcasecmp): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * configure.in: check strcasecmp().glass2013-07-161-0/+2
| | | | | | | | | | * include/ruby/ruby.h: use strcasecmp() as st_strcasecmp() if it exists. * st.c (st_strcasecmp): define the function only if strcasecmp() doesn't exist. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c (st_shift): remove unused variable.nobu2013-04-251-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * benchmark/bm_hash_shift.rb: add benchmark for Hash#shiftcharliesome2013-04-251-0/+29
| | | | | | | | | | | | | | | * hash.c (rb_hash_shift): use st_shift if hash is not being iterated to delete element without iterating the whole hash. * hash.c (shift_i): remove function * include/ruby/st.h (st_shift): add st_shift function * st.c (st_shift): ditto [Bug #8312] [ruby-core:54524] Patch by funny-falcon git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fixed comment typo, found by @ThePablickzzak2013-04-191-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * regint.h: fix typo: _M_AMD86 -> _M_AMD64.naruse2013-04-101-1/+1
| | | | | | | | * siphash.c: ditto. * st.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st_update passes the key in st_tableshirosaki2012-11-171-0/+2
| | | | | | | | | | | * st.c (st_update): pass the key in st_table so that we can free memory of the key in st_table when deleting. [ruby-core:49220] [Bug #7330] * test/-ext-/st/test_update.rb (Bug::StTable#test_pass_objects_in_st_table): add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c (st_foreach_check, st_foreach): remove ancient check. Thisnobu2012-03-311-2/+0
| | | | | | | check are from initial ordered hash commit when first entry were created with entry->fore = entry->back = entry. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c (st_delete): use real_entries in st_delete for packed tablesnobu2012-03-311-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c (st_foreach_check): remove the entry by replacing with nevernobu2012-03-301-8/+13
| | | | | | | when ST_DELETE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * st.c (st_update): pass pointer to key to the callback function.nobu2012-03-291-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e