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
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
..
backward Check if __assume is supported 2022-02-19 23:32:52 +09:00
fiber Fix typos [ci skip] 2021-12-25 10:33:49 +09:00
internal Finer-grained inline constant cache invalidation 2022-03-24 09:14:38 -07:00
io Add fiber scheduler hooks for pread/pwrite, and add support to IO::Buffer. 2021-12-23 12:20:09 +13:00
assert.h
atomic.h Align the implementation precedences with rb_atomic_t definition 2021-09-24 10:11:32 +09:00
backward.h Finer-grained inline constant cache invalidation 2022-03-24 09:14:38 -07:00
debug.h include/ruby/debug.h: add doxygen 2021-09-10 20:00:06 +09:00
defines.h include/ruby/defines.h: add doxygen 2021-09-10 20:00:06 +09:00
encoding.h split include/ruby/encoding.h 2021-10-05 14:18:23 +09:00
intern.h
io.h include/ruby/io.h: use 0 as POLLPRI when no support for it 2022-01-19 13:19:58 +09:00
memory_view.h memory_view.c: Add _memory_view_entry member in rb_memory_view_t (#5088) 2021-11-08 12:52:09 +09:00
missing.h [wasm] wasm/missing.{c,h}: add missing libc stubs for wasi-libc 2022-01-19 11:19:06 +09:00
onigmo.h
oniguruma.h
ractor.h Fix typos 2021-11-02 19:17:37 +09:00
random.h include/ruby/random.h: add doxygen 2021-09-10 20:00:06 +09:00
re.h include/ruby/re.h: add doxygen 2021-09-10 20:00:06 +09:00
regex.h include/ruby/regex.h: skip doxygen 2021-09-10 20:00:06 +09:00
ruby.h [Feature #18249] Implement ABI checking 2022-02-22 09:55:21 -05:00
st.h
subst.h
thread.h
thread_native.h [wasm] add no thread variant for freestanding environment 2022-01-19 11:19:06 +09:00
util.h ruby_scan_oct, ruby_scan_hex: are not pure 2021-09-10 20:00:06 +09:00
version.h Development of 3.1.0 started. 2021-12-26 23:22:26 +09:00
vm.h
win32.h include/ruby/win32.h: explicitly define HAVE_SHUTDOWN 2022-01-19 17:52:19 +09:00