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

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: addressing comments. 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..4b7c366b8078a7df724603f7969d5e5912c410e3 100644
--- a/src/profiler/sampling-heap-profiler.h
+++ b/src/profiler/sampling-heap-profiler.h
@@ -80,13 +80,33 @@ 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,
+ const char* name) {
+ // script_id == kNoScriptId case:
+ // Use function name pointer as an id. Names derived from VM state
+ // must not collide with the builtin names. The least significant bit
+ // of the id is set to 1.
+ if (script_id == v8::UnboundScript::kNoScriptId) {
+ return reinterpret_cast<intptr_t>(name) | 1;
+ }
+ // script_id != kNoScriptId case:
+ // Use script_id, start_position pair to uniquelly identify the node.
+ // The least significant bit of the id is set to 0.
+ DCHECK(static_cast<unsigned>(start_position) < (1u << 31));
+ return (static_cast<uint64_t>(script_id) << 32) + (start_position << 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 +138,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