Descriptiondart2js 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 #
Messages
Total messages: 7 (2 generated)
|