diff options
author | Koichi Sasada <ko1@atdot.net> | 2023-03-10 01:30:30 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2023-03-23 14:03:12 +0900 |
commit | c9fd81b860b5ec193ba57c73c740955937452497 (patch) | |
tree | 37d7f0ac40f0122c222b1dc952ef0f0907440b0a /vm_callinfo.h | |
parent | e5a5e43c36443e06756aba6de95c94b41b910a82 (diff) |
`vm_call_single_noarg_inline_builtin`
If the iseq only contains `opt_invokebuiltin_delegate_leave` insn and
the builtin-function (bf) is inline-able, the caller doesn't need to
build a method frame.
`vm_call_single_noarg_inline_builtin` is fast path for such cases.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7486
Diffstat (limited to 'vm_callinfo.h')
-rw-r--r-- | vm_callinfo.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/vm_callinfo.h b/vm_callinfo.h index 1edeee1f56..bf34908eea 100644 --- a/vm_callinfo.h +++ b/vm_callinfo.h @@ -290,6 +290,7 @@ struct rb_callcache { } attr; const enum method_missing_reason method_missing_reason; /* used by method_missing */ VALUE v; + const struct rb_builtin_function *bf; } aux_; }; @@ -439,6 +440,9 @@ vm_cc_valid_p(const struct rb_callcache *cc, const rb_callable_method_entry_t *c /* callcache: mutate */ +#define VM_CALLCACH_IVAR IMEMO_FL_USER0 +#define VM_CALLCACH_BF IMEMO_FL_USER1 + static inline void vm_cc_call_set(const struct rb_callcache *cc, vm_call_handler call) { @@ -458,6 +462,13 @@ vm_cc_attr_index_set(const struct rb_callcache *cc, attr_index_t index, shape_id VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache)); VM_ASSERT(cc != vm_cc_empty()); *attr_value = (attr_index_t)(index + 1) | ((uintptr_t)(dest_shape_id) << SHAPE_FLAG_SHIFT); + *(VALUE *)&cc->flags |= VM_CALLCACH_IVAR; +} + +static inline bool +vm_cc_ivar_p(const struct rb_callcache *cc) +{ + return (cc->flags & VM_CALLCACH_IVAR) != 0; } static inline void @@ -481,6 +492,21 @@ vm_cc_method_missing_reason_set(const struct rb_callcache *cc, enum method_missi } static inline void +vm_cc_bf_set(const struct rb_callcache *cc, const struct rb_builtin_function *bf) +{ + VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache)); + VM_ASSERT(cc != vm_cc_empty()); + *(const struct rb_builtin_function **)&cc->aux_.bf = bf; + *(VALUE *)&cc->flags |= VM_CALLCACH_BF; +} + +static inline bool +vm_cc_bf_p(const struct rb_callcache *cc) +{ + return (cc->flags & VM_CALLCACH_BF) != 0; +} + +static inline void vm_cc_invalidate(const struct rb_callcache *cc) { VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache)); |