Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 | 775 |
| 776 profiler->processor()->StopSynchronously(); | 776 profiler->processor()->StopSynchronously(); |
| 777 | 777 |
| 778 CHECK_EQ(1, GetFunctionLineNumber(&env, "foo_at_the_first_line")); | 778 CHECK_EQ(1, GetFunctionLineNumber(&env, "foo_at_the_first_line")); |
| 779 CHECK_EQ(0, GetFunctionLineNumber(&env, "lazy_func_at_forth_line")); | 779 CHECK_EQ(0, GetFunctionLineNumber(&env, "lazy_func_at_forth_line")); |
| 780 CHECK_EQ(2, GetFunctionLineNumber(&env, "bar_at_the_second_line")); | 780 CHECK_EQ(2, GetFunctionLineNumber(&env, "bar_at_the_second_line")); |
| 781 CHECK_EQ(0, GetFunctionLineNumber(&env, "lazy_func_at_6th_line")); | 781 CHECK_EQ(0, GetFunctionLineNumber(&env, "lazy_func_at_6th_line")); |
| 782 | 782 |
| 783 profiler->StopProfiling("LineNumber"); | 783 profiler->StopProfiling("LineNumber"); |
| 784 } | 784 } |
| 785 | |
| 786 | |
| 787 | |
| 788 TEST(BailoutReason) { | |
| 789 const char* extensions[] = { "v8/profiler" }; | |
| 790 v8::ExtensionConfiguration config(1, extensions); | |
| 791 LocalContext env(&config); | |
| 792 v8::HandleScope hs(env->GetIsolate()); | |
| 793 | |
| 794 v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler(); | |
| 795 CHECK_EQ(0, profiler->GetProfileCount()); | |
| 796 v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New( | |
| 797 "function kTryCatch() {\n" | |
| 798 " try {\n" | |
| 799 " startProfiling();\n" | |
| 800 " } catch (e) { };\n" | |
| 801 "}\n" | |
| 802 "function kTryFinally() {\n" | |
|
yurys
2013/09/02 14:40:05
Why this "k" prefix?
loislo
2013/09/02 16:03:45
Done.
| |
| 803 " try {\n" | |
| 804 " kTryCatch();\n" | |
| 805 " } finally { };\n" | |
| 806 "}\n" | |
| 807 "kTryFinally();\n" | |
| 808 "stopProfiling();")); | |
| 809 script->Run(); | |
| 810 CHECK_EQ(1, profiler->GetProfileCount()); | |
| 811 const v8::CpuProfile* profile = profiler->GetCpuProfile(0); | |
| 812 const v8::CpuProfileNode* current = profile->GetTopDownRoot(); | |
| 813 reinterpret_cast<ProfileNode*>( | |
| 814 const_cast<v8::CpuProfileNode*>(current))->Print(0); | |
| 815 // The tree should look like this: | |
| 816 // (root) | |
| 817 // (anonymous function) | |
| 818 // kTryFinally | |
| 819 // kTryCatch | |
| 820 // There can also be: | |
| 821 // startProfiling | |
|
yurys
2013/09/02 14:40:05
There should always be that tick as we generate it
loislo
2013/09/02 16:03:45
Done.
| |
| 822 // if the sampler managed to get a tick. | |
| 823 current = PickChild(current, i::ProfileGenerator::kAnonymousFunctionName); | |
| 824 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | |
| 825 | |
| 826 current = PickChild(current, "kTryFinally"); | |
| 827 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | |
| 828 CHECK_EQ(v8::String::New("TryFinallyStatement"), | |
| 829 current->GetBailoutReason()); | |
| 830 | |
| 831 current = PickChild(current, "kTryCatch"); | |
| 832 CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | |
| 833 CHECK_EQ(v8::String::New("TryCatchStatement"), | |
| 834 current->GetBailoutReason()); | |
| 835 } | |
| OLD | NEW |