aboutsummaryrefslogtreecommitdiffstats
path: root/internal.h
Commit message (Collapse)AuthorAgeFilesLines
...
* struct MEMO now free from ANYARGS卜部昌平2019-08-271-1/+1
| | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. There is only one usage of MEMO::u3::func in load.c (where void Init_Foobar(vodi) is registered) so why not just be explicit.
* rb_hash_foreach now free from ANYARGS卜部昌平2019-08-271-2/+2
| | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit adds function prototypes for rb_hash_foreach / st_foreach_safe. Also fixes some prototype mismatches.
* rb_ensure now free from ANYARGS卜部昌平2019-08-271-1/+1
| | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from rb_ensure, which also revealed many arity / type mismatches.
* decouple compile.c usage of imemo_ifunc卜部昌平2019-08-271-3/+3
| | | | | | | After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is dangerous and should be extinct. This commit deletes ANYARGS from struct vm_ifunc, but in doing so we also have to decouple the usage of this struct in compile.c, which (I think) is an abuse of ANYARGS.
* delete rb_method_defined_by declaration.卜部昌平2019-08-271-1/+0
| | | | Ko1 missed this in d5893b91faa7dc77ca6c9728d1054dabd757aead.
* `rp(obj)` shows func, file and line. (#2394)Koichi Sasada2019-08-211-2/+4
| | | | | | rp() macro for debug also shows file location and function name such as: [OBJ_INFO:rb_call_inits@inits.c:73] 0x000056147741b248 ...
* Renamed ruby_finalize_{0,1}Nobuyoshi Nakada2019-08-131-1/+0
| | | | And pass rb_execution_context_t as an argument.
* Expanded f_quoNobuyoshi Nakada2019-08-101-0/+1
|
* add rp() and bp() in internal.h.Koichi Sasada2019-08-091-0/+16
| | | | | | | | debug utility macro rp() (rp_m()) and bp() are introduced. * rp(obj) shows obj information w/o any side-effect to STDERR. * rp_m(m, obj) is similar to rp(obj), but show m before. * bp() is alias of ruby_debug_breakpoint(), which is registered as a breakpoint in run.gdb (used by `make gdb` or make gdb-ruby`).
* introduce RCLASS_CLONED flag for inline cache.Koichi Sasada2019-08-091-0/+1
| | | | | | | | | Methods on duplicated class/module refer same constant inline cache (IC). Constant access lookup should be done for cloned class/modules but inline cache doesn't check it. To check it, this patch introduce new RCLASS_CLONED flag which are set when if class/module is cloned (both orig and dst). [Bug #15877]
* leafify opt_plus卜部昌平2019-08-061-0/+1
| | | | | | Inspired by 346aa557b31fe96760e505d30da26eb7a846bac9 Closes: https://github.com/ruby/ruby/pull/2321
* Make opt_eq and opt_neq insns leafTakashi Kokubun2019-08-041-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # Benchmark zero? ``` require 'benchmark/ips' Numeric.class_eval do def ruby_zero? self == 0 end end Benchmark.ips do |x| x.report('0.zero?') { 0.ruby_zero? } x.report('1.zero?') { 1.ruby_zero? } x.compare! end ``` ## VM No significant impact for VM. ### before ruby 2.7.0dev (2019-08-04T02:56:02Z master 2d8c037e97) [x86_64-linux] 0.zero?: 21855445.5 i/s 1.zero?: 21770817.3 i/s - same-ish: difference falls within error ### after ruby 2.7.0dev (2019-08-04T11:17:10Z opt-eq-leaf 6404bebd6a) [x86_64-linux] 1.zero?: 21958912.3 i/s 0.zero?: 21881625.9 i/s - same-ish: difference falls within error ## JIT The performance improves about 1.23x. ### before ruby 2.7.0dev (2019-08-04T02:56:02Z master 2d8c037e97) +JIT [x86_64-linux] 0.zero?: 36343111.6 i/s 1.zero?: 36295153.3 i/s - same-ish: difference falls within error ### after ruby 2.7.0dev (2019-08-04T11:17:10Z opt-eq-leaf 6404bebd6a) +JIT [x86_64-linux] 0.zero?: 44740467.2 i/s 1.zero?: 44363616.1 i/s - same-ish: difference falls within error # Benchmark str == str / str != str ``` # frozen_string_literal: true require 'benchmark/ips' Benchmark.ips do |x| x.report('a == a') { 'a' == 'a' } x.report('a == b') { 'a' == 'b' } x.report('a != a') { 'a' != 'a' } x.report('a != b') { 'a' != 'b' } x.compare! end ``` ## VM No significant impact for VM. ### before ruby 2.7.0dev (2019-08-04T02:56:02Z master 2d8c037e97) [x86_64-linux] a == a: 27286219.0 i/s a != a: 24892389.5 i/s - 1.10x slower a == b: 23623635.8 i/s - 1.16x slower a != b: 21800958.0 i/s - 1.25x slower ### after ruby 2.7.0dev (2019-08-04T11:17:10Z opt-eq-leaf 6404bebd6a) [x86_64-linux] a == a: 27224016.2 i/s a != a: 24490109.5 i/s - 1.11x slower a == b: 23391052.4 i/s - 1.16x slower a != b: 21811321.7 i/s - 1.25x slower ## JIT The performance improves on JIT a little. ### before ruby 2.7.0dev (2019-08-04T02:56:02Z master 2d8c037e97) +JIT [x86_64-linux] a == a: 42010674.7 i/s a != a: 38920311.2 i/s - same-ish: difference falls within error a == b: 32574262.2 i/s - 1.29x slower a != b: 32099790.3 i/s - 1.31x slower ### after ruby 2.7.0dev (2019-08-04T11:17:10Z opt-eq-leaf 6404bebd6a) +JIT [x86_64-linux] a == a: 46902738.8 i/s a != a: 43097258.6 i/s - 1.09x slower a == b: 35822018.4 i/s - 1.31x slower a != b: 33377257.8 i/s - 1.41x slower This is needed towards Bug#15589. Closes: https://github.com/ruby/ruby/pull/2318
* Expanded f_ceilNobuyoshi Nakada2019-08-021-0/+1
|
* introduce ar_hint_t.Koichi Sasada2019-08-011-2/+10
| | | | | Hash hint for ar_array is 1 byte (unsigned char). This patch introduce ar_hint_t which represents hint type.
* move macro to internal.h for documentation.Koichi Sasada2019-07-311-0/+4
| | | | | | 13e84d5c0a changes enum to macro, but the flags usage information are lost in internal.h. It should be same place with other flags information.
* Moved RHASH_LEV_MASK and turned into a macroNobuyoshi Nakada2019-07-311-2/+0
| | | | | Get rid of "ISO C restricts enumerator values to range of 'int'" error.
* Use 1 byte hint for ar_table [Feature #15602]Koichi Sasada2019-07-311-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On ar_table, Do not keep a full-length hash value (FLHV, 8 bytes) but keep a 1 byte hint from a FLHV (lowest byte of FLHV). An ar_table only contains at least 8 entries, so hints consumes 8 bytes at most. We can store hints in RHash::ar_hint. On 32bit CPU, we use 4 entries ar_table. The advantages: * We don't need to keep FLHV so ar_table only consumes 16 bytes (VALUEs of key and value) * 8 entries = 128 bytes. * We don't need to scan ar_table, but only need to check hints in many cases. Especially we don't need to access ar_table if there is no match entries (in many cases). It will increase memory cache locality. The disadvantages: * This technique can increase `#eql?` time because hints can conflicts (in theory, it conflicts once in 256 times). It can introduce incompatibility if there is a object x where x.eql? returns true even if hash values are different. I believe we don't need to care such irregular case. * We need to re-calculate FLHV if we need to switch from ar_table to st_table (e.g. exceeds 8 entries). It also can introduce incompatibility, on mutating key objects. I believe we don't need to care such irregular case too. Add new debug counters to measure the performance: * artable_hint_hit - hint is matched and eql?#=>true * artable_hint_miss - hint is not matched but eql?#=>false * artable_hint_notfound - lookup counts
* remove RHash::iter_lev.Koichi Sasada2019-07-311-8/+14
| | | | | | | | | | | | | | | iter_lev is used to detect the hash is iterating or not. Usually, iter_lev should be very small number (1 or 2) so `int` is overkill. This patch introduce iter_lev in flags (7 bits, FL13 to FL19) and if iter_lev exceeds this range, save it in hidden attribute. We can get 1 word in RHash. We can't modify frozen objects. Therefore I added new internal API `rb_ivar_set_internal()` which allows us to set an attribute even if the target object is frozen if the name is hidden ivar (the name without `@` prefix).
* Reuse match dataNobuyoshi Nakada2019-07-281-0/+1
| | | | * string.c (rb_str_split_m): reuse occupied match data. [Bug #16024]
* constify again.Koichi Sasada2019-07-221-12/+12
| | | | | | | | | | | | | | | | | | | | Same as last commit, make some fields `const`. include/ruby/ruby.h: * Rasic::klass * RArray::heap::aux::shared_root * RRegexp::src internal.h: * rb_classext_struct::origin_, redefined_class * vm_svar::cref_or_me, lastline, backref, others * vm_throw_data::throw_obj * vm_ifunc::data * MEMO::v1, v2, u3::value While modifying this patch, I found write-barrier miss on rb_classext_struct::redefined_class. Also vm_throw_data::throw_state is only `int` so change the type.
* constify RHash::ifnone.Koichi Sasada2019-07-221-1/+1
| | | | | | | RHash::ifnone should be protected by write-barriers so this field should be const. However, to introduce GC.compact, the const was removed. This commit revert this removing `const` and modify gc.c `TYPED_UPDATE_IF_MOVED` to remove `const` forcely by a type cast.
* Moved the check for `exception` to rb_execarg_addoptNobuyoshi Nakada2019-07-161-0/+1
| | | | | | Check for `exception` option in rb_execarg_addopt, as well as other options. And then raise a particular ArgumentError if it is not allowed.
* Expanded f_numeratorNobuyoshi Nakada2019-07-161-0/+1
|
* Expanded f_denominatorNobuyoshi Nakada2019-07-161-0/+1
|
* respect RUBY_DEBUG.Koichi Sasada2019-07-151-1/+1
| | | | see RUBY_DEBUG for each debug options.
* socket: use frozen string buffer when releasing GVLTanaka Akira2019-07-141-2/+2
| | | | Thanks for the patch by normalperson (Eric Wong) [Bug #14204].
* Check exception flag as a bool [Bug #15987]Nobuyoshi Nakada2019-07-111-0/+4
|
* Use rb_ident_hash_new instead of rb_hash_new_compare_by_idNobuyoshi Nakada2019-07-031-3/+0
| | | | The latter is same as the former, removed the duplicate function.
* Turned `recur` into `int` [Feature #15777]Nobuyoshi Nakada2019-06-211-1/+1
|
* Add an optional `inherit` argument to Module#autoload?Jean Boussier2019-06-211-0/+1
| | | | | | [Feature #15777] Closes: https://github.com/ruby/ruby/pull/2173
* Make opt_aref instruction support Integer#[]Yusuke Endoh2019-06-011-0/+1
| | | | | | | | | | | | only when its receiver and the argument are both Integers. Since 6bedbf4625, Integer#[] has supported a range extraction. This means that Integer#[] now accepts multiple arguments, which made the method very slow unfortunately. This change fixes the performance issue by adding a special handling for its traditional use case: `num[idx]` where both `num` and `idx` are Integers.
* Use UNALIGNED_MEMBER_PTRNobuyoshi Nakada2019-05-311-0/+17
| | | | | | | | | | | * internal.h (UNALIGNED_MEMBER_ACCESS, UNALIGNED_MEMBER_PTR): moved from eval_intern.h. * compile.c iseq.c, vm.c: use UNALIGNED_MEMBER_PTR for `entries` in `struct iseq_catch_table`. * vm_eval.c, vm_insnhelper.c: use UNALIGNED_MEMBER_PTR for `body` in `rb_method_definition_t`.
* Fix Possible Control flow issues (DEADCODE)Kazuhiro NISHIYAMA2019-05-291-0/+8
| | | | | Coverity Scan says `Execution cannot reach this statement: "poison_object(v);"`, so do nothing when `ptr` is always 0 without address_sanitizer.
* Fix typos [ci skip]Kazuhiro NISHIYAMA2019-05-241-2/+2
|
* Suppress paranoid warnings for external/3rd-party librariesNobuyoshi Nakada2019-05-231-4/+4
| | | | [Feature #15665]
* add comments [ci skip]Urabe, Shyouhei2019-05-231-0/+46
| | | | Also requested by Ko1.
* prefix ASAN related inline functions asan_Urabe, Shyouhei2019-05-231-13/+10
| | | | requested by Ko1.
* Fixing function nameAaron Patterson2019-05-141-1/+1
| | | | | This function is used for marking / pinning vm stack values, so it should have "vm" in the function name to be more clear.
* turn T_MOVED in to a linked listAaron Patterson2019-05-131-0/+1
|
* guard include with has_featureNARUSE, Yui2019-05-011-1/+3
| | | | | clang's sanitizer/msan_interface.h has fallback macros. It causes redefinition of __msan_unpoison().
* use __attribute__((__no_sanitize__("memory")))Urabe, Shyouhei2019-04-261-8/+11
|
* Make rb_hash_bulk_insert publicnaruse2019-04-211-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add `GC.compact` again.tenderlove2019-04-201-17/+25
| | | | | | 🙏 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting compaction for nowtenderlove2019-04-171-25/+17
| | | | | | 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
* Introduce pattern matching [EXPERIMENTAL]ktsj2019-04-171-0/+1
| | | | | | [ruby-core:87945] [Feature #14912] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adding `GC.compact` and compacting GC support.tenderlove2019-04-171-17/+25
| | | | | | | | | | | 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
* * expand tabs.svn2019-04-101-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Reverting all commits from r67479 to r67496 because of CI failureskazu2019-04-101-25/+17
| | | | | | | | 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
* fix RMoved definition locationtenderlove2019-04-091-0/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Adding `GC.compact` and compacting GC support.tenderlove2019-04-091-17/+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