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 1f98bec849f80f7f068c8e903d6b6b8e190f79e2..4816af085e172422b4f91c09b0d2665d47e5f0d9 100644 |
| --- a/src/profiler/sampling-heap-profiler.h |
| +++ b/src/profiler/sampling-heap-profiler.h |
| @@ -69,29 +69,36 @@ class SamplingHeapProfiler { |
| const int start_position_; |
| }; |
| - class SampledAllocation { |
| + class AllocationNode; |
| + |
| + struct Sample { |
| + size_t size; |
| + AllocationNode* owner; |
| + Global<Value>* global; |
|
ofrobots
2016/02/14 23:57:42
It is more idiomatic to keep Globals (and Locals a
mattloring
2016/02/16 05:28:40
Globals are held by value now. How does DISALLOW_C
|
| + }; |
| + |
| + class AllocationNode { |
| public: |
| - SampledAllocation(SamplingHeapProfiler* sampling_heap_profiler, |
| - Isolate* isolate, Local<Value> local, size_t size, |
| - int max_frames); |
| - ~SampledAllocation() { |
| - for (auto info : stack_) { |
| - delete info; |
| + explicit AllocationNode(FunctionInfo* info) |
| + : script_id_(info->get_script_id()), |
| + script_position_(info->get_start_position()), |
| + name_(info->get_name()) {} |
| + ~AllocationNode() { |
| + for (auto child : children_) { |
| + delete child; |
| } |
| - global_.Reset(); // drop the reference. |
| } |
| - size_t get_size() const { return size_; } |
| - const std::vector<FunctionInfo*>& get_stack() const { return stack_; } |
| private: |
| - static void OnWeakCallback(const WeakCallbackInfo<SampledAllocation>& data); |
| + std::map<size_t, unsigned int> allocations_; |
| + std::vector<AllocationNode*> children_; |
| + int script_id_; |
| + int script_position_; |
| + const char* name_; |
| - SamplingHeapProfiler* const sampling_heap_profiler_; |
| - Global<Value> global_; |
| - std::vector<FunctionInfo*> stack_; |
| - const size_t size_; |
| + friend class SamplingHeapProfiler; |
| - DISALLOW_COPY_AND_ASSIGN(SampledAllocation); |
| + DISALLOW_COPY_AND_ASSIGN(AllocationNode); |
| }; |
| private: |
| @@ -99,23 +106,23 @@ class SamplingHeapProfiler { |
| void SampleObject(Address soon_object, size_t size); |
| + static void OnWeakCallback(const WeakCallbackInfo<Sample>& data); |
| + |
| // Methods that construct v8::AllocationProfile. |
| - v8::AllocationProfile::Node* AddStack( |
| - AllocationProfile* profile, const std::map<int, Script*>& scripts, |
| - const std::vector<FunctionInfo*>& stack); |
| - v8::AllocationProfile::Node* FindOrAddChildNode( |
| - AllocationProfile* profile, const std::map<int, Script*>& scripts, |
| - v8::AllocationProfile::Node* parent, FunctionInfo* function_info); |
| - v8::AllocationProfile::Node* AllocateNode( |
| - AllocationProfile* profile, const std::map<int, Script*>& scripts, |
| - FunctionInfo* function_info); |
| + v8::AllocationProfile::Node* GenerateProfile( |
| + AllocationProfile* profile, SamplingHeapProfiler::AllocationNode* node, |
| + const std::map<int, Script*>& scripts); |
| + AllocationNode* AddStack(const std::vector<FunctionInfo*>& stack); |
| + std::vector<FunctionInfo*> CollectStack(int max_frames); |
| + AllocationNode* FindOrAddChildNode(AllocationNode* parent, |
| + FunctionInfo* function_info); |
| Isolate* const isolate_; |
| Heap* const heap_; |
| base::SmartPointer<SamplingAllocationObserver> new_space_observer_; |
| base::SmartPointer<SamplingAllocationObserver> other_spaces_observer_; |
| StringsStorage* const names_; |
| - std::set<SampledAllocation*> samples_; |
| + AllocationNode* profile_root_; |
| const int stack_depth_; |
| friend class SamplingAllocationObserver; |