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 660452: Assign to "sample.state" before reading it. (Closed)
Patch Set: Created 10 years, 9 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
« no previous file with comments | « src/platform-macos.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 1800
1801 // Sampler thread handler. 1801 // Sampler thread handler.
1802 void Runner() { 1802 void Runner() {
1803 // Context used for sampling the register state of the profiled thread. 1803 // Context used for sampling the register state of the profiled thread.
1804 CONTEXT context; 1804 CONTEXT context;
1805 memset(&context, 0, sizeof(context)); 1805 memset(&context, 0, sizeof(context));
1806 // Loop until the sampler is disengaged. 1806 // Loop until the sampler is disengaged.
1807 while (sampler_->IsActive()) { 1807 while (sampler_->IsActive()) {
1808 TickSample sample; 1808 TickSample sample;
1809 1809
1810 // We always sample the VM state.
1811 sample.state = Logger::state();
1812
1810 // If profiling, we record the pc and sp of the profiled thread. 1813 // If profiling, we record the pc and sp of the profiled thread.
1811 if (sampler_->IsProfiling() 1814 if (sampler_->IsProfiling()
1812 && SuspendThread(profiled_thread_) != (DWORD)-1) { 1815 && SuspendThread(profiled_thread_) != (DWORD)-1) {
1813 context.ContextFlags = CONTEXT_FULL; 1816 context.ContextFlags = CONTEXT_FULL;
1814 if (GetThreadContext(profiled_thread_, &context) != 0) { 1817 if (GetThreadContext(profiled_thread_, &context) != 0) {
1815 #if V8_HOST_ARCH_X64 1818 #if V8_HOST_ARCH_X64
1816 sample.pc = reinterpret_cast<Address>(context.Rip); 1819 sample.pc = reinterpret_cast<Address>(context.Rip);
1817 sample.sp = reinterpret_cast<Address>(context.Rsp); 1820 sample.sp = reinterpret_cast<Address>(context.Rsp);
1818 sample.fp = reinterpret_cast<Address>(context.Rbp); 1821 sample.fp = reinterpret_cast<Address>(context.Rbp);
1819 #else 1822 #else
1820 sample.pc = reinterpret_cast<Address>(context.Eip); 1823 sample.pc = reinterpret_cast<Address>(context.Eip);
1821 sample.sp = reinterpret_cast<Address>(context.Esp); 1824 sample.sp = reinterpret_cast<Address>(context.Esp);
1822 sample.fp = reinterpret_cast<Address>(context.Ebp); 1825 sample.fp = reinterpret_cast<Address>(context.Ebp);
1823 #endif 1826 #endif
1824 sampler_->SampleStack(&sample); 1827 sampler_->SampleStack(&sample);
1825 } 1828 }
1826 ResumeThread(profiled_thread_); 1829 ResumeThread(profiled_thread_);
1827 } 1830 }
1828 1831
1829 // We always sample the VM state.
1830 sample.state = Logger::state();
1831 // Invoke tick handler with program counter and stack pointer. 1832 // Invoke tick handler with program counter and stack pointer.
1832 sampler_->Tick(&sample); 1833 sampler_->Tick(&sample);
1833 1834
1834 // Wait until next sampling. 1835 // Wait until next sampling.
1835 Sleep(sampler_->interval_); 1836 Sleep(sampler_->interval_);
1836 } 1837 }
1837 } 1838 }
1838 }; 1839 };
1839 1840
1840 1841
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1899 1900
1900 // Release the thread handles 1901 // Release the thread handles
1901 CloseHandle(data_->sampler_thread_); 1902 CloseHandle(data_->sampler_thread_);
1902 CloseHandle(data_->profiled_thread_); 1903 CloseHandle(data_->profiled_thread_);
1903 } 1904 }
1904 1905
1905 1906
1906 #endif // ENABLE_LOGGING_AND_PROFILING 1907 #endif // ENABLE_LOGGING_AND_PROFILING
1907 1908
1908 } } // namespace v8::internal 1909 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/platform-macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698