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

Side by Side Diff: src/log.cc

Issue 14293009: Nuke SamplerRegistry (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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/log.h ('k') | src/sampler.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 delete profiler_; 1922 delete profiler_;
1923 profiler_ = NULL; 1923 profiler_ = NULL;
1924 } 1924 }
1925 1925
1926 delete ticker_; 1926 delete ticker_;
1927 ticker_ = NULL; 1927 ticker_ = NULL;
1928 1928
1929 return log_->Close(); 1929 return log_->Close();
1930 } 1930 }
1931 1931
1932
1933 // Protects the state below.
1934 static Mutex* active_samplers_mutex = NULL;
1935
1936 List<Sampler*>* SamplerRegistry::active_samplers_ = NULL;
1937
1938
1939 void SamplerRegistry::SetUp() {
1940 if (!active_samplers_mutex) {
1941 active_samplers_mutex = OS::CreateMutex();
1942 }
1943 }
1944
1945
1946 bool SamplerRegistry::IterateActiveSamplers(VisitSampler func, void* param) {
1947 ScopedLock lock(active_samplers_mutex);
1948 for (int i = 0;
1949 ActiveSamplersExist() && i < active_samplers_->length();
1950 ++i) {
1951 func(active_samplers_->at(i), param);
1952 }
1953 return ActiveSamplersExist();
1954 }
1955
1956
1957 static void ComputeCpuProfiling(Sampler* sampler, void* flag_ptr) {
1958 bool* flag = reinterpret_cast<bool*>(flag_ptr);
1959 *flag |= sampler->IsProfiling();
1960 }
1961
1962
1963 SamplerRegistry::State SamplerRegistry::GetState() {
1964 bool flag = false;
1965 if (!IterateActiveSamplers(&ComputeCpuProfiling, &flag)) {
1966 return HAS_NO_SAMPLERS;
1967 }
1968 return flag ? HAS_CPU_PROFILING_SAMPLERS : HAS_SAMPLERS;
1969 }
1970
1971
1972 void SamplerRegistry::AddActiveSampler(Sampler* sampler) {
1973 ASSERT(sampler->IsActive());
1974 ScopedLock lock(active_samplers_mutex);
1975 if (active_samplers_ == NULL) {
1976 active_samplers_ = new List<Sampler*>;
1977 } else {
1978 ASSERT(!active_samplers_->Contains(sampler));
1979 }
1980 active_samplers_->Add(sampler);
1981 }
1982
1983
1984 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) {
1985 ASSERT(sampler->IsActive());
1986 ScopedLock lock(active_samplers_mutex);
1987 ASSERT(active_samplers_ != NULL);
1988 bool removed = active_samplers_->RemoveElement(sampler);
1989 ASSERT(removed);
1990 USE(removed);
1991 }
1992
1993 } } // namespace v8::internal 1932 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698