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

Issue 9649012: Implement logical AND/OR. (Closed)

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

Description

Implement logical AND/OR. Committed: https://code.google.com/p/dart/source/detail?r=5253

Patch Set 1 #

Patch Set 2 : #

Total comments: 4

Patch Set 3 : #

Patch Set 4 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+58 lines, -3 lines) Patch
M runtime/vm/flow_graph_builder.h View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M runtime/vm/flow_graph_builder.cc View 1 2 3 2 chunks +55 lines, -3 lines 0 comments Download
M runtime/vm/intermediate_language.cc View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
srdjan
8 years, 9 months ago (2012-03-09 00:39:21 UTC) #1
Kevin Millikin (Google)
It needs a conversion of 'right' in value contexts (probably using strict equality to true). ...
8 years, 9 months ago (2012-03-09 12:29:14 UTC) #2
srdjan
8 years, 9 months ago (2012-03-09 19:47:40 UTC) #3
https://chromiumcodereview.appspot.com/9649012/diff/3001/runtime/vm/flow_grap...
File runtime/vm/flow_graph_builder.cc (right):

https://chromiumcodereview.appspot.com/9649012/diff/3001/runtime/vm/flow_grap...
runtime/vm/flow_graph_builder.cc:225: if (node->kind() == Token::kAND) {
On 2012/03/09 12:29:14, kmillikin wrote:
> Maybe too cute is to write:
> 
> EffectGraphVisitor for_right(owner(), temp_index());
> node->right()->Visit(&for_right);
> EffectGraphVisitor empty(owner(), temp_index());
> if (node->kind() == Token::kAND) {
>   Join(for_left, for_right, empty);
> } else {
>   Join(for_left, empty, for_right);
> }

Done.

https://chromiumcodereview.appspot.com/9649012/diff/3001/runtime/vm/flow_grap...
runtime/vm/flow_graph_builder.cc:262: // AND:  left ? right : false;
On 2012/03/09 12:29:14, kmillikin wrote:
> right needs a conversion to boolean (e.g., right === true).  This translation
> won't work for:
> 
> print(true && 0);
> 
> Then, in a test context, we can do better than testing the literal false when
> left is not true---translate right in a test context as well.  (Not as an
> optimization in the non-optimizing compiler, but because that's what we want
in
> the optimizing compiler and it's easier if we keep the graph with the same
shape
> early.)

Thanks for catching it. Added tests (separate CL). There are two possibilities:
one is to use StrictCompare to convert right to boolean, the other is to use the
test context. I assume you would prefer the second, and I agree that it would
better convey the intent. However, I gave up on it (could not understand the
visitor interaction after many attempts) and implemented the correct version
using StrictCompare test.

Powered by Google App Engine
This is Rietveld 408576698