@@ -3216,6 +3216,7 @@ impl Function {
32163216 self . push_insn_id ( block, insn_id) ; continue ;
32173217 }
32183218
3219+ // Method test
32193220 self . push_insn ( block, Insn :: PatchPoint { invariant : Invariant :: MethodRedefined { klass, method : mid, cme } , state } ) ;
32203221 if let Some ( profiled_type) = profiled_type {
32213222 recv = self . push_insn ( block, Insn :: GuardType { val : recv, guard_type : Type :: from_profiled_type ( profiled_type) , state } ) ;
@@ -3826,17 +3827,22 @@ impl Function {
38263827 // Strength reduce to LoadFields/CCall when receiver has a known shape from RefineShape
38273828 if let Insn :: RefineShape { val : refined_val, shape : known_shape, is_t_object, is_embedded } = self . find ( self_val) {
38283829 let mut ivar_index: u16 = 0 ;
3829- let replacement = if !unsafe { rb_shape_get_iv_index ( known_shape. 0 , id, & mut ivar_index) } {
3830+ let replacement = if known_shape. is_too_complex ( ) {
3831+ // Leave the GetIvar as is when the shape is too complex.
3832+ // Too-complex shapes are not valid inputs to rb_shape_get_iv_index().
3833+ // TODO: set fallback reason
3834+ insn_id
3835+ } else if !unsafe { rb_shape_get_iv_index ( known_shape. 0 , id, & mut ivar_index) } {
38303836 // Ivar not in this shape, return nil
38313837 self . push_insn ( block, Insn :: Const { val : Const :: Value ( Qnil ) } )
38323838 } else if is_t_object {
38333839 // T_OBJECT: use LoadField
38343840 if is_embedded {
3835- let offset = ROBJECT_OFFSET_AS_ARY as i32 + ( SIZEOF_VALUE * ivar_index . to_usize ( ) ) as i32 ;
3841+ let offset = ROBJECT_OFFSET_AS_ARY as i32 + SIZEOF_VALUE_I32 * i32 :: from ( ivar_index ) ;
38363842 self . push_insn ( block, Insn :: LoadField { recv : refined_val, id, offset, return_type : types:: BasicObject } )
38373843 } else {
38383844 let as_heap = self . push_insn ( block, Insn :: LoadField { recv : refined_val, id : ID ! ( _as_heap) , offset : ROBJECT_OFFSET_AS_HEAP_FIELDS as i32 , return_type : types:: CPtr } ) ;
3839- let offset = SIZEOF_VALUE_I32 * ivar_index as i32 ;
3845+ let offset = SIZEOF_VALUE_I32 * i32:: from ( ivar_index ) ;
38403846 self . push_insn ( block, Insn :: LoadField { recv : as_heap, id, offset, return_type : types:: BasicObject } )
38413847 }
38423848 } else {
0 commit comments