dart2js cps: Fix bug in trampoline visitor.

If a continuation was visited directly (as the root of the
trampoline) the actions pushed in traverseContinuation would
not get processed.

BUG=
R=kmillikin@google.com

Review URL: https://codereview.chromium.org/1427643009 .
This commit is contained in:
Asger Feldthaus 2015-11-05 13:14:55 +01:00
parent b13607d247
commit b466453025

View file

@ -2067,7 +2067,9 @@ class TrampolineRecursiveVisitor extends DeepRecursiveVisitor {
if (cont.isReturnContinuation) {
traverseContinuation(cont);
} else {
_trampoline(traverseContinuation(cont));
int initialHeight = _stack.length;
Expression body = traverseContinuation(cont);
_trampoline(body, initialHeight: initialHeight);
}
}
@ -2107,8 +2109,8 @@ class TrampolineRecursiveVisitor extends DeepRecursiveVisitor {
return node.body;
}
void _trampoline(Expression node) {
int initialHeight = _stack.length;
void _trampoline(Expression node, {int initialHeight}) {
initialHeight = initialHeight ?? _stack.length;
_processBlock(node);
while (_stack.length > initialHeight) {
StackAction callback = _stack.removeLast();