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

Unified Diff: third_party/WebKit/Source/wtf/PartitionAlloc.cpp

Issue 1391933004: [Tracing] Add hook to PartitionAlloc for heap profiling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
Index: third_party/WebKit/Source/wtf/PartitionAlloc.cpp
diff --git a/third_party/WebKit/Source/wtf/PartitionAlloc.cpp b/third_party/WebKit/Source/wtf/PartitionAlloc.cpp
index d076568fcfc59bd6984d319884c0c6c19b18d6af..f78112afbbd19d229a650e9827a815c94839ba13 100644
--- a/third_party/WebKit/Source/wtf/PartitionAlloc.cpp
+++ b/third_party/WebKit/Source/wtf/PartitionAlloc.cpp
@@ -61,6 +61,9 @@ PartitionPage PartitionRootBase::gSeedPage;
PartitionBucket PartitionRootBase::gPagedBucket;
void (*PartitionRootBase::gOomHandlingFunction)() = nullptr;
+void (*partitionAllocHookAlloc)(void* addr, size_t size) = nullptr;
+void (*partitionAllocHookFree)(void* addr) = nullptr;
+
static uint16_t partitionBucketNumSystemPages(size_t size)
{
// This works out reasonably for the current bucket sizes of the generic
@@ -1060,8 +1063,16 @@ void* partitionReallocGeneric(PartitionRootGeneric* root, void* ptr, size_t newS
// We may be able to perform the realloc in place by changing the
// accessibility of memory pages and, if reducing the size, decommitting
// them.
- if (partitionReallocDirectMappedInPlace(root, page, newSize))
+ if (partitionReallocDirectMappedInPlace(root, page, newSize)) {
+ // Report a realloc as a free followed by alloc when heap profiling
+ // is enabled.
+ if (UNLIKELY(partitionAllocHookAlloc && partitionAllocHookFree)) {
Primiano Tucci (use gerrit) 2015/10/12 16:36:46 just check one of them. You always set/reset them
Ruud van Asseldonk 2015/10/13 10:42:18 My reasoning was that an allocation could be happe
Primiano Tucci (use gerrit) 2015/10/14 10:10:12 After discussion offline, I think you want to just
+ partitionAllocHookFree(ptr);
+ partitionAllocHookAlloc(ptr, newSize);
+ }
+
return ptr;
+ }
}
size_t actualNewSize = partitionAllocActualSize(root, newSize);
@@ -1085,6 +1096,14 @@ void* partitionReallocGeneric(PartitionRootGeneric* root, void* ptr, size_t newS
memcpy(ret, ptr, copySize);
partitionFreeGeneric(root, ptr);
+
+ // Report a realloc as a free followed by alloc when heap profiling is
+ // enabled.
Primiano Tucci (use gerrit) 2015/10/12 16:36:46 ditto
+ if (UNLIKELY(partitionAllocHookAlloc && partitionAllocHookFree)) {
+ partitionAllocHookFree(ptr);
+ partitionAllocHookAlloc(ret, newSize);
+ }
+
return ret;
#endif
}

Powered by Google App Engine
This is Rietveld 408576698