You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ZJIT: Pull GetEP out of GetLocal (with level > 0) (ruby#16215)
Closes: Shopify#944
As a first step toward enabling CSE/LVN-based deduplication of frame EP loads,
splitting `GetLocal` handling for `level > 0` into an explicit `GetEP + LoadField` path.
A follow-up PR will handle the `level == 0` case.
let local_idx = ep_offset_to_local_idx(current_iseq, ep_offset);
1289
-
let id:ID = unsafe{rb_zjit_local_id(current_iseq, local_idx.try_into().unwrap())};
1294
+
let id = get_local_var_id(iseq?, level, ep_offset);
1290
1295
1291
1296
if id.0 == 0 || unsafe{rb_id2str(id)} == Qfalse{
1292
1297
returnSome(String::from("<empty>"));
@@ -3057,6 +3062,29 @@ impl Function {
3057
3062
self.push_insn(block,Insn::GuardNoBitsSet{val: flags,mask:Const::CUInt64(RUBY_ELTS_SHAREDasu64),mask_name:Some(ID!(RUBY_ELTS_SHARED)),reason:SideExitReason::GuardNotShared, state });
3058
3063
}
3059
3064
3065
+
// TODO: This helper is currently used for level>0 local reads only.
3066
+
// Split GetLocal(level==0) into explicit SP/EP helpers in a follow-up.
3067
+
fnget_local_from_ep(
3068
+
&mutself,
3069
+
block:BlockId,
3070
+
ep_offset:u32,
3071
+
level:u32,
3072
+
return_type:Type,
3073
+
) -> InsnId{
3074
+
let ep = self.push_insn(block,Insn::GetEP{ level });
3075
+
let local_id = get_local_var_id(self.iseq, level, ep_offset);
3076
+
let ep_offset = i32::try_from(ep_offset)
3077
+
.unwrap_or_else(|_| panic!("Could not convert ep_offset {ep_offset} to i32"));
3078
+
let offset = -(SIZEOF_VALUE_I32* ep_offset);
3079
+
3080
+
self.push_insn(block,Insn::LoadField{
3081
+
recv: ep,
3082
+
id: local_id,
3083
+
offset,
3084
+
return_type,
3085
+
})
3086
+
}
3087
+
3060
3088
/// Rewrite eligible Send opcodes into SendDirect
3061
3089
/// opcodes if we know the target ISEQ statically. This removes run-time method lookups and
0 commit comments