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

Side by Side Diff: src/platform-openbsd.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-nullos.cc ('k') | src/platform-solaris.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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 522
523 class Thread::PlatformData : public Malloced { 523 class Thread::PlatformData : public Malloced {
524 public: 524 public:
525 PlatformData() : thread_(kNoThread) {} 525 PlatformData() : thread_(kNoThread) {}
526 526
527 pthread_t thread_; // Thread handle for pthread. 527 pthread_t thread_; // Thread handle for pthread.
528 }; 528 };
529 529
530 Thread::Thread(const Options& options) 530 Thread::Thread(const Options& options)
531 : data_(new PlatformData()), 531 : data_(new PlatformData()),
532 stack_size_(options.stack_size()) { 532 stack_size_(options.stack_size()),
533 start_semaphore_(NULL) {
533 set_name(options.name()); 534 set_name(options.name());
534 } 535 }
535 536
536 537
537 Thread::~Thread() { 538 Thread::~Thread() {
538 delete data_; 539 delete data_;
539 } 540 }
540 541
541 542
542 static void* ThreadEntry(void* arg) { 543 static void* ThreadEntry(void* arg) {
543 Thread* thread = reinterpret_cast<Thread*>(arg); 544 Thread* thread = reinterpret_cast<Thread*>(arg);
544 // This is also initialized by the first argument to pthread_create() but we 545 // This is also initialized by the first argument to pthread_create() but we
545 // don't know which thread will run first (the original thread or the new 546 // don't know which thread will run first (the original thread or the new
546 // one) so we initialize it here too. 547 // one) so we initialize it here too.
547 #ifdef PR_SET_NAME 548 #ifdef PR_SET_NAME
548 prctl(PR_SET_NAME, 549 prctl(PR_SET_NAME,
549 reinterpret_cast<unsigned long>(thread->name()), // NOLINT 550 reinterpret_cast<unsigned long>(thread->name()), // NOLINT
550 0, 0, 0); 551 0, 0, 0);
551 #endif 552 #endif
552 thread->data()->thread_ = pthread_self(); 553 thread->data()->thread_ = pthread_self();
553 ASSERT(thread->data()->thread_ != kNoThread); 554 ASSERT(thread->data()->thread_ != kNoThread);
554 thread->Run(); 555 thread->NotifyStartedAndRun();
555 return NULL; 556 return NULL;
556 } 557 }
557 558
558 559
559 void Thread::set_name(const char* name) { 560 void Thread::set_name(const char* name) {
560 strncpy(name_, name, sizeof(name_)); 561 strncpy(name_, name, sizeof(name_));
561 name_[sizeof(name_) - 1] = '\0'; 562 name_[sizeof(name_) - 1] = '\0';
562 } 563 }
563 564
564 565
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 } 821 }
821 } 822 }
822 823
823 static void AddActiveSampler(Sampler* sampler) { 824 static void AddActiveSampler(Sampler* sampler) {
824 ScopedLock lock(mutex_); 825 ScopedLock lock(mutex_);
825 SamplerRegistry::AddActiveSampler(sampler); 826 SamplerRegistry::AddActiveSampler(sampler);
826 if (instance_ == NULL) { 827 if (instance_ == NULL) {
827 // Start a thread that will send SIGPROF signal to VM threads, 828 // Start a thread that will send SIGPROF signal to VM threads,
828 // when CPU profiling will be enabled. 829 // when CPU profiling will be enabled.
829 instance_ = new SignalSender(sampler->interval()); 830 instance_ = new SignalSender(sampler->interval());
830 instance_->Start(); 831 instance_->StartSynchronously();
831 } else { 832 } else {
832 ASSERT(instance_->interval_ == sampler->interval()); 833 ASSERT(instance_->interval_ == sampler->interval());
833 } 834 }
834 } 835 }
835 836
836 static void RemoveActiveSampler(Sampler* sampler) { 837 static void RemoveActiveSampler(Sampler* sampler) {
837 ScopedLock lock(mutex_); 838 ScopedLock lock(mutex_);
838 SamplerRegistry::RemoveActiveSampler(sampler); 839 SamplerRegistry::RemoveActiveSampler(sampler);
839 if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) { 840 if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) {
840 RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(instance_); 841 RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(instance_);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 950
950 951
951 void Sampler::Stop() { 952 void Sampler::Stop() {
952 ASSERT(IsActive()); 953 ASSERT(IsActive());
953 SignalSender::RemoveActiveSampler(this); 954 SignalSender::RemoveActiveSampler(this);
954 SetActive(false); 955 SetActive(false);
955 } 956 }
956 957
957 958
958 } } // namespace v8::internal 959 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-nullos.cc ('k') | src/platform-solaris.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698