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

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

Issue 1967673002: Sampling heap profiler: use map instead of vector for children. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix the id function Created 4 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 | src/profiler/sampling-heap-profiler.cc » ('j') | no next file with comments »
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 e0dc004d5576b7cca55593152d85e8a6a2fc4992..d36d5ee5cef53b7979dfd5291744a50aa9949f42 100644
--- a/src/profiler/sampling-heap-profiler.h
+++ b/src/profiler/sampling-heap-profiler.h
@@ -80,13 +80,25 @@ class SamplingHeapProfiler {
pinned_(false) {}
~AllocationNode() {
for (auto child : children_) {
- delete child;
+ delete child.second;
}
}
private:
+ typedef uint64_t FunctionId;
+ static FunctionId function_id(int script_id, int start_position,
ulan 2016/05/13 09:05:00 Please add a comment describing what this function
alph 2016/05/13 18:34:35 Done.
+ const char* name) {
ulan 2016/05/12 10:01:20 Instead of relying on name pointers, can we use "i
+ return script_id != v8::UnboundScript::kNoScriptId
+ ? (static_cast<uint64_t>(script_id) << 32) +
+ (start_position << 1)
ulan 2016/05/13 09:05:00 DCHECK(start_position >= 0 && start_position < (1
alph 2016/05/13 18:34:35 Done.
+ : reinterpret_cast<intptr_t>(name) | 1;
+ }
+ 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 +130,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_;
« no previous file with comments | « no previous file | src/profiler/sampling-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698