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

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

Issue 50052: Support profiler stack sampling in any situation. (Closed)
Patch Set: Fixes according to comments Created 11 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/log.cc ('k') | test/cctest/test-log-ia32.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 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 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 // Loop until the sampler is disengaged. 1743 // Loop until the sampler is disengaged.
1744 while (sampler_->IsActive()) { 1744 while (sampler_->IsActive()) {
1745 TickSample sample; 1745 TickSample sample;
1746 1746
1747 // If profiling, we record the pc and sp of the profiled thread. 1747 // If profiling, we record the pc and sp of the profiled thread.
1748 if (sampler_->IsProfiling()) { 1748 if (sampler_->IsProfiling()) {
1749 // Pause the profiled thread and get its context. 1749 // Pause the profiled thread and get its context.
1750 SuspendThread(profiled_thread_); 1750 SuspendThread(profiled_thread_);
1751 context.ContextFlags = CONTEXT_FULL; 1751 context.ContextFlags = CONTEXT_FULL;
1752 GetThreadContext(profiled_thread_, &context); 1752 GetThreadContext(profiled_thread_, &context);
1753 ResumeThread(profiled_thread_);
1754 // Invoke tick handler with program counter and stack pointer. 1753 // Invoke tick handler with program counter and stack pointer.
1755 sample.pc = context.Eip; 1754 sample.pc = context.Eip;
1756 sample.sp = context.Esp; 1755 sample.sp = context.Esp;
1757 sample.fp = context.Ebp; 1756 sample.fp = context.Ebp;
1758 } 1757 }
1759 1758
1760 // We always sample the VM state. 1759 // We always sample the VM state.
1761 sample.state = Logger::state(); 1760 sample.state = Logger::state();
1762 sampler_->Tick(&sample); 1761 sampler_->Tick(&sample);
1763 1762
1763 if (sampler_->IsProfiling()) {
1764 ResumeThread(profiled_thread_);
1765 }
1766
1764 // Wait until next sampling. 1767 // Wait until next sampling.
1765 Sleep(sampler_->interval_); 1768 Sleep(sampler_->interval_);
1766 } 1769 }
1767 } 1770 }
1768 }; 1771 };
1769 1772
1770 1773
1771 // Entry point for sampler thread. 1774 // Entry point for sampler thread.
1772 static unsigned int __stdcall SamplerEntry(void* arg) { 1775 static unsigned int __stdcall SamplerEntry(void* arg) {
1773 Sampler::PlatformData* data = 1776 Sampler::PlatformData* data =
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 1829
1827 // Release the thread handles 1830 // Release the thread handles
1828 CloseHandle(data_->sampler_thread_); 1831 CloseHandle(data_->sampler_thread_);
1829 CloseHandle(data_->profiled_thread_); 1832 CloseHandle(data_->profiled_thread_);
1830 } 1833 }
1831 1834
1832 1835
1833 #endif // ENABLE_LOGGING_AND_PROFILING 1836 #endif // ENABLE_LOGGING_AND_PROFILING
1834 1837
1835 } } // namespace v8::internal 1838 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log.cc ('k') | test/cctest/test-log-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698