Commit 46639e2f authored by Alexei Filippov's avatar Alexei Filippov Committed by Commit Bot

Sampling Heap Profiler: Implement MacOS specific alloc hooks

The following hooks are implemented:
  - batch_malloc_function
  - batch_free_function
  - free_definite_size_function

BUG=803276

Change-Id: Icea416e33ec87674c4829115aa99f086cc09f4c5
Reviewed-on: https://chromium-review.googlesource.com/884742
Commit-Queue: Alexei Filippov <alph@chromium.org>
Reviewed-by: default avatarPrimiano Tucci <primiano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532743}
parent 3bbbdf94
...@@ -114,8 +114,11 @@ unsigned SamplingNativeHeapProfiler::BatchMallocFn( ...@@ -114,8 +114,11 @@ unsigned SamplingNativeHeapProfiler::BatchMallocFn(
void** results, void** results,
unsigned num_requested, unsigned num_requested,
void* context) { void* context) {
CHECK(false) << "Not implemented."; unsigned num_allocated = self->next->batch_malloc_function(
return 0; self->next, size, results, num_requested, context);
for (unsigned i = 0; i < num_allocated; ++i)
MaybeRecordAlloc(results[i], size);
return num_allocated;
} }
// static // static
...@@ -123,16 +126,20 @@ void SamplingNativeHeapProfiler::BatchFreeFn(const AllocatorDispatch* self, ...@@ -123,16 +126,20 @@ void SamplingNativeHeapProfiler::BatchFreeFn(const AllocatorDispatch* self,
void** to_be_freed, void** to_be_freed,
unsigned num_to_be_freed, unsigned num_to_be_freed,
void* context) { void* context) {
CHECK(false) << "Not implemented."; for (unsigned i = 0; i < num_to_be_freed; ++i)
MaybeRecordFree(to_be_freed[i]);
self->next->batch_free_function(self->next, to_be_freed, num_to_be_freed,
context);
} }
// static // static
void SamplingNativeHeapProfiler::FreeDefiniteSizeFn( void SamplingNativeHeapProfiler::FreeDefiniteSizeFn(
const AllocatorDispatch* self, const AllocatorDispatch* self,
void* ptr, void* address,
size_t size, size_t size,
void* context) { void* context) {
CHECK(false) << "Not implemented."; MaybeRecordFree(address);
self->next->free_definite_size_function(self->next, address, size, context);
} }
AllocatorDispatch SamplingNativeHeapProfiler::allocator_dispatch_ = { AllocatorDispatch SamplingNativeHeapProfiler::allocator_dispatch_ = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment