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

Side by Side Diff: test/mjsunit/compiler/function-bind.js

Issue 2916063002: [turbofan] Optimize Function.prototype.bind for the common case. (Closed)
Patch Set: Address feedback. Created 3 years, 6 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/objects.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
(Empty)
1 // Copyright 2017 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
6
7 (function() {
8 "use strict";
9 function bar() { return this; }
10
11 function foo(x) {
12 return bar.bind(x);
13 }
14
15 assertEquals(0, foo(0)());
16 assertEquals(1, foo(1)());
17 %OptimizeFunctionOnNextCall(foo);
18 assertEquals("", foo("")());
19 })();
20
21 (function() {
22 "use strict";
23 function bar(x) { return x; }
24
25 function foo(x) {
26 return bar.bind(undefined, x);
27 }
28
29 assertEquals(0, foo(0)());
30 assertEquals(1, foo(1)());
31 %OptimizeFunctionOnNextCall(foo);
32 assertEquals("", foo("")());
33 })();
34
35 (function() {
36 function bar(x) { return x; }
37
38 function foo(x) {
39 return bar.bind(undefined, x);
40 }
41
42 assertEquals(0, foo(0)());
43 assertEquals(1, foo(1)());
44 %OptimizeFunctionOnNextCall(foo);
45 assertEquals("", foo("")());
46 })();
47
48 (function() {
49 "use strict";
50 function bar(x, y) { return x + y; }
51
52 function foo(x, y) {
53 return bar.bind(undefined, x, y);
54 }
55
56 assertEquals(0, foo(0, 0)());
57 assertEquals(2, foo(1, 1)());
58 %OptimizeFunctionOnNextCall(foo);
59 assertEquals("ab", foo("a", "b")());
60 assertEquals(0, foo(0, 1).length);
61 assertEquals("bound bar", foo(1, 2).name)
62 })();
63
64 (function() {
65 function bar(x, y) { return x + y; }
66
67 function foo(x, y) {
68 return bar.bind(undefined, x, y);
69 }
70
71 assertEquals(0, foo(0, 0)());
72 assertEquals(2, foo(1, 1)());
73 %OptimizeFunctionOnNextCall(foo);
74 assertEquals("ab", foo("a", "b")());
75 assertEquals(0, foo(0, 1).length);
76 assertEquals("bound bar", foo(1, 2).name)
77 })();
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698