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

Unified Diff: src/profile-generator.cc

Issue 5537001: New Heap Profiler: add API method for finding a graph node by id. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 10 years, 1 month 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 | « src/profile-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/profile-generator.cc
diff --git a/src/profile-generator.cc b/src/profile-generator.cc
index 640f13cd62ceb33c227ca2e5d7101ca68ca7c2eb..1bb22be03de0409bcfb4e2c44c8cef989e5a7ae8 100644
--- a/src/profile-generator.cc
+++ b/src/profile-generator.cc
@@ -1544,6 +1544,28 @@ HeapSnapshotsDiff* HeapSnapshot::CompareWith(HeapSnapshot* snapshot) {
}
+HeapEntry* HeapSnapshot::GetEntryById(uint64_t id) {
+ // GetSortedEntriesList is used in diff algorithm and sorts
+ // entries by their id.
+ List<HeapEntry*>* entries_by_id = GetSortedEntriesList();
+
+ // Perform a binary search by id.
+ int low = 0;
+ int high = entries_by_id->length() - 1;
+ while (low <= high) {
+ int mid = ((unsigned int)low + (unsigned int)high) >> 1;
Søren Thygesen Gjesse 2010/12/02 07:37:15 No C-style casts please.
mnaganov (inactive) 2010/12/02 15:38:25 Done.
+ uint64_t mid_id = entries_by_id->at(mid)->id();
+ if (mid_id > id)
+ high = mid - 1;
+ else if (mid_id < id)
+ low = mid + 1;
+ else
+ return entries_by_id->at(mid);
+ }
+ return NULL;
+}
+
+
List<HeapGraphPath*>* HeapSnapshot::GetRetainingPaths(HeapEntry* entry) {
HashMap::Entry* p =
retaining_paths_.Lookup(entry, HeapEntry::Hash(entry), true);
« no previous file with comments | « src/profile-generator.h ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698