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

Issue 1229563005: dart2js cps: Rewrite iterator/moveNext/current into JS array accesses. (Closed)

Created:
5 years, 5 months ago by asgerf
Modified:
5 years, 2 months ago
Reviewers:
karlklose, floitsch, sra1
CC:
reviews_dartlang.org
Base URL:
git@github.com:dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

dart2js cps: Rewrite iterator/moveNext/current into JS array accesses. For example, the code (assuming 'list' is a native list): for (var x in list) { print(x); } Becomes: var i = 0, x = null, $length = list.length, v0; while (true) { if (i < list.length) { x = list[i]; i = i + 1; v0 = true; } else { x = null; v0 = false; } if (!v0) return null; P.print(x); if ($length !== list.length) H.throwConcurrentModificationError(list); } This is clearly in need of redundant join elimination, which is an optimization that I plan to land separately. After redundant join elimination it becomes: var i = 0, x = null, $length = list.length; while (i < list.length) { x = list[i]; i = i + 1; P.print(x); if ($length !== list.length) H.throwConcurrentModificationError(list); } x = null; There is still room for improvement regarding redundant assignemnts to 'x'. They occur because x is a MutableVariable. Rewriting these into "SSA variables" (continuation parameters) is another optimization we may want to implement. BUG= R=floitsch@google.com Committed: https://github.com/dart-lang/sdk/commit/9a7d77604b07be6094abafb189aca09c518840f6

Patch Set 1 #

Total comments: 15

Patch Set 2 : Address comments #

Patch Set 3 : Rebase #

Patch Set 4 : Run redundant phi elimination before type propagation #

Unified diffs Side-by-side diffs Delta from patch set Stats (+223 lines, -25 lines) Patch
M pkg/compiler/lib/src/cps_ir/cps_fragment.dart View 1 3 chunks +29 lines, -3 lines 0 comments Download
M pkg/compiler/lib/src/cps_ir/type_propagation.dart View 1 5 chunks +193 lines, -22 lines 0 comments Download
M pkg/compiler/lib/src/js_backend/codegen/task.dart View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 7 (2 generated)
asgerf
5 years, 5 months ago (2015-07-08 13:40:19 UTC) #2
floitsch
LGTM. https://codereview.chromium.org/1229563005/diff/1/pkg/compiler/lib/src/cps_ir/cps_fragment.dart File pkg/compiler/lib/src/cps_ir/cps_fragment.dart (right): https://codereview.chromium.org/1229563005/diff/1/pkg/compiler/lib/src/cps_ir/cps_fragment.dart#newcode274 pkg/compiler/lib/src/cps_ir/cps_fragment.dart:274: Primitive getMutable(MutableVariable variable) { add dartdocs (here and ...
5 years, 5 months ago (2015-07-08 18:45:51 UTC) #3
asgerf
https://codereview.chromium.org/1229563005/diff/1/pkg/compiler/lib/src/cps_ir/cps_fragment.dart File pkg/compiler/lib/src/cps_ir/cps_fragment.dart (right): https://codereview.chromium.org/1229563005/diff/1/pkg/compiler/lib/src/cps_ir/cps_fragment.dart#newcode274 pkg/compiler/lib/src/cps_ir/cps_fragment.dart:274: Primitive getMutable(MutableVariable variable) { On 2015/07/08 18:45:50, floitsch wrote: ...
5 years, 5 months ago (2015-07-09 10:22:40 UTC) #4
asgerf
Committed patchset #4 (id:60001) manually as 9a7d77604b07be6094abafb189aca09c518840f6 (presubmit successful).
5 years, 5 months ago (2015-07-10 13:22:05 UTC) #5
sra1
5 years, 2 months ago (2015-09-30 17:08:32 UTC) #7
Message was sent while issue was closed.
DBC

https://chromiumcodereview.appspot.com/1229563005/diff/1/pkg/compiler/lib/src...
File pkg/compiler/lib/src/cps_ir/type_propagation.dart (right):

https://chromiumcodereview.appspot.com/1229563005/diff/1/pkg/compiler/lib/src...
pkg/compiler/lib/src/cps_ir/type_propagation.dart:1026: case 'iterator':
Pull this 150 lines into a helper method.

Powered by Google App Engine
This is Rietveld 408576698