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

Issue 1088493002: Assignment expressions in tree IR. (Closed)

Created:
5 years, 8 months ago by asgerf
Modified:
5 years, 8 months ago
CC:
reviews_dartlang.org
Target Ref:
refs/remotes/git-svn
Visibility:
Public.

Description

Assignment expressions in tree IR. Assignments are propagated into their first use, e.g: var x = foo(), y = bar(); baz(x, y, y) Becomes: var y; baz(foo(), y = bar(), y); By itself, this usually degrades readability and is only a modest improvement in code size (but it never degrades code size). The main advantage is when it unlocks other optimizations such as inlining of `x` in the above example. The ability to rewrite ugly while(true) loops is one of the main wins for this, but there are currently other things also blocking that, which I will take in another CL. Setters are also propagated to their use site, mostly to assist introduction of compound operators in the future. I'm considering if some of this should be enabled only when minifying due to the unreadable output, but for now it's always on. OVERVIEW OF CHANGES: - Assign and SetField are now Expressions. - VariableDeclaration is a new Dart-specific statement for declaring captured variables inside loops (previously handled by the `Assign.isDeclaration` field). - StatementRewriter now propagates assignments into variable uses, regardless of use count. The assignment is then converted to a variable use if there are no more uses of the variable. E.g: { x = foo(); bar(x); } ==> bar(x = foo()) ==> bar(foo()) - Combining statements and expressions now works a bit differently so we can inline combined assignments into an inlined combined break without risking reprocessing. - New phase PullIntoInitializers moves assignment expressions back into statements so they can be part of the variable initializer. The StatementRewriter cannot be predict ahead of time whether an assignment propagation is beneficial, so this phase cleans up some bad propagations. R=kmillikin@google.com Committed: https://code.google.com/p/dart/source/detail?r=45132

Patch Set 1 #

Total comments: 12

Patch Set 2 : Comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+940 lines, -310 lines) Patch
M pkg/analyzer2dart/test/end2end_data.dart View 1 chunk +1 line, -2 lines 0 comments Download
M pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart View 1 chunk +0 lines, -1 line 0 comments Download
M pkg/compiler/lib/src/dart_backend/backend.dart View 1 chunk +3 lines, -3 lines 0 comments Download
M pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart View 1 9 chunks +75 lines, -49 lines 0 comments Download
M pkg/compiler/lib/src/js_backend/codegen/codegen.dart View 4 chunks +14 lines, -15 lines 0 comments Download
M pkg/compiler/lib/src/js_backend/codegen/js_tree_builder.dart View 1 chunk +5 lines, -4 lines 0 comments Download
M pkg/compiler/lib/src/js_backend/codegen/task.dart View 1 chunk +2 lines, -1 line 0 comments Download
M pkg/compiler/lib/src/tree_ir/optimization/logical_rewriter.dart View 1 chunk +0 lines, -1 line 0 comments Download
M pkg/compiler/lib/src/tree_ir/optimization/optimization.dart View 1 chunk +1 line, -0 lines 0 comments Download
A pkg/compiler/lib/src/tree_ir/optimization/pull_into_initializers.dart View 1 1 chunk +317 lines, -0 lines 0 comments Download
M pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart View 17 chunks +359 lines, -123 lines 0 comments Download
M pkg/compiler/lib/src/tree_ir/optimization/variable_merger.dart View 4 chunks +37 lines, -13 lines 0 comments Download
M pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart View 8 chunks +23 lines, -13 lines 0 comments Download
M pkg/compiler/lib/src/tree_ir/tree_ir_integrity.dart View 1 chunk +8 lines, -9 lines 0 comments Download
M pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart View 16 chunks +64 lines, -52 lines 0 comments Download
M pkg/compiler/lib/src/tree_ir/tree_ir_tracer.dart View 7 chunks +27 lines, -16 lines 0 comments Download
M tests/compiler/dart2js/js_backend_cps_ir_closures_test.dart View 3 chunks +3 lines, -6 lines 0 comments Download
M tests/compiler/dart2js/js_backend_cps_ir_constructor_test.dart View 1 chunk +1 line, -2 lines 0 comments Download

Messages

Total messages: 5 (1 generated)
asgerf
5 years, 8 months ago (2015-04-13 09:32:13 UTC) #2
Kevin Millikin (Google)
LGTM. https://codereview.chromium.org/1088493002/diff/1/pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart File pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart (right): https://codereview.chromium.org/1088493002/diff/1/pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart#newcode928 pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart:928: BuilderContext context) { Goofy indentation here. https://codereview.chromium.org/1088493002/diff/1/pkg/compiler/lib/src/tree_ir/optimization/pull_into_initializers.dart File ...
5 years, 8 months ago (2015-04-14 08:41:01 UTC) #3
asgerf
https://codereview.chromium.org/1088493002/diff/1/pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart File pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart (right): https://codereview.chromium.org/1088493002/diff/1/pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart#newcode928 pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart:928: BuilderContext context) { On 2015/04/14 08:41:00, kmillikin wrote: > ...
5 years, 8 months ago (2015-04-14 10:12:14 UTC) #4
asgerf
5 years, 8 months ago (2015-04-14 11:16:51 UTC) #5
Message was sent while issue was closed.
Committed patchset #2 (id:20001) manually as 45132 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698