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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 } | 362 } |
363 | 363 |
364 | 364 |
365 class Thread::PlatformData : public Malloced { | 365 class Thread::PlatformData : public Malloced { |
366 public: | 366 public: |
367 PlatformData() : thread_(kNoThread) { } | 367 PlatformData() : thread_(kNoThread) { } |
368 | 368 |
369 pthread_t thread_; // Thread handle for pthread. | 369 pthread_t thread_; // Thread handle for pthread. |
370 }; | 370 }; |
371 | 371 |
372 | |
373 Thread::Thread(const Options& options) | 372 Thread::Thread(const Options& options) |
374 : data_(new PlatformData()), | 373 : data_(new PlatformData()), |
375 stack_size_(options.stack_size()) { | 374 stack_size_(options.stack_size) { |
376 set_name(options.name()); | 375 set_name(options.name); |
| 376 } |
| 377 |
| 378 |
| 379 Thread::Thread(const char* name) |
| 380 : data_(new PlatformData()), |
| 381 stack_size_(0) { |
| 382 set_name(name); |
377 } | 383 } |
378 | 384 |
379 | 385 |
380 Thread::~Thread() { | 386 Thread::~Thread() { |
381 delete data_; | 387 delete data_; |
382 } | 388 } |
383 | 389 |
384 | 390 |
385 static void* ThreadEntry(void* arg) { | 391 static void* ThreadEntry(void* arg) { |
386 Thread* thread = reinterpret_cast<Thread*>(arg); | 392 Thread* thread = reinterpret_cast<Thread*>(arg); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 }; | 619 }; |
614 | 620 |
615 | 621 |
616 class SignalSender : public Thread { | 622 class SignalSender : public Thread { |
617 public: | 623 public: |
618 enum SleepInterval { | 624 enum SleepInterval { |
619 HALF_INTERVAL, | 625 HALF_INTERVAL, |
620 FULL_INTERVAL | 626 FULL_INTERVAL |
621 }; | 627 }; |
622 | 628 |
623 static const int kSignalSenderStackSize = 32 * KB; | |
624 | |
625 explicit SignalSender(int interval) | 629 explicit SignalSender(int interval) |
626 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), | 630 : Thread("SignalSender"), |
627 interval_(interval) {} | 631 interval_(interval) {} |
628 | 632 |
629 static void InstallSignalHandler() { | 633 static void InstallSignalHandler() { |
630 struct sigaction sa; | 634 struct sigaction sa; |
631 sa.sa_sigaction = ProfilerSignalHandler; | 635 sa.sa_sigaction = ProfilerSignalHandler; |
632 sigemptyset(&sa.sa_mask); | 636 sigemptyset(&sa.sa_mask); |
633 sa.sa_flags = SA_RESTART | SA_SIGINFO; | 637 sa.sa_flags = SA_RESTART | SA_SIGINFO; |
634 signal_handler_installed_ = | 638 signal_handler_installed_ = |
635 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); | 639 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); |
636 } | 640 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 } | 791 } |
788 | 792 |
789 | 793 |
790 void Sampler::Stop() { | 794 void Sampler::Stop() { |
791 ASSERT(IsActive()); | 795 ASSERT(IsActive()); |
792 SignalSender::RemoveActiveSampler(this); | 796 SignalSender::RemoveActiveSampler(this); |
793 SetActive(false); | 797 SetActive(false); |
794 } | 798 } |
795 | 799 |
796 } } // namespace v8::internal | 800 } } // namespace v8::internal |
OLD | NEW |