OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 106 |
107 static Handle<JSFunction> GetJSFunction(v8::Handle<v8::Object> obj, | 107 static Handle<JSFunction> GetJSFunction(v8::Handle<v8::Object> obj, |
108 const char* property_name) { | 108 const char* property_name) { |
109 v8::Local<v8::Function> fun = | 109 v8::Local<v8::Function> fun = |
110 v8::Local<v8::Function>::Cast(obj->Get(v8_str(property_name))); | 110 v8::Local<v8::Function>::Cast(obj->Get(v8_str(property_name))); |
111 return v8::Utils::OpenHandle(*fun); | 111 return v8::Utils::OpenHandle(*fun); |
112 } | 112 } |
113 | 113 |
114 | 114 |
115 TEST(DeoptimizeSimple) { | 115 TEST(DeoptimizeSimple) { |
116 v8::HandleScope scope; | |
117 LocalContext env; | 116 LocalContext env; |
| 117 v8::HandleScope scope(env->GetIsolate()); |
118 | 118 |
119 // Test lazy deoptimization of a simple function. | 119 // Test lazy deoptimization of a simple function. |
120 { | 120 { |
121 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 121 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
122 CompileRun( | 122 CompileRun( |
123 "var count = 0;" | 123 "var count = 0;" |
124 "function h() { %DeoptimizeFunction(f); }" | 124 "function h() { %DeoptimizeFunction(f); }" |
125 "function g() { count++; h(); }" | 125 "function g() { count++; h(); }" |
126 "function f() { g(); };" | 126 "function f() { g(); };" |
127 "f();"); | 127 "f();"); |
(...skipping 16 matching lines...) Expand all Loading... |
144 } | 144 } |
145 NonIncrementalGC(); | 145 NonIncrementalGC(); |
146 | 146 |
147 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 147 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
148 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); | 148 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); |
149 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 149 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
150 } | 150 } |
151 | 151 |
152 | 152 |
153 TEST(DeoptimizeSimpleWithArguments) { | 153 TEST(DeoptimizeSimpleWithArguments) { |
154 v8::HandleScope scope; | |
155 LocalContext env; | 154 LocalContext env; |
| 155 v8::HandleScope scope(env->GetIsolate()); |
156 | 156 |
157 // Test lazy deoptimization of a simple function with some arguments. | 157 // Test lazy deoptimization of a simple function with some arguments. |
158 { | 158 { |
159 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 159 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
160 CompileRun( | 160 CompileRun( |
161 "var count = 0;" | 161 "var count = 0;" |
162 "function h(x) { %DeoptimizeFunction(f); }" | 162 "function h(x) { %DeoptimizeFunction(f); }" |
163 "function g(x, y) { count++; h(x); }" | 163 "function g(x, y) { count++; h(x); }" |
164 "function f(x, y, z) { g(1,x); y+z; };" | 164 "function f(x, y, z) { g(1,x); y+z; };" |
165 "f(1, \"2\", false);"); | 165 "f(1, \"2\", false);"); |
(...skipping 17 matching lines...) Expand all Loading... |
183 } | 183 } |
184 NonIncrementalGC(); | 184 NonIncrementalGC(); |
185 | 185 |
186 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 186 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
187 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); | 187 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); |
188 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 188 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
189 } | 189 } |
190 | 190 |
191 | 191 |
192 TEST(DeoptimizeSimpleNested) { | 192 TEST(DeoptimizeSimpleNested) { |
193 v8::HandleScope scope; | |
194 LocalContext env; | 193 LocalContext env; |
| 194 v8::HandleScope scope(env->GetIsolate()); |
195 | 195 |
196 // Test lazy deoptimization of a simple function. Have a nested function call | 196 // Test lazy deoptimization of a simple function. Have a nested function call |
197 // do the deoptimization. | 197 // do the deoptimization. |
198 { | 198 { |
199 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 199 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
200 CompileRun( | 200 CompileRun( |
201 "var count = 0;" | 201 "var count = 0;" |
202 "var result = 0;" | 202 "var result = 0;" |
203 "function h(x, y, z) { return x + y + z; }" | 203 "function h(x, y, z) { return x + y + z; }" |
204 "function g(z) { count++; %DeoptimizeFunction(f); return z;}" | 204 "function g(z) { count++; %DeoptimizeFunction(f); return z;}" |
205 "function f(x,y,z) { return h(x, y, g(z)); };" | 205 "function f(x,y,z) { return h(x, y, g(z)); };" |
206 "result = f(1, 2, 3);"); | 206 "result = f(1, 2, 3);"); |
207 NonIncrementalGC(); | 207 NonIncrementalGC(); |
208 | 208 |
209 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 209 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
210 CHECK_EQ(6, env->Global()->Get(v8_str("result"))->Int32Value()); | 210 CHECK_EQ(6, env->Global()->Get(v8_str("result"))->Int32Value()); |
211 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); | 211 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); |
212 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 212 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 | 216 |
217 TEST(DeoptimizeRecursive) { | 217 TEST(DeoptimizeRecursive) { |
218 v8::HandleScope scope; | |
219 LocalContext env; | 218 LocalContext env; |
| 219 v8::HandleScope scope(env->GetIsolate()); |
220 | 220 |
221 { | 221 { |
222 // Test lazy deoptimization of a simple function called recursively. Call | 222 // Test lazy deoptimization of a simple function called recursively. Call |
223 // the function recursively a number of times before deoptimizing it. | 223 // the function recursively a number of times before deoptimizing it. |
224 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 224 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
225 CompileRun( | 225 CompileRun( |
226 "var count = 0;" | 226 "var count = 0;" |
227 "var calls = 0;" | 227 "var calls = 0;" |
228 "function g() { count++; %DeoptimizeFunction(f); }" | 228 "function g() { count++; %DeoptimizeFunction(f); }" |
229 "function f(x) { calls++; if (x > 0) { f(x - 1); } else { g(); } };" | 229 "function f(x) { calls++; if (x > 0) { f(x - 1); } else { g(); } };" |
230 "f(10);"); | 230 "f(10);"); |
231 } | 231 } |
232 NonIncrementalGC(); | 232 NonIncrementalGC(); |
233 | 233 |
234 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 234 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
235 CHECK_EQ(11, env->Global()->Get(v8_str("calls"))->Int32Value()); | 235 CHECK_EQ(11, env->Global()->Get(v8_str("calls"))->Int32Value()); |
236 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 236 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
237 | 237 |
238 v8::Local<v8::Function> fun = | 238 v8::Local<v8::Function> fun = |
239 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); | 239 v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f"))); |
240 CHECK(!fun.IsEmpty()); | 240 CHECK(!fun.IsEmpty()); |
241 } | 241 } |
242 | 242 |
243 | 243 |
244 TEST(DeoptimizeMultiple) { | 244 TEST(DeoptimizeMultiple) { |
245 v8::HandleScope scope; | |
246 LocalContext env; | 245 LocalContext env; |
| 246 v8::HandleScope scope(env->GetIsolate()); |
247 | 247 |
248 { | 248 { |
249 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 249 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
250 CompileRun( | 250 CompileRun( |
251 "var count = 0;" | 251 "var count = 0;" |
252 "var result = 0;" | 252 "var result = 0;" |
253 "function g() { count++;" | 253 "function g() { count++;" |
254 " %DeoptimizeFunction(f1);" | 254 " %DeoptimizeFunction(f1);" |
255 " %DeoptimizeFunction(f2);" | 255 " %DeoptimizeFunction(f2);" |
256 " %DeoptimizeFunction(f3);" | 256 " %DeoptimizeFunction(f3);" |
257 " %DeoptimizeFunction(f4);}" | 257 " %DeoptimizeFunction(f4);}" |
258 "function f4(x) { g(); };" | 258 "function f4(x) { g(); };" |
259 "function f3(x, y, z) { f4(); return x + y + z; };" | 259 "function f3(x, y, z) { f4(); return x + y + z; };" |
260 "function f2(x, y) { return x + f3(y + 1, y + 1, y + 1) + y; };" | 260 "function f2(x, y) { return x + f3(y + 1, y + 1, y + 1) + y; };" |
261 "function f1(x) { return f2(x + 1, x + 1) + x; };" | 261 "function f1(x) { return f2(x + 1, x + 1) + x; };" |
262 "result = f1(1);"); | 262 "result = f1(1);"); |
263 } | 263 } |
264 NonIncrementalGC(); | 264 NonIncrementalGC(); |
265 | 265 |
266 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 266 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
267 CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); | 267 CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); |
268 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 268 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
269 } | 269 } |
270 | 270 |
271 | 271 |
272 TEST(DeoptimizeConstructor) { | 272 TEST(DeoptimizeConstructor) { |
273 v8::HandleScope scope; | |
274 LocalContext env; | 273 LocalContext env; |
| 274 v8::HandleScope scope(env->GetIsolate()); |
275 | 275 |
276 { | 276 { |
277 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 277 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
278 CompileRun( | 278 CompileRun( |
279 "var count = 0;" | 279 "var count = 0;" |
280 "function g() { count++;" | 280 "function g() { count++;" |
281 " %DeoptimizeFunction(f); }" | 281 " %DeoptimizeFunction(f); }" |
282 "function f() { g(); };" | 282 "function f() { g(); };" |
283 "result = new f() instanceof f;"); | 283 "result = new f() instanceof f;"); |
284 } | 284 } |
(...skipping 16 matching lines...) Expand all Loading... |
301 } | 301 } |
302 NonIncrementalGC(); | 302 NonIncrementalGC(); |
303 | 303 |
304 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 304 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
305 CHECK_EQ(3, env->Global()->Get(v8_str("result"))->Int32Value()); | 305 CHECK_EQ(3, env->Global()->Get(v8_str("result"))->Int32Value()); |
306 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 306 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
307 } | 307 } |
308 | 308 |
309 | 309 |
310 TEST(DeoptimizeConstructorMultiple) { | 310 TEST(DeoptimizeConstructorMultiple) { |
311 v8::HandleScope scope; | |
312 LocalContext env; | 311 LocalContext env; |
| 312 v8::HandleScope scope(env->GetIsolate()); |
313 | 313 |
314 { | 314 { |
315 AlwaysOptimizeAllowNativesSyntaxNoInlining options; | 315 AlwaysOptimizeAllowNativesSyntaxNoInlining options; |
316 CompileRun( | 316 CompileRun( |
317 "var count = 0;" | 317 "var count = 0;" |
318 "var result = 0;" | 318 "var result = 0;" |
319 "function g() { count++;" | 319 "function g() { count++;" |
320 " %DeoptimizeFunction(f1);" | 320 " %DeoptimizeFunction(f1);" |
321 " %DeoptimizeFunction(f2);" | 321 " %DeoptimizeFunction(f2);" |
322 " %DeoptimizeFunction(f3);" | 322 " %DeoptimizeFunction(f3);" |
323 " %DeoptimizeFunction(f4);}" | 323 " %DeoptimizeFunction(f4);}" |
324 "function f4(x) { this.result = x; g(); };" | 324 "function f4(x) { this.result = x; g(); };" |
325 "function f3(x, y, z) { this.result = new f4(x + y + z).result; };" | 325 "function f3(x, y, z) { this.result = new f4(x + y + z).result; };" |
326 "function f2(x, y) {" | 326 "function f2(x, y) {" |
327 " this.result = x + new f3(y + 1, y + 1, y + 1).result + y; };" | 327 " this.result = x + new f3(y + 1, y + 1, y + 1).result + y; };" |
328 "function f1(x) { this.result = new f2(x + 1, x + 1).result + x; };" | 328 "function f1(x) { this.result = new f2(x + 1, x + 1).result + x; };" |
329 "result = new f1(1).result;"); | 329 "result = new f1(1).result;"); |
330 } | 330 } |
331 NonIncrementalGC(); | 331 NonIncrementalGC(); |
332 | 332 |
333 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 333 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
334 CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); | 334 CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); |
335 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 335 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
336 } | 336 } |
337 | 337 |
338 | 338 |
339 TEST(DeoptimizeBinaryOperationADDString) { | 339 TEST(DeoptimizeBinaryOperationADDString) { |
340 v8::HandleScope scope; | |
341 LocalContext env; | 340 LocalContext env; |
| 341 v8::HandleScope scope(env->GetIsolate()); |
342 | 342 |
343 const char* f_source = "function f(x, y) { return x + y; };"; | 343 const char* f_source = "function f(x, y) { return x + y; };"; |
344 | 344 |
345 { | 345 { |
346 AllowNativesSyntaxNoInlining options; | 346 AllowNativesSyntaxNoInlining options; |
347 // Compile function f and collect to type feedback to insert binary op stub | 347 // Compile function f and collect to type feedback to insert binary op stub |
348 // call in the optimized code. | 348 // call in the optimized code. |
349 i::FLAG_prepare_always_opt = true; | 349 i::FLAG_prepare_always_opt = true; |
350 CompileRun("var count = 0;" | 350 CompileRun("var count = 0;" |
351 "var result = 0;" | 351 "var result = 0;" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 420 |
421 // Call f and force deoptimization while processing the binary operation. | 421 // Call f and force deoptimization while processing the binary operation. |
422 CompileRun("deopt = true;" | 422 CompileRun("deopt = true;" |
423 "var result = f(7, new X());"); | 423 "var result = f(7, new X());"); |
424 NonIncrementalGC(); | 424 NonIncrementalGC(); |
425 CHECK(!GetJSFunction((*env)->Global(), "f")->IsOptimized()); | 425 CHECK(!GetJSFunction((*env)->Global(), "f")->IsOptimized()); |
426 } | 426 } |
427 | 427 |
428 | 428 |
429 TEST(DeoptimizeBinaryOperationADD) { | 429 TEST(DeoptimizeBinaryOperationADD) { |
430 v8::HandleScope scope; | |
431 LocalContext env; | 430 LocalContext env; |
| 431 v8::HandleScope scope(env->GetIsolate()); |
432 | 432 |
433 TestDeoptimizeBinaryOpHelper(&env, "+"); | 433 TestDeoptimizeBinaryOpHelper(&env, "+"); |
434 | 434 |
435 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 435 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
436 CHECK_EQ(15, env->Global()->Get(v8_str("result"))->Int32Value()); | 436 CHECK_EQ(15, env->Global()->Get(v8_str("result"))->Int32Value()); |
437 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 437 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
438 } | 438 } |
439 | 439 |
440 | 440 |
441 TEST(DeoptimizeBinaryOperationSUB) { | 441 TEST(DeoptimizeBinaryOperationSUB) { |
442 v8::HandleScope scope; | |
443 LocalContext env; | 442 LocalContext env; |
| 443 v8::HandleScope scope(env->GetIsolate()); |
444 | 444 |
445 TestDeoptimizeBinaryOpHelper(&env, "-"); | 445 TestDeoptimizeBinaryOpHelper(&env, "-"); |
446 | 446 |
447 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 447 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
448 CHECK_EQ(-1, env->Global()->Get(v8_str("result"))->Int32Value()); | 448 CHECK_EQ(-1, env->Global()->Get(v8_str("result"))->Int32Value()); |
449 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 449 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
450 } | 450 } |
451 | 451 |
452 | 452 |
453 TEST(DeoptimizeBinaryOperationMUL) { | 453 TEST(DeoptimizeBinaryOperationMUL) { |
454 v8::HandleScope scope; | |
455 LocalContext env; | 454 LocalContext env; |
| 455 v8::HandleScope scope(env->GetIsolate()); |
456 | 456 |
457 TestDeoptimizeBinaryOpHelper(&env, "*"); | 457 TestDeoptimizeBinaryOpHelper(&env, "*"); |
458 | 458 |
459 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 459 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
460 CHECK_EQ(56, env->Global()->Get(v8_str("result"))->Int32Value()); | 460 CHECK_EQ(56, env->Global()->Get(v8_str("result"))->Int32Value()); |
461 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 461 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
462 } | 462 } |
463 | 463 |
464 | 464 |
465 TEST(DeoptimizeBinaryOperationDIV) { | 465 TEST(DeoptimizeBinaryOperationDIV) { |
466 v8::HandleScope scope; | |
467 LocalContext env; | 466 LocalContext env; |
| 467 v8::HandleScope scope(env->GetIsolate()); |
468 | 468 |
469 TestDeoptimizeBinaryOpHelper(&env, "/"); | 469 TestDeoptimizeBinaryOpHelper(&env, "/"); |
470 | 470 |
471 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 471 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
472 CHECK_EQ(0, env->Global()->Get(v8_str("result"))->Int32Value()); | 472 CHECK_EQ(0, env->Global()->Get(v8_str("result"))->Int32Value()); |
473 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 473 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
474 } | 474 } |
475 | 475 |
476 | 476 |
477 TEST(DeoptimizeBinaryOperationMOD) { | 477 TEST(DeoptimizeBinaryOperationMOD) { |
478 v8::HandleScope scope; | |
479 LocalContext env; | 478 LocalContext env; |
| 479 v8::HandleScope scope(env->GetIsolate()); |
480 | 480 |
481 TestDeoptimizeBinaryOpHelper(&env, "%"); | 481 TestDeoptimizeBinaryOpHelper(&env, "%"); |
482 | 482 |
483 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 483 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
484 CHECK_EQ(7, env->Global()->Get(v8_str("result"))->Int32Value()); | 484 CHECK_EQ(7, env->Global()->Get(v8_str("result"))->Int32Value()); |
485 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 485 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
486 } | 486 } |
487 | 487 |
488 | 488 |
489 TEST(DeoptimizeCompare) { | 489 TEST(DeoptimizeCompare) { |
490 v8::HandleScope scope; | |
491 LocalContext env; | 490 LocalContext env; |
| 491 v8::HandleScope scope(env->GetIsolate()); |
492 | 492 |
493 const char* f_source = "function f(x, y) { return x < y; };"; | 493 const char* f_source = "function f(x, y) { return x < y; };"; |
494 | 494 |
495 { | 495 { |
496 AllowNativesSyntaxNoInlining options; | 496 AllowNativesSyntaxNoInlining options; |
497 // Compile function f and collect to type feedback to insert compare ic | 497 // Compile function f and collect to type feedback to insert compare ic |
498 // call in the optimized code. | 498 // call in the optimized code. |
499 i::FLAG_prepare_always_opt = true; | 499 i::FLAG_prepare_always_opt = true; |
500 CompileRun("var count = 0;" | 500 CompileRun("var count = 0;" |
501 "var result = 0;" | 501 "var result = 0;" |
(...skipping 21 matching lines...) Expand all Loading... |
523 NonIncrementalGC(); | 523 NonIncrementalGC(); |
524 | 524 |
525 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); | 525 CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); |
526 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 526 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
527 CHECK_EQ(true, env->Global()->Get(v8_str("result"))->BooleanValue()); | 527 CHECK_EQ(true, env->Global()->Get(v8_str("result"))->BooleanValue()); |
528 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 528 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
529 } | 529 } |
530 | 530 |
531 | 531 |
532 TEST(DeoptimizeLoadICStoreIC) { | 532 TEST(DeoptimizeLoadICStoreIC) { |
533 v8::HandleScope scope; | |
534 LocalContext env; | 533 LocalContext env; |
| 534 v8::HandleScope scope(env->GetIsolate()); |
535 | 535 |
536 // Functions to generate load/store/keyed load/keyed store IC calls. | 536 // Functions to generate load/store/keyed load/keyed store IC calls. |
537 const char* f1_source = "function f1(x) { return x.y; };"; | 537 const char* f1_source = "function f1(x) { return x.y; };"; |
538 const char* g1_source = "function g1(x) { x.y = 1; };"; | 538 const char* g1_source = "function g1(x) { x.y = 1; };"; |
539 const char* f2_source = "function f2(x, y) { return x[y]; };"; | 539 const char* f2_source = "function f2(x, y) { return x[y]; };"; |
540 const char* g2_source = "function g2(x, y) { x[y] = 1; };"; | 540 const char* g2_source = "function g2(x, y) { x[y] = 1; };"; |
541 | 541 |
542 { | 542 { |
543 AllowNativesSyntaxNoInlining options; | 543 AllowNativesSyntaxNoInlining options; |
544 // Compile functions and collect to type feedback to insert ic | 544 // Compile functions and collect to type feedback to insert ic |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); | 603 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); |
604 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); | 604 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); |
605 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); | 605 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); |
606 CHECK_EQ(4, env->Global()->Get(v8_str("count"))->Int32Value()); | 606 CHECK_EQ(4, env->Global()->Get(v8_str("count"))->Int32Value()); |
607 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); | 607 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); |
608 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 608 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
609 } | 609 } |
610 | 610 |
611 | 611 |
612 TEST(DeoptimizeLoadICStoreICNested) { | 612 TEST(DeoptimizeLoadICStoreICNested) { |
613 v8::HandleScope scope; | |
614 LocalContext env; | 613 LocalContext env; |
| 614 v8::HandleScope scope(env->GetIsolate()); |
615 | 615 |
616 // Functions to generate load/store/keyed load/keyed store IC calls. | 616 // Functions to generate load/store/keyed load/keyed store IC calls. |
617 const char* f1_source = "function f1(x) { return x.y; };"; | 617 const char* f1_source = "function f1(x) { return x.y; };"; |
618 const char* g1_source = "function g1(x) { x.y = 1; };"; | 618 const char* g1_source = "function g1(x) { x.y = 1; };"; |
619 const char* f2_source = "function f2(x, y) { return x[y]; };"; | 619 const char* f2_source = "function f2(x, y) { return x[y]; };"; |
620 const char* g2_source = "function g2(x, y) { x[y] = 1; };"; | 620 const char* g2_source = "function g2(x, y) { x[y] = 1; };"; |
621 | 621 |
622 { | 622 { |
623 AllowNativesSyntaxNoInlining options; | 623 AllowNativesSyntaxNoInlining options; |
624 // Compile functions and collect to type feedback to insert ic | 624 // Compile functions and collect to type feedback to insert ic |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 NonIncrementalGC(); | 681 NonIncrementalGC(); |
682 | 682 |
683 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); | 683 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); |
684 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); | 684 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); |
685 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); | 685 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); |
686 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); | 686 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); |
687 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 687 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
688 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); | 688 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); |
689 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); | 689 CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(Isolate::Current())); |
690 } | 690 } |
OLD | NEW |