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

Issue 9863037: Generate prettier loops. (Closed)

Created:
8 years, 9 months ago by Lasse Reichstein Nielsen
Modified:
8 years, 8 months ago
Reviewers:
floitsch, ngeoffray
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Generate prettier loops. Add structure information to HLoopInformation, and use it to generate prettier loops when the condition can be generated as an expression. If it can't, it still falls back to the while(true){if(!cond) break;} pattern. Only handle for/while/for-in, not do-while yet. Committed: https://code.google.com/p/dart/source/detail?r=6023

Patch Set 1 #

Total comments: 42

Patch Set 2 : Adressed review comments. A few fixes. #

Total comments: 6

Patch Set 3 : Address review comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+504 lines, -47 lines) Patch
M frog/leg/resolver.dart View 1 1 chunk +2 lines, -1 line 0 comments Download
M frog/leg/scanner/listener.dart View 2 chunks +3 lines, -3 lines 0 comments Download
M frog/leg/scanner/parser.dart View 1 chunk +1 line, -1 line 0 comments Download
M frog/leg/ssa/builder.dart View 1 10 chunks +35 lines, -8 lines 0 comments Download
M frog/leg/ssa/codegen.dart View 1 2 13 chunks +311 lines, -18 lines 0 comments Download
M frog/leg/ssa/nodes.dart View 1 2 9 chunks +50 lines, -6 lines 0 comments Download
M frog/leg/tree/nodes.dart View 3 chunks +6 lines, -6 lines 0 comments Download
M frog/leg/tree/unparser.dart View 1 chunk +1 line, -1 line 0 comments Download
M frog/leg/tree/visitors.dart View 1 chunk +1 line, -1 line 0 comments Download
M frog/leg/typechecker.dart View 1 chunk +1 line, -1 line 0 comments Download
A frog/tests/leg/src/LoopTest.dart View 1 1 chunk +89 lines, -0 lines 0 comments Download
M frog/tests/leg/src/mock_compiler.dart View 1 1 chunk +4 lines, -1 line 0 comments Download

Messages

Total messages: 6 (0 generated)
Lasse Reichstein Nielsen
8 years, 9 months ago (2012-03-27 12:47:02 UTC) #1
floitsch
LGTM. https://chromiumcodereview.appspot.com/9863037/diff/1/frog/leg/ssa/codegen.dart File frog/leg/ssa/codegen.dart (left): https://chromiumcodereview.appspot.com/9863037/diff/1/frog/leg/ssa/codegen.dart#oldcode387 frog/leg/ssa/codegen.dart:387: // TODO(floitsch): HACK HACK HACK. WOOT!!! ;) https://chromiumcodereview.appspot.com/9863037/diff/1/frog/leg/ssa/codegen.dart ...
8 years, 9 months ago (2012-03-28 04:03:48 UTC) #2
ngeoffray
LGTM https://chromiumcodereview.appspot.com/9863037/diff/1/frog/leg/ssa/codegen.dart File frog/leg/ssa/codegen.dart (right): https://chromiumcodereview.appspot.com/9863037/diff/1/frog/leg/ssa/codegen.dart#newcode225 frog/leg/ssa/codegen.dart:225: // E.g, BailoutTarget. BailoutTarget does not exist anymore. ...
8 years, 9 months ago (2012-03-28 15:28:04 UTC) #3
Lasse Reichstein Nielsen
PTanotherL https://chromiumcodereview.appspot.com/9863037/diff/1/frog/leg/ssa/codegen.dart File frog/leg/ssa/codegen.dart (left): https://chromiumcodereview.appspot.com/9863037/diff/1/frog/leg/ssa/codegen.dart#oldcode387 frog/leg/ssa/codegen.dart:387: // TODO(floitsch): HACK HACK HACK. Don't be too ...
8 years, 8 months ago (2012-03-29 13:09:38 UTC) #4
floitsch
SLGTM. https://chromiumcodereview.appspot.com/9863037/diff/1/frog/leg/ssa/codegen.dart File frog/leg/ssa/codegen.dart (right): https://chromiumcodereview.appspot.com/9863037/diff/1/frog/leg/ssa/codegen.dart#newcode237 frog/leg/ssa/codegen.dart:237: // Check the second half, which will continue ...
8 years, 8 months ago (2012-03-29 21:44:10 UTC) #5
Lasse Reichstein Nielsen
8 years, 8 months ago (2012-03-30 09:37:17 UTC) #6
https://chromiumcodereview.appspot.com/9863037/diff/1/frog/leg/ssa/codegen.dart
File frog/leg/ssa/codegen.dart (right):

