mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
629908586b
Current behavior - caches depend on a global counter. All constant mutations cause caches to be invalidated. ```ruby class A B = 1 end def foo A::B # inline cache depends on global counter end foo # populate inline cache foo # hit inline cache C = 1 # global counter increments, all caches are invalidated foo # misses inline cache due to `C = 1` ``` Proposed behavior - caches depend on name components. Only constant mutations with corresponding names will invalidate the cache. ```ruby class A B = 1 end def foo A::B # inline cache depends constants named "A" and "B" end foo # populate inline cache foo # hit inline cache C = 1 # caches that depend on the name "C" are invalidated foo # hits inline cache because IC only depends on "A" and "B" ``` Examples of breaking the new cache: ```ruby module C # Breaks `foo` cache because "A" constant is set and the cache in foo depends # on "A" and "B" class A; end end B = 1 ``` We expect the new cache scheme to be invalidated less often because names aren't frequently reused. With the cache being invalidated less, we can rely on its stability more to keep our constant references fast and reduce the need to throw away generated code in YJIT. |
||
---|---|---|
.. | ||
backward | ||
fiber | ||
internal | ||
io | ||
assert.h | ||
atomic.h | ||
backward.h | ||
debug.h | ||
defines.h | ||
encoding.h | ||
intern.h | ||
io.h | ||
memory_view.h | ||
missing.h | ||
onigmo.h | ||
oniguruma.h | ||
ractor.h | ||
random.h | ||
re.h | ||
regex.h | ||
ruby.h | ||
st.h | ||
subst.h | ||
thread.h | ||
thread_native.h | ||
util.h | ||
version.h | ||
vm.h | ||
win32.h |