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

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

Issue 10105026: Version 3.10.3 (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: 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-linux.cc ('k') | src/platform-nullos.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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 736
737 737
738 class SamplerThread : public Thread { 738 class SamplerThread : public Thread {
739 public: 739 public:
740 static const int kSamplerThreadStackSize = 64 * KB; 740 static const int kSamplerThreadStackSize = 64 * KB;
741 741
742 explicit SamplerThread(int interval) 742 explicit SamplerThread(int interval)
743 : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), 743 : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)),
744 interval_(interval) {} 744 interval_(interval) {}
745 745
746 static void SetUp() { 746 static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); }
747 if (!mutex_) { 747 static void TearDown() { delete mutex_; }
748 mutex_ = OS::CreateMutex();
749 }
750 }
751 748
752 static void AddActiveSampler(Sampler* sampler) { 749 static void AddActiveSampler(Sampler* sampler) {
753 ScopedLock lock(mutex_); 750 ScopedLock lock(mutex_);
754 SamplerRegistry::AddActiveSampler(sampler); 751 SamplerRegistry::AddActiveSampler(sampler);
755 if (instance_ == NULL) { 752 if (instance_ == NULL) {
756 instance_ = new SamplerThread(sampler->interval()); 753 instance_ = new SamplerThread(sampler->interval());
757 instance_->Start(); 754 instance_->Start();
758 } else { 755 } else {
759 ASSERT(instance_->interval_ == sampler->interval()); 756 ASSERT(instance_->interval_ == sampler->interval());
760 } 757 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 871
875 void OS::SetUp() { 872 void OS::SetUp() {
876 // Seed the random number generator. We preserve microsecond resolution. 873 // Seed the random number generator. We preserve microsecond resolution.
877 uint64_t seed = Ticks() ^ (getpid() << 16); 874 uint64_t seed = Ticks() ^ (getpid() << 16);
878 srandom(static_cast<unsigned int>(seed)); 875 srandom(static_cast<unsigned int>(seed));
879 limit_mutex = CreateMutex(); 876 limit_mutex = CreateMutex();
880 SamplerThread::SetUp(); 877 SamplerThread::SetUp();
881 } 878 }
882 879
883 880
881 void OS::TearDown() {
882 SamplerThread::TearDown();
883 delete limit_mutex;
884 }
885
886
884 Sampler::Sampler(Isolate* isolate, int interval) 887 Sampler::Sampler(Isolate* isolate, int interval)
885 : isolate_(isolate), 888 : isolate_(isolate),
886 interval_(interval), 889 interval_(interval),
887 profiling_(false), 890 profiling_(false),
888 active_(false), 891 active_(false),
889 samples_taken_(0) { 892 samples_taken_(0) {
890 data_ = new PlatformData; 893 data_ = new PlatformData;
891 } 894 }
892 895
893 896
(...skipping 11 matching lines...) Expand all
905 908
906 909
907 void Sampler::Stop() { 910 void Sampler::Stop() {
908 ASSERT(IsActive()); 911 ASSERT(IsActive());
909 SamplerThread::RemoveActiveSampler(this); 912 SamplerThread::RemoveActiveSampler(this);
910 SetActive(false); 913 SetActive(false);
911 } 914 }
912 915
913 916
914 } } // namespace v8::internal 917 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-linux.cc ('k') | src/platform-nullos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698