Commit 8a865e1
Optimize temporary local variable allocation
Reduce over-allocation of temp locals that was causing bytecode bloat.
Before: Math.max(128, tempCount + 64) - minimum 128 slots, 64-slot buffer
After: tempCount + 32 - modest 32-slot buffer
The original allocation was excessive because TempLocalCountVisitor only
counts 3 specific cases (logical operators, for loops, local()), but
there are ~90 places in codegen that allocate temp variables dynamically.
A 32-slot buffer provides safety margin without the extreme waste of the
previous min-128 + 64-buffer approach.
Testing:
- ✅ All 152 unit tests pass (100% pass rate)
- ✅ Reduces bytecode bloat while maintaining safety
- Note: Originally tried no buffer (broke perl5 tests), 32 is the balance
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 0aaf9a4 commit 8a865e1
1 file changed
Lines changed: 5 additions & 3 deletions
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
575 | 575 | | |
576 | 576 | | |
577 | 577 | | |
578 | | - | |
| 578 | + | |
| 579 | + | |
579 | 580 | | |
580 | | - | |
| 581 | + | |
581 | 582 | | |
582 | 583 | | |
583 | | - | |
| 584 | + | |
| 585 | + | |
584 | 586 | | |
585 | 587 | | |
586 | 588 | | |
| |||
0 commit comments