Commit bf2d478
committed
fix: allocate stack space for struct undef values in Cranelift JIT
Previously, HirValueKind::Undef for struct types was mapped to iconst(0),
causing InsertValue operations to attempt stores to address 0, resulting
in segfaults during JIT execution.
Now struct undef values are properly allocated on the stack:
- Calculate struct size from field types
- Create stack slot with cranelift_codegen::ir::StackSlotData
- Return stack address pointer instead of zero constant
This enables struct initialization with field access to work correctly:
const p = Point{ .x = 10, .y = 20 };
return p.x; // Returns 101 parent 8ebf3c5 commit bf2d478
1 file changed
Lines changed: 39 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
702 | 702 | | |
703 | 703 | | |
704 | 704 | | |
| 705 | + | |
705 | 706 | | |
706 | 707 | | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
716 | 730 | | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
721 | 747 | | |
722 | 748 | | |
723 | 749 | | |
| |||
0 commit comments