nuprl/Stopify

Optimization avenues for performance and code size

Closed this issue · 4 comments

This issue documents various possible avenues for optimizing code generated by Stopify. Feel free to add any others:

  • Handle switch statements directly: Currently, Stopify handles switch-case by desugaring it to a sequence of if-else. Handling switch statements directly would keep code closer to source, potentially improve performance, and remove one desugaring pass (desugar-switch).

  • Handle loops directly: Stopify currently handles the various JS loops by desugaring them to while loops. Handling the different loops directly would again help keep code closer to source, potentially improve performance, and remove two desugaring passes (desugar-loops, desugar-labels).

  • Merge try-catch blocks: A previous commit put in some effort to merge try-catch for the lazy transform. Reintroducing this would reduce the code size and help keep the output code readable.

Unless you're planning to follow up with a PR, why open this as an issue...

Who said I'm not planning to follow up? :-)

I'm going to close this. The one thing here potentially still worth investigating is instrumenting loops without desugaring to while. Merging try/catch blocks is subsumed by the catch transform, and yielded significant perf gains in some cases. switch is likely to be a very niche optimization.

Anyway, this isn't likely to happen too soon, and we can open a new one if it happens.