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

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

Issue 1609893003: [es6] Tail calls support. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebasing Created 4 years, 11 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 | « test/mjsunit/es6/tail-call.js ('k') | test/mjsunit/es6/tail-call-simple.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Flags: --allow-natives-syntax --harmony-tailcalls --harmony-proxies
6 "use strict";
7
8 Error.prepareStackTrace = (e,s) => s;
9
10 function CheckStackTrace(expected) {
11 var stack = (new Error()).stack;
12 assertEquals("CheckStackTrace", stack[0].getFunctionName());
13 for (var i = 0; i < expected.length; i++) {
14 assertEquals(expected[i].name, stack[i + 1].getFunctionName());
15 }
16 }
17
18
19 // Tail call proxy function when caller does not have an arguments
20 // adaptor frame.
21 (function test() {
22 // Caller and callee have same number of arguments.
23 function f1(a) {
24 CheckStackTrace([f1, test]);
25 return 10 + a;
26 }
27 var p1 = new Proxy(f1, {});
28 function g1(a) { return p1(2); }
29 assertEquals(12, g1(1));
30
31 // Caller has more arguments than callee.
32 function f2(a) {
33 CheckStackTrace([f2, test]);
34 return 10 + a;
35 }
36 var p2 = new Proxy(f2, {});
37 function g2(a, b, c) { return p2(2); }
38 assertEquals(12, g2(1, 2, 3));
39
40 // Caller has less arguments than callee.
41 function f3(a, b, c) {
42 CheckStackTrace([f3, test]);
43 return 10 + a + b + c;
44 }
45 var p3 = new Proxy(f3, {});
46 function g3(a) { return p3(2, 3, 4); }
47 assertEquals(19, g3(1));
48
49 // Callee has arguments adaptor frame.
50 function f4(a, b, c) {
51 CheckStackTrace([f4, test]);
52 return 10 + a;
53 }
54 var p4 = new Proxy(f4, {});
55 function g4(a) { return p4(2); }
56 assertEquals(12, g4(1));
57 })();
58
59
60 // Tail call proxy function when caller has an arguments adaptor frame.
61 (function test() {
62 // Caller and callee have same number of arguments.
63 function f1(a) {
64 CheckStackTrace([f1, test]);
65 return 10 + a;
66 }
67 var p1 = new Proxy(f1, {});
68 function g1(a) { return p1(2); }
69 assertEquals(12, g1());
70
71 // Caller has more arguments than callee.
72 function f2(a) {
73 CheckStackTrace([f2, test]);
74 return 10 + a;
75 }
76 var p2 = new Proxy(f2, {});
77 function g2(a, b, c) { return p2(2); }
78 assertEquals(12, g2());
79
80 // Caller has less arguments than callee.
81 function f3(a, b, c) {
82 CheckStackTrace([f3, test]);
83 return 10 + a + b + c;
84 }
85 var p3 = new Proxy(f3, {});
86 function g3(a) { return p3(2, 3, 4); }
87 assertEquals(19, g3());
88
89 // Callee has arguments adaptor frame.
90 function f4(a, b, c) {
91 CheckStackTrace([f4, test]);
92 return 10 + a;
93 }
94 var p4 = new Proxy(f4, {});
95 function g4(a) { return p4(2); }
96 assertEquals(12, g4());
97 })();
OLDNEW
« no previous file with comments | « test/mjsunit/es6/tail-call.js ('k') | test/mjsunit/es6/tail-call-simple.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698