Commit 6bc8695
vm: lower $b = &$a ref-assign for simple-local LHS natively
Adds OP_STORE_LOCAL_REF, writing a ref-typed ZVal into a local slot
without the COW-Dup that OP_STORE_LOCAL applies to ZtArray values
(frame.go:160-166 follows ref→Nude+Dup, which detaches the ref).
Emit path: $b = &$a where LHS is a simple variable
- emit RHS (\&$a → OP_CREATE_REF produces ref ZVal)
- OP_STORE_LOCAL_REF idx=$b localIdx
Handler:
- pop value
- if IsRef, call RefInner() to track alias count
- write directly into the slot (no Dup, no Nude)
- mirror through ctx.OffsetSet for non-slot-only frames
- keep-value flag for expr context ($x = ($b = &$a))
Complex LHS (object prop, array elem, static prop) still routes
through AST — those write paths each carry their own ref-installation
semantics that this stage-1 lowering doesn't replicate.
VM output byte-identical to AST baseline across the 7-test smoke
suite (scalar/array/string ref-share, function by-ref pass-through,
unset-detach, ref-chain, and the expr-context $x = ($b = &$a) edge).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent f2d9b9f commit 6bc8695
3 files changed
Lines changed: 66 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
615 | 615 | | |
616 | 616 | | |
617 | 617 | | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
618 | 637 | | |
619 | 638 | | |
620 | 639 | | |
| |||
765 | 784 | | |
766 | 785 | | |
767 | 786 | | |
| 787 | + | |
768 | 788 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1898 | 1898 | | |
1899 | 1899 | | |
1900 | 1900 | | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
1901 | 1925 | | |
1902 | 1926 | | |
1903 | 1927 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
879 | 879 | | |
880 | 880 | | |
881 | 881 | | |
882 | | - | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
883 | 887 | | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
884 | 905 | | |
885 | 906 | | |
886 | 907 | | |
| |||
0 commit comments