| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 505 |
| 506 class Thread::PlatformData : public Malloced { | 506 class Thread::PlatformData : public Malloced { |
| 507 public: | 507 public: |
| 508 PlatformData() : thread_(kNoThread) {} | 508 PlatformData() : thread_(kNoThread) {} |
| 509 | 509 |
| 510 pthread_t thread_; // Thread handle for pthread. | 510 pthread_t thread_; // Thread handle for pthread. |
| 511 }; | 511 }; |
| 512 | 512 |
| 513 Thread::Thread(const Options& options) | 513 Thread::Thread(const Options& options) |
| 514 : data_(new PlatformData()), | 514 : data_(new PlatformData()), |
| 515 stack_size_(options.stack_size()) { | 515 stack_size_(options.stack_size) { |
| 516 set_name(options.name()); | 516 set_name(options.name); |
| 517 } |
| 518 |
| 519 |
| 520 Thread::Thread(const char* name) |
| 521 : data_(new PlatformData()), |
| 522 stack_size_(0) { |
| 523 set_name(name); |
| 517 } | 524 } |
| 518 | 525 |
| 519 | 526 |
| 520 Thread::~Thread() { | 527 Thread::~Thread() { |
| 521 delete data_; | 528 delete data_; |
| 522 } | 529 } |
| 523 | 530 |
| 524 | 531 |
| 525 static void* ThreadEntry(void* arg) { | 532 static void* ThreadEntry(void* arg) { |
| 526 Thread* thread = reinterpret_cast<Thread*>(arg); | 533 Thread* thread = reinterpret_cast<Thread*>(arg); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 }; | 782 }; |
| 776 | 783 |
| 777 | 784 |
| 778 class SignalSender : public Thread { | 785 class SignalSender : public Thread { |
| 779 public: | 786 public: |
| 780 enum SleepInterval { | 787 enum SleepInterval { |
| 781 HALF_INTERVAL, | 788 HALF_INTERVAL, |
| 782 FULL_INTERVAL | 789 FULL_INTERVAL |
| 783 }; | 790 }; |
| 784 | 791 |
| 785 static const int kSignalSenderStackSize = 32 * KB; | |
| 786 | |
| 787 explicit SignalSender(int interval) | 792 explicit SignalSender(int interval) |
| 788 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), | 793 : Thread("SignalSender"), |
| 789 vm_tgid_(getpid()), | 794 vm_tgid_(getpid()), |
| 790 interval_(interval) {} | 795 interval_(interval) {} |
| 791 | 796 |
| 792 static void InstallSignalHandler() { | 797 static void InstallSignalHandler() { |
| 793 struct sigaction sa; | 798 struct sigaction sa; |
| 794 sa.sa_sigaction = ProfilerSignalHandler; | 799 sa.sa_sigaction = ProfilerSignalHandler; |
| 795 sigemptyset(&sa.sa_mask); | 800 sigemptyset(&sa.sa_mask); |
| 796 sa.sa_flags = SA_RESTART | SA_SIGINFO; | 801 sa.sa_flags = SA_RESTART | SA_SIGINFO; |
| 797 signal_handler_installed_ = | 802 signal_handler_installed_ = |
| 798 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); | 803 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 | 957 |
| 953 | 958 |
| 954 void Sampler::Stop() { | 959 void Sampler::Stop() { |
| 955 ASSERT(IsActive()); | 960 ASSERT(IsActive()); |
| 956 SignalSender::RemoveActiveSampler(this); | 961 SignalSender::RemoveActiveSampler(this); |
| 957 SetActive(false); | 962 SetActive(false); |
| 958 } | 963 } |
| 959 | 964 |
| 960 | 965 |
| 961 } } // namespace v8::internal | 966 } } // namespace v8::internal |
| OLD | NEW |