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); | |
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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 }; | 762 }; |
770 | 763 |
771 | 764 |
772 class SignalSender : public Thread { | 765 class SignalSender : public Thread { |
773 public: | 766 public: |
774 enum SleepInterval { | 767 enum SleepInterval { |
775 HALF_INTERVAL, | 768 HALF_INTERVAL, |
776 FULL_INTERVAL | 769 FULL_INTERVAL |
777 }; | 770 }; |
778 | 771 |
| 772 static const int kSignalSenderStackSize = 32 * KB; |
| 773 |
779 explicit SignalSender(int interval) | 774 explicit SignalSender(int interval) |
780 : Thread("SignalSender"), | 775 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), |
781 vm_tgid_(getpid()), | 776 vm_tgid_(getpid()), |
782 interval_(interval) {} | 777 interval_(interval) {} |
783 | 778 |
784 static void InstallSignalHandler() { | 779 static void InstallSignalHandler() { |
785 struct sigaction sa; | 780 struct sigaction sa; |
786 sa.sa_sigaction = ProfilerSignalHandler; | 781 sa.sa_sigaction = ProfilerSignalHandler; |
787 sigemptyset(&sa.sa_mask); | 782 sigemptyset(&sa.sa_mask); |
788 sa.sa_flags = SA_RESTART | SA_SIGINFO; | 783 sa.sa_flags = SA_RESTART | SA_SIGINFO; |
789 signal_handler_installed_ = | 784 signal_handler_installed_ = |
790 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); | 785 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 | 939 |
945 | 940 |
946 void Sampler::Stop() { | 941 void Sampler::Stop() { |
947 ASSERT(IsActive()); | 942 ASSERT(IsActive()); |
948 SignalSender::RemoveActiveSampler(this); | 943 SignalSender::RemoveActiveSampler(this); |
949 SetActive(false); | 944 SetActive(false); |
950 } | 945 } |
951 | 946 |
952 | 947 |
953 } } // namespace v8::internal | 948 } } // namespace v8::internal |
OLD | NEW |