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

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

Issue 147150: Reimplement profiler sampler on Mac OS X to get it working under Chromium. (Closed)
Patch Set: moved thread resuming and got rid of thread_suspended flag Created 11 years, 5 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 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 // Sampler thread handler. 1769 // Sampler thread handler.
1770 void Runner() { 1770 void Runner() {
1771 // Context used for sampling the register state of the profiled thread. 1771 // Context used for sampling the register state of the profiled thread.
1772 CONTEXT context; 1772 CONTEXT context;
1773 memset(&context, 0, sizeof(context)); 1773 memset(&context, 0, sizeof(context));
1774 // Loop until the sampler is disengaged. 1774 // Loop until the sampler is disengaged.
1775 while (sampler_->IsActive()) { 1775 while (sampler_->IsActive()) {
1776 TickSample sample; 1776 TickSample sample;
1777 1777
1778 // If profiling, we record the pc and sp of the profiled thread. 1778 // If profiling, we record the pc and sp of the profiled thread.
1779 if (sampler_->IsProfiling()) { 1779 if (sampler_->IsProfiling()
1780 // Pause the profiled thread and get its context. 1780 && SuspendThread(profiled_thread_) != (DWORD)-1) {
1781 SuspendThread(profiled_thread_);
1782 context.ContextFlags = CONTEXT_FULL; 1781 context.ContextFlags = CONTEXT_FULL;
1783 GetThreadContext(profiled_thread_, &context); 1782 if (GetThreadContext(profiled_thread_, &context) != 0) {
1784 // Invoke tick handler with program counter and stack pointer.
1785 #if V8_HOST_ARCH_X64 1783 #if V8_HOST_ARCH_X64
1786 UNIMPLEMENTED(); 1784 UNIMPLEMENTED();
1787 sample.pc = context.Rip; 1785 sample.pc = context.Rip;
1788 sample.sp = context.Rsp; 1786 sample.sp = context.Rsp;
1789 sample.fp = context.Rbp; 1787 sample.fp = context.Rbp;
1790 #else 1788 #else
1791 sample.pc = context.Eip; 1789 sample.pc = context.Eip;
1792 sample.sp = context.Esp; 1790 sample.sp = context.Esp;
1793 sample.fp = context.Ebp; 1791 sample.fp = context.Ebp;
1794 #endif 1792 #endif
1793 sampler_->SampleStack(&sample);
1794 }
1795 ResumeThread(profiled_thread_);
1795 } 1796 }
1796 1797
1797 // We always sample the VM state. 1798 // We always sample the VM state.
1798 sample.state = Logger::state(); 1799 sample.state = Logger::state();
1800 // Invoke tick handler with program counter and stack pointer.
1799 sampler_->Tick(&sample); 1801 sampler_->Tick(&sample);
1800 1802
1801 if (sampler_->IsProfiling()) {
1802 ResumeThread(profiled_thread_);
1803 }
1804
1805 // Wait until next sampling. 1803 // Wait until next sampling.
1806 Sleep(sampler_->interval_); 1804 Sleep(sampler_->interval_);
1807 } 1805 }
1808 } 1806 }
1809 }; 1807 };
1810 1808
1811 1809
1812 // Entry point for sampler thread. 1810 // Entry point for sampler thread.
1813 static unsigned int __stdcall SamplerEntry(void* arg) { 1811 static unsigned int __stdcall SamplerEntry(void* arg) {
1814 Sampler::PlatformData* data = 1812 Sampler::PlatformData* data =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 1868
1871 // Release the thread handles 1869 // Release the thread handles
1872 CloseHandle(data_->sampler_thread_); 1870 CloseHandle(data_->sampler_thread_);
1873 CloseHandle(data_->profiled_thread_); 1871 CloseHandle(data_->profiled_thread_);
1874 } 1872 }
1875 1873
1876 1874
1877 #endif // ENABLE_LOGGING_AND_PROFILING 1875 #endif // ENABLE_LOGGING_AND_PROFILING
1878 1876
1879 } } // namespace v8::internal 1877 } } // 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