Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Unified Diff: pkg/compiler/lib/src/ssa/codegen.dart

Issue 2072883004: Code changes to avoid Firefox debug 'error' lint warnings. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/js_runtime/lib/js_helper.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/codegen.dart
diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart
index 0ff32f29c1d3b3bbdb850f0c356cf454fb2787fd..963754991ceff88c0296859854c958b35cc0fabc 100644
--- a/pkg/compiler/lib/src/ssa/codegen.dart
+++ b/pkg/compiler/lib/src/ssa/codegen.dart
@@ -1496,8 +1496,25 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
js.Statement elsePart =
unwrapStatement(generateStatementsInNewBlock(elseGraph));
- pushStatement(new js.If(test, thenPart, elsePart)
- .withSourceInformation(node.sourceInformation));
+ js.Statement code;
+ // Peephole rewrites:
+ //
+ // if (e); else S; --> if(!e) S;
+ //
+ // if (e); --> e;
+ //
+ // TODO(sra): This peephole optimization would be better done as an SSA
+ // optimization.
+ if (thenPart is js.EmptyStatement) {
+ if (elsePart is js.EmptyStatement) {
+ code = new js.ExpressionStatement(test);
+ } else {
+ code = new js.If.noElse(new js.Prefix('!', test), elsePart);
+ }
+ } else {
+ code = new js.If(test, thenPart, elsePart);
+ }
+ pushStatement(code.withSourceInformation(node.sourceInformation));
}
visitIf(HIf node) {
« no previous file with comments | « no previous file | sdk/lib/_internal/js_runtime/lib/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698