-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit ce3fcb3
Scala.js: Inline the target of Closure nodes in their js.Closures.
This is forward port of the Scala.js commit
scala-js/scala-js@0d16b42
The body of `Closure` nodes always has a simple shape that calls a
helper method. We previously generated that call in the body of the
`js.Closure`, and marked the target method `@inline` so that the
optimizer would always inline it.
Instead, we now directly "inline" it from the codegen, by
generating the `js.MethodDef` right inside the `js.Closure` scope.
As is, this does not change the generated code. However, it may
speed up (cold) linker runs, since it will have less work to do.
Notably, it performs two fewer knowledge queries to find and inline
the target method. It also reduces the total amount of methods to
manipulate in the incremental analysis.
More importantly, this will be necessary later if we want to add
support for `async/await` or `function*/yield`. Indeed, for those,
we will need `await`/`yield` expressions to be lexically scoped
in the body of their enclosing closure. That won't work if they are
in the body of a separate helper method.1 parent 256e684 commit ce3fcb3
File tree
3 files changed
+256
-118
lines changed- compiler/src/dotty/tools
- backend/sjs
- dotc/transform
3 files changed
+256
-118
lines changed
0 commit comments