Граф коммитов

152 Коммитов

Автор SHA1 Сообщение Дата
normal d0240cbb6d st.c: constify st_table* in private functions
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-29 23:55:23 +00:00
nobu 7d517ffc80 st.c: fix arguments order to compare
* 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-24 12:29:57 +00:00
usa 37c8a704bf * st.c: get rid of VC++'s warnings of C4700 (uninitialized local
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-07-02 05:48:14 +00:00
normal c31b0def42 st.c: use ccan linked-list (try 3)
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-29 18:10:00 +00:00
normal b8d544832b Revert "st.c: use ccan linked-list (try 2)"
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-26 22:52:26 +00:00
normal d3725a86de st.c: use ccan linked-list (try 2)
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-26 22:32:06 +00:00
normal c94a94805d st.c: include ccan/list/list.h to test build
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-26 18:59:59 +00:00
normal cc5547a4ad Revert r51034 "st.c: use ccan linked-list"
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-25 19:56:20 +00:00
normal d8748874cc st.c: use ccan linked-list
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-06-25 19:01:25 +00:00
nobu 059ea6e4d8 hash.c: move Hash specific functions
* 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-23 02:36:50 +00:00
normal 6d56fd067e fix flonum hashing regression from r45384
* 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
2015-01-22 07:48:59 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
nobu 54af8757b3 internal.h: STATIC_ASSERT
* 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-11-13 02:56:14 +00:00
nobu 6557a6b9ed st.c: update st_reverse_foreach
* 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-04 14:13:36 +00:00
normal 1b5acebef2 st.c (new_size): use next_pow2 function
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-10-02 21:17:13 +00:00
nari a3307d5e5a * st.c (do_hash_bin): unused macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-21 10:07:44 +00:00
nari a5c91a3811 * st.c (numberof): unused. internal.h has same macro.
* node.c (F_CUSTOM2): unused.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-21 09:22:42 +00:00
nobu 63360be4d2 UNALIGNED_WORD_ACCESS on ppc64
* 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-23 14:50:12 +00:00
nobu 6a9b242a80 st.c: fix uninitialized variable
* 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-06 15:22:19 +00:00
nobu 783b3c8d5a st.c: remove equality checks
* 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-06 15:11:53 +00:00
nobu ea74da0c6c st.c: re-calc hash_val before adding
* 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-06 14:42:57 +00:00
nobu e6be6ebc77 st.c: update the key too if changed
* 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-07-06 14:19:47 +00:00
nobu 6ab08d2e8d configure.in, missing.h: jemalloc mangling
* 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-06-05 05:16:46 +00:00
tarui c94cb8b805 * st.c (st_foreach_check): chnage start point of search at check
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-04-20 03:58:22 +00:00
normal 8125399c09 st.c (st_init_table_with_size): update comment
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-31 01:34:19 +00:00
normal ef59670a44 st.c: use power-of-two sizes to avoid slow modulo ops
* 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-22 23:34:21 +00:00
normal b50780eac0 * st.c (st_update): remove unnecessary assignment
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-14 22:25:48 +00:00
tarui de1f3c92e7 * st.c (st_foreach): fix type of hash. not st_data_t but st_index_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-04 11:51:53 +00:00
nobu 254add068a st.c: hash_pos
* 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
2014-01-18 05:47:38 +00:00
duerst 737c7d816b st.c: tweaked comment
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-05 10:35:50 +00:00
glass 79e6336495 * st.c: add st_values() and st_values_check().
* 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 08:39:16 +00:00
glass 78cfcbc657 * st.c (st_keys): fix not to use Qundef in st.c.
* 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-28 08:15:26 +00:00
glass b426e1b1fa * st.c (st_keys): define st_keys(). it writes each key to buffer.
* 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-27 16:07:10 +00:00
nobu b0af0592fd hash.c, st.c: fix for ST_CHECK
* 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-11-14 02:33:50 +00:00
nobu b28ce966c7 st.c: revert st_keys
* 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 16:28:56 +00:00
glass 026955e375 * st.c (st_keys): define st_keys() for performance improvement of
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-10-10 12:06:01 +00:00
akr 8795574510 * st.c (st_locale_insensitive_strcasecmp): Renamed from st_strcasecmp.
(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 23:15:41 +00:00
glass 13a1fd6d82 * configure.in: revert r42008. strcasecmp() uses the current locale.
* 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 12:49:01 +00:00
glass a0d9bd4445 * configure.in: check strcasecmp().
* 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-07-16 12:13:19 +00:00
nobu 5a3fab5918 * st.c (st_shift): remove unused variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-25 05:25:53 +00:00
charliesome 5d7b5481ca * benchmark/bm_hash_shift.rb: add benchmark for Hash#shift
* 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-25 05:03:30 +00:00
zzak ff6eb8fe9a Fixed comment typo, found by @ThePablick
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-19 14:32:29 +00:00
naruse 29f347af11 * regint.h: fix typo: _M_AMD86 -> _M_AMD64.
* siphash.c: ditto.

* st.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-10 21:16:44 +00:00
shirosaki 262cb379d6 st_update passes the key in st_table
* 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-11-17 02:46:13 +00:00
nobu 94d0221df4 * st.c (st_foreach_check, st_foreach): remove ancient check. This
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 01:13:26 +00:00
nobu 44e6f5a1bb * st.c (st_delete): use real_entries in st_delete for packed tables
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-31 01:01:41 +00:00
nobu 197627354e * st.c (st_foreach_check): remove the entry by replacing with never
when ST_DELETE.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-30 22:53:26 +00:00
nobu 28cc4f7543 * st.c (st_update): pass pointer to key to the callback function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-29 14:50:20 +00:00
nobu 30cea65767 * st.c (st_update): add existing parameter to the callback function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-29 07:36:12 +00:00
nobu 3007acfbc6 * st.c: pack tables also generic keys. patched by Sokolov Yura at
https://github.com/ruby/ruby/pull/84


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-10 14:52:30 +00:00