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

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

Issue 10871039: Replacing circular queue by single buffer in CPU Profiler. (Closed) Base URL: http://git.chromium.org/external/v8.git@profiling
Patch Set: an attempt to fix a test that strangely crashed only once Created 8 years, 3 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
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 2020 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 } 2031 }
2032 2032
2033 void SampleContext(Sampler* sampler) { 2033 void SampleContext(Sampler* sampler) {
2034 HANDLE profiled_thread = sampler->platform_data()->profiled_thread(); 2034 HANDLE profiled_thread = sampler->platform_data()->profiled_thread();
2035 if (profiled_thread == NULL) return; 2035 if (profiled_thread == NULL) return;
2036 2036
2037 // Context used for sampling the register state of the profiled thread. 2037 // Context used for sampling the register state of the profiled thread.
2038 CONTEXT context; 2038 CONTEXT context;
2039 memset(&context, 0, sizeof(context)); 2039 memset(&context, 0, sizeof(context));
2040 2040
2041 TickSample sample_obj; 2041 TickSample* sample = CpuProfiler::StartTickSampleEvent(sampler->isolate());
2042 TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate()); 2042 if (sample == NULL) return;
2043 if (sample == NULL) sample = &sample_obj;
2044 2043
2045 static const DWORD kSuspendFailed = static_cast<DWORD>(-1); 2044 static const DWORD kSuspendFailed = static_cast<DWORD>(-1);
2046 if (SuspendThread(profiled_thread) == kSuspendFailed) return; 2045 if (SuspendThread(profiled_thread) == kSuspendFailed) return;
2047 sample->state = sampler->isolate()->current_vm_state(); 2046 sample->state = sampler->isolate()->current_vm_state();
2048 2047
2049 context.ContextFlags = CONTEXT_FULL; 2048 context.ContextFlags = CONTEXT_FULL;
2050 if (GetThreadContext(profiled_thread, &context) != 0) { 2049 if (GetThreadContext(profiled_thread, &context) != 0) {
2051 #if V8_HOST_ARCH_X64 2050 #if V8_HOST_ARCH_X64
2052 sample->pc = reinterpret_cast<Address>(context.Rip); 2051 sample->pc = reinterpret_cast<Address>(context.Rip);
2053 sample->sp = reinterpret_cast<Address>(context.Rsp); 2052 sample->sp = reinterpret_cast<Address>(context.Rsp);
2054 sample->fp = reinterpret_cast<Address>(context.Rbp); 2053 sample->fp = reinterpret_cast<Address>(context.Rbp);
2055 #else 2054 #else
2056 sample->pc = reinterpret_cast<Address>(context.Eip); 2055 sample->pc = reinterpret_cast<Address>(context.Eip);
2057 sample->sp = reinterpret_cast<Address>(context.Esp); 2056 sample->sp = reinterpret_cast<Address>(context.Esp);
2058 sample->fp = reinterpret_cast<Address>(context.Ebp); 2057 sample->fp = reinterpret_cast<Address>(context.Ebp);
2059 #endif 2058 #endif
2060 sampler->SampleStack(sample); 2059 sampler->SampleStack(sample);
2061 sampler->Tick(sample); 2060 sampler->Tick(sample);
2062 } 2061 }
2062 CpuProfiler::FinishTickSampleEvent(sampler->isolate());
2063 ResumeThread(profiled_thread); 2063 ResumeThread(profiled_thread);
2064 } 2064 }
2065 2065
2066 const int interval_; 2066 const int interval_;
2067 RuntimeProfilerRateLimiter rate_limiter_; 2067 RuntimeProfilerRateLimiter rate_limiter_;
2068 2068
2069 // Protects the process wide state below. 2069 // Protects the process wide state below.
2070 static Mutex* mutex_; 2070 static Mutex* mutex_;
2071 static SamplerThread* instance_; 2071 static SamplerThread* instance_;
2072 2072
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 2127
2128 2128
2129 void Sampler::Stop() { 2129 void Sampler::Stop() {
2130 ASSERT(IsActive()); 2130 ASSERT(IsActive());
2131 SamplerThread::RemoveActiveSampler(this); 2131 SamplerThread::RemoveActiveSampler(this);
2132 SetActive(false); 2132 SetActive(false);
2133 } 2133 }
2134 2134
2135 2135
2136 } } // namespace v8::internal 2136 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698