From c46bda6f191b01121ebbc8afa88b35683b6417a9 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Mon, 20 Sep 2021 14:55:10 -0400 Subject: Fix excessive invalidation for opt_getinlinecache YJIT expects the VM to invalidate opt_getinlinecache when updating the constant cache, and the invalidation used to happen even when YJIT can't use the cached value. Once the first invalidation happens, the block for opt_getinlinecache becomes a stub. When the stub is hit, YJIT fails to compile the instruction as the cache is not usable. The stub becomes a block that exits for opt_getinlinecache which can be invalidated again. Some workloads that bust the interpreter's constant cache can create an invalidation loop with this behavior. Check if the cache is usable become doing invalidation to fix this problem. In the test harness, evaluate the test script in a lambda instead of a proc so `return` doesn't return out of the harness. --- yjit_codegen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yjit_codegen.c') diff --git a/yjit_codegen.c b/yjit_codegen.c index 4fec409621..0afe617bb1 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -4068,7 +4068,7 @@ gen_opt_getinlinecache(jitstate_t *jit, ctx_t *ctx) VALUE const_cache_as_value = jit_get_arg(jit, 1); IC ic = (IC)const_cache_as_value; - // See vm_ic_hit_p(). + // See vm_ic_hit_p(). The same conditions are checked in yjit_constant_ic_update(). struct iseq_inline_constant_cache_entry *ice = ic->entry; if (!ice || // cache not filled ice->ic_serial != ruby_vm_global_constant_state || // cache out of date -- cgit v1.2.3