Make the J2clOpts pass more effective when there are transitive dependencies in constant intialization.#6571
Conversation
…ant hoisted from in "optimize-j2cl" pass.
…tive propagating getters that recurse through the hierarchy.
Let's put some detailed description of what and why we are doing for future reference. |
|
I think all the comments were addressed. Let me know if there is anything else. |
|
re. tests: It s kind of difficult to check all the coverage but do you mind double checking we have have coverage for
|
test/lit/passes/j2cl-inline.wast
Outdated
| @@ -2,7 +2,7 @@ | |||
|
|
|||
| ;; NOTE: In real world example no-inline would use _<once>_ but there is escaping problem in a multi-platform | |||
There was a problem hiding this comment.
If escaping is fixed, this comment is now stale.
There was a problem hiding this comment.
Updated j2cl-inline.wast to show that without the inlining it has the same result as before.
|
LGTM minus the comments. (one of them ended up being hidden behind resolved comments) |
Both of those are already reflected in j2cl.wat. The module at line 156 shows a transitive inline and hoisting that is 3 deep. |
|
Sorry post an LGTM earlier but didn't notice I can mark it as approved. Thanks. |
Constants that need to be hoisted sometimes are initialized by calling getters of other constants that need to be hoisted. These getters are non-trivial, e.g.
and can only be simplified after the constants they initialize are hoisted. After the constant is hoisted the getter can be inlined and constants that depend on it for their initialization can now be hoisted.
Before this pass, inilining would happen after the pass was run by a subsquent run of the inliner (likely as part of
-O3), requiring as many runs of this pass, interleaved with the inliner, as the depth in the call sequence.By having a simpler inliner run as part of the loop in this pass, the pass becomes more effective and more independent of the call depths.