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

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

Issue 10084003: Valgrind cleanliness, part 6: Introduce OS::TearDown, cleaning up 2 mutexes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixed typo. Created 8 years, 8 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-cygwin.cc ('k') | src/platform-linux.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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 HALF_INTERVAL, 709 HALF_INTERVAL,
710 FULL_INTERVAL 710 FULL_INTERVAL
711 }; 711 };
712 712
713 static const int kSignalSenderStackSize = 64 * KB; 713 static const int kSignalSenderStackSize = 64 * KB;
714 714
715 explicit SignalSender(int interval) 715 explicit SignalSender(int interval)
716 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), 716 : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)),
717 interval_(interval) {} 717 interval_(interval) {}
718 718
719 static void SetUp() { 719 static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); }
720 if (!mutex_) { 720 static void TearDown() { delete mutex_; }
721 mutex_ = OS::CreateMutex();
722 }
723 }
724 721
725 static void AddActiveSampler(Sampler* sampler) { 722 static void AddActiveSampler(Sampler* sampler) {
726 ScopedLock lock(mutex_); 723 ScopedLock lock(mutex_);
727 SamplerRegistry::AddActiveSampler(sampler); 724 SamplerRegistry::AddActiveSampler(sampler);
728 if (instance_ == NULL) { 725 if (instance_ == NULL) {
729 // Install a signal handler. 726 // Install a signal handler.
730 struct sigaction sa; 727 struct sigaction sa;
731 sa.sa_sigaction = ProfilerSignalHandler; 728 sa.sa_sigaction = ProfilerSignalHandler;
732 sigemptyset(&sa.sa_mask); 729 sigemptyset(&sa.sa_mask);
733 sa.sa_flags = SA_RESTART | SA_SIGINFO; 730 sa.sa_flags = SA_RESTART | SA_SIGINFO;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 // to an unsigned. Going directly can cause an overflow and the seed to be 854 // to an unsigned. Going directly can cause an overflow and the seed to be
858 // set to all ones. The seed will be identical for different instances that 855 // set to all ones. The seed will be identical for different instances that
859 // call this setup code within the same millisecond. 856 // call this setup code within the same millisecond.
860 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); 857 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
861 srandom(static_cast<unsigned int>(seed)); 858 srandom(static_cast<unsigned int>(seed));
862 limit_mutex = CreateMutex(); 859 limit_mutex = CreateMutex();
863 SignalSender::SetUp(); 860 SignalSender::SetUp();
864 } 861 }
865 862
866 863
864 void OS::TearDown() {
865 SignalSender::TearDown();
866 delete limit_mutex;
867 }
868
869
867 Sampler::Sampler(Isolate* isolate, int interval) 870 Sampler::Sampler(Isolate* isolate, int interval)
868 : isolate_(isolate), 871 : isolate_(isolate),
869 interval_(interval), 872 interval_(interval),
870 profiling_(false), 873 profiling_(false),
871 active_(false), 874 active_(false),
872 samples_taken_(0) { 875 samples_taken_(0) {
873 data_ = new PlatformData; 876 data_ = new PlatformData;
874 } 877 }
875 878
876 879
(...skipping 11 matching lines...) Expand all
888 891
889 892
890 void Sampler::Stop() { 893 void Sampler::Stop() {
891 ASSERT(IsActive()); 894 ASSERT(IsActive());
892 SignalSender::RemoveActiveSampler(this); 895 SignalSender::RemoveActiveSampler(this);
893 SetActive(false); 896 SetActive(false);
894 } 897 }
895 898
896 899
897 } } // namespace v8::internal 900 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-cygwin.cc ('k') | src/platform-linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698