| 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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() { | 334 void CpuProfiler::DeleteAllProfiles() { |
| 335 ASSERT(Isolate::Current()->cpu_profiler() != NULL); | 335 Isolate* isolate = Isolate::Current(); |
| 336 ASSERT(isolate->cpu_profiler() != NULL); |
| 336 if (is_profiling()) | 337 if (is_profiling()) |
| 337 Isolate::Current()->cpu_profiler()->StopProcessor(); | 338 isolate->cpu_profiler()->StopProcessor(); |
| 338 Isolate::Current()->cpu_profiler()->ResetProfiles(); | 339 isolate->cpu_profiler()->ResetProfiles(); |
| 339 } | 340 } |
| 340 | 341 |
| 341 | 342 |
| 342 void CpuProfiler::DeleteProfile(CpuProfile* profile) { | 343 void CpuProfiler::DeleteProfile(CpuProfile* profile) { |
| 343 ASSERT(Isolate::Current()->cpu_profiler() != NULL); | 344 ASSERT(Isolate::Current()->cpu_profiler() != NULL); |
| 344 Isolate::Current()->cpu_profiler()->profiles_->RemoveProfile(profile); | 345 Isolate::Current()->cpu_profiler()->profiles_->RemoveProfile(profile); |
| 345 delete profile; | 346 delete profile; |
| 346 } | 347 } |
| 347 | 348 |
| 348 | 349 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 360 | 361 |
| 361 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 362 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 362 Code* code, const char* comment) { | 363 Code* code, const char* comment) { |
| 363 Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent( | 364 Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent( |
| 364 tag, comment, code->address(), code->ExecutableSize()); | 365 tag, comment, code->address(), code->ExecutableSize()); |
| 365 } | 366 } |
| 366 | 367 |
| 367 | 368 |
| 368 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 369 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 369 Code* code, String* name) { | 370 Code* code, String* name) { |
| 370 Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent( | 371 Isolate* isolate = Isolate::Current(); |
| 372 isolate->cpu_profiler()->processor_->CodeCreateEvent( |
| 371 tag, | 373 tag, |
| 372 name, | 374 name, |
| 373 HEAP->empty_string(), | 375 isolate->heap()->empty_string(), |
| 374 v8::CpuProfileNode::kNoLineNumberInfo, | 376 v8::CpuProfileNode::kNoLineNumberInfo, |
| 375 code->address(), | 377 code->address(), |
| 376 code->ExecutableSize(), | 378 code->ExecutableSize(), |
| 377 NULL); | 379 NULL); |
| 378 } | 380 } |
| 379 | 381 |
| 380 | 382 |
| 381 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 383 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 382 Code* code, | 384 Code* code, |
| 383 SharedFunctionInfo* shared, | 385 SharedFunctionInfo* shared, |
| 384 String* name) { | 386 String* name) { |
| 385 Isolate::Current()->cpu_profiler()->processor_->CodeCreateEvent( | 387 Isolate* isolate = Isolate::Current(); |
| 388 isolate->cpu_profiler()->processor_->CodeCreateEvent( |
| 386 tag, | 389 tag, |
| 387 name, | 390 name, |
| 388 HEAP->empty_string(), | 391 isolate->heap()->empty_string(), |
| 389 v8::CpuProfileNode::kNoLineNumberInfo, | 392 v8::CpuProfileNode::kNoLineNumberInfo, |
| 390 code->address(), | 393 code->address(), |
| 391 code->ExecutableSize(), | 394 code->ExecutableSize(), |
| 392 shared->address()); | 395 shared->address()); |
| 393 } | 396 } |
| 394 | 397 |
| 395 | 398 |
| 396 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, | 399 void CpuProfiler::CodeCreateEvent(Logger::LogEventsAndTags tag, |
| 397 Code* code, | 400 Code* code, |
| 398 SharedFunctionInfo* shared, | 401 SharedFunctionInfo* shared, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 } | 489 } |
| 487 | 490 |
| 488 | 491 |
| 489 void CpuProfiler::StartCollectingProfile(String* title) { | 492 void CpuProfiler::StartCollectingProfile(String* title) { |
| 490 StartCollectingProfile(profiles_->GetName(title)); | 493 StartCollectingProfile(profiles_->GetName(title)); |
| 491 } | 494 } |
| 492 | 495 |
| 493 | 496 |
| 494 void CpuProfiler::StartProcessorIfNotStarted() { | 497 void CpuProfiler::StartProcessorIfNotStarted() { |
| 495 if (processor_ == NULL) { | 498 if (processor_ == NULL) { |
| 499 Isolate* isolate = Isolate::Current(); |
| 500 |
| 496 // Disable logging when using the new implementation. | 501 // Disable logging when using the new implementation. |
| 497 saved_logging_nesting_ = LOGGER->logging_nesting_; | 502 saved_logging_nesting_ = isolate->logger()->logging_nesting_; |
| 498 LOGGER->logging_nesting_ = 0; | 503 isolate->logger()->logging_nesting_ = 0; |
| 499 generator_ = new ProfileGenerator(profiles_); | 504 generator_ = new ProfileGenerator(profiles_); |
| 500 processor_ = new ProfilerEventsProcessor(Isolate::Current(), generator_); | 505 processor_ = new ProfilerEventsProcessor(isolate, generator_); |
| 501 NoBarrier_Store(&is_profiling_, true); | 506 NoBarrier_Store(&is_profiling_, true); |
| 502 processor_->Start(); | 507 processor_->Start(); |
| 503 // Enumerate stuff we already have in the heap. | 508 // Enumerate stuff we already have in the heap. |
| 504 if (HEAP->HasBeenSetup()) { | 509 if (isolate->heap()->HasBeenSetup()) { |
| 505 if (!FLAG_prof_browser_mode) { | 510 if (!FLAG_prof_browser_mode) { |
| 506 bool saved_log_code_flag = FLAG_log_code; | 511 bool saved_log_code_flag = FLAG_log_code; |
| 507 FLAG_log_code = true; | 512 FLAG_log_code = true; |
| 508 LOGGER->LogCodeObjects(); | 513 isolate->logger()->LogCodeObjects(); |
| 509 FLAG_log_code = saved_log_code_flag; | 514 FLAG_log_code = saved_log_code_flag; |
| 510 } | 515 } |
| 511 LOGGER->LogCompiledFunctions(); | 516 isolate->logger()->LogCompiledFunctions(); |
| 512 LOGGER->LogAccessorCallbacks(); | 517 isolate->logger()->LogAccessorCallbacks(); |
| 513 } | 518 } |
| 514 // Enable stack sampling. | 519 // Enable stack sampling. |
| 515 Sampler* sampler = reinterpret_cast<Sampler*>(LOGGER->ticker_); | 520 Sampler* sampler = reinterpret_cast<Sampler*>(isolate->logger()->ticker_); |
| 516 if (!sampler->IsActive()) { | 521 if (!sampler->IsActive()) { |
| 517 sampler->Start(); | 522 sampler->Start(); |
| 518 need_to_stop_sampler_ = true; | 523 need_to_stop_sampler_ = true; |
| 519 } | 524 } |
| 520 sampler->IncreaseProfilingDepth(); | 525 sampler->IncreaseProfilingDepth(); |
| 521 } | 526 } |
| 522 } | 527 } |
| 523 | 528 |
| 524 | 529 |
| 525 CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) { | 530 CpuProfile* CpuProfiler::StopCollectingProfile(const char* title) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 545 return profiles_->StopProfiling(token, profile_title, actual_sampling_rate); | 550 return profiles_->StopProfiling(token, profile_title, actual_sampling_rate); |
| 546 } | 551 } |
| 547 | 552 |
| 548 | 553 |
| 549 void CpuProfiler::StopProcessorIfLastProfile(const char* title) { | 554 void CpuProfiler::StopProcessorIfLastProfile(const char* title) { |
| 550 if (profiles_->IsLastProfile(title)) StopProcessor(); | 555 if (profiles_->IsLastProfile(title)) StopProcessor(); |
| 551 } | 556 } |
| 552 | 557 |
| 553 | 558 |
| 554 void CpuProfiler::StopProcessor() { | 559 void CpuProfiler::StopProcessor() { |
| 555 Sampler* sampler = reinterpret_cast<Sampler*>(LOGGER->ticker_); | 560 Logger* logger = Isolate::Current()->logger(); |
| 561 Sampler* sampler = reinterpret_cast<Sampler*>(logger->ticker_); |
| 556 sampler->DecreaseProfilingDepth(); | 562 sampler->DecreaseProfilingDepth(); |
| 557 if (need_to_stop_sampler_) { | 563 if (need_to_stop_sampler_) { |
| 558 sampler->Stop(); | 564 sampler->Stop(); |
| 559 need_to_stop_sampler_ = false; | 565 need_to_stop_sampler_ = false; |
| 560 } | 566 } |
| 561 processor_->Stop(); | 567 processor_->Stop(); |
| 562 processor_->Join(); | 568 processor_->Join(); |
| 563 delete processor_; | 569 delete processor_; |
| 564 delete generator_; | 570 delete generator_; |
| 565 processor_ = NULL; | 571 processor_ = NULL; |
| 566 NoBarrier_Store(&is_profiling_, false); | 572 NoBarrier_Store(&is_profiling_, false); |
| 567 generator_ = NULL; | 573 generator_ = NULL; |
| 568 LOGGER->logging_nesting_ = saved_logging_nesting_; | 574 logger->logging_nesting_ = saved_logging_nesting_; |
| 569 } | 575 } |
| 570 | 576 |
| 571 } } // namespace v8::internal | 577 } } // namespace v8::internal |
| 572 | 578 |
| 573 #endif // ENABLE_LOGGING_AND_PROFILING | 579 #endif // ENABLE_LOGGING_AND_PROFILING |
| 574 | 580 |
| 575 namespace v8 { | 581 namespace v8 { |
| 576 namespace internal { | 582 namespace internal { |
| 577 | 583 |
| 578 void CpuProfiler::Setup() { | 584 void CpuProfiler::Setup() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 589 #ifdef ENABLE_LOGGING_AND_PROFILING | 595 #ifdef ENABLE_LOGGING_AND_PROFILING |
| 590 Isolate* isolate = Isolate::Current(); | 596 Isolate* isolate = Isolate::Current(); |
| 591 if (isolate->cpu_profiler() != NULL) { | 597 if (isolate->cpu_profiler() != NULL) { |
| 592 delete isolate->cpu_profiler(); | 598 delete isolate->cpu_profiler(); |
| 593 } | 599 } |
| 594 isolate->set_cpu_profiler(NULL); | 600 isolate->set_cpu_profiler(NULL); |
| 595 #endif | 601 #endif |
| 596 } | 602 } |
| 597 | 603 |
| 598 } } // namespace v8::internal | 604 } } // namespace v8::internal |
| OLD | NEW |