| 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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 v8::Context::Scope context_scope(env); | 691 v8::Context::Scope context_scope(env); |
| 692 | 692 |
| 693 v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler(); | 693 v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler(); |
| 694 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler); | 694 i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler); |
| 695 CHECK_EQ(0, iprofiler->GetProfilesCount()); | 695 CHECK_EQ(0, iprofiler->GetProfilesCount()); |
| 696 v8::Local<v8::Script> script = | 696 v8::Local<v8::Script> script = |
| 697 v8_compile(v8_str("function Debugger() {\n" | 697 v8_compile(v8_str("function Debugger() {\n" |
| 698 " debugger;\n" | 698 " debugger;\n" |
| 699 " startProfiling();\n" | 699 " startProfiling();\n" |
| 700 "}\n" | 700 "}\n" |
| 701 "function TryFinally() {\n" | 701 "Debugger();\n" |
| 702 " try {\n" | |
| 703 " Debugger();\n" | |
| 704 " } finally { };\n" | |
| 705 "}\n" | |
| 706 "TryFinally();\n" | |
| 707 "stopProfiling();")); | 702 "stopProfiling();")); |
| 708 script->Run(v8::Isolate::GetCurrent()->GetCurrentContext()).ToLocalChecked(); | 703 script->Run(v8::Isolate::GetCurrent()->GetCurrentContext()).ToLocalChecked(); |
| 709 CHECK_EQ(1, iprofiler->GetProfilesCount()); | 704 CHECK_EQ(1, iprofiler->GetProfilesCount()); |
| 710 const v8::CpuProfile* profile = i::ProfilerExtension::last_profile; | 705 const v8::CpuProfile* profile = i::ProfilerExtension::last_profile; |
| 711 CHECK(profile); | 706 CHECK(profile); |
| 712 const v8::CpuProfileNode* current = profile->GetTopDownRoot(); | 707 const v8::CpuProfileNode* current = profile->GetTopDownRoot(); |
| 713 reinterpret_cast<ProfileNode*>( | 708 reinterpret_cast<ProfileNode*>( |
| 714 const_cast<v8::CpuProfileNode*>(current))->Print(0); | 709 const_cast<v8::CpuProfileNode*>(current))->Print(0); |
| 715 // The tree should look like this: | 710 // The tree should look like this: |
| 716 // (root) | 711 // (root) |
| 717 // "" | 712 // "" |
| 718 // kTryFinallyStatement | 713 // kDebuggerStatement |
| 719 // kDebuggerStatement | |
| 720 current = PickChild(current, ""); | 714 current = PickChild(current, ""); |
| 721 CHECK(const_cast<v8::CpuProfileNode*>(current)); | 715 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
| 722 | 716 |
| 723 current = PickChild(current, "TryFinally"); | |
| 724 CHECK(const_cast<v8::CpuProfileNode*>(current)); | |
| 725 CHECK(!strcmp("TryFinallyStatement", current->GetBailoutReason())); | |
| 726 | |
| 727 current = PickChild(current, "Debugger"); | 717 current = PickChild(current, "Debugger"); |
| 728 CHECK(const_cast<v8::CpuProfileNode*>(current)); | 718 CHECK(const_cast<v8::CpuProfileNode*>(current)); |
| 729 CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason())); | 719 CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason())); |
| 730 } | 720 } |
| OLD | NEW |