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

Side by Side Diff: test/cctest/compiler/test-run-inlining.cc

Issue 712403003: Fix bug in graph copy while inlining loops. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | « test/cctest/cctest.status ('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 2014 the V8 project authors. All rights reserved. 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 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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "test/cctest/compiler/function-tester.h" 7 #include "test/cctest/compiler/function-tester.h"
8 8
9 #if V8_TURBOFAN_TARGET 9 #if V8_TURBOFAN_TARGET
10 10
(...skipping 19 matching lines...) Expand all
30 30
31 31
32 static void InstallAssertInlineCountHelper(v8::Isolate* isolate) { 32 static void InstallAssertInlineCountHelper(v8::Isolate* isolate) {
33 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 33 v8::Local<v8::Context> context = isolate->GetCurrentContext();
34 v8::Local<v8::FunctionTemplate> t = 34 v8::Local<v8::FunctionTemplate> t =
35 v8::FunctionTemplate::New(isolate, AssertInlineCount); 35 v8::FunctionTemplate::New(isolate, AssertInlineCount);
36 context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction()); 36 context->Global()->Set(v8_str("AssertInlineCount"), t->GetFunction());
37 } 37 }
38 38
39 39
40 static uint32_t kInlineFlags = CompilationInfo::kInliningEnabled |
41 CompilationInfo::kContextSpecializing |
42 CompilationInfo::kTypingEnabled;
43
44
40 TEST(SimpleInlining) { 45 TEST(SimpleInlining) {
41 FLAG_turbo_deoptimization = true; 46 FLAG_turbo_deoptimization = true;
42 FunctionTester T( 47 FunctionTester T(
43 "(function(){" 48 "(function(){"
44 "function foo(s) { AssertInlineCount(2); return s; };" 49 " function foo(s) { AssertInlineCount(2); return s; };"
45 "function bar(s, t) { return foo(s); };" 50 " function bar(s, t) { return foo(s); };"
46 "return bar;})();", 51 " return bar;"
47 CompilationInfo::kInliningEnabled | 52 "})();",
48 CompilationInfo::kContextSpecializing | 53 kInlineFlags);
49 CompilationInfo::kTypingEnabled);
50 54
51 InstallAssertInlineCountHelper(CcTest::isolate()); 55 InstallAssertInlineCountHelper(CcTest::isolate());
52 T.CheckCall(T.Val(1), T.Val(1), T.Val(2)); 56 T.CheckCall(T.Val(1), T.Val(1), T.Val(2));
53 } 57 }
54 58
55 59
56 TEST(SimpleInliningDeopt) { 60 TEST(SimpleInliningDeopt) {
57 FLAG_turbo_deoptimization = true; 61 FLAG_turbo_deoptimization = true;
58 FunctionTester T( 62 FunctionTester T(
59 "(function(){" 63 "(function(){"
60 "function foo(s) { %DeoptimizeFunction(bar); return " 64 " function foo(s) { %DeoptimizeFunction(bar); return s; };"
61 "s; };" 65 " function bar(s, t) { return foo(s); };"
62 "function bar(s, t) { return foo(s); };" 66 " return bar;"
63 "return bar;})();", 67 "})();",
64 CompilationInfo::kInliningEnabled | 68 kInlineFlags);
65 CompilationInfo::kContextSpecializing |
66 CompilationInfo::kTypingEnabled);
67 69
68 InstallAssertInlineCountHelper(CcTest::isolate()); 70 InstallAssertInlineCountHelper(CcTest::isolate());
69 T.CheckCall(T.Val(1), T.Val(1), T.Val(2)); 71 T.CheckCall(T.Val(1), T.Val(1), T.Val(2));
70 } 72 }
71 73
72 74
73 TEST(SimpleInliningContext) { 75 TEST(SimpleInliningContext) {
74 FLAG_turbo_deoptimization = true; 76 FLAG_turbo_deoptimization = true;
75 FunctionTester T( 77 FunctionTester T(
76 "(function () {" 78 "(function () {"
77 "function foo(s) { AssertInlineCount(2); var x = 12; return s + x; };" 79 " function foo(s) { AssertInlineCount(2); var x = 12; return s + x; };"
78 "function bar(s, t) { return foo(s); };" 80 " function bar(s, t) { return foo(s); };"
79 "return bar;" 81 " return bar;"
80 "})();", 82 "})();",
81 CompilationInfo::kInliningEnabled | 83 kInlineFlags);
82 CompilationInfo::kContextSpecializing |
83 CompilationInfo::kTypingEnabled);
84 84
85 InstallAssertInlineCountHelper(CcTest::isolate()); 85 InstallAssertInlineCountHelper(CcTest::isolate());
86 T.CheckCall(T.Val(13), T.Val(1), T.Val(2)); 86 T.CheckCall(T.Val(13), T.Val(1), T.Val(2));
87 } 87 }
88 88
89 89
90 TEST(SimpleInliningContextDeopt) { 90 TEST(SimpleInliningContextDeopt) {
91 FLAG_turbo_deoptimization = true; 91 FLAG_turbo_deoptimization = true;
92 FunctionTester T( 92 FunctionTester T(
93 "(function () {" 93 "(function () {"
94 "function foo(s) { " 94 " function foo(s) {"
95 " AssertInlineCount(2); %DeoptimizeFunction(bar); var x = 12;" 95 " AssertInlineCount(2); %DeoptimizeFunction(bar); var x = 12;"
96 " return s + x;" 96 " return s + x;"
97 "};" 97 " };"
98 "function bar(s, t) { return foo(s); };" 98 " function bar(s, t) { return foo(s); };"
99 "return bar;" 99 " return bar;"
100 "})();", 100 "})();",
101 CompilationInfo::kInliningEnabled | 101 kInlineFlags);
102 CompilationInfo::kContextSpecializing |
103 CompilationInfo::kTypingEnabled);
104 102
105 InstallAssertInlineCountHelper(CcTest::isolate()); 103 InstallAssertInlineCountHelper(CcTest::isolate());
106 T.CheckCall(T.Val(13), T.Val(1), T.Val(2)); 104 T.CheckCall(T.Val(13), T.Val(1), T.Val(2));
107 } 105 }
108 106
109 107
110 TEST(CaptureContext) { 108 TEST(CaptureContext) {
111 FLAG_turbo_deoptimization = true; 109 FLAG_turbo_deoptimization = true;
112 FunctionTester T( 110 FunctionTester T(
113 "var f = (function () {" 111 "var f = (function () {"
114 "var x = 42;" 112 "var x = 42;"
115 "function bar(s) { return x + s; };" 113 "function bar(s) { return x + s; };"
116 "return (function (s) { return bar(s); });" 114 "return (function (s) { return bar(s); });"
117 "})();" 115 "})();"
118 "(function (s) { return f(s)})", 116 "(function (s) { return f(s)})",
119 CompilationInfo::kInliningEnabled | 117 kInlineFlags);
120 CompilationInfo::kContextSpecializing |
121 CompilationInfo::kTypingEnabled);
122 118
123 InstallAssertInlineCountHelper(CcTest::isolate()); 119 InstallAssertInlineCountHelper(CcTest::isolate());
124 T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); 120 T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined());
125 } 121 }
126 122
127 123
128 // TODO(sigurds) For now we do not inline any native functions. If we do at 124 // TODO(sigurds) For now we do not inline any native functions. If we do at
129 // some point, change this test. 125 // some point, change this test.
130 TEST(DontInlineEval) { 126 TEST(DontInlineEval) {
131 FLAG_turbo_deoptimization = true; 127 FLAG_turbo_deoptimization = true;
132 FunctionTester T( 128 FunctionTester T(
133 "var x = 42;" 129 "var x = 42;"
134 "(function () {" 130 "(function () {"
135 "function bar(s, t) { return eval(\"AssertInlineCount(1); x\") };" 131 " function bar(s, t) { return eval(\"AssertInlineCount(1); x\") };"
136 "return bar;" 132 " return bar;"
137 "})();", 133 "})();",
138 CompilationInfo::kInliningEnabled | 134 kInlineFlags);
139 CompilationInfo::kContextSpecializing |
140 CompilationInfo::kTypingEnabled);
141 135
142 InstallAssertInlineCountHelper(CcTest::isolate()); 136 InstallAssertInlineCountHelper(CcTest::isolate());
143 T.CheckCall(T.Val(42), T.Val("x"), T.undefined()); 137 T.CheckCall(T.Val(42), T.Val("x"), T.undefined());
144 } 138 }
145 139
146 140
147 TEST(InlineOmitArguments) { 141 TEST(InlineOmitArguments) {
148 FLAG_turbo_deoptimization = true; 142 FLAG_turbo_deoptimization = true;
149 FunctionTester T( 143 FunctionTester T(
150 "(function () {" 144 "(function () {"
151 "var x = 42;" 145 " var x = 42;"
152 "function bar(s, t, u, v) { AssertInlineCount(2); return x + s; };" 146 " function bar(s, t, u, v) { AssertInlineCount(2); return x + s; };"
153 "return (function (s,t) { return bar(s); });" 147 " return (function (s,t) { return bar(s); });"
154 "})();", 148 "})();",
155 CompilationInfo::kInliningEnabled | 149 kInlineFlags);
156 CompilationInfo::kContextSpecializing |
157 CompilationInfo::kTypingEnabled);
158 150
159 InstallAssertInlineCountHelper(CcTest::isolate()); 151 InstallAssertInlineCountHelper(CcTest::isolate());
160 T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); 152 T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined());
161 } 153 }
162 154
163 155
164 TEST(InlineOmitArgumentsDeopt) { 156 TEST(InlineOmitArgumentsDeopt) {
165 FLAG_turbo_deoptimization = true; 157 FLAG_turbo_deoptimization = true;
166 FunctionTester T( 158 FunctionTester T(
167 "(function () {" 159 "(function () {"
168 "function foo(s,t,u,v) { AssertInlineCount(2); %DeoptimizeFunction(bar); " 160 " function foo(s,t,u,v) { AssertInlineCount(2);"
169 "return baz(); };" 161 " %DeoptimizeFunction(bar); return baz(); };"
170 "function bar() { return foo(11); };" 162 " function bar() { return foo(11); };"
171 "function baz() { return foo.arguments.length == 1 && " 163 " function baz() { return foo.arguments.length == 1 &&"
172 " foo.arguments[0] == 11 ; }" 164 " foo.arguments[0] == 11; }"
173 "return bar;" 165 " return bar;"
174 "})();", 166 "})();",
175 CompilationInfo::kInliningEnabled | 167 kInlineFlags);
176 CompilationInfo::kContextSpecializing |
177 CompilationInfo::kTypingEnabled);
178 168
179 InstallAssertInlineCountHelper(CcTest::isolate()); 169 InstallAssertInlineCountHelper(CcTest::isolate());
180 T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); 170 T.CheckCall(T.true_value(), T.Val(12), T.Val(14));
181 } 171 }
182 172
183 173
184 TEST(InlineSurplusArguments) { 174 TEST(InlineSurplusArguments) {
185 FLAG_turbo_deoptimization = true; 175 FLAG_turbo_deoptimization = true;
186 FunctionTester T( 176 FunctionTester T(
187 "(function () {" 177 "(function () {"
188 "var x = 42;" 178 " var x = 42;"
189 "function foo(s) { AssertInlineCount(2); return x + s; };" 179 " function foo(s) { AssertInlineCount(2); return x + s; };"
190 "function bar(s,t) { return foo(s,t,13); };" 180 " function bar(s,t) { return foo(s,t,13); };"
191 "return bar;" 181 " return bar;"
192 "})();", 182 "})();",
193 CompilationInfo::kInliningEnabled | 183 kInlineFlags);
194 CompilationInfo::kContextSpecializing |
195 CompilationInfo::kTypingEnabled);
196 184
197 InstallAssertInlineCountHelper(CcTest::isolate()); 185 InstallAssertInlineCountHelper(CcTest::isolate());
198 T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined()); 186 T.CheckCall(T.Val(42 + 12), T.Val(12), T.undefined());
199 } 187 }
200 188
201 189
202 TEST(InlineSurplusArgumentsDeopt) { 190 TEST(InlineSurplusArgumentsDeopt) {
203 FLAG_turbo_deoptimization = true; 191 FLAG_turbo_deoptimization = true;
204 FunctionTester T( 192 FunctionTester T(
205 "(function () {" 193 "(function () {"
206 "function foo(s) { AssertInlineCount(2); %DeoptimizeFunction(bar); " 194 " function foo(s) { AssertInlineCount(2); %DeoptimizeFunction(bar);"
207 "return baz(); };" 195 " return baz(); };"
208 "function bar() { return foo(13, 14, 15); };" 196 " function bar() { return foo(13, 14, 15); };"
209 "function baz() { return foo.arguments.length == 3 && " 197 " function baz() { return foo.arguments.length == 3 &&"
210 " foo.arguments[0] == 13 && " 198 " foo.arguments[0] == 13 &&"
211 " foo.arguments[1] == 14 && " 199 " foo.arguments[1] == 14 &&"
212 " foo.arguments[2] == 15; }" 200 " foo.arguments[2] == 15; }"
213 "return bar;" 201 " return bar;"
214 "})();", 202 "})();",
215 CompilationInfo::kInliningEnabled | 203 kInlineFlags);
216 CompilationInfo::kContextSpecializing |
217 CompilationInfo::kTypingEnabled);
218 204
219 InstallAssertInlineCountHelper(CcTest::isolate()); 205 InstallAssertInlineCountHelper(CcTest::isolate());
220 T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); 206 T.CheckCall(T.true_value(), T.Val(12), T.Val(14));
221 } 207 }
222 208
223 209
224 TEST(InlineTwice) { 210 TEST(InlineTwice) {
225 FLAG_turbo_deoptimization = true; 211 FLAG_turbo_deoptimization = true;
226 FunctionTester T( 212 FunctionTester T(
227 "(function () {" 213 "(function () {"
228 "var x = 42;" 214 " var x = 42;"
229 "function bar(s) { AssertInlineCount(2); return x + s; };" 215 " function bar(s) { AssertInlineCount(2); return x + s; };"
230 "return (function (s,t) { return bar(s) + bar(t); });" 216 " return (function (s,t) { return bar(s) + bar(t); });"
231 "})();", 217 "})();",
232 CompilationInfo::kInliningEnabled | 218 kInlineFlags);
233 CompilationInfo::kContextSpecializing |
234 CompilationInfo::kTypingEnabled);
235 219
236 InstallAssertInlineCountHelper(CcTest::isolate()); 220 InstallAssertInlineCountHelper(CcTest::isolate());
237 T.CheckCall(T.Val(2 * 42 + 12 + 4), T.Val(12), T.Val(4)); 221 T.CheckCall(T.Val(2 * 42 + 12 + 4), T.Val(12), T.Val(4));
238 } 222 }
239 223
240 224
241 TEST(InlineTwiceDependent) { 225 TEST(InlineTwiceDependent) {
242 FLAG_turbo_deoptimization = true; 226 FLAG_turbo_deoptimization = true;
243 FunctionTester T( 227 FunctionTester T(
244 "(function () {" 228 "(function () {"
245 "var x = 42;" 229 " var x = 42;"
246 "function foo(s) { AssertInlineCount(2); return x + s; };" 230 " function foo(s) { AssertInlineCount(2); return x + s; };"
247 "function bar(s,t) { return foo(foo(s)); };" 231 " function bar(s,t) { return foo(foo(s)); };"
248 "return bar;" 232 " return bar;"
249 "})();", 233 "})();",
250 CompilationInfo::kInliningEnabled | 234 kInlineFlags);
251 CompilationInfo::kContextSpecializing |
252 CompilationInfo::kTypingEnabled);
253 235
254 InstallAssertInlineCountHelper(CcTest::isolate()); 236 InstallAssertInlineCountHelper(CcTest::isolate());
255 T.CheckCall(T.Val(42 + 42 + 12), T.Val(12), T.Val(4)); 237 T.CheckCall(T.Val(42 + 42 + 12), T.Val(12), T.Val(4));
256 } 238 }
257 239
258 240
259 TEST(InlineTwiceDependentDiamond) { 241 TEST(InlineTwiceDependentDiamond) {
260 FLAG_turbo_deoptimization = true; 242 FLAG_turbo_deoptimization = true;
261 FunctionTester T( 243 FunctionTester T(
262 "(function () {" 244 "(function () {"
263 "var x = 41;" 245 " var x = 41;"
264 "function foo(s) { AssertInlineCount(2); if (s % 2 == 0) {" 246 " function foo(s) { AssertInlineCount(2); if (s % 2 == 0) {"
265 " return x - s } else { return x + s; } };" 247 " return x - s } else { return x + s; } };"
266 "function bar(s,t) { return foo(foo(s)); };" 248 " function bar(s,t) { return foo(foo(s)); };"
267 "return bar;" 249 " return bar;"
268 "})();", 250 "})();",
269 CompilationInfo::kInliningEnabled | 251 kInlineFlags);
270 CompilationInfo::kContextSpecializing |
271 CompilationInfo::kTypingEnabled);
272 252
273 InstallAssertInlineCountHelper(CcTest::isolate()); 253 InstallAssertInlineCountHelper(CcTest::isolate());
274 T.CheckCall(T.Val(-11), T.Val(11), T.Val(4)); 254 T.CheckCall(T.Val(-11), T.Val(11), T.Val(4));
275 } 255 }
276 256
277 257
278 TEST(InlineTwiceDependentDiamondDifferent) { 258 TEST(InlineTwiceDependentDiamondDifferent) {
279 FLAG_turbo_deoptimization = true; 259 FLAG_turbo_deoptimization = true;
280 FunctionTester T( 260 FunctionTester T(
281 "(function () {" 261 "(function () {"
282 "var x = 41;" 262 " var x = 41;"
283 "function foo(s,t) { AssertInlineCount(2); if (s % 2 == 0) {" 263 " function foo(s,t) { AssertInlineCount(2); if (s % 2 == 0) {"
284 " return x - s * t } else { return x + s * t; } };" 264 " return x - s * t } else { return x + s * t; } };"
285 "function bar(s,t) { return foo(foo(s, 3), 5); };" 265 " function bar(s,t) { return foo(foo(s, 3), 5); };"
286 "return bar;" 266 " return bar;"
287 "})();", 267 "})();",
288 CompilationInfo::kInliningEnabled | 268 kInlineFlags);
289 CompilationInfo::kContextSpecializing |
290 CompilationInfo::kTypingEnabled);
291 269
292 InstallAssertInlineCountHelper(CcTest::isolate()); 270 InstallAssertInlineCountHelper(CcTest::isolate());
293 T.CheckCall(T.Val(-329), T.Val(11), T.Val(4)); 271 T.CheckCall(T.Val(-329), T.Val(11), T.Val(4));
294 } 272 }
295 273
296 274
297 TEST(InlineLoop) { 275 TEST(InlineLoopGuardedEmpty) {
298 FLAG_turbo_deoptimization = true; 276 FLAG_turbo_deoptimization = true;
299 FunctionTester T( 277 FunctionTester T(
300 "(function () {" 278 "(function () {"
301 "var x = 41;" 279 " function foo(s) { AssertInlineCount(2); if (s) while (s); return s; };"
302 "function foo(s) { AssertInlineCount(2); while (s > 0) {" 280 " function bar(s,t) { return foo(s); };"
303 " s = s - 1; }; return s; };" 281 " return bar;"
304 "function bar(s,t) { return foo(foo(s)); };"
305 "return bar;"
306 "})();", 282 "})();",
307 CompilationInfo::kInliningEnabled | 283 kInlineFlags);
308 CompilationInfo::kContextSpecializing | 284
309 CompilationInfo::kTypingEnabled); 285 InstallAssertInlineCountHelper(CcTest::isolate());
286 T.CheckCall(T.Val(0.0), T.Val(0.0), T.Val(4));
287 }
288
289
290 TEST(InlineLoopGuardedOnce) {
291 FLAG_turbo_deoptimization = true;
292 FunctionTester T(
293 "(function () {"
294 " function foo(s,t) { AssertInlineCount(2); if (t > 0) while (s > 0) {"
295 " s = s - 1; }; return s; };"
296 " function bar(s,t) { return foo(s,t); };"
297 " return bar;"
298 "})();",
299 kInlineFlags);
310 300
311 InstallAssertInlineCountHelper(CcTest::isolate()); 301 InstallAssertInlineCountHelper(CcTest::isolate());
312 T.CheckCall(T.Val(0.0), T.Val(11), T.Val(4)); 302 T.CheckCall(T.Val(0.0), T.Val(11), T.Val(4));
303 }
304
305
306 TEST(InlineLoopGuardedTwice) {
307 FLAG_turbo_deoptimization = true;
308 FunctionTester T(
309 "(function () {"
310 " function foo(s,t) { AssertInlineCount(2); if (t > 0) while (s > 0) {"
311 " s = s - 1; }; return s; };"
312 " function bar(s,t) { return foo(foo(s,t),t); };"
313 " return bar;"
314 "})();",
315 kInlineFlags);
316
317 InstallAssertInlineCountHelper(CcTest::isolate());
318 T.CheckCall(T.Val(0.0), T.Val(11), T.Val(4));
313 } 319 }
314 320
315 321
316 TEST(InlineStrictIntoNonStrict) { 322 TEST(InlineStrictIntoNonStrict) {
317 FLAG_turbo_deoptimization = true; 323 FLAG_turbo_deoptimization = true;
318 FunctionTester T( 324 FunctionTester T(
319 "(function () {" 325 "(function () {"
320 "var x = Object.create({}, { y: { value:42, writable:false } });" 326 " var x = Object.create({}, { y: { value:42, writable:false } });"
321 "function foo(s) { 'use strict';" 327 " function foo(s) { 'use strict';"
322 " x.y = 9; };" 328 " x.y = 9; };"
323 "function bar(s,t) { return foo(s); };" 329 " function bar(s,t) { return foo(s); };"
324 "return bar;" 330 " return bar;"
325 "})();", 331 "})();",
326 CompilationInfo::kInliningEnabled | 332 kInlineFlags);
327 CompilationInfo::kContextSpecializing |
328 CompilationInfo::kTypingEnabled);
329 333
330 InstallAssertInlineCountHelper(CcTest::isolate()); 334 InstallAssertInlineCountHelper(CcTest::isolate());
331 T.CheckThrows(T.undefined(), T.undefined()); 335 T.CheckThrows(T.undefined(), T.undefined());
332 } 336 }
333 337
334 338
335 TEST(InlineNonStrictIntoStrict) { 339 TEST(InlineNonStrictIntoStrict) {
336 FLAG_turbo_deoptimization = true; 340 FLAG_turbo_deoptimization = true;
337 FunctionTester T( 341 FunctionTester T(
338 "(function () {" 342 "(function () {"
339 "var x = Object.create({}, { y: { value:42, writable:false } });" 343 " var x = Object.create({}, { y: { value:42, writable:false } });"
340 "function foo(s) { x.y = 9; return x.y; };" 344 " function foo(s) { x.y = 9; return x.y; };"
341 "function bar(s,t) { \'use strict\'; return foo(s); };" 345 " function bar(s,t) { \'use strict\'; return foo(s); };"
342 "return bar;" 346 " return bar;"
343 "})();", 347 "})();",
344 CompilationInfo::kInliningEnabled | 348 kInlineFlags);
345 CompilationInfo::kContextSpecializing |
346 CompilationInfo::kTypingEnabled);
347 349
348 InstallAssertInlineCountHelper(CcTest::isolate()); 350 InstallAssertInlineCountHelper(CcTest::isolate());
349 T.CheckCall(T.Val(42), T.undefined(), T.undefined()); 351 T.CheckCall(T.Val(42), T.undefined(), T.undefined());
350 } 352 }
351 353
352 354
353 TEST(InlineIntrinsicIsSmi) { 355 TEST(InlineIntrinsicIsSmi) {
354 FLAG_turbo_deoptimization = true; 356 FLAG_turbo_deoptimization = true;
355 FunctionTester T( 357 FunctionTester T(
356 "(function () {" 358 "(function () {"
357 "var x = 42;" 359 " var x = 42;"
358 "function bar(s,t) { return %_IsSmi(x); };" 360 " function bar(s,t) { return %_IsSmi(x); };"
359 "return bar;" 361 " return bar;"
360 "})();", 362 "})();",
361 CompilationInfo::kInliningEnabled | 363 kInlineFlags);
362 CompilationInfo::kContextSpecializing |
363 CompilationInfo::kTypingEnabled);
364 364
365 InstallAssertInlineCountHelper(CcTest::isolate()); 365 InstallAssertInlineCountHelper(CcTest::isolate());
366 T.CheckCall(T.true_value(), T.Val(12), T.Val(4)); 366 T.CheckCall(T.true_value(), T.Val(12), T.Val(4));
367 } 367 }
368 368
369 369
370 TEST(InlineIntrinsicIsNonNegativeSmi) { 370 TEST(InlineIntrinsicIsNonNegativeSmi) {
371 FLAG_turbo_deoptimization = true; 371 FLAG_turbo_deoptimization = true;
372 FunctionTester T( 372 FunctionTester T(
373 "(function () {" 373 "(function () {"
374 "var x = 42;" 374 " var x = 42;"
375 "function bar(s,t) { return %_IsNonNegativeSmi(x); };" 375 " function bar(s,t) { return %_IsNonNegativeSmi(x); };"
376 "return bar;" 376 " return bar;"
377 "})();", 377 "})();",
378 CompilationInfo::kInliningEnabled | 378 kInlineFlags);
379 CompilationInfo::kContextSpecializing |
380 CompilationInfo::kTypingEnabled);
381 379
382 InstallAssertInlineCountHelper(CcTest::isolate()); 380 InstallAssertInlineCountHelper(CcTest::isolate());
383 T.CheckCall(T.true_value(), T.Val(12), T.Val(4)); 381 T.CheckCall(T.true_value(), T.Val(12), T.Val(4));
384 } 382 }
385 383
386 384
387 TEST(InlineIntrinsicIsArray) { 385 TEST(InlineIntrinsicIsArray) {
388 FLAG_turbo_deoptimization = true; 386 FLAG_turbo_deoptimization = true;
389 FunctionTester T( 387 FunctionTester T(
390 "(function () {" 388 "(function () {"
391 "var x = [1,2,3];" 389 " var x = [1,2,3];"
392 "function bar(s,t) { return %_IsArray(x); };" 390 " function bar(s,t) { return %_IsArray(x); };"
393 "return bar;" 391 " return bar;"
394 "})();", 392 "})();",
395 CompilationInfo::kInliningEnabled | 393 kInlineFlags);
396 CompilationInfo::kContextSpecializing |
397 CompilationInfo::kTypingEnabled);
398 394
399 InstallAssertInlineCountHelper(CcTest::isolate()); 395 InstallAssertInlineCountHelper(CcTest::isolate());
400 T.CheckCall(T.true_value(), T.Val(12), T.Val(4)); 396 T.CheckCall(T.true_value(), T.Val(12), T.Val(4));
401 397
402 FunctionTester T2( 398 FunctionTester T2(
403 "(function () {" 399 "(function () {"
404 "var x = 32;" 400 " var x = 32;"
405 "function bar(s,t) { return %_IsArray(x); };" 401 " function bar(s,t) { return %_IsArray(x); };"
406 "return bar;" 402 " return bar;"
407 "})();", 403 "})();",
408 CompilationInfo::kInliningEnabled | 404 kInlineFlags);
409 CompilationInfo::kContextSpecializing |
410 CompilationInfo::kTypingEnabled);
411 405
412 T2.CheckCall(T.false_value(), T.Val(12), T.Val(4)); 406 T2.CheckCall(T.false_value(), T.Val(12), T.Val(4));
413 407
414 FunctionTester T3( 408 FunctionTester T3(
415 "(function () {" 409 "(function () {"
416 "var x = bar;" 410 " var x = bar;"
417 "function bar(s,t) { return %_IsArray(x); };" 411 " function bar(s,t) { return %_IsArray(x); };"
418 "return bar;" 412 " return bar;"
419 "})();", 413 "})();",
420 CompilationInfo::kInliningEnabled | 414 kInlineFlags);
421 CompilationInfo::kContextSpecializing |
422 CompilationInfo::kTypingEnabled);
423 415
424 T3.CheckCall(T.false_value(), T.Val(12), T.Val(4)); 416 T3.CheckCall(T.false_value(), T.Val(12), T.Val(4));
425 } 417 }
426 418
427 419
428 TEST(InlineWithArguments) { 420 TEST(InlineWithArguments) {
429 FLAG_turbo_deoptimization = true; 421 FLAG_turbo_deoptimization = true;
430 FunctionTester T( 422 FunctionTester T(
431 "(function () {" 423 "(function () {"
432 " function foo(s,t,u) { AssertInlineCount(2); " 424 " function foo(s,t,u) { AssertInlineCount(2);"
433 " return foo.arguments.length == 3 && " 425 " return foo.arguments.length == 3 &&"
434 " foo.arguments[0] == 13 && " 426 " foo.arguments[0] == 13 &&"
435 " foo.arguments[1] == 14 && " 427 " foo.arguments[1] == 14 &&"
436 " foo.arguments[2] == 15; " 428 " foo.arguments[2] == 15;"
437 " }" 429 " }"
438 " function bar() { return foo(13, 14, 15); };" 430 " function bar() { return foo(13, 14, 15); };"
439 " return bar;" 431 " return bar;"
440 "}" 432 "})();",
441 ")();", 433 kInlineFlags);
442 CompilationInfo::kInliningEnabled |
443 CompilationInfo::kContextSpecializing |
444 CompilationInfo::kTypingEnabled);
445 434
446 InstallAssertInlineCountHelper(CcTest::isolate()); 435 InstallAssertInlineCountHelper(CcTest::isolate());
447 T.CheckCall(T.true_value(), T.Val(12), T.Val(14)); 436 T.CheckCall(T.true_value(), T.Val(12), T.Val(14));
448 } 437 }
449 438
450 #endif // V8_TURBOFAN_TARGET 439 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698