Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: src/platform-solaris.cc

Issue 9666052: Landing for pliard@chromium.org: Remove static initializers in v8. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform-posix.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 } 726 }
727 727
728 static void RestoreSignalHandler() { 728 static void RestoreSignalHandler() {
729 if (signal_handler_installed_) { 729 if (signal_handler_installed_) {
730 sigaction(SIGPROF, &old_signal_handler_, 0); 730 sigaction(SIGPROF, &old_signal_handler_, 0);
731 signal_handler_installed_ = false; 731 signal_handler_installed_ = false;
732 } 732 }
733 } 733 }
734 734
735 static void AddActiveSampler(Sampler* sampler) { 735 static void AddActiveSampler(Sampler* sampler) {
736 ScopedLock lock(mutex_); 736 ScopedLock lock(mutex_.Pointer());
737 SamplerRegistry::AddActiveSampler(sampler); 737 SamplerRegistry::AddActiveSampler(sampler);
738 if (instance_ == NULL) { 738 if (instance_ == NULL) {
739 // Start a thread that will send SIGPROF signal to VM threads, 739 // Start a thread that will send SIGPROF signal to VM threads,
740 // when CPU profiling will be enabled. 740 // when CPU profiling will be enabled.
741 instance_ = new SignalSender(sampler->interval()); 741 instance_ = new SignalSender(sampler->interval());
742 instance_->Start(); 742 instance_->Start();
743 } else { 743 } else {
744 ASSERT(instance_->interval_ == sampler->interval()); 744 ASSERT(instance_->interval_ == sampler->interval());
745 } 745 }
746 } 746 }
747 747
748 static void RemoveActiveSampler(Sampler* sampler) { 748 static void RemoveActiveSampler(Sampler* sampler) {
749 ScopedLock lock(mutex_); 749 ScopedLock lock(mutex_.Pointer());
750 SamplerRegistry::RemoveActiveSampler(sampler); 750 SamplerRegistry::RemoveActiveSampler(sampler);
751 if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) { 751 if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) {
752 RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(instance_); 752 RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(instance_);
753 delete instance_; 753 delete instance_;
754 instance_ = NULL; 754 instance_ = NULL;
755 RestoreSignalHandler(); 755 RestoreSignalHandler();
756 } 756 }
757 } 757 }
758 758
759 // Implement Thread::Run(). 759 // Implement Thread::Run().
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 ASSERT(result == 0 || errno == EINTR); 833 ASSERT(result == 0 || errno == EINTR);
834 } 834 }
835 #endif 835 #endif
836 USE(result); 836 USE(result);
837 } 837 }
838 838
839 const int interval_; 839 const int interval_;
840 RuntimeProfilerRateLimiter rate_limiter_; 840 RuntimeProfilerRateLimiter rate_limiter_;
841 841
842 // Protects the process wide state below. 842 // Protects the process wide state below.
843 static Mutex* mutex_; 843 static LazyMutex mutex_;
844 static SignalSender* instance_; 844 static SignalSender* instance_;
845 static bool signal_handler_installed_; 845 static bool signal_handler_installed_;
846 static struct sigaction old_signal_handler_; 846 static struct sigaction old_signal_handler_;
847 847
848 private: 848 private:
849 DISALLOW_COPY_AND_ASSIGN(SignalSender); 849 DISALLOW_COPY_AND_ASSIGN(SignalSender);
850 }; 850 };
851 851
852 Mutex* SignalSender::mutex_ = OS::CreateMutex(); 852 LazyMutex SignalSender::mutex_ = LAZY_MUTEX_INITIALIZER;
853 SignalSender* SignalSender::instance_ = NULL; 853 SignalSender* SignalSender::instance_ = NULL;
854 struct sigaction SignalSender::old_signal_handler_; 854 struct sigaction SignalSender::old_signal_handler_;
855 bool SignalSender::signal_handler_installed_ = false; 855 bool SignalSender::signal_handler_installed_ = false;
856 856
857 857
858 Sampler::Sampler(Isolate* isolate, int interval) 858 Sampler::Sampler(Isolate* isolate, int interval)
859 : isolate_(isolate), 859 : isolate_(isolate),
860 interval_(interval), 860 interval_(interval),
861 profiling_(false), 861 profiling_(false),
862 active_(false), 862 active_(false),
(...skipping 15 matching lines...) Expand all
878 } 878 }
879 879
880 880
881 void Sampler::Stop() { 881 void Sampler::Stop() {
882 ASSERT(IsActive()); 882 ASSERT(IsActive());
883 SignalSender::RemoveActiveSampler(this); 883 SignalSender::RemoveActiveSampler(this);
884 SetActive(false); 884 SetActive(false);
885 } 885 }
886 886
887 } } // namespace v8::internal 887 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-posix.cc ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698