Commit 813f2778 authored by ishell's avatar ishell Committed by Commit bot

[es6] Don't eliminate tail calls from for-in and for-of bodies.

BUG=v8:4698
LOG=N

Review URL: https://codereview.chromium.org/1914393002

Cr-Commit-Position: refs/heads/master@{#35813}
parent 7752614f
......@@ -3555,6 +3555,8 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
factory()->NewBlock(NULL, 3, false, RelocInfo::kNoPosition);
{
DontCollectExpressionsInTailPositionScope no_tail_calls(
function_state_);
BlockState block_state(&scope_, body_scope);
Statement* body = ParseScopedStatement(NULL, true, CHECK_OK);
......
......@@ -247,6 +247,52 @@ function f_153(expected_call_stack, a) {
})();
// Tail calling from various statements.
(function() {
function g1() {
for (var v in {a:0}) {
return f_153([f_153, g1, test]);
}
}
function g2() {
for (var v of [1, 2, 3]) {
return f_153([f_153, g2, test]);
}
}
function g3() {
for (var i = 0; i < 10; i++) {
return f_153([f_153, test]);
}
}
function g4() {
while (true) {
return f_153([f_153, test]);
}
}
function g5() {
do {
return f_153([f_153, test]);
} while (true);
}
function test() {
assertEquals(153, g1());
assertEquals(153, g2());
assertEquals(153, g3());
assertEquals(153, g4());
assertEquals(153, g5());
}
test();
test();
%OptimizeFunctionOnNextCall(test);
test();
})();
// Test tail calls from try-catch constructs.
(function() {
function tc1(a) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment