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

Unified Diff: base/profiler/native_stack_sampler.h

Issue 2601633002: Use a common buffer across all instances for stack-copy. (Closed)
Patch Set: addressed review comments by wittman Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/profiler/native_stack_sampler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/profiler/native_stack_sampler.h
diff --git a/base/profiler/native_stack_sampler.h b/base/profiler/native_stack_sampler.h
index 8d7e441b69306b072ed67321a531ac76aee4e28c..ebd7c3c4b816ad1416eb2867f71dc05f43b8f986 100644
--- a/base/profiler/native_stack_sampler.h
+++ b/base/profiler/native_stack_sampler.h
@@ -21,6 +21,26 @@ class NativeStackSamplerTestDelegate;
// given thread.
class NativeStackSampler {
public:
+ // This class contains a buffer for stack copies that can be shared across
+ // multiple instances of NativeStackSampler.
+ class StackBuffer {
+ public:
+ StackBuffer(size_t buffer_size);
+ ~StackBuffer();
+
+ void* buffer() const { return buffer_.get(); }
+ size_t size() const { return size_; }
+
+ private:
+ // The word-aligned buffer.
+ const std::unique_ptr<uintptr_t[]> buffer_;
+
+ // The size of the buffer.
+ const size_t size_;
+
+ DISALLOW_COPY_AND_ASSIGN(StackBuffer);
+ };
+
// The callback type used to add annotations to a sample during collection.
// This is passed to the native sampler to be applied at the most appropriate
// time. It is a simple function-pointer because the generated code must be
@@ -39,6 +59,13 @@ class NativeStackSampler {
AnnotateCallback annotator,
NativeStackSamplerTestDelegate* test_delegate);
+ // Gets the required size of the stack buffer.
+ static size_t GetStackBufferSize();
+
+ // Creates an instance of the a stack buffer that can be used for calls to
+ // any NativeStackSampler object.
+ static std::unique_ptr<StackBuffer> CreateStackBuffer();
+
// The following functions are all called on the SamplingThread (not the
// thread being sampled).
@@ -48,11 +75,12 @@ class NativeStackSampler {
std::vector<StackSamplingProfiler::Module>* modules) = 0;
// Records a stack sample to |sample|.
- virtual void RecordStackSample(StackSamplingProfiler::Sample* sample) = 0;
+ virtual void RecordStackSample(StackBuffer* stackbuffer,
+ StackSamplingProfiler::Sample* sample) = 0;
// Notifies the sampler that we've stopped recording the current
// profile.
- virtual void ProfileRecordingStopped() = 0;
+ virtual void ProfileRecordingStopped(StackBuffer* stackbuffer) = 0;
protected:
NativeStackSampler();
« no previous file with comments | « no previous file | base/profiler/native_stack_sampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698