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 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 HALF_INTERVAL, | 705 HALF_INTERVAL, |
706 FULL_INTERVAL | 706 FULL_INTERVAL |
707 }; | 707 }; |
708 | 708 |
709 static const int kSignalSenderStackSize = 64 * KB; | 709 static const int kSignalSenderStackSize = 64 * KB; |
710 | 710 |
711 explicit SignalSender(int interval) | 711 explicit SignalSender(int interval) |
712 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), | 712 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), |
713 interval_(interval) {} | 713 interval_(interval) {} |
714 | 714 |
715 static void SetUp() { | 715 static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); } |
716 if (!mutex_) { | 716 static void TearDown() { delete mutex_; } |
717 mutex_ = OS::CreateMutex(); | |
718 } | |
719 } | |
720 | 717 |
721 static void InstallSignalHandler() { | 718 static void InstallSignalHandler() { |
722 struct sigaction sa; | 719 struct sigaction sa; |
723 sa.sa_sigaction = ProfilerSignalHandler; | 720 sa.sa_sigaction = ProfilerSignalHandler; |
724 sigemptyset(&sa.sa_mask); | 721 sigemptyset(&sa.sa_mask); |
725 sa.sa_flags = SA_RESTART | SA_SIGINFO; | 722 sa.sa_flags = SA_RESTART | SA_SIGINFO; |
726 signal_handler_installed_ = | 723 signal_handler_installed_ = |
727 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); | 724 (sigaction(SIGPROF, &sa, &old_signal_handler_) == 0); |
728 } | 725 } |
729 | 726 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 // to an unsigned. Going directly will cause an overflow and the seed to be | 860 // to an unsigned. Going directly will cause an overflow and the seed to be |
864 // set to all ones. The seed will be identical for different instances that | 861 // set to all ones. The seed will be identical for different instances that |
865 // call this setup code within the same millisecond. | 862 // call this setup code within the same millisecond. |
866 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); | 863 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); |
867 srandom(static_cast<unsigned int>(seed)); | 864 srandom(static_cast<unsigned int>(seed)); |
868 limit_mutex = CreateMutex(); | 865 limit_mutex = CreateMutex(); |
869 SignalSender::SetUp(); | 866 SignalSender::SetUp(); |
870 } | 867 } |
871 | 868 |
872 | 869 |
| 870 void OS::TearDown() { |
| 871 SignalSender::TearDown(); |
| 872 delete limit_mutex; |
| 873 } |
| 874 |
| 875 |
873 Sampler::Sampler(Isolate* isolate, int interval) | 876 Sampler::Sampler(Isolate* isolate, int interval) |
874 : isolate_(isolate), | 877 : isolate_(isolate), |
875 interval_(interval), | 878 interval_(interval), |
876 profiling_(false), | 879 profiling_(false), |
877 active_(false), | 880 active_(false), |
878 samples_taken_(0) { | 881 samples_taken_(0) { |
879 data_ = new PlatformData; | 882 data_ = new PlatformData; |
880 } | 883 } |
881 | 884 |
882 | 885 |
(...skipping 10 matching lines...) Expand all Loading... |
893 } | 896 } |
894 | 897 |
895 | 898 |
896 void Sampler::Stop() { | 899 void Sampler::Stop() { |
897 ASSERT(IsActive()); | 900 ASSERT(IsActive()); |
898 SignalSender::RemoveActiveSampler(this); | 901 SignalSender::RemoveActiveSampler(this); |
899 SetActive(false); | 902 SetActive(false); |
900 } | 903 } |
901 | 904 |
902 } } // namespace v8::internal | 905 } } // namespace v8::internal |
OLD | NEW |