mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
679ef34586
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. |
||
---|---|---|
.. | ||
annocheck | ||
bundler | ||
dummy-rake-compiler/rake | ||
lib | ||
m4 | ||
releng | ||
ruby_vm | ||
test | ||
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 | ||
fake.rb | ||
fetch-bundled_gems.rb | ||
file2lastrev.rb | ||
format-release | ||
gen-mailmap.rb | ||
gen_dummy_probes.rb | ||
gen_ruby_tapset.rb | ||
generic_erb.rb | ||
git-refresh | ||
gperf.sed | ||
id2token.rb | ||
ifchange | ||
insns2vm.rb | ||
install-sh | ||
intern_ids.rb | ||
leaked-globals | ||
ln_sr.rb | ||
make-snapshot | ||
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 | ||
rbuninstall.rb | ||
redmine-backporter.rb | ||
release.sh | ||
rmdirs | ||
run-gcov.rb | ||
run-lcov.rb | ||
runruby.rb | ||
search-cgvars.rb | ||
strip-rdoc.rb | ||
sync_default_gems.rb | ||
test-annocheck.sh | ||
test-bundled-gems.rb | ||
test-coverage.rb | ||
transcode-tblgen.rb | ||
transform_mjit_header.rb | ||
travis_retry.sh | ||
travis_wait.sh | ||
update-bundled_gems.rb | ||
update-deps | ||
vtlh.rb | ||
wasm-clangw | ||
ytab.sed |