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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 i::Code* moved_code = CreateCode(&env); | 140 i::Code* moved_code = CreateCode(&env); |
141 i::Code* args3_code = CreateCode(&env); | 141 i::Code* args3_code = CreateCode(&env); |
142 i::Code* args4_code = CreateCode(&env); | 142 i::Code* args4_code = CreateCode(&env); |
143 | 143 |
144 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap()); | 144 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap()); |
145 profiles->StartProfiling("", 1, false); | 145 profiles->StartProfiling("", 1, false); |
146 ProfileGenerator generator(profiles); | 146 ProfileGenerator generator(profiles); |
147 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( | 147 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( |
148 &generator, NULL, TimeDelta::FromMicroseconds(100))); | 148 &generator, NULL, TimeDelta::FromMicroseconds(100))); |
149 processor->Start(); | 149 processor->Start(); |
150 CpuProfiler profiler(isolate, profiles, &generator, *processor); | 150 CpuProfiler profiler(isolate, profiles, &generator, processor.get()); |
151 | 151 |
152 // Enqueue code creation events. | 152 // Enqueue code creation events. |
153 const char* aaa_str = "aaa"; | 153 const char* aaa_str = "aaa"; |
154 i::Handle<i::String> aaa_name = factory->NewStringFromAscii( | 154 i::Handle<i::String> aaa_name = factory->NewStringFromAscii( |
155 i::Vector<const char>(aaa_str, i::StrLength(aaa_str))); | 155 i::Vector<const char>(aaa_str, i::StrLength(aaa_str))); |
156 profiler.CodeCreateEvent(i::Logger::FUNCTION_TAG, aaa_code, *aaa_name); | 156 profiler.CodeCreateEvent(i::Logger::FUNCTION_TAG, aaa_code, *aaa_name); |
157 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment_code, "comment"); | 157 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment_code, "comment"); |
158 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args5_code, 5); | 158 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args5_code, 5); |
159 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment2_code, "comment2"); | 159 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, comment2_code, "comment2"); |
160 profiler.CodeMoveEvent(comment2_code->address(), moved_code->address()); | 160 profiler.CodeMoveEvent(comment2_code->address(), moved_code->address()); |
161 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args3_code, 3); | 161 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args3_code, 3); |
162 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4); | 162 profiler.CodeCreateEvent(i::Logger::STUB_TAG, args4_code, 4); |
163 | 163 |
164 // Enqueue a tick event to enable code events processing. | 164 // Enqueue a tick event to enable code events processing. |
165 EnqueueTickSampleEvent(*processor, aaa_code->address()); | 165 EnqueueTickSampleEvent(processor.get(), aaa_code->address()); |
166 | 166 |
167 processor->StopSynchronously(); | 167 processor->StopSynchronously(); |
168 | 168 |
169 // Check the state of profile generator. | 169 // Check the state of profile generator. |
170 CodeEntry* aaa = generator.code_map()->FindEntry(aaa_code->address()); | 170 CodeEntry* aaa = generator.code_map()->FindEntry(aaa_code->address()); |
171 CHECK_NE(NULL, aaa); | 171 CHECK_NE(NULL, aaa); |
172 CHECK_EQ(aaa_str, aaa->name()); | 172 CHECK_EQ(aaa_str, aaa->name()); |
173 | 173 |
174 CodeEntry* comment = generator.code_map()->FindEntry(comment_code->address()); | 174 CodeEntry* comment = generator.code_map()->FindEntry(comment_code->address()); |
175 CHECK_NE(NULL, comment); | 175 CHECK_NE(NULL, comment); |
(...skipping 26 matching lines...) Expand all Loading... |
202 i::Code* frame1_code = CreateCode(&env); | 202 i::Code* frame1_code = CreateCode(&env); |
203 i::Code* frame2_code = CreateCode(&env); | 203 i::Code* frame2_code = CreateCode(&env); |
204 i::Code* frame3_code = CreateCode(&env); | 204 i::Code* frame3_code = CreateCode(&env); |
205 | 205 |
206 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap()); | 206 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap()); |
207 profiles->StartProfiling("", 1, false); | 207 profiles->StartProfiling("", 1, false); |
208 ProfileGenerator generator(profiles); | 208 ProfileGenerator generator(profiles); |
209 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( | 209 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( |
210 &generator, NULL, TimeDelta::FromMicroseconds(100))); | 210 &generator, NULL, TimeDelta::FromMicroseconds(100))); |
211 processor->Start(); | 211 processor->Start(); |
212 CpuProfiler profiler(isolate, profiles, &generator, *processor); | 212 CpuProfiler profiler(isolate, profiles, &generator, processor.get()); |
213 | 213 |
214 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame1_code, "bbb"); | 214 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame1_code, "bbb"); |
215 profiler.CodeCreateEvent(i::Logger::STUB_TAG, frame2_code, 5); | 215 profiler.CodeCreateEvent(i::Logger::STUB_TAG, frame2_code, 5); |
216 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame3_code, "ddd"); | 216 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, frame3_code, "ddd"); |
217 | 217 |
218 EnqueueTickSampleEvent(*processor, frame1_code->instruction_start()); | 218 EnqueueTickSampleEvent(processor.get(), frame1_code->instruction_start()); |
219 EnqueueTickSampleEvent( | 219 EnqueueTickSampleEvent( |
220 *processor, | 220 processor.get(), |
221 frame2_code->instruction_start() + frame2_code->ExecutableSize() / 2, | 221 frame2_code->instruction_start() + frame2_code->ExecutableSize() / 2, |
222 frame1_code->instruction_start() + frame2_code->ExecutableSize() / 2); | 222 frame1_code->instruction_start() + frame2_code->ExecutableSize() / 2); |
223 EnqueueTickSampleEvent( | 223 EnqueueTickSampleEvent( |
224 *processor, | 224 processor.get(), |
225 frame3_code->instruction_end() - 1, | 225 frame3_code->instruction_end() - 1, |
226 frame2_code->instruction_end() - 1, | 226 frame2_code->instruction_end() - 1, |
227 frame1_code->instruction_end() - 1); | 227 frame1_code->instruction_end() - 1); |
228 | 228 |
229 processor->StopSynchronously(); | 229 processor->StopSynchronously(); |
230 CpuProfile* profile = profiles->StopProfiling(""); | 230 CpuProfile* profile = profiles->StopProfiling(""); |
231 CHECK_NE(NULL, profile); | 231 CHECK_NE(NULL, profile); |
232 | 232 |
233 // Check call trees. | 233 // Check call trees. |
234 const i::List<ProfileNode*>* top_down_root_children = | 234 const i::List<ProfileNode*>* top_down_root_children = |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 i::HandleScope scope(isolate); | 271 i::HandleScope scope(isolate); |
272 | 272 |
273 i::Code* code = CreateCode(&env); | 273 i::Code* code = CreateCode(&env); |
274 | 274 |
275 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap()); | 275 CpuProfilesCollection* profiles = new CpuProfilesCollection(isolate->heap()); |
276 profiles->StartProfiling("", 1, false); | 276 profiles->StartProfiling("", 1, false); |
277 ProfileGenerator generator(profiles); | 277 ProfileGenerator generator(profiles); |
278 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( | 278 SmartPointer<ProfilerEventsProcessor> processor(new ProfilerEventsProcessor( |
279 &generator, NULL, TimeDelta::FromMicroseconds(100))); | 279 &generator, NULL, TimeDelta::FromMicroseconds(100))); |
280 processor->Start(); | 280 processor->Start(); |
281 CpuProfiler profiler(isolate, profiles, &generator, *processor); | 281 CpuProfiler profiler(isolate, profiles, &generator, processor.get()); |
282 | 282 |
283 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb"); | 283 profiler.CodeCreateEvent(i::Logger::BUILTIN_TAG, code, "bbb"); |
284 | 284 |
285 i::TickSample* sample = processor->StartTickSample(); | 285 i::TickSample* sample = processor->StartTickSample(); |
286 sample->pc = code->address(); | 286 sample->pc = code->address(); |
287 sample->tos = 0; | 287 sample->tos = 0; |
288 sample->frames_count = i::TickSample::kMaxFramesCount; | 288 sample->frames_count = i::TickSample::kMaxFramesCount; |
289 for (int i = 0; i < sample->frames_count; ++i) { | 289 for (int i = 0; i < sample->frames_count; ++i) { |
290 sample->stack[i] = code->address(); | 290 sample->stack[i] = code->address(); |
291 } | 291 } |
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 const v8::CpuProfileNode* baz = GetChild(env->GetIsolate(), script, "baz"); | 1530 const v8::CpuProfileNode* baz = GetChild(env->GetIsolate(), script, "baz"); |
1531 CheckFunctionDetails(env->GetIsolate(), baz, "baz", "script_b", | 1531 CheckFunctionDetails(env->GetIsolate(), baz, "baz", "script_b", |
1532 script_b->GetId(), 3, 16); | 1532 script_b->GetId(), 3, 16); |
1533 const v8::CpuProfileNode* foo = GetChild(env->GetIsolate(), baz, "foo"); | 1533 const v8::CpuProfileNode* foo = GetChild(env->GetIsolate(), baz, "foo"); |
1534 CheckFunctionDetails(env->GetIsolate(), foo, "foo", "script_a", | 1534 CheckFunctionDetails(env->GetIsolate(), foo, "foo", "script_a", |
1535 script_a->GetId(), 2, 1); | 1535 script_a->GetId(), 2, 1); |
1536 const v8::CpuProfileNode* bar = GetChild(env->GetIsolate(), foo, "bar"); | 1536 const v8::CpuProfileNode* bar = GetChild(env->GetIsolate(), foo, "bar"); |
1537 CheckFunctionDetails(env->GetIsolate(), bar, "bar", "script_a", | 1537 CheckFunctionDetails(env->GetIsolate(), bar, "bar", "script_a", |
1538 script_a->GetId(), 3, 14); | 1538 script_a->GetId(), 3, 14); |
1539 } | 1539 } |
OLD | NEW |