OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 | 457 |
458 | 458 |
459 class Thread::PlatformData : public Malloced { | 459 class Thread::PlatformData : public Malloced { |
460 public: | 460 public: |
461 pthread_t thread_; // Thread handle for pthread. | 461 pthread_t thread_; // Thread handle for pthread. |
462 }; | 462 }; |
463 | 463 |
464 | 464 |
465 Thread::Thread(const Options& options) | 465 Thread::Thread(const Options& options) |
466 : data_(new PlatformData), | 466 : data_(new PlatformData), |
467 stack_size_(options.stack_size()) { | 467 stack_size_(options.stack_size) { |
468 set_name(options.name()); | 468 set_name(options.name); |
| 469 } |
| 470 |
| 471 |
| 472 Thread::Thread(const char* name) |
| 473 : data_(new PlatformData), |
| 474 stack_size_(0) { |
| 475 set_name(name); |
469 } | 476 } |
470 | 477 |
471 | 478 |
472 Thread::~Thread() { | 479 Thread::~Thread() { |
473 delete data_; | 480 delete data_; |
474 } | 481 } |
475 | 482 |
476 | 483 |
477 static void* ThreadEntry(void* arg) { | 484 static void* ThreadEntry(void* arg) { |
478 Thread* thread = reinterpret_cast<Thread*>(arg); | 485 Thread* thread = reinterpret_cast<Thread*>(arg); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 } | 710 } |
704 | 711 |
705 | 712 |
706 class SignalSender : public Thread { | 713 class SignalSender : public Thread { |
707 public: | 714 public: |
708 enum SleepInterval { | 715 enum SleepInterval { |
709 HALF_INTERVAL, | 716 HALF_INTERVAL, |
710 FULL_INTERVAL | 717 FULL_INTERVAL |
711 }; | 718 }; |
712 | 719 |
713 static const int kSignalSenderStackSize = 32 * KB; | |
714 | |
715 explicit SignalSender(int interval) | 720 explicit SignalSender(int interval) |
716 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), | 721 : Thread("SignalSender"), |
717 interval_(interval) {} | 722 interval_(interval) {} |
718 | 723 |
719 static void AddActiveSampler(Sampler* sampler) { | 724 static void AddActiveSampler(Sampler* sampler) { |
720 ScopedLock lock(mutex_); | 725 ScopedLock lock(mutex_); |
721 SamplerRegistry::AddActiveSampler(sampler); | 726 SamplerRegistry::AddActiveSampler(sampler); |
722 if (instance_ == NULL) { | 727 if (instance_ == NULL) { |
723 // Install a signal handler. | 728 // Install a signal handler. |
724 struct sigaction sa; | 729 struct sigaction sa; |
725 sa.sa_sigaction = ProfilerSignalHandler; | 730 sa.sa_sigaction = ProfilerSignalHandler; |
726 sigemptyset(&sa.sa_mask); | 731 sigemptyset(&sa.sa_mask); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 | 873 |
869 | 874 |
870 void Sampler::Stop() { | 875 void Sampler::Stop() { |
871 ASSERT(IsActive()); | 876 ASSERT(IsActive()); |
872 SignalSender::RemoveActiveSampler(this); | 877 SignalSender::RemoveActiveSampler(this); |
873 SetActive(false); | 878 SetActive(false); |
874 } | 879 } |
875 | 880 |
876 | 881 |
877 } } // namespace v8::internal | 882 } } // namespace v8::internal |
OLD | NEW |