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 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1954 | 1954 |
1955 class SamplerThread : public Thread { | 1955 class SamplerThread : public Thread { |
1956 public: | 1956 public: |
1957 static const int kSamplerThreadStackSize = 64 * KB; | 1957 static const int kSamplerThreadStackSize = 64 * KB; |
1958 | 1958 |
1959 explicit SamplerThread(int interval) | 1959 explicit SamplerThread(int interval) |
1960 : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), | 1960 : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), |
1961 interval_(interval) {} | 1961 interval_(interval) {} |
1962 | 1962 |
1963 static void AddActiveSampler(Sampler* sampler) { | 1963 static void AddActiveSampler(Sampler* sampler) { |
1964 ScopedLock lock(mutex_); | 1964 ScopedLock lock(mutex_.Pointer()); |
1965 SamplerRegistry::AddActiveSampler(sampler); | 1965 SamplerRegistry::AddActiveSampler(sampler); |
1966 if (instance_ == NULL) { | 1966 if (instance_ == NULL) { |
1967 instance_ = new SamplerThread(sampler->interval()); | 1967 instance_ = new SamplerThread(sampler->interval()); |
1968 instance_->Start(); | 1968 instance_->Start(); |
1969 } else { | 1969 } else { |
1970 ASSERT(instance_->interval_ == sampler->interval()); | 1970 ASSERT(instance_->interval_ == sampler->interval()); |
1971 } | 1971 } |
1972 } | 1972 } |
1973 | 1973 |
1974 static void RemoveActiveSampler(Sampler* sampler) { | 1974 static void RemoveActiveSampler(Sampler* sampler) { |
1975 ScopedLock lock(mutex_); | 1975 ScopedLock lock(mutex_.Pointer()); |
1976 SamplerRegistry::RemoveActiveSampler(sampler); | 1976 SamplerRegistry::RemoveActiveSampler(sampler); |
1977 if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) { | 1977 if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) { |
1978 RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(instance_); | 1978 RuntimeProfiler::StopRuntimeProfilerThreadBeforeShutdown(instance_); |
1979 delete instance_; | 1979 delete instance_; |
1980 instance_ = NULL; | 1980 instance_ = NULL; |
1981 } | 1981 } |
1982 } | 1982 } |
1983 | 1983 |
1984 // Implement Thread::Run(). | 1984 // Implement Thread::Run(). |
1985 virtual void Run() { | 1985 virtual void Run() { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2094 | 2094 |
2095 | 2095 |
2096 void Sampler::Stop() { | 2096 void Sampler::Stop() { |
2097 ASSERT(IsActive()); | 2097 ASSERT(IsActive()); |
2098 SamplerThread::RemoveActiveSampler(this); | 2098 SamplerThread::RemoveActiveSampler(this); |
2099 SetActive(false); | 2099 SetActive(false); |
2100 } | 2100 } |
2101 | 2101 |
2102 | 2102 |
2103 } } // namespace v8::internal | 2103 } } // namespace v8::internal |
OLD | NEW |