Skip to content

Improve duplicate clinit removal - #10383

Open
niloc132 wants to merge 19 commits into
gwtproject:mainfrom
niloc132:9731-dup-clinits-commas-test
Open

niloc132 wants to merge 19 commits into
gwtproject:mainfrom
niloc132:9731-dup-clinits-commas-test

Conversation

@niloc132

Copy link
Copy Markdown
Member

Explore comma expression contents when finding class initializers, and mark them as seen to avoid their inclusion later in method bodies. Also improved try block handling when there are no catches or finallys, and left notes for how this can be later improved when control flow is more structured (#10248, #10381)

Moved this pass into the main JS optimization loop - inlining methods tends to produce grouped clinits, and clinit removal can leave behind dead code that needs to be simplified away. In some cases, clinit removal make also make a method eligible for inlining.

This code previously had no tests, so added a test class, and improved the JS OptimizerTestBase to allow for minor changes (newlines, etc) between input and expected contents, as well as asserting for "no change" when appropriate. This more closely mirrors the Java version of this test base.

Also cleans up some "XO" references ("eXactly Once") in favor of "clinit" as referenced elsewhere.

Fixes #9731

@niloc132 niloc132 added this to the 2.14 milestone Jul 22, 2026
@niloc132

Copy link
Copy Markdown
Member Author

Marked as draft for now, some additional tests are required, and some text blocks can be used in place of separate string vararg params. Showcase improves by about 0.1%, or about 300 bytes over 300-400kb permutations.

Comment thread dev/core/src/com/google/gwt/dev/js/DuplicateClinitRemover.java Outdated
Comment thread dev/core/test/com/google/gwt/dev/js/JsDuplicateCaseFolderTest.java
Comment thread dev/core/test/com/google/gwt/dev/js/JsDuplicateClinitRemoverTest.java Outdated
@niloc132
niloc132 marked this pull request as ready for review September 16, 2026 18:19
@niloc132 niloc132 added the ready This PR has been reviewed by a maintainer and is ready for a CI run. label Sep 16, 2026
@niloc132
niloc132 force-pushed the 9731-dup-clinits-commas-test branch from 6894e13 to 3e8403b Compare September 16, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready This PR has been reviewed by a maintainer and is ready for a CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dead code not eliminated when two Boolean.parseBoolean in same function

2 participants