Commit 2324c4f
Compiler: Fix register exhaustion by freeing argument registers after calls
Function calls and constructor invocations were reserving registers for
arguments via reserve_registers() but never freeing them afterwards. This
caused register count to grow unboundedly with each call, eventually
hitting the 255 register limit in code with many function calls.
Added free_registers() method to BytecodeBuilder and updated emit_call(),
compile_new_expression(), and SuperCall handling to free argument registers
after the call completes.
- Add BytecodeBuilder::free_registers(start, count) to free consecutive registers
- Free argument registers after Call/CallSpread opcodes in emit_call()
- Free argument registers after Construct/ConstructSpread in compile_new_expression()
- Free argument registers after SuperCall
This fixes the "Too many registers needed (max 255)" error when running
examples/collections/main.ts which has ~70 function calls.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent d6ad8b7 commit 2324c4f
File tree
4 files changed
+1567
-1
lines changed- src/compiler
- tests
- interpreter
4 files changed
+1567
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
565 | 573 | | |
566 | 574 | | |
567 | 575 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1713 | 1713 | | |
1714 | 1714 | | |
1715 | 1715 | | |
1716 | | - | |
| 1716 | + | |
1717 | 1717 | | |
1718 | 1718 | | |
1719 | 1719 | | |
1720 | 1720 | | |
1721 | 1721 | | |
1722 | 1722 | | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
1723 | 1730 | | |
1724 | 1731 | | |
1725 | 1732 | | |
| |||
2159 | 2166 | | |
2160 | 2167 | | |
2161 | 2168 | | |
| 2169 | + | |
| 2170 | + | |
2162 | 2171 | | |
2163 | 2172 | | |
2164 | 2173 | | |
| |||
2167 | 2176 | | |
2168 | 2177 | | |
2169 | 2178 | | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
2170 | 2183 | | |
2171 | 2184 | | |
2172 | 2185 | | |
| |||
2220 | 2233 | | |
2221 | 2234 | | |
2222 | 2235 | | |
| 2236 | + | |
| 2237 | + | |
2223 | 2238 | | |
2224 | 2239 | | |
2225 | 2240 | | |
2226 | 2241 | | |
2227 | 2242 | | |
2228 | 2243 | | |
2229 | 2244 | | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
2230 | 2249 | | |
2231 | 2250 | | |
2232 | 2251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
705 | 705 | | |
706 | 706 | | |
707 | 707 | | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
0 commit comments