Commit 77ddd16
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 optimized code paths for each shape using
IsBitEqual checks on the shape ID.
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 219ad68 commit 77ddd16
6 files changed
Lines changed: 559 additions & 154 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
| 535 | + | |
535 | 536 | | |
536 | 537 | | |
537 | 538 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
0 commit comments