aboutsummaryrefslogtreecommitdiffstats
path: root/st.c
Commit message (Collapse)AuthorAgeFilesLines
* [Bug #19969] Compact st_table after deleted if possibleNobuyoshi Nakada2023-11-111-11/+29
|
* Define `NO_SANITIZE` with reference to ext/bigdecimal/missing.cjinroq2023-07-011-5/+5
|
* Supress `warning: ‘unsigned-integer-overflow’ attribute directive ↵jinroq2023-07-011-5/+5
| | | | ignored [-Wattributes]`
* Don't check for null pointer in calls to freePeter Zhu2023-06-301-12/+8
| | | | | | | | 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.
* Fix memory leak when copying ST tablesPeter Zhu2023-06-291-11/+23
| | | | | | | | | | | | | | | | | 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 ```
* De-duplicate parse_st.c code from st.cNobuyoshi Nakada2023-06-241-1/+1
|
* Use ruby functions if `RUBY` is definedNobuyoshi Nakada2023-06-171-1/+1
|
* Expand `#ifdef RUBY` regionNobuyoshi Nakada2023-06-171-1/+1
| | | | | Include the functions which are only used for `rb_hash_bulk_insert_into_st_table`.
* Implement Hash ST tables on VWAPeter Zhu2023-05-171-10/+26
|
* Use an st table for "too complex" objectsAaron Patterson2023-03-201-0/+6
| | | | | | | | | | 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>
* st.c: spell `perturb' properlyEric Wong2023-02-101-18/+18
| | | | | Otherwise, a reader may wonder who `Peter B.' is and why a variable is named after them...
* Fix and improve coroutines for Darwin (macOS) ppc/ppc64. (#5975)Sergey Fedorov2022-10-191-1/+2
|
* [Bug #19038] Fix corruption of generic_iv_tbl when compactingPeter Zhu2022-10-061-5/+10
| | | | | | | | | | | | | | 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>
* Expand tabs [ci skip]Takashi Kokubun2022-07-211-317/+317
| | | | [Misc #18891]
* st.c: Fix a typo in a commentYusuke Endoh2022-02-281-1/+1
|
* st.c: Do not clear entries_bound when calling Hash#shift for empty hashYusuke Endoh2022-02-101-1/+0
| | | | | | | | | | | | 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]
* Adjust styles [ci skip]Nobuyoshi Nakada2021-06-171-3/+5
| | | | | | | | | * --braces-after-func-def-line * --dont-cuddle-else * --procnames-start-lines * --space-after-for * --space-after-if * --space-after-while
* st.c: skip all deleted entries [Bug #17779]tompng (tomoya ishida)2021-04-111-2/+7
| | | | | Update the start entry skipping all already deleted entries. Fixes performance issue of `Hash#first` in a certain case.
* Replace "iff" with "if and only if"Gannon McGibbon2021-01-191-1/+1
| | | | | | | 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.
* [DOC] Fixed st_udpate comment [ci skip]Nobuyoshi Nakada2020-11-301-8/+9
| | | | | | Clarified that the first and second arguments to the callback function are pointers to the KEY and the VALUE, but not those values themselves.
* sync RClass::ext::iv_index_tblKoichi Sasada2020-10-171-0/+15
| | | | | | | | | | | | 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.
* Enable arm64 optimizations that exist for power/x86 (#3393)AGSaidi2020-08-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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|
* Removed no longer used constants [Bug #16934]Nobuyoshi Nakada2020-06-041-3/+0
| | | | | `RESERVED_HASH_VAL` and `RESERVED_HASH_SUBSTITUTION_VAL` have not been used directly in hash.c since 72825c35b0d8.
* Adjusted indents [ci skip]Nobuyoshi Nakada2020-03-161-28/+28
|
* Fix typos (#2958)K.Takata2020-03-111-3/+3
| | | | | * Fix a typo * Fix typos in st.[ch]
* st.c: remove variables that are no longer usedYusuke Endoh2020-02-271-4/+1
| | | | to suppress a warning "variable 'check' set but not used"
* kill ST_DEBUG [Bug #16521]卜部昌平2020-02-261-153/+0
| | | | | | 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.
* more on NULL versus functions.卜部昌平2020-02-071-2/+2
| | | | | | Function pointers are not void*. See also ce4ea956d24eab5089a143bba38126f2b11b55b6 8427fca49bd85205f5a8766292dd893f003c0e48
* decouple internal.h headers卜部昌平2019-12-261-0/+3
| | | | | | | | | | | | | | | | | | 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).
* Fixed misspellingsNobuyoshi Nakada2019-12-201-1/+1
| | | | Fixed misspellings reported at [Bug #16437], only in ruby and rubyspec.
* st: Do error check only on non-RubyK.Takata2019-10-211-0/+16
|
* st: Add NULL checkingK.Takata2019-10-211-2/+26
| | | | These are found by Coverity.
* st.c: Use rb_st_* prefix instead of st_* (#2479)Yusuke Endoh2019-09-221-1/+1
| | | | | | | | | | | 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.
* st.c (st_add_direct_with_hash): make it "static inline"Yusuke Endoh2019-09-221-1/+1
| | | | | It was originally static inline, but seemed to be accidentally published at 8f675cdd00e2c5b5a0f143f5e508dbbafdb20ccd.
* optimize get_power2 [Feature #15631]pavel2019-08-281-4/+1
| | | | Merged: https://github.com/ruby/ruby/pull/2292
* struct st_hash_type now free from ANYARGS卜部昌平2019-08-271-3/+20
| | | | | | | 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.
* st_foreach now free from ANYARGS卜部昌平2019-08-271-5/+18
| | | | | | | | 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.
* Add `GC.compact` again.tenderlove2019-04-201-3/+20
| | | | | | 🙏 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting compaction for nowtenderlove2019-04-171-20/+3
| | | | | | 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
* Adding `GC.compact` and compacting GC support.tenderlove2019-04-171-3/+20
| | | | | | | | | | | 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
* Reverting all commits from r67479 to r67496 because of CI failureskazu2019-04-101-20/+3
| | | | | | | | 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
* Adding `GC.compact` and compacting GC support.tenderlove2019-04-091-3/+20
| | | | | | | | | | | 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
* st.c (rb_hash_bulk_insert_into_st_table): avoid out-of-bounds writemame2019-01-151-1/+1
| | | | | | | | | | | | | | "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
* Adjust reserved hash valuesnobu2018-12-071-0/+3
| | | | | | | 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
* st.c: bin might be zeroshyouhei2018-11-081-1/+1
| | | | | | | | | 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
* avoid (size_t)-- (2nd try)shyouhei2018-11-081-1/+2
| | | | | | | | | | | 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
* svn merge -r 65625:65623 .shyouhei2018-11-081-2/+1
| | | | | | | Was breaking make test-all git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: fix comparison between signed and unsignedshyouhei2018-11-081-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* avoid (size_t)--shyouhei2018-11-081-1/+2
| | | | | | | | | | | 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
* st.c: straight-forward comparison of charactersshyouhei2018-11-081-10/+10
| | | | | | | | | | | 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