summaryrefslogtreecommitdiff
path: root/st.c
AgeCommit message (Collapse)Author
2023-07-01Define `NO_SANITIZE` with reference to ext/bigdecimal/missing.cjinroq
2023-07-01Supress `warning: ‘unsigned-integer-overflow’ attribute directive ↵jinroq
ignored [-Wattributes]`
2023-06-30Don't check for null pointer in calls to freePeter Zhu
According to the C99 specification section 7.20.3.2 paragraph 2: > If ptr is a null pointer, no action occurs. So we do not need to check that the pointer is a null pointer. Notes: Merged: https://github.com/ruby/ruby/pull/8004
2023-06-29Fix memory leak when copying ST tablesPeter Zhu
st_copy allocates a st_table, which is not needed for hashes since it is allocated by VWA and embedded, so this causes a memory leak. The following script demonstrates the issue: ```ruby 20.times do 100_000.times do {a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9} end puts `ps -o rss= -p #{$$}` end ``` Notes: Merged: https://github.com/ruby/ruby/pull/8000
2023-06-24De-duplicate parse_st.c code from st.cNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7956
2023-06-17Use ruby functions if `RUBY` is definedNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/7949
2023-06-17Expand `#ifdef RUBY` regionNobuyoshi Nakada
Include the functions which are only used for `rb_hash_bulk_insert_into_st_table`. Notes: Merged: https://github.com/ruby/ruby/pull/7949
2023-05-17Implement Hash ST tables on VWAPeter Zhu
Notes: Merged: https://github.com/ruby/ruby/pull/7742
2023-03-20Use an st table for "too complex" objectsAaron Patterson
st tables will maintain insertion order so we can marshal dump / load objects with instance variables in the same order they were set on that particular instance [ruby-core:112926] [Bug #19535] Co-Authored-By: Jemma Issroff <jemmaissroff@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/7560
2023-02-10st.c: spell `perturb' properlyEric Wong
Otherwise, a reader may wonder who `Peter B.' is and why a variable is named after them...
2022-10-19Fix and improve coroutines for Darwin (macOS) ppc/ppc64. (#5975)Sergey Fedorov
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-10-06[Bug #19038] Fix corruption of generic_iv_tbl when compactingPeter Zhu
When the generic_iv_tbl is resized up, rebuild_table performs allocations that can trigger GC. If autocompaction is enabled, then moved objects are removed from and inserted into the generic_iv_tbl. This may cause another call to rebuild_table to resize the generic_iv_tbl. When returning back to the original rebuild_table, some of the data may be stale, causing the generic_iv_tbl to be corrupted. This commit changes rebuild_table to only read data from the st_table after the allocations have completed. Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com> Notes: Merged: https://github.com/ruby/ruby/pull/6494
2022-07-21Expand tabs [ci skip]Takashi Kokubun
[Misc #18891] Notes: Merged: https://github.com/ruby/ruby/pull/6094
2022-02-28st.c: Fix a typo in a commentYusuke Endoh
2022-02-10st.c: Do not clear entries_bound when calling Hash#shift for empty hashYusuke Endoh
tab->entries_bound is used to check if the bins are full in rebuild_table_if_necessary. Hash#shift against an empty hash assigned 0 to tab->entries_bound, but didn't clear the bins. Thus, the table is not rebuilt even when the bins are full. Attempting to add a new element into full-bin hash gets stuck. This change stops clearing tab->entries_bound in Hash#shift. [Bug #18578] Notes: Merged: https://github.com/ruby/ruby/pull/5539
2021-06-17Adjust styles [ci skip]Nobuyoshi Nakada
* --braces-after-func-def-line * --dont-cuddle-else * --procnames-start-lines * --space-after-for * --space-after-if * --space-after-while
2021-04-11st.c: skip all deleted entries [Bug #17779]tompng (tomoya ishida)
Update the start entry skipping all already deleted entries. Fixes performance issue of `Hash#first` in a certain case.
2021-01-19Replace "iff" with "if and only if"Gannon McGibbon
iff means if and only if, but readers without that knowledge might assume this to be a spelling mistake. To me, this seems like exclusionary language that is unnecessary. Simply using "if and only if" instead should suffice. Notes: Merged: https://github.com/ruby/ruby/pull/4035
2020-11-30[DOC] Fixed st_udpate comment [ci skip]Nobuyoshi Nakada
Clarified that the first and second arguments to the callback function are pointers to the KEY and the VALUE, but not those values themselves.
2020-10-17sync RClass::ext::iv_index_tblKoichi Sasada
iv_index_tbl manages instance variable indexes (ID -> index). This data structure should be synchronized with other ractors so introduce some VM locks. This patch also introduced atomic ivar cache used by set/getinlinecache instructions. To make updating ivar cache (IVC), we changed iv_index_tbl data structure to manage (ID -> entry) and an entry points serial and index. IVC points to this entry so that cache update becomes atomically. Notes: Merged: https://github.com/ruby/ruby/pull/3662
2020-08-14Enable arm64 optimizations that exist for power/x86 (#3393)AGSaidi
* Enable unaligned accesses on arm64 64-bit Arm platforms support unaligned accesses. Running the string benchmarks this change improves performance by an average of 1.04x, min .96x, max 1.21x, median 1.01x * arm64 enable gc optimizations Similar to x86 and powerpc optimizations. | |compare-ruby|built-ruby| |:------|-----------:|---------:| |hash1 | 0.225| 0.237| | | -| 1.05x| |hash2 | 0.110| 0.110| | | 1.00x| -| * vm_exec.c: improve performance for arm64 | |compare-ruby|built-ruby| |:------------------------------|-----------:|---------:| |vm_array | 26.501M| 27.959M| | | -| 1.06x| |vm_attr_ivar | 21.606M| 31.429M| | | -| 1.45x| |vm_attr_ivar_set | 21.178M| 26.113M| | | -| 1.23x| |vm_backtrace | 6.621| 6.668| | | -| 1.01x| |vm_bigarray | 26.205M| 29.958M| | | -| 1.14x| |vm_bighash | 504.155k| 479.306k| | | 1.05x| -| |vm_block | 16.692M| 21.315M| | | -| 1.28x| |block_handler_type_iseq | 5.083| 7.004| | | -| 1.38x| Notes: Merged-By: nurse <naruse@airemix.jp>
2020-06-04Removed no longer used constants [Bug #16934]Nobuyoshi Nakada
`RESERVED_HASH_VAL` and `RESERVED_HASH_SUBSTITUTION_VAL` have not been used directly in hash.c since 72825c35b0d8.
2020-03-16Adjusted indents [ci skip]Nobuyoshi Nakada
2020-03-11Fix typos (#2958)K.Takata
* Fix a typo * Fix typos in st.[ch] Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2020-02-27st.c: remove variables that are no longer usedYusuke Endoh
to suppress a warning "variable 'check' set but not used"
2020-02-26kill ST_DEBUG [Bug #16521]卜部昌平
This compile-time option has been broken for years (at least since commit 4663c224fa6c925ce54af32fd1c1cbac9508f5ec, according to git bisect). Let's delete codes that no longer work. Notes: Merged: https://github.com/ruby/ruby/pull/2926
2020-02-07more on NULL versus functions.卜部昌平
Function pointers are not void*. See also ce4ea956d24eab5089a143bba38126f2b11b55b6 8427fca49bd85205f5a8766292dd893f003c0e48
2019-12-26decouple internal.h headers卜部昌平
Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-20Fixed misspellingsNobuyoshi Nakada
Fixed misspellings reported at [Bug #16437], only in ruby and rubyspec.
2019-10-21st: Do error check only on non-RubyK.Takata
Notes: Merged: https://github.com/ruby/ruby/pull/2304
2019-10-21st: Add NULL checkingK.Takata
These are found by Coverity. Notes: Merged: https://github.com/ruby/ruby/pull/2304
2019-09-22st.c: Use rb_st_* prefix instead of st_* (#2479)Yusuke Endoh
The original st.c was public domain hash table implementation, but Ruby's st.c is highly modified, and its data structure is not compatiblie with the original one. Therefore, when creating an extension library to wrap C code that uses the original st.c, the symbols conflict, which leads to segfault. This changes the prefix `st_*` of st.c functions to `rb_st_*` for reflecting that they are specific to Ruby's, and avoid symbol conflicts. Notes: Merged-By: mame <mame@ruby-lang.org>
2019-09-22st.c (st_add_direct_with_hash): make it "static inline"Yusuke Endoh
It was originally static inline, but seemed to be accidentally published at 8f675cdd00e2c5b5a0f143f5e508dbbafdb20ccd.
2019-08-28optimize get_power2 [Feature #15631]pavel
Merged: https://github.com/ruby/ruby/pull/2292
2019-08-27struct st_hash_type now free from ANYARGS卜部昌平
After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit adds function prototypes for struct st_hash_type. Honestly I don't understand why they were commented out at the first place.
2019-08-27st_foreach now free from ANYARGS卜部昌平
After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from st_foreach. I strongly believe that this commit should have had come with b0af0592fdd9e9d4e4b863fde006d67ccefeac21, which added extra parameter to st_foreach callbacks.
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-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-01-15st.c (rb_hash_bulk_insert_into_st_table): avoid out-of-bounds writemame
"hash_bulk_insert" first expands the table, but the target size was wrong: it was calculated by "num_entries + (size to buld insert)", but it was wrong when "num_entries < entries_bound", i.e., it has a deleted entry. "hash_bulk_insert" adds the given entries from entries_bound, which led to out-of-bounds write access. [Bug #15536] As a simple fix, this commit changes the calculation to "entries_bound + size". I'm afraid if this might be inefficient, but I think it is safe anyway. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66832 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-11-08st.c: bin might be zeroshyouhei
When EMPTY_OR_DELETED_BIN_P(bin) is true, it is a wrong idea to subtract ENTRY_BASE from it. Delay doing so until we are sure to be safe. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08avoid (size_t)-- (2nd try)shyouhei
The decrements overflow and these variables remain ~0 when leaving the while loops. They are not fatal by accident, but better replace with ordinal for loops. See also: https://travis-ci.org/ruby/ruby/jobs/452218871#L3246 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08svn merge -r 65625:65623 .shyouhei
Was breaking make test-all git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08st.c: fix comparison between signed and unsignedshyouhei
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08avoid (size_t)--shyouhei
The decrements overflow and these variables remain ~0 when leaving the while loops. They are not fatal by accident, but better replace with ordinal for loops. See also: https://travis-ci.org/ruby/ruby/jobs/452218871#L3246 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08st.c: straight-forward comparison of charactersshyouhei
These functions are used in strcasehash, which is used to store encoding names. Encoding names often include hyphens (e.g. "UTF-8"), and ` '-' - 'A' ` is negative (cannot express in unsigned int). Don't be tricky, just do what to do. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08st.c: suppress integer overlow warningsshyouhei
This `i += h;` overflows. Don't know the intention of the operation, so just suppress UBSAN. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e