summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authorAlan Wu <[email protected]>2024-10-08 11:44:59 -0400
committerGitHub <[email protected]>2024-10-08 11:44:59 -0400
commitded078c2c44e5a1f9f4191a7021cfe394ac93ba2 (patch)
tree583df72f394de2d873780aba7ce8f90d8cb3ce34 /variable.c
parentcb19dfca2c9b315d29c5303203d8d0d1bbbd8511 (diff)
YJIT: Fastpath for Module#name (#11819)
Module#name shows up as a top C method callee in lobsters so probably common enough. It's also easy to substitute thanks to rb_mod_name() already having no GC yield points. klass = BasicObject 50_000_000.times { klass.name } Benchmark 1: /.rubies/post/bin/ruby --yjit mod_name.rb Time (mean ± σ): 1.433 s ± 0.010 s [User: 1.410 s, System: 0.010 s] Range (min … max): 1.421 s … 1.449 s 10 runs Benchmark 2: /.rubies/mstr/bin/ruby --yjit mod_name.rb Time (mean ± σ): 1.491 s ± 0.012 s [User: 1.468 s, System: 0.010 s] Range (min … max): 1.470 s … 1.511 s 10 runs Summary /.rubies/post/bin/ruby --yjit mod_name.rb ran 1.04 ± 0.01 times faster than /.rubies/mstr/bin/ruby --yjit mod_name.rb
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/variable.c b/variable.c
index 4e55427ff5..bcdf2fb070 100644
--- a/variable.c
+++ b/variable.c
@@ -97,6 +97,8 @@ rb_namespace_p(VALUE obj)
* to not be anonymous. <code>*permanent</code> is set to 1
* if +classpath+ has no anonymous components. There is no builtin
* Ruby level APIs that can change a permanent +classpath+.
+ *
+ * YJIT needs this function to not allocate.
*/
static VALUE
classname(VALUE klass, bool *permanent)
@@ -127,6 +129,7 @@ rb_mod_name0(VALUE klass, bool *permanent)
VALUE
rb_mod_name(VALUE mod)
{
+ // YJIT needs this function to not allocate.
bool permanent;
return classname(mod, &permanent);
}