summaryrefslogtreecommitdiff
path: root/hash.c
AgeCommit message (Collapse)Author
2019-04-21Drop MJIT_FUNC_EXPORTED from rb_hash_bulk_insertk0kubun
it's official API after r67677 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-20Add `GC.compact` again.tenderlove
🙏 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17Reverting compaction for nowtenderlove
For some reason symbols (or classes) are being overridden in trunk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17Introduce pattern matching [EXPERIMENTAL]ktsj
[ruby-core:87945] [Feature #14912] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17Adding `GC.compact` and compacting GC support.tenderlove
This commit adds the new method `GC.compact` and compacting GC support. Please see this issue for caveats: https://bugs.ruby-lang.org/issues/15626 [Feature #15626] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-10Reverting all commits from r67479 to r67496 because of CI failureskazu
Because hard to specify commits related to r67479 only. So please commit again. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-09Adding `GC.compact` and compacting GC support.tenderlove
This commit adds the new method `GC.compact` and compacting GC support. Please see this issue for caveats: https://bugs.ruby-lang.org/issues/15626 [Feature #15626] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-22[DOC] fix markups [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-27* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-27Remove stale argumentsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-30hash.c: hoisted out st_index_hashnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-30hash.c: hoisted out dbl_to_indexnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-30* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-30hash.c: remove repeated rb_hash_startnobu
* hash.c (rb_dbl_long_hash): remove repeated rb_hash_start as rb_objid_hash includes rb_hash_start, git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-17reset bound if the size is 0.ko1
* hash.c (RHASH_AR_TABLE_SIZE_DEC): generally, we need to check all entries to calculate exact "bound" in ar_table, but if size == 0, we can clear bound because there are no active entries. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-09add setter of iter_lev.ko1
* hash.c: add special setter function (inc and dec). * internal.h: constify RHash::iter_leve. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-05fix last commit.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-05refactoring.ko1
* hash.c (EQUAL, PTR_EQUAL): make corresponding inline functions ar_equal() and ar_ptr_equal(). * hash.c (SET_*): removed. set fields directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-05add ar_ prefix for ar_table functions.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-05fix trivial indentation.ko1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-05call functions directly.ko1
* hash.c: ar_table only supports `objhash` so we can call compare/hash functions directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-04refactoring usage of ar_lookup().ko1
* hash.c (hash_stlike_lookup): introduce inline a function and use it instead of using ar_lookup()/st_lookup() directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-04skip to calculate hash value on empty Hash ar_table lookup.ko1
* hash.c (ar_lookup): don't calculate hash_value if ar_table is empty. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-04ar_table_entry::hash should be `st_hash_t`.ko1
* hash.c: the type of `ar_table_entry::hash` is not a `VALUE`, but a `st_hash_t`. Also `st_hash_t` is not a `st_data_t`, but `st_index_t` (same as st.c). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-29hide ar_table internals from internal.h.ko1
* internal.h: move ar_table def to hash.c because other files don't need to know implementation of ar_table. * hash.c (rb_hash_ar_table_size): added because gc.c needs to know the size_of(ar_table). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-20hide iseq operand object for duphash. [Bug #15440]ko1
* compile.c (compile_array): hide source Hash object. * hash.c (rb_hash_resurrect): introduced to dup Hash object using rb_cHash. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-14separte NULL and EMPTY check.ko1
* hash.c: separate NULL and EMPTY check functions. `RHASH_TABLE_EMPTY` function checks NULL table or not, but it should be named "NULL_P". Introduce `RHASH_TABLE_EMPTY_P` function to check size == 0. There are cases that hash has table data even if data is not NULL (in case removed after inserted elements). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-14rename li_table->ar_table (and related names).ko1
* internal.h: rename the following names: * li_table -> ar_table. "li" means linear (from linear search), but we use the word "array" (from data layout). * RHASH_ARRAY -> RHASH_AR_TABLE. AR_TABLE is more clear. * rb_hash_array_* -> rb_hash_ar_table_*. * RHASH_TABLE_P() -> RHASH_ST_TABLE_P(). more clear. * RHASH_CLEAR() -> RHASH_ST_CLEAR(). * hash.c: rename "linear_" prefix functions to "ar_" prefix. * hash.c (linear_init_table): rename to ar_alloc_table. * debug_counter.h: rename obj_hash_array to obj_hash_ar. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-10Initialize binnobu
* hash.c (linear_update): initialize `bin` just to silence false warnings by old gcc 4.8. [Bug #15299] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-07Adjust reserved hash valuesnobu
The reserved hash values in hash.c must be consistend with st.c. [ruby-core:90356] [Bug #15389] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-07Should use the proper constantnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03make `RARRAY_PTR_USE` more conservertive.ko1
* include/ruby/ruby.h: de-transient at `RARRAY_PTR_USE` and `RARRAY_PTR_USE_START`. Introduce `RARRAY_PTR_USE_TRANSIENT` and `RARRAY_PTR_USE_START_TRANSIENT` if you don't want to de-transient an array. Generally, it is difficult so C-extension writers should not use them. * array.c: use `RARRAY_PTR_USE_TRANSIENT` if possible. * hash.c: ditto. * enum.c (enum_sort_by): remove `rb_ary_transient_heap_evacuate()` because `RARRAY_PTR_USE` do de-transient. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-29clear dst Hash on Hash#replace. [Bug #15358]ko1
* hash.c (linear_copy): solve two issues on `Hash#replace`. (1) fix memory leak (1-1) don't allocate memory if destination already has a memory area. (1-2) free destination memory if src is NULL. (2) clear transient heap flag if src is NULL. [Bug #15358] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-15hash.c: cast from double to unsigned is undefinedshyouhei
When a negative double is casted into an unsigned type, that operation is undefined (cf: ISO/IEC 9899:1990 section 6.2.9.3). Recent versions of C kindly footnotes that "The remaindering operation performed when a value of integer type is converted to unsigned type need not be performed when a value of real floating type is converted to unsigned type" (cf: ISO/IEC 9899:1999 section 6.3.1.4 footnote 50). So it is a wrong idea to just cast a double to st_data_t. The intention of the code is commented as "mix the actual float value in". It seems we should do a reinterpret_cast and rule out static_cast. Confirmed this changeset does not affect `make benchmark`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08hash.c: +(-1) is a wrong ideashyouhei
Before this changeset RHASH_ARRAY_SIZE_DEC() was expaneded to include an expression like `RHASH_ARRAY_SIZE+(-1)`. RHASH_ARRAY_SIZE is by definition unsigned int. -1 is signed, of course. Adding a signed and an unsigned value requires the "usual arithmetic conversions" (cf: ISO/IEC 9899:1990 section 6.2.1.5). -1 is converted to 0xFFFF by that. This patch prevents that conversion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-04hash.c: [DOC] add docs for ENV.{filter,filter!}stomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-04hash.c: [DOC] fix wrong cross-referencesstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-04hash.c: [DOC] add missing `block' in call-seq'sstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-04hash.c: [DOC] add docs for Hash#{filter,filter!}stomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-04hash.c: [DOC] improve Hash#{select!,keep_if} docsstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-03hash.c: fix typesnobu
* hash.c (RHASH_ARRAY_BOUND_RAW): should be unsigned as well as RHASH_ARRAY_SIZE_RAW. * hash.c (find_entry): return unsigned for the consistency with RHASH_ARRAY_SIZE and RHASH_ARRAY_BOUND. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-01introduce USE_TRANSIENT_HEAP to enable/disable theap.ko1
* include/ruby/ruby.h: intrdocue `USE_TRANSIENT_HEAP` macro to enable/disable transient heap. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-01fix WB miss.ko1
* hash.c (linear_copy): remember a hash object to mark pointing objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-31remove '//' style comments.ko1
* hash.c: remove '//' style comments pointed out by the following build log: https://travis-ci.org/ruby/ruby/jobs/448551951 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30fix type.ko1
* internal.h (RHASH_ARRAY_SIZE_RAW): should be `int` because it returns n<=8. * hash.c (RHASH_ARRAY_BOUND_RAW): ditto. * hash.c (RHASH_ARRAY_SIZE_RAW): remove a duplicated definition. * hash.c (linear_keys, linear_values): return `long`. * hash.c (linear_keys): fix initialize expression of `key_end`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65458 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30* remove trailing spaces, expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-30support theap for T_HASH. [Feature #14989]ko1
* hash.c, internal.h: support theap for small Hash. Introduce RHASH_ARRAY (li_table) besides st_table and small Hash (<=8 entries) are managed by an array data structure. This array data can be managed by theap. If st_table is needed, then converting array data to st_table data. For st_table using code, we prepare "stlike" APIs which accepts hash value and are very similar to st_ APIs. This work is based on the GSoC achievement by tacinight <tacingiht@gmail.com> and refined by ko1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-26Fix a condition and just call rb_fstring [Feature #15251]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-26* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-26Simplify conditions [Feature #15251]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e