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

Unified Diff: src/profiler/sampling-heap-profiler.h

Issue 1697903002: Sampling heap profiler data structure changes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove functioninfo Created 4 years, 10 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 | src/profiler/sampling-heap-profiler.cc » ('j') | src/profiler/sampling-heap-profiler.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4a26e94d6b5414fb9c5bcdfc9e271c9eabd2a6cd 100644
--- a/src/profiler/sampling-heap-profiler.h
+++ b/src/profiler/sampling-heap-profiler.h
@@ -48,50 +48,38 @@ class SamplingHeapProfiler {
StringsStorage* names() const { return names_; }
- class FunctionInfo {
- public:
- FunctionInfo(SharedFunctionInfo* shared, StringsStorage* names);
- explicit FunctionInfo(const char* name)
- : name_(name),
- script_name_(""),
- script_id_(v8::UnboundScript::kNoScriptId),
- start_position_(0) {}
-
- const char* get_name() const { return name_; }
- const char* get_script_name() const { return script_name_; }
- int get_script_id() const { return script_id_; }
- int get_start_position() const { return start_position_; }
+ class AllocationNode;
- private:
- const char* const name_;
- const char* script_name_;
- int script_id_;
- const int start_position_;
+ struct Sample {
+ size_t size;
+ AllocationNode* owner;
+ Global<Value> global;
+ SamplingHeapProfiler* profiler;
ulan 2016/02/17 11:14:50 Disallow copy and assign.
mattloring 2016/02/17 17:50:21 Done.
};
- class SampledAllocation {
+ 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(const char* const name, int script_id,
ulan 2016/02/17 11:14:50 No need for explicit here.
mattloring 2016/02/17 17:50:21 Done.
+ const int start_position)
+ : script_id_(script_id),
+ script_position_(start_position),
+ name_(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 +87,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(
ulan 2016/02/17 11:14:50 Could you please add a comment describing pre/post
mattloring 2016/02/17 17:50:21 Done.
+ AllocationProfile* profile, SamplingHeapProfiler::AllocationNode* node,
+ const std::map<int, Script*>& scripts);
+ AllocationNode* AddStack();
+ AllocationNode* FindOrAddChildNode(AllocationNode* parent, const char* name,
+ int script_id, int start_position);
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_;
+ std::set<Sample*> samples_;
const int stack_depth_;
friend class SamplingAllocationObserver;
« no previous file with comments | « no previous file | src/profiler/sampling-heap-profiler.cc » ('j') | src/profiler/sampling-heap-profiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698