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

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

Issue 11437016: Use count-based profiling exclusively. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments Created 8 years 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-solaris.cc ('k') | src/runtime.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 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after
2003 delete instance_; 2003 delete instance_;
2004 instance_ = NULL; 2004 instance_ = NULL;
2005 } 2005 }
2006 } 2006 }
2007 2007
2008 // Implement Thread::Run(). 2008 // Implement Thread::Run().
2009 virtual void Run() { 2009 virtual void Run() {
2010 SamplerRegistry::State state; 2010 SamplerRegistry::State state;
2011 while ((state = SamplerRegistry::GetState()) != 2011 while ((state = SamplerRegistry::GetState()) !=
2012 SamplerRegistry::HAS_NO_SAMPLERS) { 2012 SamplerRegistry::HAS_NO_SAMPLERS) {
2013 bool cpu_profiling_enabled =
2014 (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS);
2015 bool runtime_profiler_enabled = RuntimeProfiler::IsEnabled();
2016 // When CPU profiling is enabled both JavaScript and C++ code is 2013 // When CPU profiling is enabled both JavaScript and C++ code is
2017 // profiled. We must not suspend. 2014 // profiled. We must not suspend.
2018 if (!cpu_profiling_enabled) { 2015 if (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS) {
2016 SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this);
2017 } else {
2019 if (rate_limiter_.SuspendIfNecessary()) continue; 2018 if (rate_limiter_.SuspendIfNecessary()) continue;
2020 } 2019 }
2021 if (cpu_profiling_enabled) {
2022 if (!SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this)) {
2023 return;
2024 }
2025 }
2026 if (runtime_profiler_enabled) {
2027 if (!SamplerRegistry::IterateActiveSamplers(&DoRuntimeProfile, NULL)) {
2028 return;
2029 }
2030 }
2031 OS::Sleep(interval_); 2020 OS::Sleep(interval_);
2032 } 2021 }
2033 } 2022 }
2034 2023
2035 static void DoCpuProfile(Sampler* sampler, void* raw_sampler_thread) { 2024 static void DoCpuProfile(Sampler* sampler, void* raw_sampler_thread) {
2036 if (!sampler->isolate()->IsInitialized()) return; 2025 if (!sampler->isolate()->IsInitialized()) return;
2037 if (!sampler->IsProfiling()) return; 2026 if (!sampler->IsProfiling()) return;
2038 SamplerThread* sampler_thread = 2027 SamplerThread* sampler_thread =
2039 reinterpret_cast<SamplerThread*>(raw_sampler_thread); 2028 reinterpret_cast<SamplerThread*>(raw_sampler_thread);
2040 sampler_thread->SampleContext(sampler); 2029 sampler_thread->SampleContext(sampler);
2041 } 2030 }
2042 2031
2043 static void DoRuntimeProfile(Sampler* sampler, void* ignored) {
2044 if (!sampler->isolate()->IsInitialized()) return;
2045 sampler->isolate()->runtime_profiler()->NotifyTick();
2046 }
2047
2048 void SampleContext(Sampler* sampler) { 2032 void SampleContext(Sampler* sampler) {
2049 HANDLE profiled_thread = sampler->platform_data()->profiled_thread(); 2033 HANDLE profiled_thread = sampler->platform_data()->profiled_thread();
2050 if (profiled_thread == NULL) return; 2034 if (profiled_thread == NULL) return;
2051 2035
2052 // Context used for sampling the register state of the profiled thread. 2036 // Context used for sampling the register state of the profiled thread.
2053 CONTEXT context; 2037 CONTEXT context;
2054 memset(&context, 0, sizeof(context)); 2038 memset(&context, 0, sizeof(context));
2055 2039
2056 TickSample sample_obj; 2040 TickSample sample_obj;
2057 TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate()); 2041 TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 2121
2138 2122
2139 void Sampler::Stop() { 2123 void Sampler::Stop() {
2140 ASSERT(IsActive()); 2124 ASSERT(IsActive());
2141 SamplerThread::RemoveActiveSampler(this); 2125 SamplerThread::RemoveActiveSampler(this);
2142 SetActive(false); 2126 SetActive(false);
2143 } 2127 }
2144 2128
2145 2129
2146 } } // namespace v8::internal 2130 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-solaris.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698