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

Side by Side Diff: src/platform-cygwin.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.h ('k') | src/platform-freebsd.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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 613
614 614
615 class SamplerThread : public Thread { 615 class SamplerThread : public Thread {
616 public: 616 public:
617 static const int kSamplerThreadStackSize = 64 * KB; 617 static const int kSamplerThreadStackSize = 64 * KB;
618 618
619 explicit SamplerThread(int interval) 619 explicit SamplerThread(int interval)
620 : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), 620 : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)),
621 interval_(interval) {} 621 interval_(interval) {}
622 622
623 static void SetUp() { 623 static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); }
624 if (!mutex_) { 624 static void TearDown() { delete mutex_; }
625 mutex_ = OS::CreateMutex();
626 }
627 }
628 625
629 static void AddActiveSampler(Sampler* sampler) { 626 static void AddActiveSampler(Sampler* sampler) {
630 ScopedLock lock(mutex_); 627 ScopedLock lock(mutex_);
631 SamplerRegistry::AddActiveSampler(sampler); 628 SamplerRegistry::AddActiveSampler(sampler);
632 if (instance_ == NULL) { 629 if (instance_ == NULL) {
633 instance_ = new SamplerThread(sampler->interval()); 630 instance_ = new SamplerThread(sampler->interval());
634 instance_->Start(); 631 instance_->Start();
635 } else { 632 } else {
636 ASSERT(instance_->interval_ == sampler->interval()); 633 ASSERT(instance_->interval_ == sampler->interval());
637 } 634 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 // to an unsigned. Going directly can cause an overflow and the seed to be 739 // to an unsigned. Going directly can cause an overflow and the seed to be
743 // set to all ones. The seed will be identical for different instances that 740 // set to all ones. The seed will be identical for different instances that
744 // call this setup code within the same millisecond. 741 // call this setup code within the same millisecond.
745 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); 742 uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
746 srandom(static_cast<unsigned int>(seed)); 743 srandom(static_cast<unsigned int>(seed));
747 limit_mutex = CreateMutex(); 744 limit_mutex = CreateMutex();
748 SamplerThread::SetUp(); 745 SamplerThread::SetUp();
749 } 746 }
750 747
751 748
749 void OS::TearDown() {
750 SamplerThread::TearDown();
751 delete limit_mutex;
752 }
753
754
752 Sampler::Sampler(Isolate* isolate, int interval) 755 Sampler::Sampler(Isolate* isolate, int interval)
753 : isolate_(isolate), 756 : isolate_(isolate),
754 interval_(interval), 757 interval_(interval),
755 profiling_(false), 758 profiling_(false),
756 active_(false), 759 active_(false),
757 samples_taken_(0) { 760 samples_taken_(0) {
758 data_ = new PlatformData; 761 data_ = new PlatformData;
759 } 762 }
760 763
761 764
(...skipping 11 matching lines...) Expand all
773 776
774 777
775 void Sampler::Stop() { 778 void Sampler::Stop() {
776 ASSERT(IsActive()); 779 ASSERT(IsActive());
777 SamplerThread::RemoveActiveSampler(this); 780 SamplerThread::RemoveActiveSampler(this);
778 SetActive(false); 781 SetActive(false);
779 } 782 }
780 783
781 784
782 } } // namespace v8::internal 785 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform.h ('k') | src/platform-freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698