[scudo] Minor changes and refactoring
authorKostya Kortchinsky <kostyak@google.com>
Thu, 20 Apr 2017 15:11:00 +0000 (15:11 +0000)
committerKostya Kortchinsky <kostyak@google.com>
Thu, 20 Apr 2017 15:11:00 +0000 (15:11 +0000)
commit006805d146727b6651ae462211ad2c4bba8e72fe
treee5f61d85a299e1fdc528402d7a891a8148a99807
parent04e7c08d9ecef2815a14d1e5c90898be16fcd587
[scudo] Minor changes and refactoring

Summary:
This is part of D31947 that is being split into several smaller changes.

This one deals with all the minor changes, more specifically:
- Rename some variables and functions to make their purpose clearer;
- Reorder some code;
- Mark the hot termination incurring checks as `UNLIKELY`; if they happen, the
  program will die anyway;
- Add a `getScudoChunk` method;
- Add an `eraseHeader` method to ScudoChunk that will clear a header with 0s;
- Add a parameter to `allocate` to know if the allocated chunk should be filled
  with zeros. This allows `calloc` to not have to call
  `GetActuallyAllocatedSize`; more changes to get rid of this function on the
  hot paths will follow;
- reallocate was missing a check to verify that the pointer is properly
  aligned on `MinAlignment`;
- The `Stats` in the secondary have to be protected by a mutex as the `Add`
  and `Sub` methods are actually not atomic;
- The software CRC32 function was moved to the header to allow for inlining.

Reviewers: dvyukov, alekseyshl, kcc

Reviewed By: dvyukov

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D32242

llvm-svn: 300846
compiler-rt/lib/scudo/scudo_allocator.cpp
compiler-rt/lib/scudo/scudo_allocator.h
compiler-rt/lib/scudo/scudo_allocator_secondary.h
compiler-rt/lib/scudo/scudo_utils.cpp
compiler-rt/lib/scudo/scudo_utils.h