Chromium Code Reviews
DescriptionAssignment 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 #Messages
Total messages: 5 (1 generated)
|