| 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 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 if (args.Length() > 0) | 848 if (args.Length() > 0) |
| 849 cpu_profiler->StopCpuProfiling(args[0].As<v8::String>()); | 849 cpu_profiler->StopCpuProfiling(args[0].As<v8::String>()); |
| 850 else | 850 else |
| 851 cpu_profiler->StopCpuProfiling(v8::String::New("")); | 851 cpu_profiler->StopCpuProfiling(v8::String::New("")); |
| 852 return v8::Undefined(); | 852 return v8::Undefined(); |
| 853 } | 853 } |
| 854 | 854 |
| 855 | 855 |
| 856 static ProfilerExtension kProfilerExtension; | 856 static ProfilerExtension kProfilerExtension; |
| 857 v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension); | 857 v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension); |
| 858 static v8::Persistent<v8::Context> env; | |
| 859 | 858 |
| 860 static const ProfileNode* PickChild(const ProfileNode* parent, | 859 static const ProfileNode* PickChild(const ProfileNode* parent, |
| 861 const char* name) { | 860 const char* name) { |
| 862 for (int i = 0; i < parent->children()->length(); ++i) { | 861 for (int i = 0; i < parent->children()->length(); ++i) { |
| 863 const ProfileNode* child = parent->children()->at(i); | 862 const ProfileNode* child = parent->children()->at(i); |
| 864 if (strcmp(child->entry()->name(), name) == 0) return child; | 863 if (strcmp(child->entry()->name(), name) == 0) return child; |
| 865 } | 864 } |
| 866 return NULL; | 865 return NULL; |
| 867 } | 866 } |
| 868 | 867 |
| 869 | 868 |
| 870 TEST(RecordStackTraceAtStartProfiling) { | 869 TEST(RecordStackTraceAtStartProfiling) { |
| 871 // This test does not pass with inlining enabled since inlined functions | 870 // This test does not pass with inlining enabled since inlined functions |
| 872 // don't appear in the stack trace. | 871 // don't appear in the stack trace. |
| 873 i::FLAG_use_inlining = false; | 872 i::FLAG_use_inlining = false; |
| 874 | 873 |
| 875 if (env.IsEmpty()) { | 874 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 876 v8::HandleScope scope(v8::Isolate::GetCurrent()); | 875 v8::HandleScope scope(isolate); |
| 877 const char* extensions[] = { "v8/profiler" }; | 876 const char* extensions[] = { "v8/profiler" }; |
| 878 v8::ExtensionConfiguration config(1, extensions); | 877 v8::ExtensionConfiguration config(1, extensions); |
| 879 env = v8::Context::New(&config); | 878 v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 880 } | 879 context->Enter(); |
| 881 v8::HandleScope scope(v8::Isolate::GetCurrent()); | |
| 882 (*env)->Enter(); | |
| 883 | 880 |
| 884 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); | 881 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); |
| 885 CHECK_EQ(0, profiler->GetProfilesCount()); | 882 CHECK_EQ(0, profiler->GetProfilesCount()); |
| 886 CompileRun( | 883 CompileRun( |
| 887 "function c() { startProfiling(); }\n" | 884 "function c() { startProfiling(); }\n" |
| 888 "function b() { c(); }\n" | 885 "function b() { c(); }\n" |
| 889 "function a() { b(); }\n" | 886 "function a() { b(); }\n" |
| 890 "a();\n" | 887 "a();\n" |
| 891 "stopProfiling();"); | 888 "stopProfiling();"); |
| 892 CHECK_EQ(1, profiler->GetProfilesCount()); | 889 CHECK_EQ(1, profiler->GetProfilesCount()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 i::OS::SNPrintF(title, "%d", i); | 926 i::OS::SNPrintF(title, "%d", i); |
| 930 // UID must be > 0. | 927 // UID must be > 0. |
| 931 CHECK(collection.StartProfiling(title.start(), i + 1, false)); | 928 CHECK(collection.StartProfiling(title.start(), i + 1, false)); |
| 932 titles[i] = title.start(); | 929 titles[i] = title.start(); |
| 933 } | 930 } |
| 934 CHECK(!collection.StartProfiling( | 931 CHECK(!collection.StartProfiling( |
| 935 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false)); | 932 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false)); |
| 936 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) | 933 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) |
| 937 i::DeleteArray(titles[i]); | 934 i::DeleteArray(titles[i]); |
| 938 } | 935 } |
| OLD | NEW |