scala-js/scala-js — pull request #1176 by sjrd (2014-10-17 15:44:57+00:00)
Title: Optimize Closures directly, rather than AnonFunctions.

AnonFunctions are now simply regular inlineable classes. `Closure`s are directly optimized as TentativeClosureReplacements, even when they are not the parameter of a new AnonFunction.

This simplifies the optimizer, notably because it does not need to know about tricky `@specialized` `apply` methods.

It also makes it more powerful: `js.Function`s can be closure-eliminated just as well as scala.Functions. Even for `scala.Function`s, it can do a better job if the function is applied more than once: the `AnonFunction` can still be inlined away, leaving only a JavaScript function with monomorphic dispatch, which the JS VM should be able
to deal with.