summaryrefslogtreecommitdiff
path: root/internal.h
AgeCommit message (Collapse)Author
2019-08-27rb_ensure now free from ANYARGS卜部昌平
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.
2019-08-27decouple compile.c usage of imemo_ifunc卜部昌平
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.
2019-08-27delete rb_method_defined_by declaration.卜部昌平
Ko1 missed this in d5893b91faa7dc77ca6c9728d1054dabd757aead.
2019-08-21`rp(obj)` shows func, file and line. (#2394)Koichi Sasada
rp() macro for debug also shows file location and function name such as: [OBJ_INFO:rb_call_inits@inits.c:73] 0x000056147741b248 ... Notes: Merged-By: ko1
2019-08-13Renamed ruby_finalize_{0,1}Nobuyoshi Nakada
And pass rb_execution_context_t as an argument.
2019-08-10Expanded f_quoNobuyoshi Nakada
2019-08-09add rp() and bp() in internal.h.Koichi Sasada
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`).
2019-08-09introduce RCLASS_CLONED flag for inline cache.Koichi Sasada
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]
2019-08-06leafify opt_plus卜部昌平
Inspired by 346aa557b31fe96760e505d30da26eb7a846bac9 Closes: https://github.com/ruby/ruby/pull/2321
2019-08-04Make opt_eq and opt_neq insns leafTakashi Kokubun
# 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
2019-08-02Expanded f_ceilNobuyoshi Nakada
2019-08-01introduce ar_hint_t.Koichi Sasada
Hash hint for ar_array is 1 byte (unsigned char). This patch introduce ar_hint_t which represents hint type.
2019-07-31move macro to internal.h for documentation.Koichi Sasada
13e84d5c0a changes enum to macro, but the flags usage information are lost in internal.h. It should be same place with other flags information.
2019-07-31Moved RHASH_LEV_MASK and turned into a macroNobuyoshi Nakada
Get rid of "ISO C restricts enumerator values to range of 'int'" error.
2019-07-31Use 1 byte hint for ar_table [Feature #15602]Koichi Sasada
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
2019-07-31remove RHash::iter_lev.Koichi Sasada
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).
2019-07-28Reuse match dataNobuyoshi Nakada
* string.c (rb_str_split_m): reuse occupied match data. [Bug #16024]
2019-07-22constify again.Koichi Sasada
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.
2019-07-22constify RHash::ifnone.Koichi Sasada
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.
2019-07-16Moved the check for `exception` to rb_execarg_addoptNobuyoshi Nakada
Check for `exception` option in rb_execarg_addopt, as well as other options. And then raise a particular ArgumentError if it is not allowed.
2019-07-16Expanded f_numeratorNobuyoshi Nakada
2019-07-16Expanded f_denominatorNobuyoshi Nakada
2019-07-15respect RUBY_DEBUG.Koichi Sasada
see RUBY_DEBUG for each debug options.
2019-07-14socket: use frozen string buffer when releasing GVLTanaka Akira
Thanks for the patch by normalperson (Eric Wong) [Bug #14204].
2019-07-11Check exception flag as a bool [Bug #15987]Nobuyoshi Nakada
2019-07-03Use rb_ident_hash_new instead of rb_hash_new_compare_by_idNobuyoshi Nakada
The latter is same as the former, removed the duplicate function.
2019-06-21Turned `recur` into `int` [Feature #15777]Nobuyoshi Nakada
2019-06-21Add an optional `inherit` argument to Module#autoload?Jean Boussier
[Feature #15777] Closes: https://github.com/ruby/ruby/pull/2173
2019-06-01Make opt_aref instruction support Integer#[]Yusuke Endoh
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.
2019-05-31Use UNALIGNED_MEMBER_PTRNobuyoshi Nakada
* 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`.
2019-05-29Fix Possible Control flow issues (DEADCODE)Kazuhiro NISHIYAMA
Coverity Scan says `Execution cannot reach this statement: "poison_object(v);"`, so do nothing when `ptr` is always 0 without address_sanitizer.
2019-05-24Fix typos [ci skip]Kazuhiro NISHIYAMA
2019-05-23Suppress paranoid warnings for external/3rd-party librariesNobuyoshi Nakada
[Feature #15665]
2019-05-23add comments [ci skip]Urabe, Shyouhei
Also requested by Ko1.
2019-05-23prefix ASAN related inline functions asan_Urabe, Shyouhei
requested by Ko1.
2019-05-14Fixing function nameAaron Patterson
This function is used for marking / pinning vm stack values, so it should have "vm" in the function name to be more clear.
2019-05-13turn T_MOVED in to a linked listAaron Patterson
2019-05-01guard include with has_featureNARUSE, Yui
clang's sanitizer/msan_interface.h has fallback macros. It causes redefinition of __msan_unpoison().
2019-04-26use __attribute__((__no_sanitize__("memory")))Urabe, Shyouhei
2019-04-21Make rb_hash_bulk_insert publicnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67677 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-10* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67500 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-09fix RMoved definition locationtenderlove
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67487 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-04-06internal.h: fix potential memory leaknobu
* internal.h (rb_imemo_tmpbuf_auto_free_pointer_new_from_an_RString): create tmpbuf to keep the pointer before xmalloc which can raise a NoMemoryError exception. extracted from https://github.com/bear-metal/ruby/tree/transient-imemo-tmpbuf git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67459 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-01unpoison / poison objects while walking the heaptenderlove
This fixes some ASAN errors git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e