| 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 TryCatch() {\n" | 
|  | 798       "  try {\n" | 
|  | 799       "    startProfiling();\n" | 
|  | 800       "  } catch (e) { };\n" | 
|  | 801       "}\n" | 
|  | 802       "function TryFinally() {\n" | 
|  | 803       "  try {\n" | 
|  | 804       "    TryCatch();\n" | 
|  | 805       "  } finally { };\n" | 
|  | 806       "}\n" | 
|  | 807       "TryFinally();\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   current = PickChild(current, i::ProfileGenerator::kAnonymousFunctionName); | 
|  | 821   CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 
|  | 822 | 
|  | 823   current = PickChild(current, "TryFinally"); | 
|  | 824   CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 
|  | 825   CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); | 
|  | 826 | 
|  | 827   current = PickChild(current, "TryCatch"); | 
|  | 828   CHECK_NE(NULL, const_cast<v8::CpuProfileNode*>(current)); | 
|  | 829   CHECK(!strcmp("TryCatchStatement", current->GetBailoutReason())); | 
|  | 830 } | 
| OLD | NEW | 
|---|