[前][次][番号順一覧][スレッド一覧]

ruby-changes:70049

From: eileencodes <ko1@a...>
Date: Sat, 4 Dec 2021 02:46:13 +0900 (JST)
Subject: [ruby-changes:70049] 54ca530dbe (master): YJIT: Add ivar counter exits

https://git.ruby-lang.org/ruby.git/commit/?id=54ca530dbe

From 54ca530dbe39f389da2b5972a574460a3665eeff Mon Sep 17 00:00:00 2001
From: eileencodes <eileencodes@g...>
Date: Wed, 1 Dec 2021 14:01:34 -0500
Subject: YJIT: Add ivar counter exits

On Rails we're seeing a lot of exits for ivars in the Active Record
tests. In trying to track them down it was hard to find what code is
exiting.

This change adds a counted exit for when an object is "megamorphic". In
these cases there are too many specializations in the Ruby code so YJIT
exits.

Co-authored-by: Aaron Patterson tenderlove@r...
---
 yjit.c         | 1 +
 yjit_codegen.c | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/yjit.c b/yjit.c
index 0bf84f13b70..3354c243413 100644
--- a/yjit.c
+++ b/yjit.c
@@ -103,6 +103,7 @@ YJIT_DECLARE_COUNTERS( https://github.com/ruby/ruby/blob/trunk/yjit.c#L103
 
     getivar_se_self_not_heap,
     getivar_idx_out_of_range,
+    getivar_megamorphic,
 
     setivar_se_self_not_heap,
     setivar_idx_out_of_range,
diff --git a/yjit_codegen.c b/yjit_codegen.c
index ed2d7bbcdc9..061cd1ead7f 100644
--- a/yjit_codegen.c
+++ b/yjit_codegen.c
@@ -1735,7 +1735,7 @@ gen_get_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1735
         ADD_COMMENT(cb, "guard embedded getivar");
         x86opnd_t flags_opnd = member_opnd(REG0, struct RBasic, flags);
         test(cb, flags_opnd, imm_opnd(ROBJECT_EMBED));
-        jit_chain_guard(JCC_JZ, jit, &starting_context, max_chain_depth, side_exit);
+        jit_chain_guard(JCC_JZ, jit, &starting_context, max_chain_depth, COUNTED_EXIT(jit, side_exit, getivar_megamorphic));
 
         // Load the variable
         x86opnd_t ivar_opnd = mem_opnd(64, REG0, offsetof(struct RObject, as.ary) + ivar_index * SIZEOF_VALUE);
@@ -1758,7 +1758,7 @@ gen_get_ivar(jitstate_t *jit, ctx_t *ctx, const int max_chain_depth, VALUE compt https://github.com/ruby/ruby/blob/trunk/yjit_codegen.c#L1758
         ADD_COMMENT(cb, "guard extended getivar");
         x86opnd_t flags_opnd = member_opnd(REG0, struct RBasic, flags);
         test(cb, flags_opnd, imm_opnd(ROBJECT_EMBED));
-        jit_chain_guard(JCC_JNZ, jit, &starting_context, max_chain_depth, side_exit);
+        jit_chain_guard(JCC_JNZ, jit, &starting_context, max_chain_depth, COUNTED_EXIT(jit, side_exit, getivar_megamorphic));
 
         // check that the extended table is big enough
         if (ivar_index >= ROBJECT_EMBED_LEN_MAX + 1) {
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]