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 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 ->Set(context, v8_str("IsBaselineCompiled"), | 778 ->Set(context, v8_str("IsBaselineCompiled"), |
779 t->GetFunction(context).ToLocalChecked()) | 779 t->GetFunction(context).ToLocalChecked()) |
780 .FromJust()); | 780 .FromJust()); |
781 } | 781 } |
782 | 782 |
783 TEST(IgnitionBaselineOnReturn) { | 783 TEST(IgnitionBaselineOnReturn) { |
784 FLAG_allow_natives_syntax = true; | 784 FLAG_allow_natives_syntax = true; |
785 FLAG_always_opt = false; | 785 FLAG_always_opt = false; |
786 CcTest::InitializeVM(); | 786 CcTest::InitializeVM(); |
787 FLAG_ignition = true; | 787 FLAG_ignition = true; |
788 reinterpret_cast<i::Isolate*>(CcTest::isolate())->interpreter()->Initialize(); | 788 Isolate* isolate = CcTest::i_isolate(); |
| 789 isolate->interpreter()->Initialize(); |
789 v8::HandleScope scope(CcTest::isolate()); | 790 v8::HandleScope scope(CcTest::isolate()); |
790 InstallIsBaselineCompiledHelper(CcTest::isolate()); | 791 InstallIsBaselineCompiledHelper(CcTest::isolate()); |
791 | 792 |
792 CompileRun( | 793 CompileRun( |
793 "var is_baseline_in_function, is_baseline_after_return;\n" | 794 "var is_baseline_in_function, is_baseline_after_return;\n" |
794 "var return_val;\n" | 795 "var return_val;\n" |
795 "function f() {\n" | 796 "function f() {\n" |
796 " %CompileBaseline(f);\n" | 797 " %CompileBaseline(f);\n" |
797 " is_baseline_in_function = IsBaselineCompiled(f);\n" | 798 " is_baseline_in_function = IsBaselineCompiled(f);\n" |
798 " return 1234;\n" | 799 " return 1234;\n" |
799 "};\n" | 800 "};\n" |
800 "return_val = f();\n" | 801 "return_val = f();\n" |
801 "is_baseline_after_return = IsBaselineCompiled(f);\n"); | 802 "is_baseline_after_return = IsBaselineCompiled(f);\n"); |
802 CHECK_EQ(false, GetGlobalProperty("is_baseline_in_function")->BooleanValue()); | 803 CHECK_EQ(false, GetGlobalProperty("is_baseline_in_function")->BooleanValue()); |
803 CHECK_EQ(true, GetGlobalProperty("is_baseline_after_return")->BooleanValue()); | 804 CHECK_EQ(true, GetGlobalProperty("is_baseline_after_return")->BooleanValue()); |
804 CHECK_EQ(1234.0, GetGlobalProperty("return_val")->Number()); | 805 CHECK_EQ(1234.0, GetGlobalProperty("return_val")->Number()); |
805 } | 806 } |
| 807 |
| 808 TEST(IgnitionEntryTrampolineSelfHealing) { |
| 809 FLAG_allow_natives_syntax = true; |
| 810 FLAG_always_opt = false; |
| 811 CcTest::InitializeVM(); |
| 812 FLAG_ignition = true; |
| 813 Isolate* isolate = CcTest::i_isolate(); |
| 814 isolate->interpreter()->Initialize(); |
| 815 v8::HandleScope scope(CcTest::isolate()); |
| 816 |
| 817 CompileRun( |
| 818 "function MkFun() {" |
| 819 " function f() { return 23 }" |
| 820 " return f" |
| 821 "}" |
| 822 "var f1 = MkFun(); f1();" |
| 823 "var f2 = MkFun(); f2();" |
| 824 "%BaselineFunctionOnNextCall(f1);"); |
| 825 Handle<JSFunction> f1 = Handle<JSFunction>::cast(GetGlobalProperty("f1")); |
| 826 Handle<JSFunction> f2 = Handle<JSFunction>::cast(GetGlobalProperty("f2")); |
| 827 |
| 828 // Function {f1} is marked for baseline. |
| 829 CompileRun("var result1 = f1()"); |
| 830 CHECK_NE(*isolate->builtins()->InterpreterEntryTrampoline(), f1->code()); |
| 831 CHECK_EQ(*isolate->builtins()->InterpreterEntryTrampoline(), f2->code()); |
| 832 CHECK_EQ(23.0, GetGlobalProperty("result1")->Number()); |
| 833 |
| 834 // Function {f2} will self-heal now. |
| 835 CompileRun("var result2 = f2()"); |
| 836 CHECK_NE(*isolate->builtins()->InterpreterEntryTrampoline(), f1->code()); |
| 837 CHECK_NE(*isolate->builtins()->InterpreterEntryTrampoline(), f2->code()); |
| 838 CHECK_EQ(23.0, GetGlobalProperty("result2")->Number()); |
| 839 } |
OLD | NEW |