ruby/internal
Kevin Newton 629908586b Finer-grained inline constant cache invalidation
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.
2022-03-24 09:14:38 -07:00
..
array.h Add comments about special runtime routines YJIT calls 2021-10-20 18:19:43 -04:00
bignum.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
bits.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
class.h Dedup superclass array in leaf sibling classes 2022-03-03 11:23:27 -08:00
cmdlineopt.h * expand tabs. [ci skip] 2022-01-15 20:10:30 +09:00
compar.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
compile.h `RubyVM.keep_script_lines` 2021-10-21 16:17:39 +09:00
compilers.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
complex.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
cont.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
dir.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
enc.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
encoding.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
enum.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
enumerator.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
error.h suppress GCC's -Wsuggest-attribute=format 2021-09-10 20:00:06 +09:00
eval.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
file.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
fixnum.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
gc.h Change darray size to size_t and add functions that use GC malloc 2022-02-16 09:50:29 -05:00
hash.h Restore Hash#compare_by_identity mode [Bug #18171] 2021-10-02 11:43:35 +09:00
imemo.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
inits.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
io.h Move some function declaration to internal/io.h 2021-09-28 18:08:08 +13:00
load.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
loadpath.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
math.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
missing.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
numeric.h Embed bare `double` if `sizeof(double) == sizeof(VALUE)` 2021-10-27 02:05:06 +09:00
object.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
parse.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
proc.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
process.h process.c: Add Process._fork (#5017) 2021-10-25 20:47:19 +09:00
random.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
range.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
rational.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
re.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
sanitizers.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
serial.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
signal.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
static_assert.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
string.h Add comments about special runtime routines YJIT calls 2021-10-20 18:19:43 -04:00
struct.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
symbol.h Assign temporary ID to anonymous ID [Bug #18250] 2021-11-23 21:03:19 +09:00
thread.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
time.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
transcode.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
util.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00
variable.h Extract yjit_force_iv_index and make it work when object is frozen 2021-10-20 18:19:43 -04:00
vm.h Finer-grained inline constant cache invalidation 2022-03-24 09:14:38 -07:00
warnings.h internal/*.h: skip doxygen 2021-09-10 20:00:06 +09:00