aboutsummaryrefslogtreecommitdiffstats
path: root/st.c
Commit message (Collapse)AuthorAgeFilesLines
* [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
* st.c: suppress integer overlow warningsshyouhei2018-11-081-0/+1
| | | | | | | | 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
* blacklist UBSAN's unsigned integer overflowshyouhei2018-11-071-1/+5
| | | | | | | | | | | | Integer overflow for unsigned types are fully defined in C. They are not always problematic (but not always OK). These functions in this changeset intentionally utilizes that behaviour. Blacklist from UBSAN checks for better output. See also: https://travis-ci.org/ruby/ruby/jobs/451624829 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* support theap for T_HASH. [Feature #14989]ko12018-10-301-17/+9
| | | | | | | | | | | | | | | | | * 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
* st.c: remove redundant export declarationk0kubun2018-05-271-1/+1
| | | | | | | rb_hash_bulk_insert is added to official C API in r63488. It's no longer exported only for MJIT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: retry operations if rebuiltnormal2018-02-131-73/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Calling the .eql? and .hash methods during a Hash operation can result in a thread switch or a signal handler to run: allowing one execution context to rebuild the hash table while another is still reading or writing the table. This results in a use-after-free bug affecting the thread_safe-0.3.6 test suite and likely other bugs. This bug did not affect users of commonly keys (String, Symbol, Fixnum) as those are optimized to avoid method dispatch for .eql? and .hash methods. A separate version of this change needs to be ported to Ruby 2.3.x which had a different implementation of st.c but was affected by the same bug. * st.c: Add comment about table rebuilding during comparison. (DO_PTR_EQUAL_CHECK): New macro. (REBUILT_TABLE_ENTRY_IND, REBUILT_TABLE_BIN_IND): New macros. (find_entry, find_table_entry_ind, find_table_bin_ind): Use new macros. Return the rebuild flag. (find_table_bin_ptr_and_reserve): Ditto. (st_lookup, st_get_key, st_insert, st_insert2): Retry the operation if the table was rebuilt. (st_general_delete, st_shift, st_update, st_general_foreach): Ditto. (st_rehash_linear, st_rehash_indexed): Use DO_PTR_EQUAL_CHECK. Return the rebuild flag. (st_rehash): Retry the operation if the table was rebuilt. [ruby-core:85510] [Ruby trunk Bug#14357] Thanks to Vit Ondruch for reporting the bug. From: Vladimir Makarov <vmakarov@redhat.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* mjit_compile.c: merge initial JIT compilerk0kubun2018-02-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which has been developed by Takashi Kokubun <takashikkbn@gmail> as YARV-MJIT. Many of its bugs are fixed by wanabe <s.wanabe@gmail.com>. This JIT compiler is designed to be a safe migration path to introduce JIT compiler to MRI. So this commit does not include any bytecode changes or dynamic instruction modifications, which are done in original MJIT. This commit even strips off some aggressive optimizations from YARV-MJIT, and thus it's slower than YARV-MJIT too. But it's still fairly faster than Ruby 2.5 in some benchmarks (attached below). Note that this JIT compiler passes `make test`, `make test-all`, `make test-spec` without JIT, and even with JIT. Not only it's perfectly safe with JIT disabled because it does not replace VM instructions unlike MJIT, but also with JIT enabled it stably runs Ruby applications including Rails applications. I'm expecting this version as just "initial" JIT compiler. I have many optimization ideas which are skipped for initial merging, and you may easily replace this JIT compiler with a faster one by just replacing mjit_compile.c. `mjit_compile` interface is designed for the purpose. common.mk: update dependencies for mjit_compile.c. internal.h: declare `rb_vm_insn_addr2insn` for MJIT. vm.c: exclude some definitions if `-DMJIT_HEADER` is provided to compiler. This avoids to include some functions which take a long time to compile, e.g. vm_exec_core. Some of the purpose is achieved in transform_mjit_header.rb (see `IGNORED_FUNCTIONS`) but others are manually resolved for now. Load mjit_helper.h for MJIT header. mjit_helper.h: New. This is a file used only by JIT-ed code. I'll refactor `mjit_call_cfunc` later. vm_eval.c: add some #ifdef switches to skip compiling some functions like Init_vm_eval. win32/mkexports.rb: export thread/ec functions, which are used by MJIT. include/ruby/defines.h: add MJIT_FUNC_EXPORTED macro alis to clarify that a function is exported only for MJIT. array.c: export a function used by MJIT. bignum.c: ditto. class.c: ditto. compile.c: ditto. error.c: ditto. gc.c: ditto. hash.c: ditto. iseq.c: ditto. numeric.c: ditto. object.c: ditto. proc.c: ditto. re.c: ditto. st.c: ditto. string.c: ditto. thread.c: ditto. variable.c: ditto. vm_backtrace.c: ditto. vm_insnhelper.c: ditto. vm_method.c: ditto. I would like to improve maintainability of function exports, but I believe this way is acceptable as initial merging if we clarify the new exports are for MJIT (so that we can use them as TODO list to fix) and add unit tests to detect unresolved symbols. I'll add unit tests of JIT compilations in succeeding commits. Author: Takashi Kokubun <takashikkbn@gmail.com> Contributor: wanabe <s.wanabe@gmail.com> Part of [Feature #14235] --- * Known issues * Code generated by gcc is faster than clang. The benchmark may be worse in macOS. Following benchmark result is provided by gcc w/ Linux. * Performance is decreased when Google Chrome is running * JIT can work on MinGW, but it doesn't improve performance at least in short running benchmark. * Currently it doesn't perform well with Rails. We'll try to fix this before release. --- * Benchmark reslts Benchmarked with: Intel 4.0GHz i7-4790K with 16GB memory under x86-64 Ubuntu 8 Cores - 2.0.0-p0: Ruby 2.0.0-p0 - r62186: Ruby trunk (early 2.6.0), before MJIT changes - JIT off: On this commit, but without `--jit` option - JIT on: On this commit, and with `--jit` option ** Optcarrot fps Benchmark: https://github.com/mame/optcarrot | |2.0.0-p0 |r62186 |JIT off |JIT on | |:--------|:--------|:--------|:--------|:--------| |fps |37.32 |51.46 |51.31 |58.88 | |vs 2.0.0 |1.00x |1.38x |1.37x |1.58x | ** MJIT benchmarks Benchmark: https://github.com/benchmark-driver/mjit-benchmarks (Original: https://github.com/vnmakarov/ruby/tree/rtl_mjit_branch/MJIT-benchmarks) | |2.0.0-p0 |r62186 |JIT off |JIT on | |:----------|:--------|:--------|:--------|:--------| |aread |1.00 |1.09 |1.07 |2.19 | |aref |1.00 |1.13 |1.11 |2.22 | |aset |1.00 |1.50 |1.45 |2.64 | |awrite |1.00 |1.17 |1.13 |2.20 | |call |1.00 |1.29 |1.26 |2.02 | |const2 |1.00 |1.10 |1.10 |2.19 | |const |1.00 |1.11 |1.10 |2.19 | |fannk |1.00 |1.04 |1.02 |1.00 | |fib |1.00 |1.32 |1.31 |1.84 | |ivread |1.00 |1.13 |1.12 |2.43 | |ivwrite |1.00 |1.23 |1.21 |2.40 | |mandelbrot |1.00 |1.13 |1.16 |1.28 | |meteor |1.00 |2.97 |2.92 |3.17 | |nbody |1.00 |1.17 |1.15 |1.49 | |nest-ntimes|1.00 |1.22 |1.20 |1.39 | |nest-while |1.00 |1.10 |1.10 |1.37 | |norm |1.00 |1.18 |1.16 |1.24 | |nsvb |1.00 |1.16 |1.16 |1.17 | |red-black |1.00 |1.02 |0.99 |1.12 | |sieve |1.00 |1.30 |1.28 |1.62 | |trees |1.00 |1.14 |1.13 |1.19 | |while |1.00 |1.12 |1.11 |2.41 | ** Discourse's script/bench.rb Benchmark: https://github.com/discourse/discourse/blob/v1.8.7/script/bench.rb NOTE: Rails performance was somehow a little degraded with JIT for now. We should fix this. (At least I know opt_aref is performing badly in JIT and I have an idea to fix it. Please wait for the fix.) *** JIT off Your Results: (note for timings- percentile is first, duration is second in millisecs) categories_admin: 50: 17 75: 18 90: 22 99: 29 home_admin: 50: 21 75: 21 90: 27 99: 40 topic_admin: 50: 17 75: 18 90: 22 99: 32 categories: 50: 35 75: 41 90: 43 99: 77 home: 50: 39 75: 46 90: 49 99: 95 topic: 50: 46 75: 52 90: 56 99: 101 *** JIT on Your Results: (note for timings- percentile is first, duration is second in millisecs) categories_admin: 50: 19 75: 21 90: 25 99: 33 home_admin: 50: 24 75: 26 90: 30 99: 35 topic_admin: 50: 19 75: 20 90: 25 99: 30 categories: 50: 40 75: 44 90: 48 99: 76 home: 50: 42 75: 48 90: 51 99: 89 topic: 50: 49 75: 55 90: 58 99: 99 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st_hashtype_num marked as staticshyouhei2018-01-191-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* __builtin_assume_aligned for *(foo *) castsshyouhei2018-01-151-2/+8
| | | | | | These casts are guarded. Must be safe to assume alignments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash literal deduplicates like Hash#[]=normal2017-12-301-2/+2
| | | | | | | | | | | | | From: Eric Wong <e@80x24.org> * hash.c (rb_hash_key_str): new function (hash_aset_str): use rb_hash_key_str * internal.h: add rb_hash_key_str * st.c (st_stringify): use rb_hash_key_str * test/ruby/test_hash.rb (test_NEWHASH_fstring_key): dynamic key [ruby-core:84554] [Feature #14258] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Improve performance of creating Hash object"watson19782017-12-191-59/+6
| | | | | | | | | This reverts commit r61309 Because it was unstable on mswin CI. [ruby-dev:50370][Bug #14203] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: fix upnobu2017-12-191-5/+5
| | | | | | | | | | | | * st.c (_st_table_list, _st_table_pool): symbols beginning with an underscore and a lower letter are preserved by the standard. * st.c (get_st_table): protoized. * st.c (st_insert_generic): adjust local variable type to an argument argc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: no C99 commentnobu2017-12-181-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Improve performance of creating Hash objectwatson19782017-12-181-6/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When generate Hash object, the heap area of st_table will be always allocated in internally and seems it take a time. To improve performance of creating Hash object, this patch will reduce count of allocating heap areas for st_table by reuse them. Performance of creating Hash literal -> 1.53 times faster. [Fix GH-1766] [ruby-core:84008] [Feature #14146] ### Environment * OS : macOS 10.13.1 * CPU : 1.4 GHz Intel Core i7 * Compiler : Apple LLVM version 9.0.0 (clang-900.0.39) ### Before $ ./miniruby -v -I. -I../benchmark-ips/lib ~/tmp/bench/literal.rb ruby 2.5.0dev (2017-11-28 hash 60926) [x86_64-darwin17] Warming up -------------------------------------- Hash literal 51.544k i/100ms Calculating ------------------------------------- Hash literal 869.132k (± 1.1%) i/s - 4.381M in 5.041574s ### After $ ./miniruby -v -I. -I../benchmark-ips/lib ~/tmp/bench/literal.rb ruby 2.5.0dev (2017-11-28 hash 60926) [x86_64-darwin17] Warming up -------------------------------------- Hash literal 63.068k i/100ms Calculating ------------------------------------- Hash literal 1.328M (± 2.3%) i/s - 6.685M in 5.037861s ### Test code require 'benchmark/ips' Benchmark.ips do |x| x.report "Hash literal" do |loop| count = 0 while count < loop hash = {foo: 12, bar: 34, baz: 56} count += 1 end end end git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: fix num_entriesnobu2017-09-051-0/+2
| | | | | | | * st.c (st_insert2): should manage num_entries when the key is undefined, as well as st_insert(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: fix false assertionsnobu2017-09-051-35/+42
| | | | | | | | | * st.c: split assertion conditions. * st.c (rb_hash_bulk_insert): the number of arguments should be even. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* optimize rb_hash_bulk_insert to generally outperform 2.4.shyouhei2017-09-051-25/+67
| | | | | | | | | | Specialized routine for small linear-probling hash instances to boost creation of such things [Bug #13861] Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* st.c: adjust stylenobu2017-07-191-31/+41
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert r59359, r59356, r59355, r59354normal2017-07-191-18/+2
| | | | | | | These caused numerous CI failures I haven't been able to reproduce [ruby-core:82102] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* newhash insn reuses existing keysnormal2017-07-181-2/+18
| | | | | | | | | | | | This gives the newhash VM instruction the same string reuse capabilities as rb_hash_aset. * st.c (str_key): new wrapper function to call rb_fstring_existing (rb_hash_bulk_insert): use str_key * test/ruby/test_optimization.rb (test_hash_reuse_fstring): ensure key reuse for newhash instructions git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e