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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 446 } |
447 | 447 |
448 | 448 |
449 class Thread::PlatformData : public Malloced { | 449 class Thread::PlatformData : public Malloced { |
450 public: | 450 public: |
451 PlatformData() : thread_(kNoThread) { } | 451 PlatformData() : thread_(kNoThread) { } |
452 | 452 |
453 pthread_t thread_; // Thread handle for pthread. | 453 pthread_t thread_; // Thread handle for pthread. |
454 }; | 454 }; |
455 | 455 |
| 456 |
456 Thread::Thread(const Options& options) | 457 Thread::Thread(const Options& options) |
457 : data_(new PlatformData()), | 458 : data_(new PlatformData()), |
458 stack_size_(options.stack_size) { | 459 stack_size_(options.stack_size()) { |
459 set_name(options.name); | 460 set_name(options.name()); |
460 } | |
461 | |
462 | |
463 Thread::Thread(const char* name) | |
464 : data_(new PlatformData()), | |
465 stack_size_(0) { | |
466 set_name(name); | |
467 } | 461 } |
468 | 462 |
469 | 463 |
470 Thread::~Thread() { | 464 Thread::~Thread() { |
471 delete data_; | 465 delete data_; |
472 } | 466 } |
473 | 467 |
474 | 468 |
475 static void* ThreadEntry(void* arg) { | 469 static void* ThreadEntry(void* arg) { |
476 Thread* thread = reinterpret_cast<Thread*>(arg); | 470 Thread* thread = reinterpret_cast<Thread*>(arg); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 }; | 697 }; |
704 | 698 |
705 | 699 |
706 class SignalSender : public Thread { | 700 class SignalSender : public Thread { |
707 public: | 701 public: |
708 enum SleepInterval { | 702 enum SleepInterval { |
709 HALF_INTERVAL, | 703 HALF_INTERVAL, |
710 FULL_INTERVAL | 704 FULL_INTERVAL |
711 }; | 705 }; |
712 | 706 |
| 707 static const int kSignalSenderStackSize = 32 * KB; |
| 708 |
713 explicit SignalSender(int interval) | 709 explicit SignalSender(int interval) |
714 : Thread("SignalSender"), | 710 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), |
715 interval_(interval) {} | 711 interval_(interval) {} |
716 | 712 |
717 static void InstallSignalHandler() { | 713 static void InstallSignalHandler() { |
718 struct sigaction sa; | 714 struct sigaction sa; |
719 sa.sa_sigaction = ProfilerSignalHandler; | 715 sa.sa_sigaction = ProfilerSignalHandler; |
720 sigemptyset(&sa.sa_mask); | 716 sigemptyset(&sa.sa_mask); |
721 sa.sa_flags = SA_RESTART | SA_SIGINFO; | 717 sa.sa_flags = SA_RESTART | SA_SIGINFO; |
722 signal_handler_installed_ = | 718 signal_handler_installed_ = |
723 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); | 719 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); |
724 } | 720 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 } | 872 } |
877 | 873 |
878 | 874 |
879 void Sampler::Stop() { | 875 void Sampler::Stop() { |
880 ASSERT(IsActive()); | 876 ASSERT(IsActive()); |
881 SignalSender::RemoveActiveSampler(this); | 877 SignalSender::RemoveActiveSampler(this); |
882 SetActive(false); | 878 SetActive(false); |
883 } | 879 } |
884 | 880 |
885 } } // namespace v8::internal | 881 } } // namespace v8::internal |
OLD | NEW |