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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 | 324 |
325 TickSample* CpuProfiler::TickSampleEvent(Isolate* isolate) { | 325 TickSample* CpuProfiler::TickSampleEvent(Isolate* isolate) { |
326 if (CpuProfiler::is_profiling(isolate)) { | 326 if (CpuProfiler::is_profiling(isolate)) { |
327 return isolate->cpu_profiler()->processor_->TickSampleEvent(); | 327 return isolate->cpu_profiler()->processor_->TickSampleEvent(); |
328 } else { | 328 } else { |
329 return NULL; | 329 return NULL; |
330 } | 330 } |
331 } | 331 } |
332 | 332 |
333 | 333 |
| 334 void CpuProfiler::DeleteAllProfiles() { |
| 335 ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
| 336 if (is_profiling()) |
| 337 Isolate::Current()->cpu_profiler()->StopProcessor(); |
| 338 Isolate::Current()->cpu_profiler()->ResetProfiles(); |
| 339 } |
| 340 |
| 341 |
| 342 void CpuProfiler::DeleteProfile(CpuProfile* profile) { |
| 343 ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
| 344 Isolate::Current()->cpu_profiler()->profiles_->RemoveProfile(profile); |
| 345 delete profile; |
| 346 } |
| 347 |
| 348 |
| 349 bool CpuProfiler::HasDetachedProfiles() { |
| 350 ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
| 351 return Isolate::Current()->cpu_profiler()->profiles_->HasDetachedProfiles(); |
| 352 } |
| 353 |
| 354 |
334 void CpuProfiler::CallbackEvent(String* name, Address entry_point) { | 355 void CpuProfiler::CallbackEvent(String* name, Address entry_point) { |
335 Isolate::Current()->cpu_profiler()->processor_->CallbackCreateEvent( | 356 Isolate::Current()->cpu_profiler()->processor_->CallbackCreateEvent( |
336 Logger::CALLBACK_TAG, CodeEntry::kEmptyNamePrefix, name, entry_point); | 357 Logger::CALLBACK_TAG, CodeEntry::kEmptyNamePrefix, name, entry_point); |
337 } | 358 } |
338 | 359 |
339 | 360 |
340 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 361 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
341 Code* code, const char* comment) { | 362 Code* code, const char* comment) { |
342 Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent( | 363 Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent( |
343 tag, comment, code->address(), code->ExecutableSize()); | 364 tag, comment, code->address(), code->ExecutableSize()); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 is_profiling_(false) { | 466 is_profiling_(false) { |
446 } | 467 } |
447 | 468 |
448 | 469 |
449 CpuProfiler::~CpuProfiler() { | 470 CpuProfiler::~CpuProfiler() { |
450 delete token_enumerator_; | 471 delete token_enumerator_; |
451 delete profiles_; | 472 delete profiles_; |
452 } | 473 } |
453 | 474 |
454 | 475 |
| 476 void CpuProfiler::ResetProfiles() { |
| 477 delete profiles_; |
| 478 profiles_ = new CpuProfilesCollection(); |
| 479 } |
| 480 |
455 void CpuProfiler::StartCollectingProfile(const char* title) { | 481 void CpuProfiler::StartCollectingProfile(const char* title) { |
456 if (profiles_->StartProfiling(title, next_profile_uid_++)) { | 482 if (profiles_->StartProfiling(title, next_profile_uid_++)) { |
457 StartProcessorIfNotStarted(); | 483 StartProcessorIfNotStarted(); |
458 } | 484 } |
459 processor_->AddCurrentStack(); | 485 processor_->AddCurrentStack(); |
460 } | 486 } |
461 | 487 |
462 | 488 |
463 void CpuProfiler::StartCollectingProfile(String* title) { | 489 void CpuProfiler::StartCollectingProfile(String* title) { |
464 StartCollectingProfile(profiles_->GetName(title)); | 490 StartCollectingProfile(profiles_->GetName(title)); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 String* title) { | 540 String* title) { |
515 const double actual_sampling_rate = generator_->actual_sampling_rate(); | 541 const double actual_sampling_rate = generator_->actual_sampling_rate(); |
516 const char* profile_title = profiles_->GetName(title); | 542 const char* profile_title = profiles_->GetName(title); |
517 StopProcessorIfLastProfile(profile_title); | 543 StopProcessorIfLastProfile(profile_title); |
518 int token = token_enumerator_->GetTokenId(security_token); | 544 int token = token_enumerator_->GetTokenId(security_token); |
519 return profiles_->StopProfiling(token, profile_title, actual_sampling_rate); | 545 return profiles_->StopProfiling(token, profile_title, actual_sampling_rate); |
520 } | 546 } |
521 | 547 |
522 | 548 |
523 void CpuProfiler::StopProcessorIfLastProfile(const char* title) { | 549 void CpuProfiler::StopProcessorIfLastProfile(const char* title) { |
524 if (profiles_->IsLastProfile(title)) { | 550 if (profiles_->IsLastProfile(title)) StopProcessor(); |
525 Sampler* sampler = reinterpret_cast<Sampler*>(LOGGER->ticker_); | 551 } |
526 sampler->DecreaseProfilingDepth(); | 552 |
527 if (need_to_stop_sampler_) { | 553 |
528 sampler->Stop(); | 554 void CpuProfiler::StopProcessor() { |
529 need_to_stop_sampler_ = false; | 555 Sampler* sampler = reinterpret_cast<Sampler*>(LOGGER->ticker_); |
530 } | 556 sampler->DecreaseProfilingDepth(); |
531 processor_->Stop(); | 557 if (need_to_stop_sampler_) { |
532 processor_->Join(); | 558 sampler->Stop(); |
533 delete processor_; | 559 need_to_stop_sampler_ = false; |
534 delete generator_; | |
535 processor_ = NULL; | |
536 NoBarrier_Store(&is_profiling_, false); | |
537 generator_ = NULL; | |
538 LOGGER->logging_nesting_ = saved_logging_nesting_; | |
539 } | 560 } |
| 561 processor_->Stop(); |
| 562 processor_->Join(); |
| 563 delete processor_; |
| 564 delete generator_; |
| 565 processor_ = NULL; |
| 566 NoBarrier_Store(&is_profiling_, false); |
| 567 generator_ = NULL; |
| 568 LOGGER->logging_nesting_ = saved_logging_nesting_; |
540 } | 569 } |
541 | 570 |
542 } } // namespace v8::internal | 571 } } // namespace v8::internal |
543 | 572 |
544 #endif // ENABLE_LOGGING_AND_PROFILING | 573 #endif // ENABLE_LOGGING_AND_PROFILING |
545 | 574 |
546 namespace v8 { | 575 namespace v8 { |
547 namespace internal { | 576 namespace internal { |
548 | 577 |
549 void CpuProfiler::Setup() { | 578 void CpuProfiler::Setup() { |
(...skipping 10 matching lines...) Expand all Loading... |
560 #ifdef ENABLE_LOGGING_AND_PROFILING | 589 #ifdef ENABLE_LOGGING_AND_PROFILING |
561 Isolate* isolate = Isolate::Current(); | 590 Isolate* isolate = Isolate::Current(); |
562 if (isolate->cpu_profiler() != NULL) { | 591 if (isolate->cpu_profiler() != NULL) { |
563 delete isolate->cpu_profiler(); | 592 delete isolate->cpu_profiler(); |
564 } | 593 } |
565 isolate->set_cpu_profiler(NULL); | 594 isolate->set_cpu_profiler(NULL); |
566 #endif | 595 #endif |
567 } | 596 } |
568 | 597 |
569 } } // namespace v8::internal | 598 } } // namespace v8::internal |
OLD | NEW |