Chromium Code Reviews| Index: src/profiler/sampling-heap-profiler.h |
| diff --git a/src/profiler/sampling-heap-profiler.h b/src/profiler/sampling-heap-profiler.h |
| index d9b88e9b861bdaa2d135f53b056f301a6f543096..bf9bf832ab2b3d3332cb3d3cd1808b75c9e52f8e 100644 |
| --- a/src/profiler/sampling-heap-profiler.h |
| +++ b/src/profiler/sampling-heap-profiler.h |
| @@ -20,6 +20,7 @@ class RandomNumberGenerator; |
| namespace internal { |
| +class SamplingAllocationObserver; |
| class AllocationProfile : public v8::AllocationProfile { |
| public: |
| @@ -37,7 +38,7 @@ class AllocationProfile : public v8::AllocationProfile { |
| DISALLOW_COPY_AND_ASSIGN(AllocationProfile); |
| }; |
| -class SamplingHeapProfiler : public InlineAllocationObserver { |
| +class SamplingHeapProfiler { |
| public: |
| SamplingHeapProfiler(Heap* heap, StringsStorage* names, uint64_t rate, |
| int stack_depth); |
| @@ -45,11 +46,6 @@ class SamplingHeapProfiler : public InlineAllocationObserver { |
| v8::AllocationProfile* GetAllocationProfile(); |
| - void Step(int bytes_allocated, Address soon_object, size_t size) override; |
| - intptr_t GetNextStepSize() override { |
| - return GetNextSampleInterval(random_, rate_); |
| - } |
| - |
| StringsStorage* names() const { return names_; } |
| class FunctionInfo { |
| @@ -99,15 +95,13 @@ class SamplingHeapProfiler : public InlineAllocationObserver { |
| }; |
| private: |
| + friend class SamplingAllocationObserver; |
|
Hannes Payer (out of office)
2016/02/08 10:13:48
Style guide: friends come after variables.
mattloring
2016/02/09 20:20:05
Done.
|
| using Node = v8::AllocationProfile::Node; |
|
Hannes Payer (out of office)
2016/02/08 10:13:48
Style guide: Do not use using-directives.
mattloring
2016/02/09 20:20:05
Done.
|
| Heap* heap() const { return heap_; } |
| void SampleObject(Address soon_object, size_t size); |
| - static intptr_t GetNextSampleInterval(base::RandomNumberGenerator* random, |
| - uint64_t rate); |
| - |
| // Methods that construct v8::AllocationProfile. |
| Node* AddStack(AllocationProfile* profile, |
| const std::map<int, Script*>& scripts, |
| @@ -121,13 +115,46 @@ class SamplingHeapProfiler : public InlineAllocationObserver { |
| Isolate* const isolate_; |
| Heap* const heap_; |
| - base::RandomNumberGenerator* const random_; |
| + SamplingAllocationObserver* new_space_observer_; |
| + SamplingAllocationObserver* other_spaces_observer_; |
| StringsStorage* const names_; |
| std::set<SampledAllocation*> samples_; |
| - const uint64_t rate_; |
| const int stack_depth_; |
| }; |
| +class SamplingAllocationObserver : public AllocationObserver { |
| + public: |
| + explicit SamplingAllocationObserver(Heap* heap, intptr_t step_size, |
| + uint64_t rate, |
| + SamplingHeapProfiler* profiler, |
| + base::RandomNumberGenerator* random) |
| + : AllocationObserver(step_size), |
| + profiler_(profiler), |
| + heap_(heap), |
| + random_(random), |
| + rate_(rate) {} |
| + virtual ~SamplingAllocationObserver() {} |
| + |
| + protected: |
| + void Step(int bytes_allocated, Address soon_object, size_t size) override { |
| + DCHECK(heap_->gc_state() == Heap::NOT_IN_GC); |
| + DCHECK(soon_object); |
| + profiler_->SampleObject(soon_object, size); |
| + } |
| + |
| + intptr_t GetNextStepSize() override { |
| + return GetNextSampleInterval(random_, rate_); |
| + } |
| + |
| + private: |
| + SamplingHeapProfiler* const profiler_; |
| + Heap* const heap_; |
| + base::RandomNumberGenerator* const random_; |
| + uint64_t const rate_; |
| + |
| + intptr_t GetNextSampleInterval(base::RandomNumberGenerator* random, |
|
Hannes Payer (out of office)
2016/02/08 10:13:48
Style guide: methods go before variables.
mattloring
2016/02/09 20:20:05
Done.
|
| + uint64_t rate); |
| +}; |
| } // namespace internal |
| } // namespace v8 |