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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 for (int i = 0; i < 3; i++) { | 378 for (int i = 0; i < 3; i++) { |
379 LocalContext env; | 379 LocalContext env; |
380 env->Global() | 380 env->Global() |
381 ->Set(env.local(), v8_str("x"), v8::Integer::New(CcTest::isolate(), i)) | 381 ->Set(env.local(), v8_str("x"), v8::Integer::New(CcTest::isolate(), i)) |
382 .FromJust(); | 382 .FromJust(); |
383 CompileRun( | 383 CompileRun( |
384 "function MakeClosure() {" | 384 "function MakeClosure() {" |
385 " return function() { return x; };" | 385 " return function() { return x; };" |
386 "}" | 386 "}" |
387 "var closure0 = MakeClosure();" | 387 "var closure0 = MakeClosure();" |
| 388 "var closure1 = MakeClosure();" // We only share optimized code |
| 389 // if there are at least two closures. |
388 "%DebugPrint(closure0());" | 390 "%DebugPrint(closure0());" |
389 "%OptimizeFunctionOnNextCall(closure0);" | 391 "%OptimizeFunctionOnNextCall(closure0);" |
390 "%DebugPrint(closure0());" | 392 "%DebugPrint(closure0());" |
391 "var closure1 = MakeClosure(); closure1();" | 393 "closure1();" |
392 "var closure2 = MakeClosure(); closure2();"); | 394 "var closure2 = MakeClosure(); closure2();"); |
393 Handle<JSFunction> fun1 = Handle<JSFunction>::cast( | 395 Handle<JSFunction> fun1 = Handle<JSFunction>::cast( |
394 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( | 396 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( |
395 env->Global() | 397 env->Global() |
396 ->Get(env.local(), v8_str("closure1")) | 398 ->Get(env.local(), v8_str("closure1")) |
397 .ToLocalChecked()))); | 399 .ToLocalChecked()))); |
398 Handle<JSFunction> fun2 = Handle<JSFunction>::cast( | 400 Handle<JSFunction> fun2 = Handle<JSFunction>::cast( |
399 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( | 401 v8::Utils::OpenHandle(*v8::Local<v8::Function>::Cast( |
400 env->Global() | 402 env->Global() |
401 ->Get(env.local(), v8_str("closure2")) | 403 ->Get(env.local(), v8_str("closure2")) |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 CompileRun("foo()"); | 668 CompileRun("foo()"); |
667 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); | 669 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); |
668 CompileRun("bar()"); | 670 CompileRun("bar()"); |
669 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); | 671 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); |
670 CompileRun("foo(); foo()"); | 672 CompileRun("foo(); foo()"); |
671 CHECK_EQ(4, foo->feedback_vector()->invocation_count()); | 673 CHECK_EQ(4, foo->feedback_vector()->invocation_count()); |
672 CompileRun("%BaselineFunctionOnNextCall(foo);"); | 674 CompileRun("%BaselineFunctionOnNextCall(foo);"); |
673 CompileRun("foo();"); | 675 CompileRun("foo();"); |
674 CHECK_EQ(5, foo->feedback_vector()->invocation_count()); | 676 CHECK_EQ(5, foo->feedback_vector()->invocation_count()); |
675 } | 677 } |
OLD | NEW |