[PRL] code size optimization via tail call elimination
Eli Barzilay
eli at barzilay.org
Fri Apr 29 17:14:17 EDT 2011
5 minutes ago, Doug Orleans wrote:
> I've been slowly making my way through the GDC Vault:
>
> http://www.gdcvault.com/free/gdc-11
>
> Specifically, the videos of post-mortem talks about classic video
> games. My favorite so far is Will Wright (of Sims and Spore fame)
> talking about his first game, Raid on Bungeling Bay, written in 1984
> for the Commodore 64. At one point he talks about optimizing the
> memory footprint of the game, since he only had about 60k to work
> with.
(64k -- obviously.)
> What amused me was that his example for how to pick up a byte here
> and there was to look for a sequence of JSR (jump to subroutine)
> immediately followed by RTS (return from subroutine) and replacing
> it with a single JMP instruction. In other words, he did tail call
> elimination, not to conserve stack space, but to conserve code size!
An even more practical example is optimizing shell scripts by placing
`exec's in the right places.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!
More information about the PRL
mailing list