From 9312f4bf62224cc0a11175cb6f9b7d0dd840a491 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Fri, 11 Mar 2022 11:48:02 -0800 Subject: Allow method caching of protected FCALLs --- vm_insnhelper.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'vm_insnhelper.h') diff --git a/vm_insnhelper.h b/vm_insnhelper.h index 126867025f..2199ee37cc 100644 --- a/vm_insnhelper.h +++ b/vm_insnhelper.h @@ -252,13 +252,18 @@ THROW_DATA_CONSUMED_SET(struct vm_throw_data *obj) #define IS_ARGS_KW_OR_KW_SPLAT(ci) (vm_ci_flag(ci) & (VM_CALL_KWARG | VM_CALL_KW_SPLAT)) #define IS_ARGS_KW_SPLAT_MUT(ci) (vm_ci_flag(ci) & VM_CALL_KW_SPLAT_MUT) +static inline bool +vm_call_cacheable(const struct rb_callinfo *ci, const struct rb_callcache *cc) +{ + return (vm_ci_flag(ci) & VM_CALL_FCALL) || + METHOD_ENTRY_VISI(vm_cc_cme(cc)) != METHOD_VISI_PROTECTED; +} /* If this returns true, an optimized function returned by `vm_call_iseq_setup_func` can be used as a fastpath. */ static inline bool vm_call_iseq_optimizable_p(const struct rb_callinfo *ci, const struct rb_callcache *cc) { - return !IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) && - METHOD_ENTRY_CACHEABLE(vm_cc_cme(cc)); + return !IS_ARGS_SPLAT(ci) && !IS_ARGS_KEYWORD(ci) && vm_call_cacheable(ci, cc); } #endif /* RUBY_INSNHELPER_H */ -- cgit v1.2.1