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 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 CHECK_NE(*isolate->builtins()->InterpreterEntryTrampoline(), f1->code()); | 835 CHECK_NE(*isolate->builtins()->InterpreterEntryTrampoline(), f1->code()); |
836 CHECK_EQ(*isolate->builtins()->InterpreterEntryTrampoline(), f2->code()); | 836 CHECK_EQ(*isolate->builtins()->InterpreterEntryTrampoline(), f2->code()); |
837 CHECK_EQ(23.0, GetGlobalProperty("result1")->Number()); | 837 CHECK_EQ(23.0, GetGlobalProperty("result1")->Number()); |
838 | 838 |
839 // Function {f2} will self-heal now. | 839 // Function {f2} will self-heal now. |
840 CompileRun("var result2 = f2()"); | 840 CompileRun("var result2 = f2()"); |
841 CHECK_NE(*isolate->builtins()->InterpreterEntryTrampoline(), f1->code()); | 841 CHECK_NE(*isolate->builtins()->InterpreterEntryTrampoline(), f1->code()); |
842 CHECK_NE(*isolate->builtins()->InterpreterEntryTrampoline(), f2->code()); | 842 CHECK_NE(*isolate->builtins()->InterpreterEntryTrampoline(), f2->code()); |
843 CHECK_EQ(23.0, GetGlobalProperty("result2")->Number()); | 843 CHECK_EQ(23.0, GetGlobalProperty("result2")->Number()); |
844 } | 844 } |
| 845 |
| 846 TEST(InvocationCount) { |
| 847 FLAG_allow_natives_syntax = true; |
| 848 FLAG_always_opt = false; |
| 849 CcTest::InitializeVM(); |
| 850 v8::HandleScope scope(CcTest::isolate()); |
| 851 |
| 852 CompileRun( |
| 853 "function bar() {};" |
| 854 "function foo() { return bar(); };" |
| 855 "foo();"); |
| 856 Handle<JSFunction> foo = Handle<JSFunction>::cast(GetGlobalProperty("foo")); |
| 857 CHECK_EQ(1, foo->feedback_vector()->invocation_count()); |
| 858 CompileRun("foo()"); |
| 859 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); |
| 860 CompileRun("bar()"); |
| 861 CHECK_EQ(2, foo->feedback_vector()->invocation_count()); |
| 862 CompileRun("foo(); foo()"); |
| 863 CHECK_EQ(4, foo->feedback_vector()->invocation_count()); |
| 864 CompileRun("%BaselineFunctionOnNextCall(foo);"); |
| 865 CompileRun("foo();"); |
| 866 CHECK_EQ(5, foo->feedback_vector()->invocation_count()); |
| 867 } |
OLD | NEW |