Index: src/profiler/sampling-heap-profiler.h |
diff --git a/src/profiler/sampling-heap-profiler.h b/src/profiler/sampling-heap-profiler.h |
index e0dc004d5576b7cca55593152d85e8a6a2fc4992..3b399ba08cd68e781299b240d79899b004dd3543 100644 |
--- a/src/profiler/sampling-heap-profiler.h |
+++ b/src/profiler/sampling-heap-profiler.h |
@@ -80,13 +80,24 @@ class SamplingHeapProfiler { |
pinned_(false) {} |
~AllocationNode() { |
for (auto child : children_) { |
- delete child; |
+ delete child.second; |
} |
} |
private: |
+ typedef uint64_t FunctionId; |
ofrobots
2016/05/11 16:48:13
Going forward it would be better to call this `Cal
alph
2016/05/11 17:37:17
I assume (need) it to be the function start positi
ofrobots
2016/05/11 22:48:09
I am considering making it the call-site position
alph
2016/05/11 23:17:34
It just reflects the current state of the nodes, w
ofrobots
2016/05/12 00:03:05
sgtm.
|
+ static FunctionId function_id(int script_id, int start_position, |
+ const char* name) { |
+ return script_id |
+ ? (static_cast<uint64_t>(script_id) << 32) + start_position |
+ : static_cast<uint32_t>(reinterpret_cast<intptr_t>(name)); |
ofrobots
2016/05/11 16:48:13
Why the truncation to 32 bits on 64-bit platforms?
alph
2016/05/11 17:37:17
The name is used only for system "functions", i.e.
ofrobots
2016/05/11 22:48:09
When called from sampling-heap-profiler.cc:204 (or
alph
2016/05/11 23:17:34
Yes, you can reach it for builtin functions like c
ofrobots
2016/05/12 00:03:05
If easy to do, it would be best to avoid the possi
alph
2016/05/12 01:37:44
Well, these are not pointers to arbitrary chars, b
|
+ } |
+ AllocationNode* FindOrAddChildNode(const char* name, int script_id, |
+ int start_position); |
+ // TODO(alph): make use of unordered_map's here. Pay attention to |
+ // iterator invalidation during TranslateAllocationNode. |
std::map<size_t, unsigned int> allocations_; |
- std::vector<AllocationNode*> children_; |
+ std::map<FunctionId, AllocationNode*> children_; |
AllocationNode* const parent_; |
const int script_id_; |
const int script_position_; |
@@ -118,8 +129,6 @@ class SamplingHeapProfiler { |
v8::AllocationProfile::Allocation ScaleSample(size_t size, |
unsigned int count); |
AllocationNode* AddStack(); |
- AllocationNode* FindOrAddChildNode(AllocationNode* parent, const char* name, |
- int script_id, int start_position); |
Isolate* const isolate_; |
Heap* const heap_; |