Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: src/cpu-profiler.cc

Issue 18336002: Test that profiler is stopped when isolate is being disposed (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Updated v8.h comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-cpu-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 next_profile_uid_(1), 418 next_profile_uid_(1),
419 token_enumerator_(new TokenEnumerator()), 419 token_enumerator_(new TokenEnumerator()),
420 generator_(NULL), 420 generator_(NULL),
421 processor_(NULL), 421 processor_(NULL),
422 need_to_stop_sampler_(false), 422 need_to_stop_sampler_(false),
423 is_profiling_(false) { 423 is_profiling_(false) {
424 } 424 }
425 425
426 426
427 CpuProfiler::~CpuProfiler() { 427 CpuProfiler::~CpuProfiler() {
428 ASSERT(!is_profiling_);
428 delete token_enumerator_; 429 delete token_enumerator_;
429 delete profiles_; 430 delete profiles_;
430 } 431 }
431 432
432 433
433 void CpuProfiler::ResetProfiles() { 434 void CpuProfiler::ResetProfiles() {
434 delete profiles_; 435 delete profiles_;
435 profiles_ = new CpuProfilesCollection(); 436 profiles_ = new CpuProfilesCollection();
436 } 437 }
437 438
438 void CpuProfiler::StartProfiling(const char* title, bool record_samples) { 439 void CpuProfiler::StartProfiling(const char* title, bool record_samples) {
439 if (profiles_->StartProfiling(title, next_profile_uid_++, record_samples)) { 440 if (profiles_->StartProfiling(title, next_profile_uid_++, record_samples)) {
440 StartProcessorIfNotStarted(); 441 StartProcessorIfNotStarted();
441 } 442 }
442 processor_->AddCurrentStack(); 443 processor_->AddCurrentStack();
443 } 444 }
444 445
445 446
446 void CpuProfiler::StartProfiling(String* title, bool record_samples) { 447 void CpuProfiler::StartProfiling(String* title, bool record_samples) {
447 StartProfiling(profiles_->GetName(title), record_samples); 448 StartProfiling(profiles_->GetName(title), record_samples);
448 } 449 }
449 450
450 451
451 void CpuProfiler::StartProcessorIfNotStarted() { 452 void CpuProfiler::StartProcessorIfNotStarted() {
452 if (processor_ == NULL) { 453 if (processor_ == NULL) {
454 Logger* logger = isolate_->logger();
453 // Disable logging when using the new implementation. 455 // Disable logging when using the new implementation.
454 saved_logging_nesting_ = isolate_->logger()->logging_nesting_; 456 saved_logging_nesting_ = logger->logging_nesting_;
455 isolate_->logger()->logging_nesting_ = 0; 457 logger->logging_nesting_ = 0;
456 generator_ = new ProfileGenerator(profiles_); 458 generator_ = new ProfileGenerator(profiles_);
457 processor_ = new ProfilerEventsProcessor(generator_, profiles_); 459 processor_ = new ProfilerEventsProcessor(generator_, profiles_);
458 is_profiling_ = true; 460 is_profiling_ = true;
459 processor_->StartSynchronously(); 461 processor_->StartSynchronously();
460 // Enumerate stuff we already have in the heap. 462 // Enumerate stuff we already have in the heap.
461 if (isolate_->heap()->HasBeenSetUp()) { 463 ASSERT(isolate_->heap()->HasBeenSetUp());
462 if (!FLAG_prof_browser_mode) { 464 if (!FLAG_prof_browser_mode) {
463 isolate_->logger()->LogCodeObjects(); 465 logger->LogCodeObjects();
464 }
465 isolate_->logger()->LogCompiledFunctions();
466 isolate_->logger()->LogAccessorCallbacks();
467 } 466 }
467 logger->LogCompiledFunctions();
468 logger->LogAccessorCallbacks();
468 // Enable stack sampling. 469 // Enable stack sampling.
469 Sampler* sampler = isolate_->logger()->sampler(); 470 Sampler* sampler = logger->sampler();
470 sampler->IncreaseProfilingDepth(); 471 sampler->IncreaseProfilingDepth();
471 if (!sampler->IsActive()) { 472 if (!sampler->IsActive()) {
472 sampler->Start(); 473 sampler->Start();
473 need_to_stop_sampler_ = true; 474 need_to_stop_sampler_ = true;
474 } 475 }
475 } 476 }
476 } 477 }
477 478
478 479
479 CpuProfile* CpuProfiler::StopProfiling(const char* title) { 480 CpuProfile* CpuProfiler::StopProfiling(const char* title) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 processor_->Join(); 520 processor_->Join();
520 delete processor_; 521 delete processor_;
521 delete generator_; 522 delete generator_;
522 processor_ = NULL; 523 processor_ = NULL;
523 generator_ = NULL; 524 generator_ = NULL;
524 logger->logging_nesting_ = saved_logging_nesting_; 525 logger->logging_nesting_ = saved_logging_nesting_;
525 } 526 }
526 527
527 528
528 } } // namespace v8::internal 529 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698