https://chromiumcodereview.appspot.com/9863037/diff/1/frog/leg/ssa/codegen.da...
frog/leg/ssa/codegen.dart:237: // Check the second half, which will continue
into the join.
On 2012/03/29 21:44:10, floitsch wrote:
> On 2012/03/29 13:09:38, Lasse Reichstein Nielsen wrote:
> > No, successors[1] is the join node, the first half is inputs[0].
> Right... missed that. Please add as comment.
> > 
> > Checking the second half is really a sanity check. It should be all
> expressions
> > or we wouldn't have made the logical operation inlinable anyway. I prefer
not
> to
> > rely too much on the preconditions for the current state (i.e., the
> > HConditionalBranch is generateAtUseSite - I allow myself to know what that
> > means, but not to make assumptions about how it was decided).
> 

Done.

https://chromiumcodereview.appspot.com/9863037/diff/1/frog/leg/ssa/codegen.da...
frog/leg/ssa/codegen.dart:899: if (isGeneratingExpression()) {
True. A HIf is only part of an expression if it's a logical operator, and that's
handled elsewhere.
I'll remove this.

https://chromiumcodereview.appspot.com/9863037/diff/1/frog/leg/ssa/codegen.da...
frog/leg/ssa/codegen.dart:1128: if (isGeneratingExpression()) {
On 2012/03/29 21:44:10, floitsch wrote:
> On 2012/03/29 13:09:38, Lasse Reichstein Nielsen wrote:
> > We can't yet.
> > Eventually I'll want to handle loops with non-expression-able conditions
using
> > subgraph traversal too, and then we'll get here when traversing the
condition
> > subgraph as statements.
> > 
> > Should I remove the special case here and always use the condition
expression
> at
> > the visitExpressionSubGraph call point?
> 
> If we can't reach this unless it's an expression, make it an internal error if
> it is not an expression. You won't lose any code, and it will be easy to
change
> once it can happen.

Done.

https://chromiumcodereview.appspot.com/9863037/diff/6001/frog/leg/ssa/codegen...
File frog/leg/ssa/codegen.dart (right):

https://chromiumcodereview.appspot.com/9863037/diff/6001/frog/leg/ssa/codegen...
frog/leg/ssa/codegen.dart:854: buffer.add("/*b*/");
On 2012/03/29 21:44:11, floitsch wrote:
> debug?

Done.

https://chromiumcodereview.appspot.com/9863037/diff/6001/frog/leg/ssa/codegen...
frog/leg/ssa/codegen.dart:856: buffer.add("/*a*/");
On 2012/03/29 21:44:11, floitsch wrote:
> ditto.

Done.

https://chromiumcodereview.appspot.com/9863037/diff/6001/frog/leg/ssa/nodes.dart
File frog/leg/ssa/nodes.dart (right):

https://chromiumcodereview.appspot.com/9863037/diff/6001/frog/leg/ssa/nodes.d...
frog/leg/ssa/nodes.dart:2002: if (element === null) throw "WHAT?!?";
On 2012/03/29 21:44:11, floitsch wrote:
> debug?

Done.

Powered by Google App Engine
This is Rietveld 408576698