1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/tool
Koichi Sasada b1b73936c1 Primitive.mandatory_only? for fast path
Compare with the C methods, A built-in methods written in Ruby is
slower if only mandatory parameters are given because it needs to
check the argumens and fill default values for optional and keyword
parameters (C methods can check the number of parameters with `argc`,
so there are no overhead). Passing mandatory arguments are common
(optional arguments are exceptional, in many cases) so it is important
to provide the fast path for such common cases.

`Primitive.mandatory_only?` is a special builtin function used with
`if` expression like that:

```ruby
  def self.at(time, subsec = false, unit = :microsecond, in: nil)
    if Primitive.mandatory_only?
      Primitive.time_s_at1(time)
    else
      Primitive.time_s_at(time, subsec, unit, Primitive.arg!(:in))
    end
  end
```

and it makes two ISeq,

```
  def self.at(time, subsec = false, unit = :microsecond, in: nil)
    Primitive.time_s_at(time, subsec, unit, Primitive.arg!(:in))
  end

  def self.at(time)
    Primitive.time_s_at1(time)
  end
```

and (2) is pointed by (1). Note that `Primitive.mandatory_only?`
should be used only in a condition of an `if` statement and the
`if` statement should be equal to the methdo body (you can not
put any expression before and after the `if` statement).

A method entry with `mandatory_only?` (`Time.at` on the above case)
is marked as `iseq_overload`. When the method will be dispatch only
with mandatory arguments (`Time.at(0)` for example), make another
method entry with ISeq (2) as mandatory only method entry and it
will be cached in an inline method cache.

The idea is similar discussed in https://bugs.ruby-lang.org/issues/16254
but it only checks mandatory parameters or more, because many cases
only mandatory parameters are given. If we find other cases (optional
or keyword parameters are used frequently and it hurts performance),
we can extend the feature.
2021-11-15 15:58:56 +09:00
..
bundler Newly generated gems require Ruby 2.6.0 2021-10-09 09:07:47 +09:00
dummy-rake-compiler/rake Bundle rbs 1.7.0.beta.5 2021-11-09 03:32:46 +09:00
lib Filter method names only if filtering method name only 2021-11-09 15:20:44 +09:00
m4 Allow the thread-model to be switched by configure option 2021-10-30 10:18:33 +09:00
releng
ruby_vm vm_core.h: Avoid unaligned access to ic_serial on 32-bit machine 2021-10-29 10:57:46 +09:00
test Disable experimental warnings in test/runner.rb 2021-11-10 17:42:09 +09:00
asm_parse.rb
bisect.sh
build-transcode
checksum.rb
ci_functions.sh tool/ci_functions.sh: Fix typos and improve the comment. [ci skip] 2021-05-31 16:24:16 +02:00
colors
darwin-cc
disable_ipv6.sh .cirrus.yml: Add Cirrus CI for Arm64 tests. 2021-09-22 09:01:43 +02:00
downloader.rb Downloader: retry when RFC 2616 noncompliant dates [ci skip] 2021-10-28 17:42:36 +09:00
enc-emoji-citrus-gen.rb
enc-emoji4unicode.rb
enc-unicode.rb Adjust tool/enc-unicode.rb to deal with new location of some emoji files 2021-07-08 14:45:03 +09:00
eval.rb
expand-config.rb
extlibs.rb Show a backtrace when tool/extlibs.rb fails 2021-05-21 23:36:56 -07:00
fake.rb Leave builddir absolute 2021-10-04 20:04:38 +09:00
fetch-bundled_gems.rb
file2lastrev.rb
format-release Update tool/format-release 2021-04-05 23:19:44 +09:00
gem-unpack.rb
gen-mailmap.rb
gen_dummy_probes.rb
gen_ruby_tapset.rb
generic_erb.rb Revert "Extracted AtomicWrite" 2021-03-13 09:14:20 +09:00
git-refresh
gperf.sed
id2token.rb
ifchange
insns2vm.rb
install-sh
intern_ids.rb Added intern_ids.rb 2021-07-27 15:40:27 +09:00
leaked-globals
make-snapshot Prepend DebugSystem to VCS class only 2021-07-26 15:44:40 +09:00
make_hgraph.rb
mdoc2man.rb
merger.rb The guard is to alert patchlevel of X.Y.0 2021-04-06 12:02:46 +09:00
mjit_archflag.sh
mjit_tabs.rb Make --without-mjit-tabs work again 2021-05-31 22:56:22 -07:00
mk_builtin_loader.rb Primitive.mandatory_only? for fast path 2021-11-15 15:58:56 +09:00
mkconfig.rb Get rid of exponential backtracks found by CodeQL 2021-10-30 02:22:42 +09:00
mkrunnable.rb Hard-link executable files to mae runnable 2021-08-19 16:10:35 +09:00
node_name.rb
parse.rb
prereq.status
probes_to_wiki.rb
pure_parser.rb
rbinstall.rb Skip bundled gem with an extension library under with-static-linked-ext 2021-11-05 09:34:46 +09:00
rbuninstall.rb
redmine-backporter.rb Pass revision by hand if the commit message lacks the ticket number 2021-02-02 19:15:45 +09:00
release.sh
rmdirs
run-gcov.rb
run-lcov.rb
runruby.rb Yet Another Ruby JIT! 2021-10-20 18:19:31 -04:00
search-cgvars.rb
strip-rdoc.rb tool/strip-rdoc.rb: optimize 2021-09-10 20:00:06 +09:00
sync_default_gems.rb Removed redundant digest namespace 2021-10-14 14:07:50 +09:00
test-bundled-gems.rb Bundle RBS 1.7.0 (#5105) 2021-11-12 02:01:53 +09:00
test-coverage.rb
transcode-tblgen.rb
transform_mjit_header.rb
travis_retry.sh
travis_wait.sh .travis.yml: Update to use arm64/ppc64le/s390x. 2021-05-25 12:38:05 +02:00
update-bundled_gems.rb Drop optional commit hash when updated 2021-07-21 20:44:13 +09:00
update-deps update-deps: prepare to run if not yet done 2021-04-06 09:33:53 +09:00
vtlh.rb
ytab.sed