Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: test/cctest/test-profile-generator.cc

Issue 15038002: Revert "deprecate Context::New which returns Persistent" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/cctest/test-random.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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;
858 859
859 static const ProfileNode* PickChild(const ProfileNode* parent, 860 static const ProfileNode* PickChild(const ProfileNode* parent,
860 const char* name) { 861 const char* name) {
861 for (int i = 0; i < parent->children()->length(); ++i) { 862 for (int i = 0; i < parent->children()->length(); ++i) {
862 const ProfileNode* child = parent->children()->at(i); 863 const ProfileNode* child = parent->children()->at(i);
863 if (strcmp(child->entry()->name(), name) == 0) return child; 864 if (strcmp(child->entry()->name(), name) == 0) return child;
864 } 865 }
865 return NULL; 866 return NULL;
866 } 867 }
867 868
868 869
869 TEST(RecordStackTraceAtStartProfiling) { 870 TEST(RecordStackTraceAtStartProfiling) {
870 // This test does not pass with inlining enabled since inlined functions 871 // This test does not pass with inlining enabled since inlined functions
871 // don't appear in the stack trace. 872 // don't appear in the stack trace.
872 i::FLAG_use_inlining = false; 873 i::FLAG_use_inlining = false;
873 874
874 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 875 if (env.IsEmpty()) {
875 v8::HandleScope scope(isolate); 876 v8::HandleScope scope(v8::Isolate::GetCurrent());
876 const char* extensions[] = { "v8/profiler" }; 877 const char* extensions[] = { "v8/profiler" };
877 v8::ExtensionConfiguration config(1, extensions); 878 v8::ExtensionConfiguration config(1, extensions);
878 v8::Local<v8::Context> context = v8::Context::New(isolate); 879 env = v8::Context::New(&config);
879 context->Enter(); 880 }
881 v8::HandleScope scope(v8::Isolate::GetCurrent());
882 (*env)->Enter();
880 883
881 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler(); 884 CpuProfiler* profiler = i::Isolate::Current()->cpu_profiler();
882 CHECK_EQ(0, profiler->GetProfilesCount()); 885 CHECK_EQ(0, profiler->GetProfilesCount());
883 CompileRun( 886 CompileRun(
884 "function c() { startProfiling(); }\n" 887 "function c() { startProfiling(); }\n"
885 "function b() { c(); }\n" 888 "function b() { c(); }\n"
886 "function a() { b(); }\n" 889 "function a() { b(); }\n"
887 "a();\n" 890 "a();\n"
888 "stopProfiling();"); 891 "stopProfiling();");
889 CHECK_EQ(1, profiler->GetProfilesCount()); 892 CHECK_EQ(1, profiler->GetProfilesCount());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 i::OS::SNPrintF(title, "%d", i); 929 i::OS::SNPrintF(title, "%d", i);
927 // UID must be > 0. 930 // UID must be > 0.
928 CHECK(collection.StartProfiling(title.start(), i + 1, false)); 931 CHECK(collection.StartProfiling(title.start(), i + 1, false));
929 titles[i] = title.start(); 932 titles[i] = title.start();
930 } 933 }
931 CHECK(!collection.StartProfiling( 934 CHECK(!collection.StartProfiling(
932 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false)); 935 "maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false));
933 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) 936 for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i)
934 i::DeleteArray(titles[i]); 937 i::DeleteArray(titles[i]);
935 } 938 }
OLDNEW
« no previous file with comments | « test/cctest/test-parsing.cc ('k') | test/cctest/test-random.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698