@@ -707,12 +707,10 @@ pub enum Insn {
707707 SetGlobal { id : ID , val : InsnId , state : InsnId } ,
708708
709709 //NewObject?
710- /// Get an instance variable `id` from `self_val`
711- GetIvar { self_val : InsnId , id : ID , state : InsnId } ,
712- /// Set `self_val`'s instance variable `id` to `val`
713- SetIvar { self_val : InsnId , id : ID , val : InsnId , state : InsnId } ,
714- /// Set `self_val`'s instance variable `id` to `val` using the interpreter inline cache
715- SetInstanceVariable { self_val : InsnId , id : ID , ic : * const iseq_inline_iv_cache_entry , val : InsnId , state : InsnId } ,
710+ /// Get an instance variable `id` from `self_val`, using the inline cache `ic` if present
711+ GetIvar { self_val : InsnId , id : ID , ic : * const iseq_inline_iv_cache_entry , state : InsnId } ,
712+ /// Set `self_val`'s instance variable `id` to `val`, using the inline cache `ic` if present
713+ SetIvar { self_val : InsnId , id : ID , val : InsnId , ic : * const iseq_inline_iv_cache_entry , state : InsnId } ,
716714 /// Check whether an instance variable exists on `self_val`
717715 DefinedIvar { self_val : InsnId , id : ID , pushval : VALUE , state : InsnId } ,
718716
@@ -912,7 +910,7 @@ impl Insn {
912910 | Insn :: PatchPoint { .. } | Insn :: SetIvar { .. } | Insn :: SetClassVar { .. } | Insn :: ArrayExtend { .. }
913911 | Insn :: ArrayPush { .. } | Insn :: SideExit { .. } | Insn :: SetGlobal { .. }
914912 | Insn :: SetLocal { .. } | Insn :: Throw { .. } | Insn :: IncrCounter ( _) | Insn :: IncrCounterPtr { .. }
915- | Insn :: CheckInterrupts { .. } | Insn :: GuardBlockParamProxy { .. } | Insn :: SetInstanceVariable { .. } | Insn :: StoreField { .. } | Insn :: WriteBarrier { .. } => false ,
913+ | Insn :: CheckInterrupts { .. } | Insn :: GuardBlockParamProxy { .. } | Insn :: StoreField { .. } | Insn :: WriteBarrier { .. } => false ,
916914 _ => true ,
917915 }
918916 }
@@ -1248,7 +1246,6 @@ impl<'a> std::fmt::Display for InsnPrinter<'a> {
12481246 & Insn :: StoreField { recv, id, offset, val } => write ! ( f, "StoreField {recv}, :{}@{:p}, {val}" , id. contents_lossy( ) , self . ptr_map. map_offset( offset) ) ,
12491247 & Insn :: WriteBarrier { recv, val } => write ! ( f, "WriteBarrier {recv}, {val}" ) ,
12501248 Insn :: SetIvar { self_val, id, val, .. } => write ! ( f, "SetIvar {self_val}, :{}, {val}" , id. contents_lossy( ) ) ,
1251- Insn :: SetInstanceVariable { self_val, id, val, .. } => write ! ( f, "SetInstanceVariable {self_val}, :{}, {val}" , id. contents_lossy( ) ) ,
12521249 Insn :: GetGlobal { id, .. } => write ! ( f, "GetGlobal :{}" , id. contents_lossy( ) ) ,
12531250 Insn :: SetGlobal { id, val, .. } => write ! ( f, "SetGlobal :{}, {val}" , id. contents_lossy( ) ) ,
12541251 & Insn :: GetLocal { level, ep_offset, use_sp : true , rest_param } => write ! ( f, "GetLocal l{level}, SP@{}{}" , ep_offset + 1 , if rest_param { ", *" } else { "" } ) ,
@@ -1891,12 +1888,11 @@ impl Function {
18911888 & ArrayInclude { ref elements, target, state } => ArrayInclude { elements : find_vec ! ( elements) , target : find ! ( target) , state : find ! ( state) } ,
18921889 & DupArrayInclude { ary, target, state } => DupArrayInclude { ary, target : find ! ( target) , state : find ! ( state) } ,
18931890 & SetGlobal { id, val, state } => SetGlobal { id, val : find ! ( val) , state } ,
1894- & GetIvar { self_val, id, state } => GetIvar { self_val : find ! ( self_val) , id, state } ,
1891+ & GetIvar { self_val, id, ic , state } => GetIvar { self_val : find ! ( self_val) , id, ic , state } ,
18951892 & LoadField { recv, id, offset, return_type } => LoadField { recv : find ! ( recv) , id, offset, return_type } ,
18961893 & StoreField { recv, id, offset, val } => StoreField { recv : find ! ( recv) , id, offset, val : find ! ( val) } ,
18971894 & WriteBarrier { recv, val } => WriteBarrier { recv : find ! ( recv) , val : find ! ( val) } ,
1898- & SetIvar { self_val, id, val, state } => SetIvar { self_val : find ! ( self_val) , id, val : find ! ( val) , state } ,
1899- & SetInstanceVariable { self_val, id, ic, val, state } => SetInstanceVariable { self_val : find ! ( self_val) , id, ic, val : find ! ( val) , state } ,
1895+ & SetIvar { self_val, id, ic, val, state } => SetIvar { self_val : find ! ( self_val) , id, ic, val : find ! ( val) , state } ,
19001896 & GetClassVar { id, ic, state } => GetClassVar { id, ic, state } ,
19011897 & SetClassVar { id, val, ic, state } => SetClassVar { id, val : find ! ( val) , ic, state } ,
19021898 & SetLocal { val, ep_offset, level } => SetLocal { val : find ! ( val) , ep_offset, level } ,
@@ -1951,7 +1947,7 @@ impl Function {
19511947 | Insn :: PatchPoint { .. } | Insn :: SetIvar { .. } | Insn :: SetClassVar { .. } | Insn :: ArrayExtend { .. }
19521948 | Insn :: ArrayPush { .. } | Insn :: SideExit { .. } | Insn :: SetLocal { .. } | Insn :: IncrCounter ( _)
19531949 | Insn :: CheckInterrupts { .. } | Insn :: GuardBlockParamProxy { .. } | Insn :: IncrCounterPtr { .. }
1954- | Insn :: SetInstanceVariable { .. } | Insn :: StoreField { .. } | Insn :: WriteBarrier { .. } =>
1950+ | Insn :: StoreField { .. } | Insn :: WriteBarrier { .. } =>
19551951 panic ! ( "Cannot infer type of instruction with no output: {}. See Insn::has_output()." , self . insns[ insn. 0 ] ) ,
19561952 Insn :: Const { val : Const :: Value ( val) } => Type :: from_value ( * val) ,
19571953 Insn :: Const { val : Const :: CBool ( val) } => Type :: from_cbool ( * val) ,
@@ -2450,7 +2446,7 @@ impl Function {
24502446 self . push_insn ( block, Insn :: PatchPoint { invariant : Invariant :: SingleRactorMode , state } ) ;
24512447 }
24522448 }
2453- let getivar = self . push_insn ( block, Insn :: GetIvar { self_val : recv, id, state } ) ;
2449+ let getivar = self . push_insn ( block, Insn :: GetIvar { self_val : recv, id, ic : std :: ptr :: null ( ) , state } ) ;
24542450 self . make_equal_to ( insn_id, getivar) ;
24552451 } else if let ( VM_METHOD_TYPE_ATTRSET , & [ val] ) = ( def_type, args. as_slice ( ) ) {
24562452 self . push_insn ( block, Insn :: PatchPoint { invariant : Invariant :: MethodRedefined { klass, method : mid, cme } , state } ) ;
@@ -2467,7 +2463,7 @@ impl Function {
24672463 self . push_insn ( block, Insn :: PatchPoint { invariant : Invariant :: SingleRactorMode , state } ) ;
24682464 }
24692465 }
2470- self . push_insn ( block, Insn :: SetIvar { self_val : recv, id, val, state } ) ;
2466+ self . push_insn ( block, Insn :: SetIvar { self_val : recv, id, ic : std :: ptr :: null ( ) , val, state } ) ;
24712467 self . make_equal_to ( insn_id, val) ;
24722468 } else if def_type == VM_METHOD_TYPE_OPTIMIZED {
24732469 let opt_type: OptimizedMethodType = unsafe { get_cme_def_body_optimized_type ( cme) } . into ( ) ;
@@ -2750,7 +2746,7 @@ impl Function {
27502746 assert ! ( self . blocks[ block. 0 ] . insns. is_empty( ) ) ;
27512747 for insn_id in old_insns {
27522748 match self . find ( insn_id) {
2753- Insn :: GetIvar { self_val, id, state } => {
2749+ Insn :: GetIvar { self_val, id, ic : _ , state } => {
27542750 let frame_state = self . frame_state ( state) ;
27552751 let Some ( recv_type) = self . profiled_type_of_at ( self_val, frame_state. insn_idx ) else {
27562752 // No (monomorphic/skewed polymorphic) profile info
@@ -3503,8 +3499,7 @@ impl Function {
35033499 worklist. push_back ( self_val) ;
35043500 worklist. push_back ( state) ;
35053501 }
3506- & Insn :: SetIvar { self_val, val, state, .. }
3507- | & Insn :: SetInstanceVariable { self_val, val, state, .. } => {
3502+ & Insn :: SetIvar { self_val, val, state, .. } => {
35083503 worklist. push_back ( self_val) ;
35093504 worklist. push_back ( val) ;
35103505 worklist. push_back ( state) ;
@@ -4082,7 +4077,6 @@ impl Function {
40824077 }
40834078 // Instructions with 2 Ruby object operands
40844079 Insn :: SetIvar { self_val : left, val : right, .. }
4085- | Insn :: SetInstanceVariable { self_val : left, val : right, .. }
40864080 | Insn :: NewRange { low : left, high : right, .. }
40874081 | Insn :: AnyToString { val : left, str : right, .. }
40884082 | Insn :: WriteBarrier { recv : left, val : right } => {
@@ -5450,11 +5444,12 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
54505444 }
54515445 YARVINSN_getinstancevariable => {
54525446 let id = ID ( get_arg ( pc, 0 ) . as_u64 ( ) ) ;
5447+ let ic = get_arg ( pc, 1 ) . as_ptr ( ) ;
54535448 // ic is in arg 1
54545449 // Assume single-Ractor mode to omit gen_prepare_non_leaf_call on gen_getivar
54555450 // TODO: We only really need this if self_val is a class/module
54565451 fun. push_insn ( block, Insn :: PatchPoint { invariant : Invariant :: SingleRactorMode , state : exit_id } ) ;
5457- let result = fun. push_insn ( block, Insn :: GetIvar { self_val : self_param, id, state : exit_id } ) ;
5452+ let result = fun. push_insn ( block, Insn :: GetIvar { self_val : self_param, id, ic , state : exit_id } ) ;
54585453 state. stack_push ( result) ;
54595454 }
54605455 YARVINSN_setinstancevariable => {
@@ -5464,7 +5459,7 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
54645459 // TODO: We only really need this if self_val is a class/module
54655460 fun. push_insn ( block, Insn :: PatchPoint { invariant : Invariant :: SingleRactorMode , state : exit_id } ) ;
54665461 let val = state. stack_pop ( ) ?;
5467- fun. push_insn ( block, Insn :: SetInstanceVariable { self_val : self_param, id, ic, val, state : exit_id } ) ;
5462+ fun. push_insn ( block, Insn :: SetIvar { self_val : self_param, id, ic, val, state : exit_id } ) ;
54685463 }
54695464 YARVINSN_getclassvariable => {
54705465 let id = ID ( get_arg ( pc, 0 ) . as_u64 ( ) ) ;
0 commit comments