1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/include/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
..
arithmetic include/ruby/internal/arithmetic/char.h: add doxygen 2021-09-10 20:00:06 +09:00
attr Introduce RBIMPL_NONNULL_ARG macro 2021-09-27 14:47:52 +09:00
compiler_is include/ruby/internal/compiler_is: skip doxygen 2021-09-10 20:00:06 +09:00
core [Feature #18634] Implement Arrays on Variable Width Allocation 2022-03-22 09:42:39 -04:00
encoding [DOC] Fix reference in rb_enc_associate() description 2022-03-01 10:11:59 +09:00
has Define HAVE___BUILTIN_UNREACHABLE instead of UNREACHABLE 2022-02-19 23:32:52 +09:00
intern Finer-grained inline constant cache invalidation 2022-03-24 09:14:38 -07:00
abi.h [Feature #18634] Implement Arrays on Variable Width Allocation 2022-03-22 09:42:39 -04:00
anyargs.h include/ruby/internal/anyargs.h: fix typo 2021-09-10 20:00:06 +09:00
arithmetic.h
assume.h Check if __assume is supported 2022-02-19 23:32:52 +09:00
cast.h include/ruby/internal/cast.h: skip doxygen 2021-09-10 20:00:06 +09:00
compiler_is.h
compiler_since.h
config.h Enable Variable Width Allocation by default 2022-01-12 12:00:55 -05:00
constant_p.h include/ruby/internal/constant_p.h: add doxygen 2021-09-10 20:00:06 +09:00
core.h
ctype.h include/ruby/internal/ctype.h: add doxygen 2021-09-10 20:00:06 +09:00
dllexport.h include/ruby/internal/dllexport.h: add doxygen 2021-09-10 20:00:06 +09:00
dosish.h include/ruby/internal/dosish.h: add doxygen 2021-09-10 20:00:06 +09:00
error.h include/ruby/internal/error.h: name a parameter 2021-09-10 20:00:06 +09:00
eval.h include/ruby/internal/eval.h: add doxygen 2021-09-10 20:00:06 +09:00
event.h include/ruby/internal/event.h: add doxygen 2021-09-10 20:00:06 +09:00
fl_type.h Remove tainted and trusted features 2021-12-26 23:28:54 +09:00
gc.h
glob.h include/ruby/internal/glob.h: add doxygen 2021-09-10 20:00:06 +09:00
globals.h Deprecate include/prepend in refinements and add Refinement#import_methods instead 2021-10-21 16:31:54 +09:00
interpreter.h ruby_cleanup: fix MSVC compile error 2021-09-10 20:00:06 +09:00
iterator.h Suppress deprecated rb_iterate declaration warnings in C++ 2021-09-11 17:54:11 +09:00
memory.h Revert zero-check for alloca 2021-12-10 18:39:48 +09:00
method.h include/ruby/internal/intern/vm.h: add doxygen 2021-09-10 20:00:06 +09:00
module.h include/ruby/internal/module.h: add doxygen 2021-09-10 20:00:06 +09:00
newobj.h include/ruby/internal/newobj.h: add doxygen 2021-09-10 20:00:06 +09:00
rgengc.h include/ruby/internal/rgengc.h: add dosygen 2021-09-10 20:00:06 +09:00
scan_args.h include/ruby/internal/scan_args.h: add doxygen 2021-09-10 20:00:06 +09:00
special_consts.h include/ruby/internal/special_consts.h: add doxygen 2021-09-10 20:00:06 +09:00
static_assert.h
stdalign.h include/ruby/internal/stdalign.h: add doxygen 2021-09-10 20:00:06 +09:00
stdbool.h Honor if _Bool is available 2022-03-16 17:50:13 +09:00
symbol.h include/ruby/internal/symbol.h: add doxygen 2021-09-10 20:00:06 +09:00
value.h include/ruby/internal/value.h: add doxygen 2021-09-10 20:00:06 +09:00
value_type.h include/ruby/internal/value_type.h: add doxygen 2021-09-10 20:00:06 +09:00
variable.h [DOC] Fix function name in example 2022-03-01 09:59:12 +09:00
warning_push.h include/ruby/internal/warning_push.h: add doxygen 2021-09-10 20:00:06 +09:00
xmalloc.h include/ruby/internal/xmalloc.h: add doxygen 2021-09-10 20:00:06 +09:00