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