| 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 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); | |
| 524 } | 517 } |
| 525 | 518 |
| 526 | 519 |
| 527 Thread::~Thread() { | 520 Thread::~Thread() { |
| 528 delete data_; | 521 delete data_; |
| 529 } | 522 } |
| 530 | 523 |
| 531 | 524 |
| 532 static void* ThreadEntry(void* arg) { | 525 static void* ThreadEntry(void* arg) { |
| 533 Thread* thread = reinterpret_cast<Thread*>(arg); | 526 Thread* thread = reinterpret_cast<Thread*>(arg); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 }; | 775 }; |
| 783 | 776 |
| 784 | 777 |
| 785 class SignalSender : public Thread { | 778 class SignalSender : public Thread { |
| 786 public: | 779 public: |
| 787 enum SleepInterval { | 780 enum SleepInterval { |
| 788 HALF_INTERVAL, | 781 HALF_INTERVAL, |
| 789 FULL_INTERVAL | 782 FULL_INTERVAL |
| 790 }; | 783 }; |
| 791 | 784 |
| 785 static const int kSignalSenderStackSize = 32 * KB; |
| 786 |
| 792 explicit SignalSender(int interval) | 787 explicit SignalSender(int interval) |
| 793 : Thread("SignalSender"), | 788 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), |
| 794 vm_tgid_(getpid()), | 789 vm_tgid_(getpid()), |
| 795 interval_(interval) {} | 790 interval_(interval) {} |
| 796 | 791 |
| 797 static void InstallSignalHandler() { | 792 static void InstallSignalHandler() { |
| 798 struct sigaction sa; | 793 struct sigaction sa; |
| 799 sa.sa_sigaction = ProfilerSignalHandler; | 794 sa.sa_sigaction = ProfilerSignalHandler; |
| 800 sigemptyset(&sa.sa_mask); | 795 sigemptyset(&sa.sa_mask); |
| 801 sa.sa_flags = SA_RESTART | SA_SIGINFO; | 796 sa.sa_flags = SA_RESTART | SA_SIGINFO; |
| 802 signal_handler_installed_ = | 797 signal_handler_installed_ = |
| 803 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); | 798 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 | 953 |
| 959 | 954 |
| 960 void Sampler::Stop() { | 955 void Sampler::Stop() { |
| 961 ASSERT(IsActive()); | 956 ASSERT(IsActive()); |
| 962 SignalSender::RemoveActiveSampler(this); | 957 SignalSender::RemoveActiveSampler(this); |
| 963 SetActive(false); | 958 SetActive(false); |
| 964 } | 959 } |
| 965 | 960 |
| 966 | 961 |
| 967 } } // namespace v8::internal | 962 } } // namespace v8::internal |
| OLD | NEW |