| OLD | NEW |
| 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 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); | |
| 476 } | 469 } |
| 477 | 470 |
| 478 | 471 |
| 479 Thread::~Thread() { | 472 Thread::~Thread() { |
| 480 delete data_; | 473 delete data_; |
| 481 } | 474 } |
| 482 | 475 |
| 483 | 476 |
| 484 static void* ThreadEntry(void* arg) { | 477 static void* ThreadEntry(void* arg) { |
| 485 Thread* thread = reinterpret_cast<Thread*>(arg); | 478 Thread* thread = reinterpret_cast<Thread*>(arg); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 } | 703 } |
| 711 | 704 |
| 712 | 705 |
| 713 class SignalSender : public Thread { | 706 class SignalSender : public Thread { |
| 714 public: | 707 public: |
| 715 enum SleepInterval { | 708 enum SleepInterval { |
| 716 HALF_INTERVAL, | 709 HALF_INTERVAL, |
| 717 FULL_INTERVAL | 710 FULL_INTERVAL |
| 718 }; | 711 }; |
| 719 | 712 |
| 713 static const int kSignalSenderStackSize = 32 * KB; |
| 714 |
| 720 explicit SignalSender(int interval) | 715 explicit SignalSender(int interval) |
| 721 : Thread("SignalSender"), | 716 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), |
| 722 interval_(interval) {} | 717 interval_(interval) {} |
| 723 | 718 |
| 724 static void AddActiveSampler(Sampler* sampler) { | 719 static void AddActiveSampler(Sampler* sampler) { |
| 725 ScopedLock lock(mutex_); | 720 ScopedLock lock(mutex_); |
| 726 SamplerRegistry::AddActiveSampler(sampler); | 721 SamplerRegistry::AddActiveSampler(sampler); |
| 727 if (instance_ == NULL) { | 722 if (instance_ == NULL) { |
| 728 // Install a signal handler. | 723 // Install a signal handler. |
| 729 struct sigaction sa; | 724 struct sigaction sa; |
| 730 sa.sa_sigaction = ProfilerSignalHandler; | 725 sa.sa_sigaction = ProfilerSignalHandler; |
| 731 sigemptyset(&sa.sa_mask); | 726 sigemptyset(&sa.sa_mask); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 | 869 |
| 875 | 870 |
| 876 void Sampler::Stop() { | 871 void Sampler::Stop() { |
| 877 ASSERT(IsActive()); | 872 ASSERT(IsActive()); |
| 878 SignalSender::RemoveActiveSampler(this); | 873 SignalSender::RemoveActiveSampler(this); |
| 879 SetActive(false); | 874 SetActive(false); |
| 880 } | 875 } |
| 881 | 876 |
| 882 | 877 |
| 883 } } // namespace v8::internal | 878 } } // namespace v8::internal |
| OLD | NEW |