| 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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 } | 688 } |
| 689 NonIncrementalGC(); | 689 NonIncrementalGC(); |
| 690 | 690 |
| 691 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); | 691 CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); |
| 692 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); | 692 CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); |
| 693 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); | 693 CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); |
| 694 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); | 694 CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); |
| 695 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); | 695 CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
| 696 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); | 696 CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); |
| 697 } | 697 } |
| 698 |
| 699 |
| 700 TEST(ReoptimizeInstantly) { |
| 701 i::FLAG_allow_natives_syntax = true; |
| 702 i::FLAG_concurrent_recompilation = false; |
| 703 if (!CcTest::i_isolate()->use_crankshaft()) return; |
| 704 LocalContext env; |
| 705 v8::HandleScope scope(env->GetIsolate()); |
| 706 |
| 707 CompileRun( |
| 708 "function f(x) {" |
| 709 " return x;" |
| 710 "};" |
| 711 "f(0); f(0); f(0);" |
| 712 "%OptimizeFunctionOnNextCall(f);" |
| 713 "f(0);"); |
| 714 Handle<JSFunction> function = GetJSFunction(env->Global(), "f"); |
| 715 CHECK(function->IsOptimized()); |
| 716 function->code()->set_marked_for_instant_optimization(true); |
| 717 CompileRun("%DeoptimizeFunction(f);"); |
| 718 CHECK(!function->IsOptimized()); |
| 719 CompileRun("f(0);"); |
| 720 CHECK(function->IsOptimized()); |
| 721 } |
| OLD | NEW |