summaryrefslogtreecommitdiff
path: root/st.c
AgeCommit message (Collapse)Author
2015-07-29st.c: constify st_table* in private functionsnormal
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
2015-07-24st.c: fix arguments order to comparenobu
* 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
2015-07-02* st.c: get rid of VC++'s warnings of C4700 (uninitialized localusa
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
2015-06-29st.c: use ccan linked-list (try 3)normal
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
2015-06-26Revert "st.c: use ccan linked-list (try 2)"normal
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
2015-06-26st.c: use ccan linked-list (try 2)normal
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
2015-06-26st.c: include ccan/list/list.h to test buildnormal
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
2015-06-25Revert r51034 "st.c: use ccan linked-list"normal
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
2015-06-25st.c: use ccan linked-listnormal
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
2015-01-23hash.c: move Hash specific functionsnobu
* 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
2015-01-22fix flonum hashing regression from r45384normal
* 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
2014-11-15* internal.h: Include ruby.h and ruby/encoding.h to beakr
includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13internal.h: STATIC_ASSERTnobu
* 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
2014-10-04st.c: update st_reverse_foreachnobu
* 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
2014-10-02st.c (new_size): use next_pow2 functionnormal
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
2014-09-21* st.c (do_hash_bin): unused macro.nari
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-21* st.c (numberof): unused. internal.h has same macro.nari
* node.c (F_CUSTOM2): unused. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-23UNALIGNED_WORD_ACCESS on ppc64nobu
* 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
2014-07-06st.c: fix uninitialized variablenobu
* 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
2014-07-06st.c: remove equality checksnobu
* 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
2014-07-06st.c: re-calc hash_val before addingnobu
* 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
2014-07-06st.c: update the key too if changednobu
* 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
2014-06-05configure.in, missing.h: jemalloc manglingnobu
* 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
2014-04-20 * st.c (st_foreach_check): chnage start point of search at checktarui
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
2014-03-31st.c (st_init_table_with_size): update commentnormal
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-22st.c: use power-of-two sizes to avoid slow modulo opsnormal
* 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
2014-03-14* st.c (st_update): remove unnecessary assignmentnormal
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-04 * st.c (st_foreach): fix type of hash. not st_data_t but st_index_t.tarui
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-18st.c: hash_posnobu
* 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
2013-12-05st.c: tweaked commentduerst
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-28* st.c: add st_values() and st_values_check().glass
* 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
2013-11-28* st.c (st_keys): fix not to use Qundef in st.c.glass
* 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
2013-11-27* st.c (st_keys): define st_keys(). it writes each key to buffer.glass
* 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
2013-11-14hash.c, st.c: fix for ST_CHECKnobu
* 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
2013-10-10st.c: revert st_keysnobu
* 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
2013-10-10* st.c (st_keys): define st_keys() for performance improvement ofglass
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
2013-07-16* st.c (st_locale_insensitive_strcasecmp): Renamed from st_strcasecmp.akr
(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
2013-07-16* configure.in: revert r42008. strcasecmp() uses the current locale.glass
* 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
2013-07-16* configure.in: check strcasecmp().glass
* 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
2013-04-25* st.c (st_shift): remove unused variable.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-25* benchmark/bm_hash_shift.rb: add benchmark for Hash#shiftcharliesome
* 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
2013-04-19Fixed comment typo, found by @ThePablickzzak
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-10* regint.h: fix typo: _M_AMD86 -> _M_AMD64.naruse
* siphash.c: ditto. * st.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-17st_update passes the key in st_tableshirosaki
* 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
2012-03-31* st.c (st_foreach_check, st_foreach): remove ancient check. Thisnobu
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
2012-03-31* st.c (st_delete): use real_entries in st_delete for packed tablesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-30* st.c (st_foreach_check): remove the entry by replacing with nevernobu
when ST_DELETE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-29* st.c (st_update): pass pointer to key to the callback function.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-29* st.c (st_update): add existing parameter to the callback function.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-10* st.c: pack tables also generic keys. patched by Sokolov Yura atnobu
https://github.com/ruby/ruby/pull/84 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e