Commit e6ea89e
committed
ZJIT: Polymorphic getivar with shape-based splitting
Add support for polymorphic getinstancevariable and attr_reader with
shape-based splitting. When multiple shapes are observed for the same
receiver, we now generate a switch block, a load block for each shape,
and a join block.
Key changes:
- Add RefineShape instruction to record known shape information with
is_t_object and is_embedded flags
- In iseq_to_hir, emit shape-based splitting for polymorphic getivar
and attr_reader (same-class-different-shapes case)
- Move guard insertion (GuardType, guard_shape) from optimize_getivar
to the HIR building phase
- Simplify optimize_getivar to only lower RefineShape inputs to
LoadField (T_OBJECT) or CCall (non-T_OBJECT)
Problem: This approach doesn't compose perfectly with the splitting for
polymorphic send. We potentially want to split twice, one for all the
different callee varying in method types and another time for shape
variations. For simplicity, we only split in the monomorphic attr_reader
callee, polymorphic shapes case for now.
Problem: We need to change the strategy for counting fallbacks because
there no one place where we can definitively say getivar won't be
optimized anymore. Maybe a fallback reason approach that Send uses.1 parent de46ae9 commit e6ea89e
4 files changed
+575
-147
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
548 | 548 | | |
549 | 549 | | |
550 | 550 | | |
| 551 | + | |
551 | 552 | | |
552 | 553 | | |
553 | 554 | | |
| |||
0 commit comments