Documentation of compiler optimisations?

109 views
Skip to first unread message

George Georgovassilis

unread,
Oct 1, 2020, 4:52:04 PM10/1/20
to GWT Contributors
Is there an up-to-date documentation of optimisations the compiler applies? An older page [1] discusses some topics but it isn't clear what of that has been implemented.
(apologies for posting here, I asked this question on the user forum [2] but didn't get any replies)


Colin Alworth

unread,
Oct 1, 2020, 5:35:04 PM10/1/20
to GWT Contributors
GWT itself hasn't changed substantially in many years - improvements have mostly been language features, adding support for incremental compilation, the jsinterop system, etc, so for the most part the optimizations haven't changed.

That said, the best way is almost certainly to take a look at the source code itself, and the JavaToJavaScriptCompiler class has the high level aspects of this. This is a different way to look at the current process, but might give you helpful insights in contrast to the link you shared.

Starting in the compilePermutation() method:
This method is well commented, showing the order of operations that take place. Optimizations on Java source itself largely happens at the optimizeJava() method, which itself does very little, just check if it should run, and if so, invokes optimizeJavaToFixedPoint(), then applies one last optimization: RemoveEmptySuperCalls. optimizeJavaToFixedPoint() can be found at
though it largely just invokes optimizeJavaOneTime in a loop until the code stops changing, and follows up with one optional run to the DataflowOptimizer. optimizeJavaOneTime can be found at
Here you can see the optimizations that happen in the main optimization loop, with a small handful of notes on the order that these must take place.

After this we're back to the compilerPermutation method, which finishes normalizing the code to JS and continuing to optimize this lightly, though not in a loop, just a few specific passes.

George Georgovassilis

unread,
Oct 2, 2020, 9:31:47 AM10/2/20
to GWT Contributors
Thank you Colin, that helped.
Reply all
Reply to author
Forward
0 new messages