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

Side by Side Diff: test/cctest/test-cpu-profiler.cc

Issue 112863002: Merge bleeding_edge 18021:18297 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 7 years 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-compiler.cc ('k') | test/cctest/test-debug.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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 i::Isolate* isolate = CcTest::i_isolate(); 52 i::Isolate* isolate = CcTest::i_isolate();
53 CpuProfilesCollection profiles(isolate->heap()); 53 CpuProfilesCollection profiles(isolate->heap());
54 ProfileGenerator generator(&profiles); 54 ProfileGenerator generator(&profiles);
55 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( 55 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor(
56 &generator, NULL, TimeDelta::FromMicroseconds(100))); 56 &generator, NULL, TimeDelta::FromMicroseconds(100)));
57 processor->Start(); 57 processor->Start();
58 processor->StopSynchronously(); 58 processor->StopSynchronously();
59 } 59 }
60 60
61 61
62 static inline i::Address ToAddress(int n) {
63 return reinterpret_cast<i::Address>(n);
64 }
65
66 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc, 62 static void EnqueueTickSampleEvent(ProfilerEventsProcessor* proc,
67 i::Address frame1, 63 i::Address frame1,
68 i::Address frame2 = NULL, 64 i::Address frame2 = NULL,
69 i::Address frame3 = NULL) { 65 i::Address frame3 = NULL) {
70 i::TickSample* sample = proc->StartTickSample(); 66 i::TickSample* sample = proc->StartTickSample();
71 sample->pc = frame1; 67 sample->pc = frame1;
72 sample->tos = frame1; 68 sample->tos = frame1;
73 sample->frames_count = 0; 69 sample->frames_count = 0;
74 if (frame2 != NULL) { 70 if (frame2 != NULL) {
75 sample->stack[0] = frame2; 71 sample->stack[0] = frame2;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 i::Code* moved_code = CreateCode(&env); 136 i::Code* moved_code = CreateCode(&env);
141 i::Code* args3_code = CreateCode(&env); 137 i::Code* args3_code = CreateCode(&env);
142 i::Code* args4_code = CreateCode(&env); 138 i::Code* args4_code = CreateCode(&env);
143 139
144 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap()); 140 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap());
145 profiles->StartProfiling("", 1, false); 141 profiles->StartProfiling("", 1, false);
146 ProfileGenerator generator(profiles); 142 ProfileGenerator generator(profiles);
147 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( 143 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor(
148 &generator, NULL, TimeDelta::FromMicroseconds(100))); 144 &generator, NULL, TimeDelta::FromMicroseconds(100)));
149 processor->Start(); 145 processor->Start();
150 CpuProfiler profiler(isolate, profiles, &generator, *processor); 146 CpuProfiler profiler(isolate, profiles, &generator, processor.get());
151 147
152 // Enqueue code creation events. 148 // Enqueue code creation events.
153 const char* aaa_str = "aaa"; 149 const char* aaa_str = "aaa";
154 i::Handle<i::String> aaa_name = factory->NewStringFromAscii( 150 i::Handle<i::String> aaa_name = factory->NewStringFromAscii(
155 i::Vector<const char>(aaa_str, i::StrLength(aaa_str))); 151 i::Vector<const char>(aaa_str, i::StrLength(aaa_str)));
156 profiler.CodeCreateEvent(i::Logger::FUNCTION_TAG, aaa_code, *aaa_name); 152 profiler.CodeCreateEvent(i::Logger::FUNCTION_TAG, aaa_code, *aaa_name);
157 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment_code, "comment"); 153 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment_code, "comment");
158 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args5_code, 5); 154 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args5_code, 5);
159 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment2_code, "comment2"); 155 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment2_code, "comment2");
160 profiler.CodeMoveEvent(comment2_code->address(), moved_code->address()); 156 profiler.CodeMoveEvent(comment2_code->address(), moved_code->address());
161 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args3_code, 3); 157 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args3_code, 3);
162 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4); 158 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4);
163 159
164 // Enqueue a tick event to enable code events processing. 160 // Enqueue a tick event to enable code events processing.
165 EnqueueTickSampleEvent(*processor, aaa_code->address()); 161 EnqueueTickSampleEvent(processor.get(), aaa_code->address());
166 162
167 processor->StopSynchronously(); 163 processor->StopSynchronously();
168 164
169 // Check the state of profile generator. 165 // Check the state of profile generator.
170 CodeEntry* aaa = generator.code_map()->FindEntry(aaa_code->address()); 166 CodeEntry* aaa = generator.code_map()->FindEntry(aaa_code->address());
171 CHECK_NE(NULL, aaa); 167 CHECK_NE(NULL, aaa);
172 CHECK_EQ(aaa_str, aaa->name()); 168 CHECK_EQ(aaa_str, aaa->name());
173 169
174 CodeEntry* comment = generator.code_map()->FindEntry(comment_code->address()); 170 CodeEntry* comment = generator.code_map()->FindEntry(comment_code->address());
175 CHECK_NE(NULL, comment); 171 CHECK_NE(NULL, comment);
(...skipping 26 matching lines...) Expand all
202 i::Code* frame1_code = CreateCode(&env); 198 i::Code* frame1_code = CreateCode(&env);
203 i::Code* frame2_code = CreateCode(&env); 199 i::Code* frame2_code = CreateCode(&env);
204 i::Code* frame3_code = CreateCode(&env); 200 i::Code* frame3_code = CreateCode(&env);
205 201
206 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap()); 202 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap());
207 profiles->StartProfiling("", 1, false); 203 profiles->StartProfiling("", 1, false);
208 ProfileGenerator generator(profiles); 204 ProfileGenerator generator(profiles);
209 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( 205 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor(
210 &generator, NULL, TimeDelta::FromMicroseconds(100))); 206 &generator, NULL, TimeDelta::FromMicroseconds(100)));
211 processor->Start(); 207 processor->Start();
212 CpuProfiler profiler(isolate, profiles, &generator, *processor); 208 CpuProfiler profiler(isolate, profiles, &generator, processor.get());
213 209
214 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame1_code, "bbb"); 210 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame1_code, "bbb");
215 profiler.CodeCreateEvent(i::Logger::STUB_TAG, frame2_code, 5); 211 profiler.CodeCreateEvent(i::Logger::STUB_TAG, frame2_code, 5);
216 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame3_code, "ddd"); 212 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame3_code, "ddd");
217 213
218 EnqueueTickSampleEvent(*processor, frame1_code->instruction_start()); 214 EnqueueTickSampleEvent(processor.get(), frame1_code->instruction_start());
219 EnqueueTickSampleEvent( 215 EnqueueTickSampleEvent(
220 *processor, 216 processor.get(),
221 frame2_code->instruction_start() + frame2_code->ExecutableSize() / 2, 217 frame2_code->instruction_start() + frame2_code->ExecutableSize() / 2,
222 frame1_code->instruction_start() + frame2_code->ExecutableSize() / 2); 218 frame1_code->instruction_start() + frame2_code->ExecutableSize() / 2);
223 EnqueueTickSampleEvent( 219 EnqueueTickSampleEvent(
224 *processor, 220 processor.get(),
225 frame3_code->instruction_end() - 1, 221 frame3_code->instruction_end() - 1,
226 frame2_code->instruction_end() - 1, 222 frame2_code->instruction_end() - 1,
227 frame1_code->instruction_end() - 1); 223 frame1_code->instruction_end() - 1);
228 224
229 processor->StopSynchronously(); 225 processor->StopSynchronously();
230 CpuProfile* profile = profiles->StopProfiling(""); 226 CpuProfile* profile = profiles->StopProfiling("");
231 CHECK_NE(NULL, profile); 227 CHECK_NE(NULL, profile);
232 228
233 // Check call trees. 229 // Check call trees.
234 const i::List<ProfileNode*>* top_down_root_children = 230 const i::List<ProfileNode*>* top_down_root_children =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 i::HandleScope scope(isolate); 267 i::HandleScope scope(isolate);
272 268
273 i::Code* code = CreateCode(&env); 269 i::Code* code = CreateCode(&env);
274 270
275 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap()); 271 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap());
276 profiles->StartProfiling("", 1, false); 272 profiles->StartProfiling("", 1, false);
277 ProfileGenerator generator(profiles); 273 ProfileGenerator generator(profiles);
278 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( 274 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor(
279 &generator, NULL, TimeDelta::FromMicroseconds(100))); 275 &generator, NULL, TimeDelta::FromMicroseconds(100)));
280 processor->Start(); 276 processor->Start();
281 CpuProfiler profiler(isolate, profiles, &generator, *processor); 277 CpuProfiler profiler(isolate, profiles, &generator, processor.get());
282 278
283 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb"); 279 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb");
284 280
285 i::TickSample* sample = processor->StartTickSample(); 281 i::TickSample* sample = processor->StartTickSample();
286 sample->pc = code->address(); 282 sample->pc = code->address();
287 sample->tos = 0; 283 sample->tos = 0;
288 sample->frames_count = i::TickSample::kMaxFramesCount; 284 sample->frames_count = i::TickSample::kMaxFramesCount;
289 for (int i = 0; i < sample->frames_count; ++i) { 285 for (int i = 0; i < sample->frames_count; ++i) {
290 sample->stack[i] = code->address(); 286 sample->stack[i] = code->address();
291 } 287 }
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 832
837 TestApiCallbacks callbacks(100); 833 TestApiCallbacks callbacks(100);
838 v8::Local<v8::External> data = 834 v8::Local<v8::External> data =
839 v8::External::New(env->GetIsolate(), &callbacks); 835 v8::External::New(env->GetIsolate(), &callbacks);
840 836
841 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); 837 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
842 func_template->SetClassName( 838 func_template->SetClassName(
843 v8::String::NewFromUtf8(env->GetIsolate(), "Test_InstanceCostructor")); 839 v8::String::NewFromUtf8(env->GetIsolate(), "Test_InstanceCostructor"));
844 v8::Local<v8::ObjectTemplate> proto_template = 840 v8::Local<v8::ObjectTemplate> proto_template =
845 func_template->PrototypeTemplate(); 841 func_template->PrototypeTemplate();
846 v8::Local<v8::Signature> signature = v8::Signature::New(func_template); 842 v8::Local<v8::Signature> signature =
843 v8::Signature::New(env->GetIsolate(), func_template);
847 proto_template->Set(v8::String::NewFromUtf8(env->GetIsolate(), "fooMethod"), 844 proto_template->Set(v8::String::NewFromUtf8(env->GetIsolate(), "fooMethod"),
848 v8::FunctionTemplate::New(&TestApiCallbacks::Callback, 845 v8::FunctionTemplate::New(&TestApiCallbacks::Callback,
849 data, signature, 0)); 846 data, signature, 0));
850 847
851 v8::Local<v8::Function> func = func_template->GetFunction(); 848 v8::Local<v8::Function> func = func_template->GetFunction();
852 v8::Local<v8::Object> instance = func->NewInstance(); 849 v8::Local<v8::Object> instance = func->NewInstance();
853 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"), 850 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
854 instance); 851 instance);
855 852
856 v8::Script::Compile(v8::String::NewFromUtf8( 853 v8::Script::Compile(v8::String::NewFromUtf8(
(...skipping 22 matching lines...) Expand all
879 876
880 TestApiCallbacks callbacks(1); 877 TestApiCallbacks callbacks(1);
881 v8::Local<v8::External> data = 878 v8::Local<v8::External> data =
882 v8::External::New(env->GetIsolate(), &callbacks); 879 v8::External::New(env->GetIsolate(), &callbacks);
883 880
884 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(); 881 v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New();
885 func_template->SetClassName( 882 func_template->SetClassName(
886 v8::String::NewFromUtf8(env->GetIsolate(), "Test_InstanceCostructor")); 883 v8::String::NewFromUtf8(env->GetIsolate(), "Test_InstanceCostructor"));
887 v8::Local<v8::ObjectTemplate> proto_template = 884 v8::Local<v8::ObjectTemplate> proto_template =
888 func_template->PrototypeTemplate(); 885 func_template->PrototypeTemplate();
889 v8::Local<v8::Signature> signature = v8::Signature::New(func_template); 886 v8::Local<v8::Signature> signature =
887 v8::Signature::New(env->GetIsolate(), func_template);
890 proto_template->Set(v8::String::NewFromUtf8(env->GetIsolate(), "fooMethod"), 888 proto_template->Set(v8::String::NewFromUtf8(env->GetIsolate(), "fooMethod"),
891 v8::FunctionTemplate::New(&TestApiCallbacks::Callback, 889 v8::FunctionTemplate::New(&TestApiCallbacks::Callback,
892 data, signature, 0)); 890 data, signature, 0));
893 891
894 v8::Local<v8::Function> func = func_template->GetFunction(); 892 v8::Local<v8::Function> func = func_template->GetFunction();
895 v8::Local<v8::Object> instance = func->NewInstance(); 893 v8::Local<v8::Object> instance = func->NewInstance();
896 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"), 894 env->Global()->Set(v8::String::NewFromUtf8(env->GetIsolate(), "instance"),
897 instance); 895 instance);
898 896
899 v8::Script::Compile(v8::String::NewFromUtf8( 897 v8::Script::Compile(v8::String::NewFromUtf8(
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 const v8::CpuProfileNode* baz = GetChild(env->GetIsolate(), script, "baz"); 1526 const v8::CpuProfileNode* baz = GetChild(env->GetIsolate(), script, "baz");
1529 CheckFunctionDetails(env->GetIsolate(), baz, "baz", "script_b", 1527 CheckFunctionDetails(env->GetIsolate(), baz, "baz", "script_b",
1530 script_b->GetId(), 3, 16); 1528 script_b->GetId(), 3, 16);
1531 const v8::CpuProfileNode* foo = GetChild(env->GetIsolate(), baz, "foo"); 1529 const v8::CpuProfileNode* foo = GetChild(env->GetIsolate(), baz, "foo");
1532 CheckFunctionDetails(env->GetIsolate(), foo, "foo", "script_a", 1530 CheckFunctionDetails(env->GetIsolate(), foo, "foo", "script_a",
1533 script_a->GetId(), 2, 1); 1531 script_a->GetId(), 2, 1);
1534 const v8::CpuProfileNode* bar = GetChild(env->GetIsolate(), foo, "bar"); 1532 const v8::CpuProfileNode* bar = GetChild(env->GetIsolate(), foo, "bar");
1535 CheckFunctionDetails(env->GetIsolate(), bar, "bar", "script_a", 1533 CheckFunctionDetails(env->GetIsolate(), bar, "bar", "script_a",
1536 script_a->GetId(), 3, 14); 1534 script_a->GetId(), 3, 14);
1537 } 1535 }
OLDNEW
« no previous file with comments | « test/cctest/test-compiler.cc ('k') | test/cctest/test-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698