Commit b6b63bd1 authored by Mao Huang's avatar Mao Huang Committed by Commit Bot

tcmalloc: allocator: add use_experimental_allocator_shim build flag

Original CL:

- https://codereview.chromium.org/1678893002

  allocator: add use_experimental_allocator_shim build flag

  This CL introduces a new GYP/GN build flag
  use_experimental_allocator_shim (default: false).  After this CL, the
  only side-effect of that flag is that tcmalloc does not override
  anymore the libc symbols (malloc, new etc.).  This is in preparation
  of a unified shim layer, which will come separately in upcoming CLs,
  which will take care of overriding those symbols in Chrome.

  Design doc: http://bit.ly/allocator-shim

  BUG=550886
  Committed: https://crrev.com/3217078aa86523fb341e0cf2b0c49d55434b534a
  Cr-Commit-Position: refs/heads/master@{#374449}

BUG=724399,b:70905156

Change-Id: Iaa205ec87dc160a2e738cc0d9adfe3c66acb12d9
Reviewed-on: https://chromium-review.googlesource.com/1130785
Commit-Queue: Gabriel Marin <gmx@chromium.org>
Reviewed-by: default avatarPrimiano Tucci <primiano@chromium.org>
Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580319}
parent 46dccb72
...@@ -68,17 +68,31 @@ ...@@ -68,17 +68,31 @@
static void ReplaceSystemAlloc(); // defined in the .h files below static void ReplaceSystemAlloc(); // defined in the .h files below
#if defined(TCMALLOC_DONT_REPLACE_SYSTEM_ALLOC)
// TCMALLOC_DONT_REPLACE_SYSTEM_ALLOC has the following semantic:
// - tcmalloc with all its tc_* (tc_malloc, tc_free) symbols is being built
// and linked as usual.
// - the default system allocator symbols (malloc, free, operator new) are NOT
// overridden. The embedded must take care of routing them to tc_* symbols.
// This no-op #if block effectively prevents the inclusion of the
// libc_override_* headers below.
static void ReplaceSystemAlloc() {}
// For windows, there are two ways to get tcmalloc. If we're // For windows, there are two ways to get tcmalloc. If we're
// patching, then src/windows/patch_function.cc will do the necessary // patching, then src/windows/patch_function.cc will do the necessary
// overriding here. Otherwise, we doing the 'redefine' trick, where // overriding here. Otherwise, we doing the 'redefine' trick, where
// we remove malloc/new/etc from mscvcrt.dll, and just need to define // we remove malloc/new/etc from mscvcrt.dll, and just need to define
// them now. // them now.
#if defined(_WIN32) && defined(WIN32_DO_PATCHING) #elif defined(_WIN32) && defined(WIN32_DO_PATCHING)
void PatchWindowsFunctions(); // in src/windows/patch_function.cc void PatchWindowsFunctions(); // in src/windows/patch_function.cc
static void ReplaceSystemAlloc() { PatchWindowsFunctions(); } static void ReplaceSystemAlloc() { PatchWindowsFunctions(); }
#elif defined(_WIN32) && !defined(WIN32_DO_PATCHING) #elif defined(_WIN32) && !defined(WIN32_DO_PATCHING)
#include "libc_override_redefine.h" // "libc_override_redefine.h" is included in the original gperftools. But,
// we define allocator functions in Chromium's base/allocator/allocator_shim.cc
// on Windows. We don't include libc_override_redefine.h here.
// ReplaceSystemAlloc() is defined here instead.
static void ReplaceSystemAlloc() {}
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include "libc_override_osx.h" #include "libc_override_osx.h"
......
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