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

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

Issue 11428103: Revert "Perform CPU sampling by CPU sampling thread only iff processing thread is not running." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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') | test/cctest/test-cpu-profiler.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 2036 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 2047
2048 void SampleContext(Sampler* sampler) { 2048 void SampleContext(Sampler* sampler) {
2049 HANDLE profiled_thread = sampler->platform_data()->profiled_thread(); 2049 HANDLE profiled_thread = sampler->platform_data()->profiled_thread();
2050 if (profiled_thread == NULL) return; 2050 if (profiled_thread == NULL) return;
2051 2051
2052 // Context used for sampling the register state of the profiled thread. 2052 // Context used for sampling the register state of the profiled thread.
2053 CONTEXT context; 2053 CONTEXT context;
2054 memset(&context, 0, sizeof(context)); 2054 memset(&context, 0, sizeof(context));
2055 2055
2056 TickSample sample_obj; 2056 TickSample sample_obj;
2057 TickSample* sample = CpuProfiler::StartTickSampleEvent(sampler->isolate()); 2057 TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate());
2058 if (sample == NULL) sample = &sample_obj; 2058 if (sample == NULL) sample = &sample_obj;
2059 2059
2060 static const DWORD kSuspendFailed = static_cast<DWORD>(-1); 2060 static const DWORD kSuspendFailed = static_cast<DWORD>(-1);
2061 if (SuspendThread(profiled_thread) == kSuspendFailed) return; 2061 if (SuspendThread(profiled_thread) == kSuspendFailed) return;
2062 sample->state = sampler->isolate()->current_vm_state(); 2062 sample->state = sampler->isolate()->current_vm_state();
2063 2063
2064 context.ContextFlags = CONTEXT_FULL; 2064 context.ContextFlags = CONTEXT_FULL;
2065 if (GetThreadContext(profiled_thread, &context) != 0) { 2065 if (GetThreadContext(profiled_thread, &context) != 0) {
2066 #if V8_HOST_ARCH_X64 2066 #if V8_HOST_ARCH_X64
2067 sample->pc = reinterpret_cast<Address>(context.Rip); 2067 sample->pc = reinterpret_cast<Address>(context.Rip);
2068 sample->sp = reinterpret_cast<Address>(context.Rsp); 2068 sample->sp = reinterpret_cast<Address>(context.Rsp);
2069 sample->fp = reinterpret_cast<Address>(context.Rbp); 2069 sample->fp = reinterpret_cast<Address>(context.Rbp);
2070 #else 2070 #else
2071 sample->pc = reinterpret_cast<Address>(context.Eip); 2071 sample->pc = reinterpret_cast<Address>(context.Eip);
2072 sample->sp = reinterpret_cast<Address>(context.Esp); 2072 sample->sp = reinterpret_cast<Address>(context.Esp);
2073 sample->fp = reinterpret_cast<Address>(context.Ebp); 2073 sample->fp = reinterpret_cast<Address>(context.Ebp);
2074 #endif 2074 #endif
2075 sampler->SampleStack(sample); 2075 sampler->SampleStack(sample);
2076 sampler->Tick(sample); 2076 sampler->Tick(sample);
2077 } 2077 }
2078 CpuProfiler::FinishTickSampleEvent(sampler->isolate());
2079 ResumeThread(profiled_thread); 2078 ResumeThread(profiled_thread);
2080 } 2079 }
2081 2080
2082 const int interval_; 2081 const int interval_;
2083 RuntimeProfilerRateLimiter rate_limiter_; 2082 RuntimeProfilerRateLimiter rate_limiter_;
2084 2083
2085 // Protects the process wide state below. 2084 // Protects the process wide state below.
2086 static Mutex* mutex_; 2085 static Mutex* mutex_;
2087 static SamplerThread* instance_; 2086 static SamplerThread* instance_;
2088 2087
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 data_ = new PlatformData; 2122 data_ = new PlatformData;
2124 } 2123 }
2125 2124
2126 2125
2127 Sampler::~Sampler() { 2126 Sampler::~Sampler() {
2128 ASSERT(!IsActive()); 2127 ASSERT(!IsActive());
2129 delete data_; 2128 delete data_;
2130 } 2129 }
2131 2130
2132 2131
2133 void Sampler::DoSample() {
2134 // TODO(rogulenko): implement
2135 }
2136
2137
2138 void Sampler::Start() { 2132 void Sampler::Start() {
2139 ASSERT(!IsActive()); 2133 ASSERT(!IsActive());
2140 SetActive(true); 2134 SetActive(true);
2141 SamplerThread::AddActiveSampler(this); 2135 SamplerThread::AddActiveSampler(this);
2142 } 2136 }
2143 2137
2144 2138
2145 void Sampler::Stop() { 2139 void Sampler::Stop() {
2146 ASSERT(IsActive()); 2140 ASSERT(IsActive());
2147 SamplerThread::RemoveActiveSampler(this); 2141 SamplerThread::RemoveActiveSampler(this);
2148 SetActive(false); 2142 SetActive(false);
2149 } 2143 }
2150 2144
2151 2145
2152 void Sampler::StartSampling() {
2153 }
2154
2155
2156 void Sampler::StopSampling() {
2157 }
2158
2159
2160 } } // namespace v8::internal 2146 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-solaris.cc ('k') | test/cctest/test-cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698