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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 | 713 |
714 class Thread::PlatformData : public Malloced { | 714 class Thread::PlatformData : public Malloced { |
715 public: | 715 public: |
716 PlatformData() : thread_(kNoThread) {} | 716 PlatformData() : thread_(kNoThread) {} |
717 | 717 |
718 pthread_t thread_; // Thread handle for pthread. | 718 pthread_t thread_; // Thread handle for pthread. |
719 }; | 719 }; |
720 | 720 |
721 Thread::Thread(const Options& options) | 721 Thread::Thread(const Options& options) |
722 : data_(new PlatformData()), | 722 : data_(new PlatformData()), |
723 stack_size_(options.stack_size()) { | 723 stack_size_(options.stack_size) { |
724 set_name(options.name()); | 724 set_name(options.name); |
| 725 } |
| 726 |
| 727 |
| 728 Thread::Thread(const char* name) |
| 729 : data_(new PlatformData()), |
| 730 stack_size_(0) { |
| 731 set_name(name); |
725 } | 732 } |
726 | 733 |
727 | 734 |
728 Thread::~Thread() { | 735 Thread::~Thread() { |
729 delete data_; | 736 delete data_; |
730 } | 737 } |
731 | 738 |
732 | 739 |
733 static void* ThreadEntry(void* arg) { | 740 static void* ThreadEntry(void* arg) { |
734 Thread* thread = reinterpret_cast<Thread*>(arg); | 741 Thread* thread = reinterpret_cast<Thread*>(arg); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 }; | 1028 }; |
1022 | 1029 |
1023 | 1030 |
1024 class SignalSender : public Thread { | 1031 class SignalSender : public Thread { |
1025 public: | 1032 public: |
1026 enum SleepInterval { | 1033 enum SleepInterval { |
1027 HALF_INTERVAL, | 1034 HALF_INTERVAL, |
1028 FULL_INTERVAL | 1035 FULL_INTERVAL |
1029 }; | 1036 }; |
1030 | 1037 |
1031 static const int kSignalSenderStackSize = 32 * KB; | |
1032 | |
1033 explicit SignalSender(int interval) | 1038 explicit SignalSender(int interval) |
1034 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), | 1039 : Thread("SignalSender"), |
1035 vm_tgid_(getpid()), | 1040 vm_tgid_(getpid()), |
1036 interval_(interval) {} | 1041 interval_(interval) {} |
1037 | 1042 |
1038 static void InstallSignalHandler() { | 1043 static void InstallSignalHandler() { |
1039 struct sigaction sa; | 1044 struct sigaction sa; |
1040 sa.sa_sigaction = ProfilerSignalHandler; | 1045 sa.sa_sigaction = ProfilerSignalHandler; |
1041 sigemptyset(&sa.sa_mask); | 1046 sigemptyset(&sa.sa_mask); |
1042 sa.sa_flags = SA_RESTART | SA_SIGINFO; | 1047 sa.sa_flags = SA_RESTART | SA_SIGINFO; |
1043 signal_handler_installed_ = | 1048 signal_handler_installed_ = |
1044 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); | 1049 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 | 1212 |
1208 | 1213 |
1209 void Sampler::Stop() { | 1214 void Sampler::Stop() { |
1210 ASSERT(IsActive()); | 1215 ASSERT(IsActive()); |
1211 SignalSender::RemoveActiveSampler(this); | 1216 SignalSender::RemoveActiveSampler(this); |
1212 SetActive(false); | 1217 SetActive(false); |
1213 } | 1218 } |
1214 | 1219 |
1215 | 1220 |
1216 } } // namespace v8::internal | 1221 } } // namespace v8::internal |
OLD | NEW |