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

Issue 9907001: Implement JumpNode for break/continue in for loops. (Closed)

Created:
8 years, 9 months ago by srdjan
Modified:
8 years, 8 months ago
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Visibility:
Public.

Description

Implement JumpNode for break/continue in for loops. Committed: https://code.google.com/p/dart/source/detail?r=6050

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : #

Total comments: 4

Patch Set 4 : #

Patch Set 5 : #

Patch Set 6 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+143 lines, -21 lines) Patch
M runtime/vm/flow_graph_builder.cc View 1 2 3 4 5 4 chunks +119 lines, -20 lines 0 comments Download
M runtime/vm/scopes.h View 1 2 3 4 5 4 chunks +24 lines, -1 line 0 comments Download

Messages

Total messages: 4 (0 generated)
srdjan
1.8% bailouts
8 years, 9 months ago (2012-03-28 23:29:34 UTC) #1
regis
LGTM
8 years, 9 months ago (2012-03-29 02:31:43 UTC) #2
Kevin Millikin (Google)
I think there's a bug in the translation of JumpNode (setting entry_ to the jump ...
8 years, 8 months ago (2012-03-29 11:38:31 UTC) #3
srdjan
8 years, 8 months ago (2012-03-30 00:53:50 UTC) #4
I like the idea of allocating join node in JumpNode as it should make the loop
coding simpler. I have added bailout tests to loops/switch/case and sequences.

This CL reminded me how painful it is to build the graph correctly. I am not
that happy with the current state, and think that we should have some higher
level abstractions for connecting the graph correctly.


On 2012/03/29 11:38:31, kmillikin wrote:
> I think there's a bug in the translation of JumpNode (setting entry_ to the
jump
> target).
> 
> It might be clearer to lazily allocate the join node in JumpNode, but you
might
> disagree about that.
> 
>
https://chromiumcodereview.appspot.com/9907001/diff/6001/runtime/vm/flow_grap...
> File runtime/vm/flow_graph_builder.cc (right):
> 
>
https://chromiumcodereview.appspot.com/9907001/diff/6001/runtime/vm/flow_grap...
> runtime/vm/flow_graph_builder.cc:760: if
(node->label()->is_break_jump_target())
> {
> You could do this lazily in VisitJumpNode:
> 
> if ((node->kind() == Token::kBREAK) &&
>     (node->label()->join_for_break() == NULL)) {
>   node->label()->join_for_break() = new Join...;
> }
> 
> It has two small advantages that I can see: avoids a join for unreachable
breaks
> (rare) and keeps the logic for break and continue out the logic for looping
> graph structure, which is already kind of complicated.
> 
>
https://chromiumcodereview.appspot.com/9907001/diff/6001/runtime/vm/flow_grap...
> runtime/vm/flow_graph_builder.cc:767: BlockEntryInstr* increment_entry = NULL;
> You could also do this lazily in VisitJumpNode.
> 
>
https://chromiumcodereview.appspot.com/9907001/diff/6001/runtime/vm/flow_grap...
> runtime/vm/flow_graph_builder.cc:777: EffectGraphVisitor
for_increment(owner(),
> temp_index());
> Then you can:
> 
> 1. Visit the body first.  After visiting the body, ask if
> node->label()->join_for_continue() is NULL.  If so and the body is open, set
its
> exit's successor to the join for continue.
> 
> If there is no join for continue, then we can accumulate the increment
> instructions in the same block as the body (avoiding an unnecessary basic
block
> in the common case) as before.
> 
> 2. Visit the condition.  Tie it to the body, and a false successor to a fresh
> target (if there is no join for break) or an edge (split by a target) to the
> join for break.
> 
> Does that make sense?
> 
>
https://chromiumcodereview.appspot.com/9907001/diff/6001/runtime/vm/flow_grap...
> runtime/vm/flow_graph_builder.cc:864: entry_ = exit_ =
> node->label()->join_for_break();
> Hmm.  We don't need to set exit_, because CloseFragment will just clear it
(the
> jump node has no fall through).
> 
> I'm not sure it's right to set entry_ either.  Won't that leave the inlined
> finally blocks and the context unchaining instructions dangling when the
caller
> tries to Append the result of translating the JumpNode?

Powered by Google App Engine
This is Rietveld 408576698