OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 generator_(generator), | 51 generator_(generator), |
52 profiles_(profiles), | 52 profiles_(profiles), |
53 running_(true), | 53 running_(true), |
54 ticks_buffer_(sizeof(TickSampleEventRecord), | 54 ticks_buffer_(sizeof(TickSampleEventRecord), |
55 kTickSamplesBufferChunkSize, | 55 kTickSamplesBufferChunkSize, |
56 kTickSamplesBufferChunksCount), | 56 kTickSamplesBufferChunksCount), |
57 enqueue_order_(0) { | 57 enqueue_order_(0) { |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 void ProfilerEventsProcessor::CallbackCreateEvent(Logger::LogEventsAndTags tag, | |
62 const char* prefix, | |
63 Name* name, | |
64 Address start) { | |
65 if (FilterOutCodeCreateEvent(tag)) return; | |
66 CodeEventsContainer evt_rec; | |
67 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
68 rec->type = CodeEventRecord::CODE_CREATION; | |
69 rec->order = ++enqueue_order_; | |
70 rec->start = start; | |
71 rec->entry = profiles_->NewCodeEntry(tag, prefix, name); | |
72 rec->size = 1; | |
73 rec->shared = NULL; | |
74 events_buffer_.Enqueue(evt_rec); | |
75 } | |
76 | |
77 | |
78 void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, | |
79 Name* name, | |
80 String* resource_name, | |
81 int line_number, | |
82 Address start, | |
83 unsigned size, | |
84 Address shared, | |
85 CompilationInfo* info) { | |
86 if (FilterOutCodeCreateEvent(tag)) return; | |
87 CodeEventsContainer evt_rec; | |
88 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
89 rec->type = CodeEventRecord::CODE_CREATION; | |
90 rec->order = ++enqueue_order_; | |
91 rec->start = start; | |
92 rec->entry = profiles_->NewCodeEntry(tag, name, resource_name, line_number); | |
93 if (info) { | |
94 rec->entry->set_no_frame_ranges(info->ReleaseNoFrameRanges()); | |
95 } | |
96 rec->size = size; | |
97 rec->shared = shared; | |
98 events_buffer_.Enqueue(evt_rec); | |
99 } | |
100 | |
101 | |
102 void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, | |
103 const char* name, | |
104 Address start, | |
105 unsigned size) { | |
106 if (FilterOutCodeCreateEvent(tag)) return; | |
107 CodeEventsContainer evt_rec; | |
108 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
109 rec->type = CodeEventRecord::CODE_CREATION; | |
110 rec->order = ++enqueue_order_; | |
111 rec->start = start; | |
112 rec->entry = profiles_->NewCodeEntry(tag, name); | |
113 rec->size = size; | |
114 rec->shared = NULL; | |
115 events_buffer_.Enqueue(evt_rec); | |
116 } | |
117 | |
118 | |
119 void ProfilerEventsProcessor::CodeCreateEvent(Logger::LogEventsAndTags tag, | |
120 int args_count, | |
121 Address start, | |
122 unsigned size) { | |
123 if (FilterOutCodeCreateEvent(tag)) return; | |
124 CodeEventsContainer evt_rec; | |
125 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
126 rec->type = CodeEventRecord::CODE_CREATION; | |
127 rec->order = ++enqueue_order_; | |
128 rec->start = start; | |
129 rec->entry = profiles_->NewCodeEntry(tag, args_count); | |
130 rec->size = size; | |
131 rec->shared = NULL; | |
132 events_buffer_.Enqueue(evt_rec); | |
133 } | |
134 | |
135 | |
136 void ProfilerEventsProcessor::CodeMoveEvent(Address from, Address to) { | 61 void ProfilerEventsProcessor::CodeMoveEvent(Address from, Address to) { |
137 CodeEventsContainer evt_rec; | 62 CodeEventsContainer evt_rec(CodeEventRecord::CODE_MOVE); |
138 CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_; | 63 CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_; |
139 rec->type = CodeEventRecord::CODE_MOVE; | |
140 rec->order = ++enqueue_order_; | 64 rec->order = ++enqueue_order_; |
141 rec->from = from; | 65 rec->from = from; |
142 rec->to = to; | 66 rec->to = to; |
143 events_buffer_.Enqueue(evt_rec); | 67 events_buffer_.Enqueue(evt_rec); |
144 } | 68 } |
145 | 69 |
146 | 70 |
147 void ProfilerEventsProcessor::SharedFunctionInfoMoveEvent(Address from, | 71 void ProfilerEventsProcessor::SharedFunctionInfoMoveEvent(Address from, |
148 Address to) { | 72 Address to) { |
149 CodeEventsContainer evt_rec; | 73 CodeEventsContainer evt_rec(CodeEventRecord::SHARED_FUNC_MOVE); |
150 SharedFunctionInfoMoveEventRecord* rec = | 74 SharedFunctionInfoMoveEventRecord* rec = |
151 &evt_rec.SharedFunctionInfoMoveEventRecord_; | 75 &evt_rec.SharedFunctionInfoMoveEventRecord_; |
152 rec->type = CodeEventRecord::SHARED_FUNC_MOVE; | |
153 rec->order = ++enqueue_order_; | 76 rec->order = ++enqueue_order_; |
154 rec->from = from; | 77 rec->from = from; |
155 rec->to = to; | 78 rec->to = to; |
156 events_buffer_.Enqueue(evt_rec); | 79 events_buffer_.Enqueue(evt_rec); |
157 } | 80 } |
158 | 81 |
159 | 82 |
160 void ProfilerEventsProcessor::RegExpCodeCreateEvent( | |
161 Logger::LogEventsAndTags tag, | |
162 const char* prefix, | |
163 String* name, | |
164 Address start, | |
165 unsigned size) { | |
166 if (FilterOutCodeCreateEvent(tag)) return; | |
167 CodeEventsContainer evt_rec; | |
168 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
169 rec->type = CodeEventRecord::CODE_CREATION; | |
170 rec->order = ++enqueue_order_; | |
171 rec->start = start; | |
172 rec->entry = profiles_->NewCodeEntry(tag, prefix, name); | |
173 rec->size = size; | |
174 events_buffer_.Enqueue(evt_rec); | |
175 } | |
176 | |
177 | |
178 void ProfilerEventsProcessor::AddCurrentStack() { | 83 void ProfilerEventsProcessor::AddCurrentStack() { |
179 TickSampleEventRecord record(enqueue_order_); | 84 TickSampleEventRecord record(enqueue_order_); |
180 TickSample* sample = &record.sample; | 85 TickSample* sample = &record.sample; |
181 Isolate* isolate = Isolate::Current(); | 86 Isolate* isolate = Isolate::Current(); |
182 sample->state = isolate->current_vm_state(); | 87 sample->state = isolate->current_vm_state(); |
183 sample->pc = reinterpret_cast<Address>(sample); // Not NULL. | 88 sample->pc = reinterpret_cast<Address>(sample); // Not NULL. |
184 for (StackTraceFrameIterator it(isolate); | 89 for (StackTraceFrameIterator it(isolate); |
185 !it.done() && sample->frames_count < TickSample::kMaxFramesCount; | 90 !it.done() && sample->frames_count < TickSample::kMaxFramesCount; |
186 it.Advance()) { | 91 it.Advance()) { |
187 sample->stack[sample->frames_count++] = it.frame()->pc(); | 92 sample->stack[sample->frames_count++] = it.frame()->pc(); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
299 delete profile; | 204 delete profile; |
300 } | 205 } |
301 | 206 |
302 | 207 |
303 bool CpuProfiler::HasDetachedProfiles() { | 208 bool CpuProfiler::HasDetachedProfiles() { |
304 return profiles_->HasDetachedProfiles(); | 209 return profiles_->HasDetachedProfiles(); |
305 } | 210 } |
306 | 211 |
307 | 212 |
308 void CpuProfiler::CallbackEvent(Name* name, Address entry_point) { | 213 void CpuProfiler::CallbackEvent(Name* name, Address entry_point) { |
309 processor_->CallbackCreateEvent( | 214 if (FilterOutCodeCreateEvent(Logger::CALLBACK_TAG)) return; |
310 Logger::CALLBACK_TAG, CodeEntry::kEmptyNamePrefix, name, entry_point); | 215 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
216 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
217 rec->start = entry_point; | |
218 rec->entry = profiles_->NewCodeEntry( | |
219 Logger::CALLBACK_TAG, | |
220 profiles_->GetName(name), | |
221 TokenEnumerator::kInheritsSecurityToken); | |
222 rec->size = 1; | |
223 rec->shared = NULL; | |
224 processor_->Enqueue(&evt_rec); | |
311 } | 225 } |
312 | 226 |
313 | 227 |
314 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 228 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
315 Code* code, const char* comment) { | 229 Code* code, |
316 processor_->CodeCreateEvent( | 230 const char* comment) { |
yurys
2013/06/28 11:33:43
comment -> name?
loislo
2013/06/28 12:33:12
Done.
| |
317 tag, comment, code->address(), code->ExecutableSize()); | 231 if (FilterOutCodeCreateEvent(tag)) return; |
232 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | |
233 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
234 rec->start = code->address(); | |
235 rec->entry = profiles_->NewCodeEntry( | |
236 tag, | |
237 profiles_->GetFunctionName(comment)); | |
238 rec->size = code->ExecutableSize(); | |
239 rec->shared = NULL; | |
240 processor_->Enqueue(&evt_rec); | |
318 } | 241 } |
319 | 242 |
320 | 243 |
321 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 244 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
322 Code* code, Name* name) { | 245 Code* code, |
323 processor_->CodeCreateEvent( | 246 Name* name) { |
324 tag, | 247 if (FilterOutCodeCreateEvent(tag)) return; |
325 name, | 248 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
326 isolate_->heap()->empty_string(), | 249 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
327 v8::CpuProfileNode::kNoLineNumberInfo, | 250 rec->start = code->address(); |
328 code->address(), | 251 rec->entry = profiles_->NewCodeEntry(tag, profiles_->GetFunctionName(name)); |
329 code->ExecutableSize(), | 252 rec->size = code->ExecutableSize(); |
330 NULL, | 253 rec->shared = NULL; |
331 NULL); | 254 processor_->Enqueue(&evt_rec); |
332 } | 255 } |
333 | 256 |
334 | 257 |
335 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 258 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
336 Code* code, | 259 Code* code, |
337 SharedFunctionInfo* shared, | 260 SharedFunctionInfo* shared, |
338 CompilationInfo* info, | 261 CompilationInfo* info, |
339 Name* name) { | 262 Name* name) { |
340 processor_->CodeCreateEvent( | 263 if (FilterOutCodeCreateEvent(tag)) return; |
341 tag, | 264 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
342 name, | 265 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; |
343 isolate_->heap()->empty_string(), | 266 rec->start = code->address(); |
344 v8::CpuProfileNode::kNoLineNumberInfo, | 267 rec->entry = profiles_->NewCodeEntry(tag, profiles_->GetFunctionName(name)); |
345 code->address(), | 268 rec->entry->set_no_frame_ranges(info ? |
346 code->ExecutableSize(), | 269 info->ReleaseNoFrameRanges() : |
347 shared->address(), | 270 NULL); |
348 info); | 271 rec->size = code->ExecutableSize(); |
272 rec->shared = shared->address(); | |
273 processor_->Enqueue(&evt_rec); | |
349 } | 274 } |
350 | 275 |
351 | 276 |
352 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 277 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
353 Code* code, | 278 Code* code, |
354 SharedFunctionInfo* shared, | 279 SharedFunctionInfo* shared, |
355 CompilationInfo* info, | 280 CompilationInfo* info, |
356 String* source, int line) { | 281 String* source, int line) { |
357 processor_->CodeCreateEvent( | 282 if (FilterOutCodeCreateEvent(tag)) return; |
283 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | |
284 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
285 rec->start = code->address(); | |
286 rec->entry = profiles_->NewCodeEntry( | |
358 tag, | 287 tag, |
359 shared->DebugName(), | 288 profiles_->GetFunctionName(shared->DebugName()), |
360 source, | 289 TokenEnumerator::kNoSecurityToken, |
361 line, | 290 CodeEntry::kEmptyNamePrefix, |
362 code->address(), | 291 profiles_->GetName(source), |
363 code->ExecutableSize(), | 292 line); |
364 shared->address(), | 293 rec->entry->set_no_frame_ranges(info ? |
365 info); | 294 info->ReleaseNoFrameRanges() : |
295 NULL); | |
296 rec->size = code->ExecutableSize(); | |
297 rec->shared = shared->address(); | |
298 processor_->Enqueue(&evt_rec); | |
366 } | 299 } |
367 | 300 |
368 | 301 |
369 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 302 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
370 Code* code, int args_count) { | 303 Code* code, |
371 processor_->CodeCreateEvent( | 304 int args_count) { |
305 if (FilterOutCodeCreateEvent(tag)) return; | |
306 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | |
307 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
308 rec->start = code->address(); | |
309 rec->entry = profiles_->NewCodeEntry( | |
372 tag, | 310 tag, |
373 args_count, | 311 profiles_->GetName(args_count), |
374 code->address(), | 312 TokenEnumerator::kInheritsSecurityToken, |
375 code->ExecutableSize()); | 313 "args_count: "); |
314 rec->size = code->ExecutableSize(); | |
315 rec->shared = NULL; | |
316 processor_->Enqueue(&evt_rec); | |
376 } | 317 } |
377 | 318 |
378 | 319 |
379 void CpuProfiler::CodeMoveEvent(Address from, Address to) { | 320 void CpuProfiler::CodeMoveEvent(Address from, Address to) { |
380 processor_->CodeMoveEvent(from, to); | 321 processor_->CodeMoveEvent(from, to); |
381 } | 322 } |
382 | 323 |
383 | 324 |
384 void CpuProfiler::CodeDeleteEvent(Address from) { | 325 void CpuProfiler::CodeDeleteEvent(Address from) { |
385 } | 326 } |
386 | 327 |
387 | 328 |
388 void CpuProfiler::SharedFunctionInfoMoveEvent(Address from, Address to) { | 329 void CpuProfiler::SharedFunctionInfoMoveEvent(Address from, Address to) { |
389 processor_->SharedFunctionInfoMoveEvent(from, to); | 330 processor_->SharedFunctionInfoMoveEvent(from, to); |
390 } | 331 } |
391 | 332 |
392 | 333 |
393 void CpuProfiler::GetterCallbackEvent(Name* name, Address entry_point) { | 334 void CpuProfiler::GetterCallbackEvent(Name* name, Address entry_point) { |
394 processor_->CallbackCreateEvent( | 335 if (FilterOutCodeCreateEvent(Logger::CALLBACK_TAG)) return; |
395 Logger::CALLBACK_TAG, "get ", name, entry_point); | 336 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
337 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
338 rec->start = entry_point; | |
339 rec->entry = profiles_->NewCodeEntry( | |
340 Logger::CALLBACK_TAG, | |
341 profiles_->GetName(name), | |
342 TokenEnumerator::kInheritsSecurityToken, | |
343 "get "); | |
344 rec->size = 1; | |
345 rec->shared = NULL; | |
346 processor_->Enqueue(&evt_rec); | |
396 } | 347 } |
397 | 348 |
398 | 349 |
399 void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) { | 350 void CpuProfiler::RegExpCodeCreateEvent(Code* code, String* source) { |
400 processor_->RegExpCodeCreateEvent( | 351 if (FilterOutCodeCreateEvent(Logger::REG_EXP_TAG)) return; |
352 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | |
353 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
354 rec->start = code->address(); | |
355 rec->entry = profiles_->NewCodeEntry( | |
401 Logger::REG_EXP_TAG, | 356 Logger::REG_EXP_TAG, |
402 "RegExp: ", | 357 profiles_->GetName(source), |
403 source, | 358 TokenEnumerator::kInheritsSecurityToken, |
404 code->address(), | 359 "RegExp: "); |
405 code->ExecutableSize()); | 360 rec->size = code->ExecutableSize(); |
361 processor_->Enqueue(&evt_rec); | |
406 } | 362 } |
407 | 363 |
408 | 364 |
409 void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) { | 365 void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) { |
410 processor_->CallbackCreateEvent( | 366 if (FilterOutCodeCreateEvent(Logger::CALLBACK_TAG)) return; |
411 Logger::CALLBACK_TAG, "set ", name, entry_point); | 367 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); |
368 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
369 rec->start = entry_point; | |
370 rec->entry = profiles_->NewCodeEntry( | |
371 Logger::CALLBACK_TAG, | |
372 profiles_->GetName(name), | |
373 TokenEnumerator::kInheritsSecurityToken, | |
374 "set "); | |
375 rec->size = 1; | |
376 rec->shared = NULL; | |
377 processor_->Enqueue(&evt_rec); | |
412 } | 378 } |
413 | 379 |
414 | 380 |
415 CpuProfiler::CpuProfiler(Isolate* isolate) | 381 CpuProfiler::CpuProfiler(Isolate* isolate) |
416 : isolate_(isolate), | 382 : isolate_(isolate), |
417 profiles_(new CpuProfilesCollection()), | 383 profiles_(new CpuProfilesCollection()), |
418 next_profile_uid_(1), | 384 next_profile_uid_(1), |
419 token_enumerator_(new TokenEnumerator()), | 385 token_enumerator_(new TokenEnumerator()), |
420 generator_(NULL), | 386 generator_(NULL), |
421 processor_(NULL), | 387 processor_(NULL), |
422 need_to_stop_sampler_(false), | 388 need_to_stop_sampler_(false), |
423 is_profiling_(false) { | 389 is_profiling_(false) { |
424 } | 390 } |
425 | 391 |
426 | 392 |
393 CpuProfiler::CpuProfiler(Isolate* isolate, | |
394 CpuProfilesCollection* test_profiles, | |
395 ProfileGenerator* test_generator, | |
396 ProfilerEventsProcessor* test_processor) | |
397 : isolate_(isolate), | |
398 profiles_(test_profiles), | |
399 next_profile_uid_(1), | |
400 token_enumerator_(new TokenEnumerator()), | |
401 generator_(test_generator), | |
402 processor_(test_processor), | |
403 need_to_stop_sampler_(false), | |
404 is_profiling_(false) { | |
405 } | |
406 | |
407 | |
427 CpuProfiler::~CpuProfiler() { | 408 CpuProfiler::~CpuProfiler() { |
428 delete token_enumerator_; | 409 delete token_enumerator_; |
429 delete profiles_; | 410 delete profiles_; |
430 } | 411 } |
431 | 412 |
432 | 413 |
433 void CpuProfiler::ResetProfiles() { | 414 void CpuProfiler::ResetProfiles() { |
434 delete profiles_; | 415 delete profiles_; |
435 profiles_ = new CpuProfilesCollection(); | 416 profiles_ = new CpuProfilesCollection(); |
436 } | 417 } |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
519 processor_->Join(); | 500 processor_->Join(); |
520 delete processor_; | 501 delete processor_; |
521 delete generator_; | 502 delete generator_; |
522 processor_ = NULL; | 503 processor_ = NULL; |
523 generator_ = NULL; | 504 generator_ = NULL; |
524 logger->logging_nesting_ = saved_logging_nesting_; | 505 logger->logging_nesting_ = saved_logging_nesting_; |
525 } | 506 } |
526 | 507 |
527 | 508 |
528 } } // namespace v8::internal | 509 } } // namespace v8::internal |
OLD | NEW |