1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/tool
John Hawthorn 679ef34586 New constant caching insn: opt_getconstant_path
Previously YARV bytecode implemented constant caching by having a pair
of instructions, opt_getinlinecache and opt_setinlinecache, wrapping a
series of getconstant calls (with putobject providing supporting
arguments).

This commit replaces that pattern with a new instruction,
opt_getconstant_path, handling both getting/setting the inline cache and
fetching the constant on a cache miss.

This is implemented by storing the full constant path as a
null-terminated array of IDs inside of the IC structure. idNULL is used
to signal an absolute constant reference.

    $ ./miniruby --dump=insns -e '::Foo::Bar::Baz'
    == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,13)> (catch: FALSE)
    0000 opt_getconstant_path                   <ic:0 ::Foo::Bar::Baz>      (   1)[Li]
    0002 leave

The motivation for this is that we had increasingly found the need to
disassemble the instructions between the opt_getinlinecache and
opt_setinlinecache in order to determine the constant we are fetching,
or otherwise store metadata.

This disassembly was done:
* In opt_setinlinecache, to register the IC against the constant names
  it is using for granular invalidation.
* In rb_iseq_free, to unregister the IC from the invalidation table.
* In YJIT to find the position of a opt_getinlinecache instruction to
  invalidate it when the cache is populated
* In YJIT to register the constant names being used for invalidation.

With this change we no longe need disassemly for these (in fact
rb_iseq_each is now unused), as the list of constant names being
referenced is held in the IC. This should also make it possible to make
more optimizations in the future.

This may also reduce the size of iseqs, as previously each segment
required 32 bytes (on 64-bit platforms) for each constant segment. This
implementation only stores one ID per-segment.

There should be no significant performance change between this and the
previous implementation. Previously opt_getinlinecache was a "leaf"
instruction, but it included a jump (almost always to a separate cache
line). Now opt_getconstant_path is a non-leaf (it may
raise/autoload/call const_missing) but it does not jump. These seem to
even out.
2022-09-01 15:20:49 -07:00
..
annocheck Add make test-annocheck to detect security issues. 2022-05-16 10:10:16 +02:00
bundler Merge RubyGems and Bundler master 2022-07-13 14:11:55 +09:00
dummy-rake-compiler/rake
lib VCS#revision_header: Make arguments optional 2022-09-01 20:57:30 +09:00
m4 Fallback mkdir_p to as_mkdir_p 2022-07-07 15:06:10 +09:00
releng
ruby_vm New constant caching insn: opt_getconstant_path 2022-09-01 15:20:49 -07:00
test Allow strings in assert_pattern_list 2022-08-19 01:28:31 +09:00
asm_parse.rb
bisect.sh
build-transcode
checksum.rb
ci_functions.sh
colors
darwin-cc
disable_ipv6.sh
downloader.rb
enc-emoji-citrus-gen.rb
enc-emoji4unicode.rb
enc-unicode.rb
eval.rb
expand-config.rb
extlibs.rb tool/extlibs.rb: Use Exception#message for older rubies 2022-06-17 18:13:19 -04:00
fake.rb Use $(bindir) for path to executable in mkmf 2022-08-04 16:29:22 +09:00
fetch-bundled_gems.rb Try the tag without "v" prefix to checkout upstream repositories 2022-07-26 21:12:58 +09:00
file2lastrev.rb VCS#revision_header: Make arguments optional 2022-09-01 20:57:30 +09:00
format-release
gen-mailmap.rb
gen_dummy_probes.rb
gen_ruby_tapset.rb
generic_erb.rb
git-refresh
gperf.sed [ruby/date] Constify gperf-generated table 2022-05-24 17:23:42 +09:00
id2token.rb
ifchange
insns2vm.rb
install-sh
intern_ids.rb
leaked-globals
ln_sr.rb Fix conversion from absolute path to relative path 2022-07-16 17:58:52 +09:00
make-snapshot VCS#revision_header: Make arguments optional 2022-09-01 20:57:30 +09:00
make_hgraph.rb
mdoc2man.rb
merger.rb
mjit_archflag.sh
mjit_tabs.rb
mk_builtin_loader.rb
mkconfig.rb
mkrunnable.rb
node_name.rb
parse.rb
prereq.status
probes_to_wiki.rb
pure_parser.rb
rbinstall.rb Make date in installed gemspec files stable 2022-08-17 00:58:56 +09:00
rbuninstall.rb
redmine-backporter.rb
release.sh
rmdirs
run-gcov.rb
run-lcov.rb
runruby.rb Set GEM_PATH environment variable in runruby.rb 2022-07-14 09:00:13 +09:00
search-cgvars.rb
strip-rdoc.rb
sync_default_gems.rb Ignore test libraries like assert_ractor from did_you_mean 2022-09-01 17:02:55 +09:00
test-annocheck.sh Add make test-annocheck to detect security issues. 2022-05-16 10:10:16 +02:00
test-bundled-gems.rb Do not load library files from repository only for test 2022-07-27 17:36:45 +09:00
test-coverage.rb
transcode-tblgen.rb
transform_mjit_header.rb Fix a typo [ci skip] 2022-08-20 18:36:52 -07:00
travis_retry.sh
travis_wait.sh
update-bundled_gems.rb Preserve each column positions in gems/bundled_gems 2022-08-12 23:51:55 +09:00
update-deps Bundled gem extensions are out of scope of update-deps 2022-07-13 22:14:30 +09:00
vtlh.rb
wasm-clangw
ytab.sed