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

Issue 2601573002: mac: Hook up allocator shim. (Closed)

Created:
3 years, 12 months ago by erikchen
Modified:
3 years, 10 months ago
CC:
chromium-reviews, wfh+watch_chromium.org, mac-reviews_chromium.org, Dai Mikurube (NOT FULLTIME), vmpstr+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

mac: Hook up allocator shim. This CL is based on dskiba's CL at https://codereview.chromium.org/2499373003/#. This CL makes several changes: * Hooks into C/C++ heap allocations so that they go through base/allocator. This brings macOS into parity with the other platforms. * Add two new functions to AllocatorDispatch: BatchMallocFn and BatchFreeFn. On macOS, there is an additional abstraction layer called malloc zones. This CL only hooks the default malloc zone, which appears to be responsible for most allocations. There is no good mechanism [short of interposition] to determine when new malloc zones are added, so there's no clean mechanism of hooking all zones. Plus we would have to rework the allocator shim abstraction. BUG=665567

Patch Set 1 #

Patch Set 2 : more plumbing. #

Patch Set 3 : compile error. #

Patch Set 4 : Symbol visibility, cleanup. #

Patch Set 5 : add comment #

Patch Set 6 : Add plumbing. #

Patch Set 7 : clang format #

Patch Set 8 : Fix test. #

Patch Set 9 : More tests. #

Patch Set 10 : Fix const correctness. #

Patch Set 11 : more const void* fixes. #

Patch Set 12 : Undo const correctness change. #

Patch Set 13 : use __attribute__((constructor)). #

Patch Set 14 : Refactor. #

Patch Set 15 : Clean up. #

Total comments: 7
Unified diffs Side-by-side diffs Delta from patch set Stats (+462 lines, -200 lines) Patch
M base/allocator/BUILD.gn View 1 chunk +2 lines, -0 lines 0 comments Download
M base/allocator/allocator_shim.h View 10 11 2 chunks +9 lines, -0 lines 1 comment Download
M base/allocator/allocator_shim.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +22 lines, -0 lines 0 comments Download
M base/allocator/allocator_shim_default_dispatch_to_glibc.cc View 1 10 11 1 chunk +2 lines, -0 lines 0 comments Download
M base/allocator/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc View 1 10 11 1 chunk +2 lines, -0 lines 0 comments Download
M base/allocator/allocator_shim_default_dispatch_to_tcmalloc.cc View 1 10 11 1 chunk +2 lines, -0 lines 0 comments Download
M base/allocator/allocator_shim_default_dispatch_to_winheap.cc View 1 11 1 chunk +2 lines, -0 lines 0 comments Download
M base/allocator/allocator_shim_override_cpp_symbols.h View 4 2 chunks +42 lines, -0 lines 0 comments Download
A base/allocator/allocator_shim_override_mac_symbols.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +181 lines, -0 lines 3 comments Download
M base/allocator/allocator_shim_unittest.cc View 1 2 3 4 5 6 7 8 10 11 14 chunks +95 lines, -31 lines 0 comments Download
M base/debug/thread_heap_usage_tracker.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +25 lines, -1 line 0 comments Download
M base/debug/thread_heap_usage_tracker_unittest.cc View 1 2 3 10 11 1 chunk +2 lines, -0 lines 0 comments Download
M base/process/memory.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 2 chunks +12 lines, -0 lines 0 comments Download
M base/process/memory.cc View 2 chunks +0 lines, -5 lines 0 comments Download
M base/process/memory_mac.mm View 1 2 3 4 5 6 7 8 9 10 11 12 13 9 chunks +20 lines, -156 lines 1 comment Download
M base/trace_event/malloc_dump_provider.cc View 1 2 3 4 5 10 11 2 chunks +27 lines, -0 lines 0 comments Download
M build/config/allocator.gni View 1 2 3 4 2 chunks +8 lines, -5 lines 1 comment Download
M chrome/app/framework.order View 1 2 3 4 1 chunk +9 lines, -2 lines 1 comment Download

Dependent Patchsets:

Messages

Total messages: 69 (62 generated)
erikchen
primiano: Please review.
3 years, 11 months ago (2016-12-28 17:21:28 UTC) #60
Robert Sesek
https://codereview.chromium.org/2601573002/diff/300001/base/process/memory_mac.mm File base/process/memory_mac.mm (left): https://codereview.chromium.org/2601573002/diff/300001/base/process/memory_mac.mm#oldcode133 base/process/memory_mac.mm:133: void* oom_killer_malloc(struct _malloc_zone_t* zone, I think this may break ...
3 years, 11 months ago (2017-01-03 19:09:07 UTC) #62
DmitrySkiba
https://codereview.chromium.org/2601573002/diff/300001/base/allocator/allocator_shim.h File base/allocator/allocator_shim.h (right): https://codereview.chromium.org/2601573002/diff/300001/base/allocator/allocator_shim.h#newcode65 base/allocator/allocator_shim.h:65: using BatchMallocFn = unsigned(const AllocatorDispatch* self, We should also ...
3 years, 11 months ago (2017-01-10 21:48:34 UTC) #64
Primiano Tucci (use gerrit)
Had a first pass here. First of all, thanks for all the hard work here, ...
3 years, 11 months ago (2017-01-17 17:09:59 UTC) #65
erikchen
> My only objection is that the current CL is making the overall code that ...
3 years, 11 months ago (2017-01-23 21:55:23 UTC) #66
erikchen
On 2017/01/23 21:55:23, erikchen wrote: > > My only objection is that the current CL ...
3 years, 10 months ago (2017-01-27 22:47:11 UTC) #67
Robert Sesek
3 years, 10 months ago (2017-01-30 11:07:22 UTC) #69
Message was sent while issue was closed.
On 2017/01/27 22:47:11, erikchen wrote:
> rsesek: The new CL does not turn on the experimental shim yet, so we can punt
> this discussion by one more CL. That being said, the process should still die
in
> TerminateBecauseOutOfMemory(), but instead it will be called from
> oom_killer_new(), which should more closely mirror the behavior of the other
> platforms.

I have no problem with changing these functions. Just please also update the
magic signature generator after it lands so that things continue to bucket as
OOM correctly.

Powered by Google App Engine
This is Rietveld 408576698