Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
9b2de0d
Raise Java language level to 17, update errorprone
niloc132 Jun 8, 2026
1458a5d
temporarily use tools branch
niloc132 Jun 8, 2026
6bf7233
new apis to triage
niloc132 Jun 8, 2026
52acf3a
Rename missing emul files
niloc132 Jun 9, 2026
d2cea9a
Revert "temporarily use tools branch"
niloc132 Jun 9, 2026
54e5fd7
Update notes about what versions are required
niloc132 Jun 9, 2026
f27bcb7
Hardcode preview methods, support java 26 with an EP workaround
niloc132 Jun 10, 2026
67d99e3
Bump asm to support Java 27
niloc132 Jun 10, 2026
c70fb47
Temp tools branch
niloc132 Jun 10, 2026
470e637
Another errorprone bug
niloc132 Jun 10, 2026
14f91f1
Remove Java 26 again, seems to break DOMSuite
niloc132 Jun 10, 2026
b8e9479
quick wip
niloc132 Nov 25, 2025
790478d
Vaguely functional implementation, except for switches
niloc132 Nov 26, 2025
207a283
A little more clean up, all samples build cleanly
niloc132 Nov 26, 2025
ccdc74d
Don't try to move {}s, better java gen, fix a js bug
niloc132 Nov 27, 2025
073dd28
Checkpoint, user tests pass but compiler fails
niloc132 Nov 27, 2025
206198d
More consistent output, still have a small size regression (inlining?)
niloc132 Nov 30, 2025
279130a
Try to restore ExpandBlocks, more problems found
niloc132 Nov 30, 2025
c93bc4c
Nearly correct impl of ExpandBlocks
niloc132 Dec 1, 2025
382b730
Cleanup dead code
niloc132 Jan 4, 2026
4bee28a
Remove the 'expand blocks' experiment
niloc132 Jan 28, 2026
118bfbf
break long line
niloc132 Jan 28, 2026
96231ff
Update tests to drop extra braces when unnecessary
niloc132 Jan 29, 2026
38fb2bd
Defensively add {}s to JS ifs
niloc132 Jan 30, 2026
d53e77d
Improved version of adding necessary braces
niloc132 Jan 30, 2026
362537d
checkstyle
niloc132 Jan 30, 2026
ac18a98
fix java ast dump to avoid dangling else
niloc132 Feb 15, 2026
ac44bd1
do/for/while support
niloc132 Feb 15, 2026
42baabe
if's else can never be null, fixed other tests
niloc132 Feb 15, 2026
19a0aa5
Updated draft, trying to unify logic, avoid copy/paste
niloc132 Feb 24, 2026
3c6fa13
Also remove continue;s, add a simple test
niloc132 Mar 3, 2026
fafdf66
Support 17 for dev core too
niloc132 Mar 3, 2026
62b4cd4
checkstyle, revert unneeded java 17 changes
niloc132 Jun 10, 2026
d0f4b4c
Merge branch 'main' into min-java17
niloc132 Jun 24, 2026
8d5288e
Remove java 26 from list for now
niloc132 Jun 24, 2026
4cce622
Revert "Temp tools branch"
niloc132 Jun 24, 2026
9dd8107
Merge branch 'min-java17' into 10248-remove-pointless-returns
niloc132 Jun 24, 2026
4e476b9
Merge branch 'main' into 10248-remove-pointless-returns
niloc132 Jun 24, 2026
ad0946e
Revert do->while rewrite, unrelated
niloc132 Jun 24, 2026
955e3d5
Remove a comment that can't be handled in the java pass anyway
niloc132 Jun 24, 2026
ae4df09
Add more cases, exclude switch-expr, and write out more tests
niloc132 Jul 1, 2026
d82c4f4
More test
niloc132 Jul 8, 2026
64594ec
Merge branch 'main' into 10248-remove-pointless-returns
niloc132 Jul 8, 2026
a0b883c
More test, fix a bug
niloc132 Jul 8, 2026
ec0109f
checkstyle
niloc132 Jul 8, 2026
a3c31e9
Guard against try without finally
niloc132 Jul 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
import com.google.gwt.dev.jjs.impl.RecordRebinds;
import com.google.gwt.dev.jjs.impl.RemoveEmptySuperCalls;
import com.google.gwt.dev.jjs.impl.RemoveSpecializations;
import com.google.gwt.dev.jjs.impl.RemoveUnnecessaryControlFlow;
import com.google.gwt.dev.jjs.impl.ReplaceCallsToNativeJavaLangObjectOverrides;
import com.google.gwt.dev.jjs.impl.ReplaceGetClassOverrides;
import com.google.gwt.dev.jjs.impl.ResolvePermutationDependentValues;
Expand Down Expand Up @@ -1469,6 +1470,7 @@ private void optimizeJavaToFixedPoint() throws InterruptedException {
stats.recordModified(MethodCallTightener.exec(jprogram, optimizerCtx));
// Note: Specialization should be done before inlining.
stats.recordModified(MethodCallSpecializer.exec(jprogram, optimizerCtx));
stats.recordModified(RemoveUnnecessaryControlFlow.exec(jprogram, optimizerCtx));
stats.recordModified(DeadCodeElimination.exec(jprogram, optimizerCtx));
stats.recordModified(MethodInliner.exec(jprogram, optimizerCtx));
if (options.shouldInlineLiteralParameters()) {
Expand Down
25 changes: 25 additions & 0 deletions dev/core/src/com/google/gwt/dev/jjs/ast/JBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@ public JBlock(SourceInfo info, JStatement... statements) {
this.statements.addAll(Arrays.asList(statements));
}

public static JBlock ensureBlock(SourceInfo info, JStatement statement) {
if (statement == null) {
return new JBlock(info);
}
if (statement instanceof JBlock) {
return (JBlock) statement;
}

return new JBlock(statement.getSourceInfo(), statement);
}

/**
* Insert a statement into this block.
*/
Expand Down Expand Up @@ -105,4 +116,18 @@ public boolean unconditionalControlBreak() {
}
return false;
}

public JStatement singleStatement() {
if (statements.isEmpty()) {
return null;
}
if (statements.size() == 1) {
JStatement jStatement = statements.get(0);
if (jStatement instanceof JBlock) {
return ((JBlock) jStatement).singleStatement();
}
return jStatement;
}
return this;
}
}
10 changes: 4 additions & 6 deletions dev/core/src/com/google/gwt/dev/jjs/ast/JDoStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
*/
public class JDoStatement extends JStatement {

private JStatement body;
private JBlock body;
private JExpression testExpr;

public JDoStatement(SourceInfo info, JExpression testExpr, JStatement body) {
super(info);
this.testExpr = testExpr;
this.body = body;
this.body = JBlock.ensureBlock(info, body);
}

public JStatement getBody() {
public JBlock getBody() {
return body;
}

Expand All @@ -43,9 +43,7 @@ public JExpression getTestExpr() {
public void traverse(JVisitor visitor, Context ctx) {
if (visitor.visit(this, ctx)) {
testExpr = visitor.accept(testExpr);
if (body != null) {
body = visitor.accept(body, true);
}
body = JBlock.ensureBlock(getSourceInfo(), visitor.accept(body, false));
}
visitor.endVisit(this, ctx);
}
Expand Down
10 changes: 4 additions & 6 deletions dev/core/src/com/google/gwt/dev/jjs/ast/JForStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
public class JForStatement extends JStatement {

private JStatement body;
private JBlock body;
private List<JStatement> initializers;
private JExpression condition;
private JExpression increments;
Expand All @@ -40,13 +40,13 @@
this.initializers = Lists.newArrayList(initializers);
this.condition = condition;
this.increments = increments;
this.body = body;
this.body = JBlock.ensureBlock(info, body);
}

/**
* Returns the {@code for} statement body.
*/
public JStatement getBody() {
public JBlock getBody() {
return body;
}

Expand Down Expand Up @@ -81,9 +81,7 @@
if (increments != null) {
increments = visitor.accept(increments);
}
if (body != null) {
body = visitor.accept(body, true);
}
body = JBlock.ensureBlock(getSourceInfo(), visitor.accept(body, false));//TODO no tests fail without this change...

Check warning on line 84 in dev/core/src/com/google/gwt/dev/jjs/ast/JForStatement.java

View workflow job for this annotation

GitHub Actions / build (21)

[checkstyle] reported by reviewdog 🐶 Line is longer than 100 characters (found 121). Raw Output: /home/runner/work/gwt/gwt/gwt/dev/core/src/com/google/gwt/dev/jjs/ast/JForStatement.java:84:0: warning: Line is longer than 100 characters (found 121). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
}
visitor.endVisit(this, ctx);
}
Expand Down
20 changes: 8 additions & 12 deletions dev/core/src/com/google/gwt/dev/jjs/ast/JIfStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,35 @@
*/
public class JIfStatement extends JStatement {

private JStatement elseStmt;
private JBlock elseStmt;
private JExpression ifExpr;
private JStatement thenStmt;
private JBlock thenStmt;

public JIfStatement(SourceInfo info, JExpression ifExpr, JStatement thenStmt, JStatement elseStmt) {

Check warning on line 29 in dev/core/src/com/google/gwt/dev/jjs/ast/JIfStatement.java

View workflow job for this annotation

GitHub Actions / build (21)

[checkstyle] reported by reviewdog 🐶 Line is longer than 100 characters (found 102). Raw Output: /home/runner/work/gwt/gwt/gwt/dev/core/src/com/google/gwt/dev/jjs/ast/JIfStatement.java:29:0: warning: Line is longer than 100 characters (found 102). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
super(info);
this.ifExpr = ifExpr;
this.thenStmt = thenStmt;
this.elseStmt = elseStmt;
this.thenStmt = JBlock.ensureBlock(info, thenStmt);
this.elseStmt = JBlock.ensureBlock(info, elseStmt);
}

public JStatement getElseStmt() {
public JBlock getElseStmt() {
return elseStmt;
}

public JExpression getIfExpr() {
return ifExpr;
}

public JStatement getThenStmt() {
public JBlock getThenStmt() {
return thenStmt;
}

@Override
public void traverse(JVisitor visitor, Context ctx) {
if (visitor.visit(this, ctx)) {
ifExpr = visitor.accept(ifExpr);
if (thenStmt != null) {
thenStmt = visitor.accept(thenStmt, true);
}
if (elseStmt != null) {
elseStmt = visitor.accept(elseStmt, true);
}
thenStmt = JBlock.ensureBlock(getSourceInfo(), visitor.accept(thenStmt, false));
elseStmt = JBlock.ensureBlock(getSourceInfo(), visitor.accept(elseStmt, false));
}
visitor.endVisit(this, ctx);
}
Expand Down
10 changes: 4 additions & 6 deletions dev/core/src/com/google/gwt/dev/jjs/ast/JWhileStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
*/
public class JWhileStatement extends JStatement {

private JStatement body;
private JBlock body;
private JExpression testExpr;

public JWhileStatement(SourceInfo info, JExpression testExpr, JStatement body) {
super(info);
this.testExpr = testExpr;
this.body = body;
this.body = JBlock.ensureBlock(info, body);
}

public JStatement getBody() {
public JBlock getBody() {
return body;
}

Expand All @@ -43,9 +43,7 @@
public void traverse(JVisitor visitor, Context ctx) {
if (visitor.visit(this, ctx)) {
testExpr = visitor.accept(testExpr);
if (body != null) {
body = visitor.accept(body, true);
}
body = JBlock.ensureBlock(getSourceInfo(), visitor.accept(body, false));//TODO no tests fail without this change...

Check warning on line 46 in dev/core/src/com/google/gwt/dev/jjs/ast/JWhileStatement.java

View workflow job for this annotation

GitHub Actions / build (21)

[checkstyle] reported by reviewdog 🐶 Line is longer than 100 characters (found 121). Raw Output: /home/runner/work/gwt/gwt/gwt/dev/core/src/com/google/gwt/dev/jjs/ast/JWhileStatement.java:46:0: warning: Line is longer than 100 characters (found 121). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
}
visitor.endVisit(this, ctx);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ public void endVisit(JDoStatement x, Context ctx) {
if (expression instanceof JBooleanLiteral) {
JBooleanLiteral booleanLiteral = (JBooleanLiteral) expression;

// If false, replace do with do's body
if (!booleanLiteral.getValue()) {
if (JjsUtils.isEmptyBlock(x.getBody())) {
// If false, replace do with do's body
if (x.getBody().isEmpty()) {
ctx.removeMe();
} else { // Unless it contains break/continue statements
FindBreakContinueStatementsVisitor visitor = new FindBreakContinueStatementsVisitor();
Expand Down Expand Up @@ -1964,10 +1964,8 @@ private void tryRemoveSwitch(JSwitchStatement x, Context ctx) {
} else {
// Create an if statement equivalent to the single-case switch.
JBinaryOperation compareOperation = caseStatement.convertToCompareExpression(x.getExpr());
JBlock block = new JBlock(x.getSourceInfo());
block.addStmt(statement);
JIfStatement ifStatement =
new JIfStatement(x.getSourceInfo(), compareOperation, block, null);
new JIfStatement(x.getSourceInfo(), compareOperation, statement, null);
replaceMe(ifStatement, ctx);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@
}

@Override
public JsStatement transformBlock(JBlock block) {
public JsBlock transformBlock(JBlock block) {
JsBlock jsBlock = new JsBlock(block.getSourceInfo());
List<JsStatement> stmts = jsBlock.getStatements();

Expand Down Expand Up @@ -692,7 +692,7 @@
public JsNode transformDoStatement(JDoStatement doStatement) {
JsDoWhile stmt = new JsDoWhile(doStatement.getSourceInfo());
stmt.setCondition(transform(doStatement.getTestExpr()));
stmt.setBody(jsEmptyIfNull(doStatement.getSourceInfo(), transform(doStatement.getBody())));
stmt.setBody(jsEmptyIfNull(doStatement.getSourceInfo(), transform(doStatement.getBody().singleStatement())));

Check warning on line 695 in dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java

View workflow job for this annotation

GitHub Actions / build (21)

[checkstyle] reported by reviewdog 🐶 Line is longer than 100 characters (found 115). Raw Output: /home/runner/work/gwt/gwt/gwt/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java:695:0: warning: Line is longer than 100 characters (found 115). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)
return stmt;
}

Expand Down Expand Up @@ -742,7 +742,7 @@
result.setInitExpr(initExpr);
result.setCondition(transform(forStatement.getCondition()));
result.setIncrExpr(transform(forStatement.getIncrements()));
result.setBody(jsEmptyIfNull(forStatement.getSourceInfo(), transform(forStatement.getBody())));
result.setBody(jsEmptyIfNull(forStatement.getSourceInfo(), transform(forStatement.getBody().singleStatement())));

Check warning on line 745 in dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java

View workflow job for this annotation

GitHub Actions / build (21)

[checkstyle] reported by reviewdog 🐶 Line is longer than 100 characters (found 119). Raw Output: /home/runner/work/gwt/gwt/gwt/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java:745:0: warning: Line is longer than 100 characters (found 119). (com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck)

return result;
}
Expand All @@ -753,8 +753,8 @@

result.setIfExpr(transform(ifStatement.getIfExpr()));
result.setThenStmt(jsEmptyIfNull(ifStatement.getSourceInfo(),
transform(ifStatement.getThenStmt())));
result.setElseStmt(transform(ifStatement.getElseStmt()));
transform(ifStatement.getThenStmt().singleStatement())));
result.setElseStmt(transform(ifStatement.getElseStmt().singleStatement()));

return result;
}
Expand Down Expand Up @@ -1168,7 +1168,7 @@
SourceInfo info = whileStatement.getSourceInfo();
JsWhile stmt = new JsWhile(info);
stmt.setCondition(transform(whileStatement.getTestExpr()));
stmt.setBody(jsEmptyIfNull(info, transform(whileStatement.getBody())));
stmt.setBody(jsEmptyIfNull(info, transform(whileStatement.getBody().singleStatement())));
return stmt;
}

Expand Down
4 changes: 2 additions & 2 deletions dev/core/src/com/google/gwt/dev/jjs/impl/GwtAstBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,8 @@ public JExpression apply(JStatement statement) {
public void endVisit(IfStatement x, BlockScope scope) {
try {
SourceInfo info = makeSourceInfo(x);
JStatement elseStatement = pop(x.elseStatement);
JStatement thenStatement = pop(x.thenStatement);
JBlock elseStatement = popBlock(info, x.elseStatement);
JBlock thenStatement = popBlock(info, x.thenStatement);
JExpression condition = pop(x.condition);
push(new JIfStatement(info, condition, thenStatement, elseStatement));
} catch (Throwable e) {
Expand Down
Loading
Loading