| 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 1931 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1942  |  1942  | 
|  1943  |  1943  | 
|  1944 class SamplerThread : public Thread { |  1944 class SamplerThread : public Thread { | 
|  1945  public: |  1945  public: | 
|  1946   static const int kSamplerThreadStackSize = 64 * KB; |  1946   static const int kSamplerThreadStackSize = 64 * KB; | 
|  1947  |  1947  | 
|  1948   explicit SamplerThread(int interval) |  1948   explicit SamplerThread(int interval) | 
|  1949       : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), |  1949       : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), | 
|  1950         interval_(interval) {} |  1950         interval_(interval) {} | 
|  1951  |  1951  | 
|  1952   static void SetUp() { |  1952   static void SetUp() { if (!mutex_) mutex_ = OS::CreateMutex(); } | 
|  1953     if (!mutex_) { |  1953   static void TearDown() { delete mutex_; } | 
|  1954       mutex_ = OS::CreateMutex(); |  | 
|  1955     } |  | 
|  1956   } |  | 
|  1957  |  1954  | 
|  1958   static void AddActiveSampler(Sampler* sampler) { |  1955   static void AddActiveSampler(Sampler* sampler) { | 
|  1959     ScopedLock lock(mutex_); |  1956     ScopedLock lock(mutex_); | 
|  1960     SamplerRegistry::AddActiveSampler(sampler); |  1957     SamplerRegistry::AddActiveSampler(sampler); | 
|  1961     if (instance_ == NULL) { |  1958     if (instance_ == NULL) { | 
|  1962       instance_ = new SamplerThread(sampler->interval()); |  1959       instance_ = new SamplerThread(sampler->interval()); | 
|  1963       instance_->Start(); |  1960       instance_->Start(); | 
|  1964     } else { |  1961     } else { | 
|  1965       ASSERT(instance_->interval_ == sampler->interval()); |  1962       ASSERT(instance_->interval_ == sampler->interval()); | 
|  1966     } |  1963     } | 
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2071   // to an unsigned. Going directly can cause an overflow and the seed to be |  2068   // to an unsigned. Going directly can cause an overflow and the seed to be | 
|  2072   // set to all ones. The seed will be identical for different instances that |  2069   // set to all ones. The seed will be identical for different instances that | 
|  2073   // call this setup code within the same millisecond. |  2070   // call this setup code within the same millisecond. | 
|  2074   uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); |  2071   uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis()); | 
|  2075   srand(static_cast<unsigned int>(seed)); |  2072   srand(static_cast<unsigned int>(seed)); | 
|  2076   limit_mutex = CreateMutex(); |  2073   limit_mutex = CreateMutex(); | 
|  2077   SamplerThread::SetUp(); |  2074   SamplerThread::SetUp(); | 
|  2078 } |  2075 } | 
|  2079  |  2076  | 
|  2080  |  2077  | 
 |  2078 void OS::TearDown() { | 
 |  2079   SamplerThread::TearDown(); | 
 |  2080   delete limit_mutex; | 
 |  2081 } | 
 |  2082  | 
 |  2083  | 
|  2081 Sampler::Sampler(Isolate* isolate, int interval) |  2084 Sampler::Sampler(Isolate* isolate, int interval) | 
|  2082     : isolate_(isolate), |  2085     : isolate_(isolate), | 
|  2083       interval_(interval), |  2086       interval_(interval), | 
|  2084       profiling_(false), |  2087       profiling_(false), | 
|  2085       active_(false), |  2088       active_(false), | 
|  2086       samples_taken_(0) { |  2089       samples_taken_(0) { | 
|  2087   data_ = new PlatformData; |  2090   data_ = new PlatformData; | 
|  2088 } |  2091 } | 
|  2089  |  2092  | 
|  2090  |  2093  | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|  2102  |  2105  | 
|  2103  |  2106  | 
|  2104 void Sampler::Stop() { |  2107 void Sampler::Stop() { | 
|  2105   ASSERT(IsActive()); |  2108   ASSERT(IsActive()); | 
|  2106   SamplerThread::RemoveActiveSampler(this); |  2109   SamplerThread::RemoveActiveSampler(this); | 
|  2107   SetActive(false); |  2110   SetActive(false); | 
|  2108 } |  2111 } | 
|  2109  |  2112  | 
|  2110  |  2113  | 
|  2111 } }  // namespace v8::internal |  2114 } }  // namespace v8::internal | 
| OLD | NEW |