diff --git a/compile.c b/compile.c index 6f2b812a1e49ba..1decebe3726155 100644 --- a/compile.c +++ b/compile.c @@ -13069,7 +13069,8 @@ inlineable_call(CALL_DATA cd, rb_vm_insns_translator_t * translator) // A leaf method is a method with the builtin inline flag set // or a method that doesn't contain a method call - bool is_leaf_method = callee_iseq->body->builtin_inline_p || !contain_method_call; + // or a method that was previously inlined + bool is_leaf_method = callee_iseq->body->builtin_inline_p || !contain_method_call || callee_iseq->body->param.flags.inlined_iseq; // Only inline simple and leaf methods if (flags & VM_CALL_ARGS_SIMPLE && is_leaf_method) { @@ -13182,8 +13183,14 @@ inline_iseqs(VALUE *code, size_t pos, iseq_value_itr_t * func, void *_ctx, rb_vm char type = opnd_types[i]; switch (type) { case TS_CALLDATA: - iseq->body->ci_size++; - ops[i] = (VALUE)(((CALL_DATA)code[pos + i + 1])->ci); + if (insn_id == BIN(jump_if_cache_miss)) { + // Reuse existing cache + ops[i] = (VALUE)(((CALL_DATA)code[pos + i + 1])); + } + else { + iseq->body->ci_size++; + ops[i] = (VALUE)(((CALL_DATA)code[pos + i + 1])->ci); + } break; case TS_OFFSET: {