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

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

Issue 1932213002: Version 5.1.281.23 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@5.1
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/preparser.h ('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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 assertEquals(153, tcf1()); 431 assertEquals(153, tcf1());
386 assertEquals(153, tcf2()); 432 assertEquals(153, tcf2());
387 assertEquals(153, tcf3()); 433 assertEquals(153, tcf3());
388 assertEquals(153, tcf4()); 434 assertEquals(153, tcf4());
389 } 435 }
390 test(); 436 test();
391 test(); 437 test();
392 %OptimizeFunctionOnNextCall(test); 438 %OptimizeFunctionOnNextCall(test);
393 test(); 439 test();
394 })(); 440 })();
441
442
443 // Test tail calls from arrow functions.
444 (function () {
445 function g1(a) {
446 return (() => { return f_153([f_153, test]); })();
447 }
448
449 function g2(a) {
450 return (() => f_153([f_153, test]))();
451 }
452
453 function test() {
454 assertEquals(153, g1());
455 assertEquals(153, g2());
456 }
457 test();
458 test();
459 %OptimizeFunctionOnNextCall(test);
460 test();
461 })();
OLDNEW
« no previous file with comments | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698