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

Side by Side Diff: src/platform-freebsd.cc

Issue 13627002: Add sanity test for CPU profiler (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Start sampler and processor threads synchronously Created 7 years, 8 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 | « src/platform-cygwin.cc ('k') | src/platform-linux.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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 493
494 494
495 class Thread::PlatformData : public Malloced { 495 class Thread::PlatformData : public Malloced {
496 public: 496 public:
497 pthread_t thread_; // Thread handle for pthread. 497 pthread_t thread_; // Thread handle for pthread.
498 }; 498 };
499 499
500 500
501 Thread::Thread(const Options& options) 501 Thread::Thread(const Options& options)
502 : data_(new PlatformData), 502 : data_(new PlatformData),
503 stack_size_(options.stack_size()) { 503 stack_size_(options.stack_size()),
504 start_semaphore_(NULL) {
504 set_name(options.name()); 505 set_name(options.name());
505 } 506 }
506 507
507 508
508 Thread::~Thread() { 509 Thread::~Thread() {
509 delete data_; 510 delete data_;
510 } 511 }
511 512
512 513
513 static void* ThreadEntry(void* arg) { 514 static void* ThreadEntry(void* arg) {
514 Thread* thread = reinterpret_cast<Thread*>(arg); 515 Thread* thread = reinterpret_cast<Thread*>(arg);
515 // This is also initialized by the first argument to pthread_create() but we 516 // This is also initialized by the first argument to pthread_create() but we
516 // don't know which thread will run first (the original thread or the new 517 // don't know which thread will run first (the original thread or the new
517 // one) so we initialize it here too. 518 // one) so we initialize it here too.
518 thread->data()->thread_ = pthread_self(); 519 thread->data()->thread_ = pthread_self();
519 ASSERT(thread->data()->thread_ != kNoThread); 520 ASSERT(thread->data()->thread_ != kNoThread);
520 thread->Run(); 521 thread->NotifyStartedAndRun();
521 return NULL; 522 return NULL;
522 } 523 }
523 524
524 525
525 void Thread::set_name(const char* name) { 526 void Thread::set_name(const char* name) {
526 strncpy(name_, name, sizeof(name_)); 527 strncpy(name_, name, sizeof(name_));
527 name_[sizeof(name_) - 1] = '\0'; 528 name_[sizeof(name_) - 1] = '\0';
528 } 529 }
529 530
530 531
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 // Install a signal handler. 759 // Install a signal handler.
759 struct sigaction sa; 760 struct sigaction sa;
760 sa.sa_sigaction = ProfilerSignalHandler; 761 sa.sa_sigaction = ProfilerSignalHandler;
761 sigemptyset(&sa.sa_mask); 762 sigemptyset(&sa.sa_mask);
762 sa.sa_flags = SA_RESTART | SA_SIGINFO; 763 sa.sa_flags = SA_RESTART | SA_SIGINFO;
763 signal_handler_installed_ = 764 signal_handler_installed_ =
764 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); 765 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0);
765 766
766 // Start a thread that sends SIGPROF signal to VM threads. 767 // Start a thread that sends SIGPROF signal to VM threads.
767 instance_ = new SignalSender(sampler->interval()); 768 instance_ = new SignalSender(sampler->interval());
768 instance_->Start(); 769 instance_->StartSynchronously();
769 } else { 770 } else {
770 ASSERT(instance_->interval_ == sampler->interval()); 771 ASSERT(instance_->interval_ == sampler->interval());
771 } 772 }
772 } 773 }
773 774
774 static void RemoveActiveSampler(Sampler* sampler) { 775 static void RemoveActiveSampler(Sampler* sampler) {
775 ScopedLock lock(mutex_); 776 ScopedLock lock(mutex_);
776 SamplerRegistry::RemoveActiveSampler(sampler); 777 SamplerRegistry::RemoveActiveSampler(sampler);
777 if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) { 778 if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) {
778 RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(instance_); 779 RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(instance_);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 893
893 894
894 void Sampler::Stop() { 895 void Sampler::Stop() {
895 ASSERT(IsActive()); 896 ASSERT(IsActive());
896 SignalSender::RemoveActiveSampler(this); 897 SignalSender::RemoveActiveSampler(this);
897 SetActive(false); 898 SetActive(false);
898 } 899 }
899 900
900 901
901 } } // namespace v8::internal 902 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-cygwin.cc ('k') | src/platform-linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698