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

Side by Side Diff: base/allocator/allocator_shim_default_dispatch_to_tcmalloc.cc

Issue 2163783003: Implement a ScopedThreadHeapUsage class to allow profiling per-thread heap usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shim-default
Patch Set: Address Nico's comments. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/allocator/allocator_shim.h" 5 #include "base/allocator/allocator_shim.h"
6 #include "base/allocator/allocator_shim_internals.h" 6 #include "base/allocator/allocator_shim_internals.h"
7 #include "third_party/tcmalloc/chromium/src/config.h" 7 #include "third_party/tcmalloc/chromium/src/config.h"
8 #include "third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h" 8 #include "third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h"
9 9
10 namespace { 10 namespace {
(...skipping 13 matching lines...) Expand all
24 } 24 }
25 25
26 void* TCRealloc(const AllocatorDispatch*, void* address, size_t size) { 26 void* TCRealloc(const AllocatorDispatch*, void* address, size_t size) {
27 return tc_realloc(address, size); 27 return tc_realloc(address, size);
28 } 28 }
29 29
30 void TCFree(const AllocatorDispatch*, void* address) { 30 void TCFree(const AllocatorDispatch*, void* address) {
31 tc_free(address); 31 tc_free(address);
32 } 32 }
33 33
34 size_t TCGetSizeEstimate(const AllocatorDispatch*, void* address) {
35 return tc_malloc_size(address);
36 }
37
34 } // namespace 38 } // namespace
35 39
36 const AllocatorDispatch AllocatorDispatch::default_dispatch = { 40 const AllocatorDispatch AllocatorDispatch::default_dispatch = {
37 &TCMalloc, /* alloc_function */ 41 &TCMalloc, /* alloc_function */
38 &TCCalloc, /* alloc_zero_initialized_function */ 42 &TCCalloc, /* alloc_zero_initialized_function */
39 &TCMemalign, /* alloc_aligned_function */ 43 &TCMemalign, /* alloc_aligned_function */
40 &TCRealloc, /* realloc_function */ 44 &TCRealloc, /* realloc_function */
41 &TCFree, /* free_function */ 45 &TCFree, /* free_function */
42 nullptr, /* next */ 46 &TCGetSizeEstimate, /* get_size_estimate_function */
47 nullptr, /* next */
43 }; 48 };
44 49
45 // In the case of tcmalloc we have also to route the diagnostic symbols, 50 // In the case of tcmalloc we have also to route the diagnostic symbols,
46 // which are not part of the unified shim layer, to tcmalloc for consistency. 51 // which are not part of the unified shim layer, to tcmalloc for consistency.
47 52
48 extern "C" { 53 extern "C" {
49 54
50 SHIM_ALWAYS_EXPORT void malloc_stats(void) __THROW { 55 SHIM_ALWAYS_EXPORT void malloc_stats(void) __THROW {
51 return tc_malloc_stats(); 56 return tc_malloc_stats();
52 } 57 }
(...skipping 14 matching lines...) Expand all
67 72
68 #if defined(__ANDROID__) 73 #if defined(__ANDROID__)
69 SHIM_ALWAYS_EXPORT size_t malloc_usable_size(const void* address) __THROW { 74 SHIM_ALWAYS_EXPORT size_t malloc_usable_size(const void* address) __THROW {
70 #else 75 #else
71 SHIM_ALWAYS_EXPORT size_t malloc_usable_size(void* address) __THROW { 76 SHIM_ALWAYS_EXPORT size_t malloc_usable_size(void* address) __THROW {
72 #endif 77 #endif
73 return tc_malloc_size(address); 78 return tc_malloc_size(address);
74 } 79 }
75 80
76 } // extern "C" 81 } // extern "C"
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698