OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/profiler/cpu-profiler.h" | 5 #include "src/profiler/cpu-profiler.h" |
6 | 6 |
7 #include "src/debug/debug.h" | 7 #include "src/debug/debug.h" |
8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
10 #include "src/locked-queue-inl.h" | 10 #include "src/locked-queue-inl.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 | 192 |
193 void CpuProfiler::DeleteProfile(CpuProfile* profile) { | 193 void CpuProfiler::DeleteProfile(CpuProfile* profile) { |
194 profiles_->RemoveProfile(profile); | 194 profiles_->RemoveProfile(profile); |
195 delete profile; | 195 delete profile; |
196 if (profiles_->profiles()->is_empty() && !is_profiling_) { | 196 if (profiles_->profiles()->is_empty() && !is_profiling_) { |
197 // If this was the last profile, clean up all accessory data as well. | 197 // If this was the last profile, clean up all accessory data as well. |
198 ResetProfiles(); | 198 ResetProfiles(); |
199 } | 199 } |
200 } | 200 } |
201 | 201 |
202 | 202 void CpuProfiler::CodeEventHandler(const CodeEventsContainer& evt_rec) { |
203 void CpuProfiler::CallbackEvent(Name* name, Address entry_point) { | 203 switch (evt_rec.generic.type) { |
204 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | 204 case CodeEventRecord::CODE_CREATION: |
205 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | 205 case CodeEventRecord::CODE_MOVE: |
206 rec->start = entry_point; | 206 case CodeEventRecord::CODE_DISABLE_OPT: { |
207 rec->entry = profiles_->NewCodeEntry( | 207 processor_->Enqueue(evt_rec); |
208 Logger::CALLBACK_TAG, | 208 break; |
209 profiles_->GetName(name)); | |
210 rec->size = 1; | |
211 processor_->Enqueue(evt_rec); | |
212 } | |
213 | |
214 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | |
215 AbstractCode* code, const char* name) { | |
216 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | |
217 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
218 rec->start = code->address(); | |
219 rec->entry = profiles_->NewCodeEntry( | |
220 tag, profiles_->GetFunctionName(name), CodeEntry::kEmptyNamePrefix, | |
221 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo, | |
222 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); | |
223 RecordInliningInfo(rec->entry, code); | |
224 rec->size = code->ExecutableSize(); | |
225 processor_->Enqueue(evt_rec); | |
226 } | |
227 | |
228 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | |
229 AbstractCode* code, Name* name) { | |
230 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | |
231 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
232 rec->start = code->address(); | |
233 rec->entry = profiles_->NewCodeEntry( | |
234 tag, profiles_->GetFunctionName(name), CodeEntry::kEmptyNamePrefix, | |
235 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo, | |
236 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); | |
237 RecordInliningInfo(rec->entry, code); | |
238 rec->size = code->ExecutableSize(); | |
239 processor_->Enqueue(evt_rec); | |
240 } | |
241 | |
242 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | |
243 AbstractCode* code, | |
244 SharedFunctionInfo* shared, | |
245 Name* script_name) { | |
246 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | |
247 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
248 rec->start = code->address(); | |
249 rec->entry = profiles_->NewCodeEntry( | |
250 tag, profiles_->GetFunctionName(shared->DebugName()), | |
251 CodeEntry::kEmptyNamePrefix, | |
252 profiles_->GetName(InferScriptName(script_name, shared)), | |
253 CpuProfileNode::kNoLineNumberInfo, CpuProfileNode::kNoColumnNumberInfo, | |
254 NULL, code->instruction_start()); | |
255 RecordInliningInfo(rec->entry, code); | |
256 rec->entry->FillFunctionInfo(shared); | |
257 rec->size = code->ExecutableSize(); | |
258 processor_->Enqueue(evt_rec); | |
259 } | |
260 | |
261 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | |
262 AbstractCode* abstract_code, | |
263 SharedFunctionInfo* shared, Name* script_name, | |
264 int line, int column) { | |
265 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | |
266 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
267 rec->start = abstract_code->address(); | |
268 Script* script = Script::cast(shared->script()); | |
269 JITLineInfoTable* line_table = NULL; | |
270 if (script) { | |
271 if (abstract_code->IsCode()) { | |
272 Code* code = abstract_code->GetCode(); | |
273 int start_position = shared->start_position(); | |
274 int end_position = shared->end_position(); | |
275 line_table = new JITLineInfoTable(); | |
276 for (RelocIterator it(code); !it.done(); it.next()) { | |
277 RelocInfo* reloc_info = it.rinfo(); | |
278 if (!RelocInfo::IsPosition(reloc_info->rmode())) continue; | |
279 int position = static_cast<int>(reloc_info->data()); | |
280 // TODO(alph): in case of inlining the position may correspond | |
281 // to an inlined function source code. Do not collect positions | |
282 // that fall beyond the function source code. There's however a | |
283 // chance the inlined function has similar positions but in another | |
284 // script. So the proper fix is to store script_id in some form | |
285 // along with the inlined function positions. | |
286 if (position < start_position || position >= end_position) continue; | |
287 int pc_offset = static_cast<int>(reloc_info->pc() - code->address()); | |
288 int line_number = script->GetLineNumber(position) + 1; | |
289 line_table->SetPosition(pc_offset, line_number); | |
290 } | |
291 } else { | |
292 BytecodeArray* bytecode = abstract_code->GetBytecodeArray(); | |
293 line_table = new JITLineInfoTable(); | |
294 interpreter::SourcePositionTableIterator it( | |
295 bytecode->source_position_table()); | |
296 for (; !it.done(); it.Advance()) { | |
297 int line_number = script->GetLineNumber(it.source_position()) + 1; | |
298 int pc_offset = it.bytecode_offset() + BytecodeArray::kHeaderSize; | |
299 line_table->SetPosition(pc_offset, line_number); | |
300 } | |
301 } | 209 } |
302 } | 210 case CodeEventRecord::CODE_DEOPT: { |
303 rec->entry = profiles_->NewCodeEntry( | 211 processor_->Enqueue(evt_rec); |
304 tag, profiles_->GetFunctionName(shared->DebugName()), | 212 CodeDeoptEventRecord* rec = |
305 CodeEntry::kEmptyNamePrefix, | 213 const_cast<CodeDeoptEventRecord*>(&evt_rec.CodeDeoptEventRecord_); |
306 profiles_->GetName(InferScriptName(script_name, shared)), line, column, | 214 processor_->AddDeoptStack(isolate_, reinterpret_cast<Address>(rec->pc), |
307 line_table, abstract_code->instruction_start()); | 215 rec->fp_to_sp_delta); |
308 RecordInliningInfo(rec->entry, abstract_code); | 216 break; |
309 RecordDeoptInlinedFrames(rec->entry, abstract_code); | |
310 rec->entry->FillFunctionInfo(shared); | |
311 rec->size = abstract_code->ExecutableSize(); | |
312 processor_->Enqueue(evt_rec); | |
313 } | |
314 | |
315 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | |
316 AbstractCode* code, int args_count) { | |
317 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | |
318 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
319 rec->start = code->address(); | |
320 rec->entry = profiles_->NewCodeEntry( | |
321 tag, profiles_->GetName(args_count), "args_count: ", | |
322 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo, | |
323 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); | |
324 RecordInliningInfo(rec->entry, code); | |
325 rec->size = code->ExecutableSize(); | |
326 processor_->Enqueue(evt_rec); | |
327 } | |
328 | |
329 void CpuProfiler::CodeMoveEvent(AbstractCode* from, Address to) { | |
330 CodeEventsContainer evt_rec(CodeEventRecord::CODE_MOVE); | |
331 CodeMoveEventRecord* rec = &evt_rec.CodeMoveEventRecord_; | |
332 rec->from = from->address(); | |
333 rec->to = to; | |
334 processor_->Enqueue(evt_rec); | |
335 } | |
336 | |
337 void CpuProfiler::CodeDisableOptEvent(AbstractCode* code, | |
338 SharedFunctionInfo* shared) { | |
339 CodeEventsContainer evt_rec(CodeEventRecord::CODE_DISABLE_OPT); | |
340 CodeDisableOptEventRecord* rec = &evt_rec.CodeDisableOptEventRecord_; | |
341 rec->start = code->address(); | |
342 rec->bailout_reason = GetBailoutReason(shared->disable_optimization_reason()); | |
343 processor_->Enqueue(evt_rec); | |
344 } | |
345 | |
346 void CpuProfiler::CodeDeoptEvent(Code* code, Address pc, int fp_to_sp_delta) { | |
347 CodeEventsContainer evt_rec(CodeEventRecord::CODE_DEOPT); | |
348 CodeDeoptEventRecord* rec = &evt_rec.CodeDeoptEventRecord_; | |
349 Deoptimizer::DeoptInfo info = Deoptimizer::GetDeoptInfo(code, pc); | |
350 rec->start = code->address(); | |
351 rec->deopt_reason = Deoptimizer::GetDeoptReason(info.deopt_reason); | |
352 rec->position = info.position; | |
353 rec->deopt_id = info.deopt_id; | |
354 processor_->Enqueue(evt_rec); | |
355 processor_->AddDeoptStack(isolate_, pc, fp_to_sp_delta); | |
356 } | |
357 | |
358 void CpuProfiler::GetterCallbackEvent(Name* name, Address entry_point) { | |
359 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | |
360 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
361 rec->start = entry_point; | |
362 rec->entry = profiles_->NewCodeEntry( | |
363 Logger::CALLBACK_TAG, | |
364 profiles_->GetName(name), | |
365 "get "); | |
366 rec->size = 1; | |
367 processor_->Enqueue(evt_rec); | |
368 } | |
369 | |
370 void CpuProfiler::RegExpCodeCreateEvent(AbstractCode* code, String* source) { | |
371 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | |
372 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
373 rec->start = code->address(); | |
374 rec->entry = profiles_->NewCodeEntry( | |
375 Logger::REG_EXP_TAG, profiles_->GetName(source), "RegExp: ", | |
376 CodeEntry::kEmptyResourceName, CpuProfileNode::kNoLineNumberInfo, | |
377 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); | |
378 rec->size = code->ExecutableSize(); | |
379 processor_->Enqueue(evt_rec); | |
380 } | |
381 | |
382 | |
383 void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) { | |
384 CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); | |
385 CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_; | |
386 rec->start = entry_point; | |
387 rec->entry = profiles_->NewCodeEntry( | |
388 Logger::CALLBACK_TAG, | |
389 profiles_->GetName(name), | |
390 "set "); | |
391 rec->size = 1; | |
392 processor_->Enqueue(evt_rec); | |
393 } | |
394 | |
395 Name* CpuProfiler::InferScriptName(Name* name, SharedFunctionInfo* info) { | |
396 if (name->IsString() && String::cast(name)->length()) return name; | |
397 if (!info->script()->IsScript()) return name; | |
398 Object* source_url = Script::cast(info->script())->source_url(); | |
399 return source_url->IsName() ? Name::cast(source_url) : name; | |
400 } | |
401 | |
402 void CpuProfiler::RecordInliningInfo(CodeEntry* entry, | |
403 AbstractCode* abstract_code) { | |
404 if (!abstract_code->IsCode()) return; | |
405 Code* code = abstract_code->GetCode(); | |
406 if (code->kind() != Code::OPTIMIZED_FUNCTION) return; | |
407 DeoptimizationInputData* deopt_input_data = | |
408 DeoptimizationInputData::cast(code->deoptimization_data()); | |
409 int deopt_count = deopt_input_data->DeoptCount(); | |
410 for (int i = 0; i < deopt_count; i++) { | |
411 int pc_offset = deopt_input_data->Pc(i)->value(); | |
412 if (pc_offset == -1) continue; | |
413 int translation_index = deopt_input_data->TranslationIndex(i)->value(); | |
414 TranslationIterator it(deopt_input_data->TranslationByteArray(), | |
415 translation_index); | |
416 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); | |
417 DCHECK_EQ(Translation::BEGIN, opcode); | |
418 it.Skip(Translation::NumberOfOperandsFor(opcode)); | |
419 int depth = 0; | |
420 std::vector<CodeEntry*> inline_stack; | |
421 while (it.HasNext() && | |
422 Translation::BEGIN != | |
423 (opcode = static_cast<Translation::Opcode>(it.Next()))) { | |
424 if (opcode != Translation::JS_FRAME && | |
425 opcode != Translation::INTERPRETED_FRAME) { | |
426 it.Skip(Translation::NumberOfOperandsFor(opcode)); | |
427 continue; | |
428 } | |
429 it.Next(); // Skip ast_id | |
430 int shared_info_id = it.Next(); | |
431 it.Next(); // Skip height | |
432 SharedFunctionInfo* shared_info = SharedFunctionInfo::cast( | |
433 deopt_input_data->LiteralArray()->get(shared_info_id)); | |
434 if (!depth++) continue; // Skip the current function itself. | |
435 CodeEntry* inline_entry = new CodeEntry( | |
436 entry->tag(), profiles_->GetFunctionName(shared_info->DebugName()), | |
437 CodeEntry::kEmptyNamePrefix, entry->resource_name(), | |
438 CpuProfileNode::kNoLineNumberInfo, | |
439 CpuProfileNode::kNoColumnNumberInfo, NULL, code->instruction_start()); | |
440 inline_entry->FillFunctionInfo(shared_info); | |
441 inline_stack.push_back(inline_entry); | |
442 } | 217 } |
443 if (!inline_stack.empty()) { | 218 default: |
444 entry->AddInlineStack(pc_offset, inline_stack); | 219 UNREACHABLE(); |
445 DCHECK(inline_stack.empty()); | |
446 } | |
447 } | 220 } |
448 } | 221 } |
449 | 222 |
450 void CpuProfiler::RecordDeoptInlinedFrames(CodeEntry* entry, | |
451 AbstractCode* abstract_code) { | |
452 if (abstract_code->kind() != AbstractCode::OPTIMIZED_FUNCTION) return; | |
453 Code* code = abstract_code->GetCode(); | |
454 DeoptimizationInputData* deopt_input_data = | |
455 DeoptimizationInputData::cast(code->deoptimization_data()); | |
456 int const mask = RelocInfo::ModeMask(RelocInfo::DEOPT_ID); | |
457 for (RelocIterator rit(code, mask); !rit.done(); rit.next()) { | |
458 RelocInfo* reloc_info = rit.rinfo(); | |
459 DCHECK(RelocInfo::IsDeoptId(reloc_info->rmode())); | |
460 int deopt_id = static_cast<int>(reloc_info->data()); | |
461 int translation_index = | |
462 deopt_input_data->TranslationIndex(deopt_id)->value(); | |
463 TranslationIterator it(deopt_input_data->TranslationByteArray(), | |
464 translation_index); | |
465 Translation::Opcode opcode = static_cast<Translation::Opcode>(it.Next()); | |
466 DCHECK_EQ(Translation::BEGIN, opcode); | |
467 it.Skip(Translation::NumberOfOperandsFor(opcode)); | |
468 std::vector<CodeEntry::DeoptInlinedFrame> inlined_frames; | |
469 while (it.HasNext() && | |
470 Translation::BEGIN != | |
471 (opcode = static_cast<Translation::Opcode>(it.Next()))) { | |
472 if (opcode != Translation::JS_FRAME && | |
473 opcode != Translation::INTERPRETED_FRAME) { | |
474 it.Skip(Translation::NumberOfOperandsFor(opcode)); | |
475 continue; | |
476 } | |
477 BailoutId ast_id = BailoutId(it.Next()); | |
478 int shared_info_id = it.Next(); | |
479 it.Next(); // Skip height | |
480 SharedFunctionInfo* shared = SharedFunctionInfo::cast( | |
481 deopt_input_data->LiteralArray()->get(shared_info_id)); | |
482 int source_position = Deoptimizer::ComputeSourcePosition(shared, ast_id); | |
483 int script_id = v8::UnboundScript::kNoScriptId; | |
484 if (shared->script()->IsScript()) { | |
485 Script* script = Script::cast(shared->script()); | |
486 script_id = script->id(); | |
487 } | |
488 CodeEntry::DeoptInlinedFrame frame = {source_position, script_id}; | |
489 inlined_frames.push_back(frame); | |
490 } | |
491 if (!inlined_frames.empty() && !entry->HasDeoptInlinedFramesFor(deopt_id)) { | |
492 entry->AddDeoptInlinedFrames(deopt_id, inlined_frames); | |
493 DCHECK(inlined_frames.empty()); | |
494 } | |
495 } | |
496 } | |
497 | |
498 CpuProfiler::CpuProfiler(Isolate* isolate) | 223 CpuProfiler::CpuProfiler(Isolate* isolate) |
499 : isolate_(isolate), | 224 : isolate_(isolate), |
500 sampling_interval_(base::TimeDelta::FromMicroseconds( | 225 sampling_interval_(base::TimeDelta::FromMicroseconds( |
501 FLAG_cpu_profiler_sampling_interval)), | 226 FLAG_cpu_profiler_sampling_interval)), |
502 profiles_(new CpuProfilesCollection(isolate->heap())), | 227 profiles_(new CpuProfilesCollection(isolate->heap())), |
503 generator_(NULL), | 228 generator_(NULL), |
504 processor_(NULL), | 229 processor_(NULL), |
505 is_profiling_(false) { | 230 is_profiling_(false) {} |
506 } | |
507 | 231 |
508 | 232 CpuProfiler::CpuProfiler(Isolate* isolate, CpuProfilesCollection* test_profiles, |
509 CpuProfiler::CpuProfiler(Isolate* isolate, | |
510 CpuProfilesCollection* test_profiles, | |
511 ProfileGenerator* test_generator, | 233 ProfileGenerator* test_generator, |
512 ProfilerEventsProcessor* test_processor) | 234 ProfilerEventsProcessor* test_processor) |
513 : isolate_(isolate), | 235 : isolate_(isolate), |
514 sampling_interval_(base::TimeDelta::FromMicroseconds( | 236 sampling_interval_(base::TimeDelta::FromMicroseconds( |
515 FLAG_cpu_profiler_sampling_interval)), | 237 FLAG_cpu_profiler_sampling_interval)), |
516 profiles_(test_profiles), | 238 profiles_(test_profiles), |
517 generator_(test_generator), | 239 generator_(test_generator), |
518 processor_(test_processor), | 240 processor_(test_processor), |
519 is_profiling_(false) { | 241 is_profiling_(false) {} |
520 } | |
521 | 242 |
522 | 243 |
523 CpuProfiler::~CpuProfiler() { | 244 CpuProfiler::~CpuProfiler() { |
524 DCHECK(!is_profiling_); | 245 DCHECK(!is_profiling_); |
525 delete profiles_; | 246 delete profiles_; |
526 } | 247 } |
527 | 248 |
528 | 249 |
529 void CpuProfiler::set_sampling_interval(base::TimeDelta value) { | 250 void CpuProfiler::set_sampling_interval(base::TimeDelta value) { |
530 DCHECK(!is_profiling_); | 251 DCHECK(!is_profiling_); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 return; | 283 return; |
563 } | 284 } |
564 Logger* logger = isolate_->logger(); | 285 Logger* logger = isolate_->logger(); |
565 // Disable logging when using the new implementation. | 286 // Disable logging when using the new implementation. |
566 saved_is_logging_ = logger->is_logging_; | 287 saved_is_logging_ = logger->is_logging_; |
567 logger->is_logging_ = false; | 288 logger->is_logging_ = false; |
568 generator_ = new ProfileGenerator(profiles_); | 289 generator_ = new ProfileGenerator(profiles_); |
569 sampler::Sampler* sampler = logger->sampler(); | 290 sampler::Sampler* sampler = logger->sampler(); |
570 processor_ = new ProfilerEventsProcessor( | 291 processor_ = new ProfilerEventsProcessor( |
571 generator_, sampler, sampling_interval_); | 292 generator_, sampler, sampling_interval_); |
293 RESOLVE_CODE_EVENT(isolate_); | |
alph
2016/06/14 03:48:45
Why it needs to be a macro?
lpy
2016/06/14 09:53:47
Done.
It doesn't need to be.
| |
294 ProfilerListener* profiler_listener = logger->profiler_listener(); | |
295 profiler_listener->RegisterObserver(this); | |
572 is_profiling_ = true; | 296 is_profiling_ = true; |
573 isolate_->set_is_profiling(true); | 297 isolate_->set_is_profiling(true); |
574 // Enumerate stuff we already have in the heap. | 298 // Enumerate stuff we already have in the heap. |
575 DCHECK(isolate_->heap()->HasBeenSetUp()); | 299 DCHECK(isolate_->heap()->HasBeenSetUp()); |
576 if (!FLAG_prof_browser_mode) { | 300 if (!FLAG_prof_browser_mode) { |
577 logger->LogCodeObjects(); | 301 logger->LogCodeObjects(); |
578 } | 302 } |
579 logger->LogCompiledFunctions(); | 303 logger->LogCompiledFunctions(); |
580 logger->LogAccessorCallbacks(); | 304 logger->LogAccessorCallbacks(); |
581 LogBuiltins(); | 305 LogBuiltins(); |
(...skipping 28 matching lines...) Expand all Loading... | |
610 if (profiles_->IsLastProfile(title)) StopProcessor(); | 334 if (profiles_->IsLastProfile(title)) StopProcessor(); |
611 } | 335 } |
612 | 336 |
613 | 337 |
614 void CpuProfiler::StopProcessor() { | 338 void CpuProfiler::StopProcessor() { |
615 Logger* logger = isolate_->logger(); | 339 Logger* logger = isolate_->logger(); |
616 sampler::Sampler* sampler = | 340 sampler::Sampler* sampler = |
617 reinterpret_cast<sampler::Sampler*>(logger->ticker_); | 341 reinterpret_cast<sampler::Sampler*>(logger->ticker_); |
618 is_profiling_ = false; | 342 is_profiling_ = false; |
619 isolate_->set_is_profiling(false); | 343 isolate_->set_is_profiling(false); |
344 ProfilerListener* profiler_listener = logger->profiler_listener(); | |
345 profiler_listener->RemoveObserver(this); | |
620 processor_->StopSynchronously(); | 346 processor_->StopSynchronously(); |
621 delete processor_; | 347 delete processor_; |
622 delete generator_; | 348 delete generator_; |
623 processor_ = NULL; | 349 processor_ = NULL; |
624 generator_ = NULL; | 350 generator_ = NULL; |
625 sampler->SetHasProcessingThread(false); | 351 sampler->SetHasProcessingThread(false); |
626 sampler->DecreaseProfilingDepth(); | 352 sampler->DecreaseProfilingDepth(); |
627 logger->is_logging_ = saved_is_logging_; | 353 logger->is_logging_ = saved_is_logging_; |
628 } | 354 } |
629 | 355 |
630 | 356 |
631 void CpuProfiler::LogBuiltins() { | 357 void CpuProfiler::LogBuiltins() { |
632 Builtins* builtins = isolate_->builtins(); | 358 Builtins* builtins = isolate_->builtins(); |
633 DCHECK(builtins->is_initialized()); | 359 DCHECK(builtins->is_initialized()); |
634 for (int i = 0; i < Builtins::builtin_count; i++) { | 360 for (int i = 0; i < Builtins::builtin_count; i++) { |
635 CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN); | 361 CodeEventsContainer evt_rec(CodeEventRecord::REPORT_BUILTIN); |
636 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 362 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; |
637 Builtins::Name id = static_cast<Builtins::Name>(i); | 363 Builtins::Name id = static_cast<Builtins::Name>(i); |
638 rec->start = builtins->builtin(id)->address(); | 364 rec->start = builtins->builtin(id)->address(); |
639 rec->builtin_id = id; | 365 rec->builtin_id = id; |
640 processor_->Enqueue(evt_rec); | 366 processor_->Enqueue(evt_rec); |
641 } | 367 } |
642 } | 368 } |
643 | 369 |
644 | |
645 } // namespace internal | 370 } // namespace internal |
646 } // namespace v8 | 371 } // namespace v8 |
OLD | NEW |