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

Issue 10520003: Use short-hand update syntax for simple updating definitions. (Closed)

Created:
8 years, 6 months ago by Mads Ager (google)
Modified:
8 years, 6 months ago
Reviewers:
ngeoffray, kasperl
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Use short-hand update syntax for simple updating definitions. For example turn 'i = i + 1' into '++i' and 'i = i / 0.2' into 'i /= 0.2'. Additionally, only move equivalent instructions to a dominator block if there is more than one successor. There is no reason to move if there is only one in any case. This has the added benefit that the update part of a simple for-loop stays in the update part in the generated code. Before: for (var i = 0; i < 10; ) { i = i + 1; } Now: for (var i = 0; i < 10; ++i) { } This code is a bit hackish. Please let me know if you have suggestions for better structure of the cod. R=ngeoffray@google.com,kasperl@google.com BUG= TEST= Committed: https://code.google.com/p/dart/source/detail?r=8250

Patch Set 1 #

Total comments: 16

Patch Set 2 : Address comments. #

Patch Set 3 : Address more comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+64 lines, -10 lines) Patch
M lib/compiler/implementation/ssa/codegen.dart View 1 2 4 chunks +60 lines, -6 lines 0 comments Download
M lib/compiler/implementation/ssa/optimize.dart View 1 2 1 chunk +4 lines, -4 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
Mads Ager (google)
8 years, 6 months ago (2012-06-04 13:08:27 UTC) #1
kasperl
LGTM! https://chromiumcodereview.appspot.com/10520003/diff/1/lib/compiler/implementation/ssa/codegen.dart File lib/compiler/implementation/ssa/codegen.dart (right): https://chromiumcodereview.appspot.com/10520003/diff/1/lib/compiler/implementation/ssa/codegen.dart#newcode496 lib/compiler/implementation/ssa/codegen.dart:496: // Extract the operation and whether or not ...
8 years, 6 months ago (2012-06-04 13:12:56 UTC) #2
Mads Ager (google)
https://chromiumcodereview.appspot.com/10520003/diff/1/lib/compiler/implementation/ssa/codegen.dart File lib/compiler/implementation/ssa/codegen.dart (right): https://chromiumcodereview.appspot.com/10520003/diff/1/lib/compiler/implementation/ssa/codegen.dart#newcode496 lib/compiler/implementation/ssa/codegen.dart:496: // Extract the operation and whether or not it ...
8 years, 6 months ago (2012-06-04 13:21:45 UTC) #3
ngeoffray
LGTM https://chromiumcodereview.appspot.com/10520003/diff/1/lib/compiler/implementation/ssa/codegen.dart File lib/compiler/implementation/ssa/codegen.dart (right): https://chromiumcodereview.appspot.com/10520003/diff/1/lib/compiler/implementation/ssa/codegen.dart#newcode494 lib/compiler/implementation/ssa/codegen.dart:494: if (!isVariableDeclared(name)) return false; I think you should ...
8 years, 6 months ago (2012-06-04 13:24:00 UTC) #4
Mads Ager (google)
8 years, 6 months ago (2012-06-04 15:27:18 UTC) #5
https://chromiumcodereview.appspot.com/10520003/diff/1/lib/compiler/implement...
File lib/compiler/implementation/ssa/codegen.dart (right):

https://chromiumcodereview.appspot.com/10520003/diff/1/lib/compiler/implement...
lib/compiler/implementation/ssa/codegen.dart:494: if (!isVariableDeclared(name))
return false;
On 2012/06/04 13:24:00, ngeoffray wrote:
> I think you should check that it's not delayed either. It should be fine to
use
> i++ if it's delayed. Or maybe should we declare a variable as declared if it's
> delayed? I think we're duplicating 'var' if we don't.

Yes, went for marking a variable declared when we add it to the
delayedVariables.

https://chromiumcodereview.appspot.com/10520003/diff/1/lib/compiler/implement...
lib/compiler/implementation/ssa/codegen.dart:497: var operation;
On 2012/06/04 13:24:00, ngeoffray wrote:
> Please use the Operation class in lib/compiler/implementation/operations.dart
to
> check for commutativity and the operation's name.

In principle that would be very nice. In practice the Operation class is not
very well suited for this. Add operations are not commutative when dealing with
strings so we need a special case for that. Not all operations that are
BinaryArithmetic operations and are builtin will work with this (such as
truncating divide). So, in the end we will end up with the same checks. I have
used the Operation class to get the name of the operation which makes the code
shorter, but I still need the other checks.

https://chromiumcodereview.appspot.com/10520003/diff/1/lib/compiler/implement...
lib/compiler/implementation/ssa/codegen.dart:526: if (left is HPhi &&
On 2012/06/04 13:24:00, ngeoffray wrote:
> I think you can remove the check. You only need to check if
> variableNames.getName(left) == name

Great, thanks!

Powered by Google App Engine
This is Rietveld 408576698