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

Side by Side Diff: test/mjsunit/es6/tail-call.js

Issue 1914393002: [es6] Don't eliminate tail calls from for-in and for-of bodies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --allow-natives-syntax --harmony-tailcalls 5 // Flags: --allow-natives-syntax --harmony-tailcalls
6 "use strict"; 6 "use strict";
7 7
8 Error.prepareStackTrace = (error,stack) => { 8 Error.prepareStackTrace = (error,stack) => {
9 error.strace = stack; 9 error.strace = stack;
10 return error.message + "\n at " + stack.join("\n at "); 10 return error.message + "\n at " + stack.join("\n at ");
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 assertEquals(true, g2()); 240 assertEquals(true, g2());
241 assertEquals(153, g3()); 241 assertEquals(153, g3());
242 } 242 }
243 test(); 243 test();
244 test(); 244 test();
245 %OptimizeFunctionOnNextCall(test); 245 %OptimizeFunctionOnNextCall(test);
246 test(); 246 test();
247 })(); 247 })();
248 248
249 249
250 // Tail calling from various statements.
251 (function() {
252 function g1() {
253 for (var v in {a:0}) {
254 return f_153([f_153, g1, test]);
255 }
256 }
257
258 function g2() {
259 for (var v of [1, 2, 3]) {
260 return f_153([f_153, g2, test]);
261 }
262 }
263
264 function g3() {
265 for (var i = 0; i < 10; i++) {
266 return f_153([f_153, test]);
267 }
268 }
269
270 function g4() {
271 while (true) {
272 return f_153([f_153, test]);
273 }
274 }
275
276 function g5() {
277 do {
278 return f_153([f_153, test]);
279 } while (true);
280 }
281
282 function test() {
283 assertEquals(153, g1());
284 assertEquals(153, g2());
285 assertEquals(153, g3());
286 assertEquals(153, g4());
287 assertEquals(153, g5());
288 }
289 test();
290 test();
291 %OptimizeFunctionOnNextCall(test);
292 test();
293 })();
294
295
250 // Test tail calls from try-catch constructs. 296 // Test tail calls from try-catch constructs.
251 (function() { 297 (function() {
252 function tc1(a) { 298 function tc1(a) {
253 try { 299 try {
254 f_153([f_153, tc1, test]); 300 f_153([f_153, tc1, test]);
255 return f_153([f_153, tc1, test]); 301 return f_153([f_153, tc1, test]);
256 } catch(e) { 302 } catch(e) {
257 f_153([f_153, tc1, test]); 303 f_153([f_153, tc1, test]);
258 } 304 }
259 } 305 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 452
407 function test() { 453 function test() {
408 assertEquals(153, g1()); 454 assertEquals(153, g1());
409 assertEquals(153, g2()); 455 assertEquals(153, g2());
410 } 456 }
411 test(); 457 test();
412 test(); 458 test();
413 %OptimizeFunctionOnNextCall(test); 459 %OptimizeFunctionOnNextCall(test);
414 test(); 460 test();
415 })(); 461 })();
OLDNEW
« no previous file with comments | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698