@@ -6852,9 +6852,33 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> {
68526852 break ; // End the block
68536853 }
68546854
6855+ // When polymorphic, build blocks like the following
6856+ // ┌──────────────────────────────────┐
6857+ // │ switch block │
6858+ // │ shape = GetShape │
6859+ // │ test0 = BitsEqual expected_shape1, shape
6860+ // ┌───┼ IfTrue test0, load_shape1 │
6861+ // │ │ test1 = BitsEqual expected_shape2, shape
6862+ // │ │ IfTrue test1, load_shape2────────┬─────────────────────┐
6863+ // │ │ ivar = GetIvar self │ │
6864+ // │ │ (push ivar in frame state) │ │
6865+ // │ │ Jump join_block │ │
6866+ // │ └─────────────────────────┬────────┘ │
6867+ // │ │ │
6868+ // │ │ │
6869+ // ┌─────────▼──────────────────────────┐ │ ┌───────────────────────────▼───────┐
6870+ // │ ivar = LoadField self, shape1_index│ │ │ ivar = LoadField self, shape2_inde│
6871+ // │ (push ivar in frame state) │ │ │ (push ivar in frame state) │
6872+ // │ Jump join_block──────────────────┐ │ │ │ Jump join_block │
6873+ // └──────────────────────────────────┼─┘ │ └─┬─────────────────────────────────┘
6874+ // │ │ │
6875+ // ┌──────────────────▼────▼────▼─────────────────────┐
6876+ // │join_block │
6877+ // │(instructions for after the `getinstancevariable`)│
6878+ // └──────────────────────────────────────────────────┘
68556879 let mut t_object_varying_shapes = true ;
68566880 if let Some ( summary) = fun. polymorphic_summary ( & profiles, self_param, exit_state. insn_idx ) {
6857- // Only split in cases that vary in shape for now -- all T_OBJECT
6881+ // TODO: Only split in cases that vary in shape for now -- all T_OBJECT
68586882 for & profiled_type in summary. buckets ( ) {
68596883 if profiled_type. is_empty ( ) { break ; }
68606884 if !profiled_type. flags ( ) . is_t_object ( ) {
0 commit comments