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

Side by Side Diff: test/mjsunit/compiler/inlined-call.js

Issue 347573002: Revert "Optimize Function.prototype.call" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« 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 2014 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 --noalways-opt
6
7 var array = [];
8 for (var i = 0; i < 100; ++i) {
9 array[i] = i;
10 }
11
12 var copy = array.slice();
13
14 function unshiftsArray(num) {
15 [].unshift.call(array, num);
16 }
17
18 unshiftsArray(50);
19 unshiftsArray(60);
20 %OptimizeFunctionOnNextCall(unshiftsArray);
21 unshiftsArray(80);
22 unshiftsArray(50);
23 unshiftsArray(60);
24
25 copy.unshift(50);
26 copy.unshift(60);
27 copy.unshift(80);
28 copy.unshift(50);
29 copy.unshift(60);
30
31 assertOptimized(unshiftsArray);
32 assertArrayEquals(array, copy);
33
34
35 var called = 0;
36 var funRecv;
37 // For the HConstant
38 Array.prototype.fun = function() {
39 funRecv = this;
40 called++;
41 assertEquals(0, arguments.length);
42 };
43
44 function callNoArgs() {
45 [].fun.call();
46 }
47
48 callNoArgs();
49 callNoArgs();
50 assertEquals(this, funRecv);
51 %OptimizeFunctionOnNextCall(callNoArgs);
52 callNoArgs();
53 assertEquals(this, funRecv);
54 assertEquals(3, called);
55 assertOptimized(callNoArgs);
56
57 var funStrictRecv;
58 called = 0;
59 Array.prototype.funStrict = function() {
60 "use strict";
61 funStrictRecv = this;
62 called++;
63 assertEquals(0, arguments.length);
64 };
65
66 function callStrictNoArgs() {
67 [].funStrict.call();
68 }
69
70 callStrictNoArgs();
71 callStrictNoArgs();
72 assertEquals(undefined, funStrictRecv);
73 %OptimizeFunctionOnNextCall(callStrictNoArgs);
74 callStrictNoArgs();
75 assertEquals(undefined, funStrictRecv);
76 assertEquals(3, called);
77 assertOptimized(callStrictNoArgs);
78
79 called = 0;
80 Array.prototype.manyArgs = function() {
81 "use strict";
82 assertEquals(5, arguments.length);
83 assertEquals(0, this);
84 assertEquals(5, arguments[4]);
85 called++;
86 }
87
88 function callManyArgs() {
89 [].manyArgs.call(0, 1, 2, 3, 4, 5);
90 }
91
92 callManyArgs();
93 callManyArgs();
94 %OptimizeFunctionOnNextCall(callManyArgs);
95 callManyArgs();
96 assertOptimized(callManyArgs);
97 assertEquals(called, 3);
98
99 called = 0;
100 Array.prototype.manyArgsSloppy = function() {
101 assertTrue(this instanceof Number);
102 assertEquals(5, arguments.length);
103 assertEquals(0, this.valueOf());
104 assertEquals(5, arguments[4]);
105 called++;
106 }
107
108 function callManyArgsSloppy() {
109 [].manyArgsSloppy.call(0, 1, 2, 3, 4, 5);
110 }
111
112 callManyArgsSloppy();
113 callManyArgsSloppy();
114 %OptimizeFunctionOnNextCall(callManyArgsSloppy);
115 callManyArgsSloppy();
116 assertOptimized(callManyArgsSloppy);
117 assertEquals(called, 3);
118
119 var str = "hello";
120 var code = str.charCodeAt(3);
121 called = 0;
122 function callBuiltinIndirectly() {
123 called++;
124 return "".charCodeAt.call(str, 3);
125 }
126
127 callBuiltinIndirectly();
128 callBuiltinIndirectly();
129 %OptimizeFunctionOnNextCall(callBuiltinIndirectly);
130 assertEquals(code, callBuiltinIndirectly());
131 assertOptimized(callBuiltinIndirectly);
132 assertEquals(3, called);
133
134 this.array = [1,2,3,4,5,6,7,8,9];
135 var copy = this.array.slice();
136 called = 0;
137
138 function callInlineableBuiltinIndirectlyWhileInlined() {
139 called++;
140 return [].push.apply(array, arguments);
141 }
142
143 function callInlined(num) {
144 return callInlineableBuiltinIndirectlyWhileInlined(num);
145 }
146
147 callInlined(1);
148 callInlined(2);
149 %OptimizeFunctionOnNextCall(callInlineableBuiltinIndirectlyWhileInlined);
150 %OptimizeFunctionOnNextCall(callInlined);
151 callInlined(3);
152 copy.push(1, 2, 3);
153 assertOptimized(callInlined);
154 assertOptimized(callInlineableBuiltinIndirectlyWhileInlined);
155 assertArrayEquals(copy, this.array);
156 assertEquals(3, called);
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