aboutsummaryrefslogtreecommitdiffstats
path: root/internal.h
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-10-29 11:37:25 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-11-05 11:39:35 +0900
commit6ff1250739c57ce7f234a2148d3f6214da01b7e5 (patch)
tree169447ceb51f397b202994104a514a8b1764ecd3 /internal.h
parent1390d56ecfac2e430df94c4d4a60d8fa80d11166 (diff)
downloadruby-6ff1250739c57ce7f234a2148d3f6214da01b7e5.tar.gz
rb_method_basic_definition_p with CC
Noticed that rb_method_basic_definition_p is frequently called. Its callers include vm_caller_setup_args_block(), rb_hash_default_value(), rb_num_neative_int_p(), and a lot more. It seems worth caching the method resolution part. Majority of rb_method_basic_definion_p() usages take fixed class and fixed method id combinations. Calculating ------------------------------------- ours trunk so_matrix 2.379 2.115 i/s - 1.000 times in 0.420409s 0.472879s Comparison: so_matrix ours: 2.4 i/s trunk: 2.1 i/s - 1.12x slower
Diffstat (limited to 'internal.h')
-rw-r--r--internal.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/internal.h b/internal.h
index 6c6e262f65..0c245c3d43 100644
--- a/internal.h
+++ b/internal.h
@@ -2389,6 +2389,8 @@ struct rb_call_data {
};
RUBY_FUNC_EXPORTED
RUBY_FUNC_NONNULL(1, VALUE rb_funcallv_with_cc(struct rb_call_data*, VALUE, ID, int, const VALUE*));
+RUBY_FUNC_EXPORTED
+RUBY_FUNC_NONNULL(1, bool rb_method_basic_definition_p_with_cc(struct rb_call_data *, VALUE, ID));
#ifdef __GNUC__
# define rb_funcallv(recv, mid, argc, argv) \
@@ -2396,6 +2398,12 @@ RUBY_FUNC_NONNULL(1, VALUE rb_funcallv_with_cc(struct rb_call_data*, VALUE, ID,
static struct rb_call_data rb_funcallv_data = { { 0, }, { 0, }, }; \
rb_funcallv_with_cc(&rb_funcallv_data, recv, mid, argc, argv); \
})
+# define rb_method_basic_definition_p(klass, mid) \
+ __extension__({ \
+ static struct rb_call_data rb_mbdp = { { 0, }, { 0, }, }; \
+ (klass == Qfalse) ? /* hidden object cannot be overridden */ true : \
+ rb_method_basic_definition_p_with_cc(&rb_mbdp, klass, mid); \
+ })
#endif
/* miniprelude.c, prelude.c */