OpenDreamProject / OpenDream

A project for running games made in the DM programming language
MIT License
186 stars 100 forks source link

Peephole optimize proc returns #1843

Closed ike709 closed 1 week ago

ike709 commented 1 week ago

(PushReferenceValue, Return) -> ReturnReferenceValue

Per my frequency analysis this pattern occurs ~16k times in Paradise and ~25k times in goon and TG. It is a top-ten offender on all codebases tested.

However, this optimization is heavily kneecapped by #1842 which causes it to only be applied 664 times in Paradise bytecode. Once that issue is fixed this will become much more significant, as a large number of procs will no longer modify their stack when they return.