Commit 6092e05e authored by Hidehiko Abe's avatar Hidehiko Abe Committed by Commit Bot

Move spinlock to a function static variable from global.

The current code hits static initializer check.
Moved to a function so that it will be initialized on demand.

Bug: 1119650
Test: Ran linux-rel tryjob.

Change-Id: Id77428a3754892c6f17fab48030d9f44673e37ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2364155Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Commit-Queue: Hidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800380}
parent f9f10f0d
...@@ -121,3 +121,4 @@ Modifications: ...@@ -121,3 +121,4 @@ Modifications:
compiler to optimize away a static constructor compiler to optimize away a static constructor
- Include <atomic> in malloc_extension.h due to std::atomic usage - Include <atomic> in malloc_extension.h due to std::atomic usage
- Precompute the pointer mask for doubly linked free lists instead of computing it on each access. - Precompute the pointer mask for doubly linked free lists instead of computing it on each access.
- Move spinlock to function static variable to fix static initializer check error.
...@@ -248,8 +248,6 @@ void* AllocWithMmap(size_t length, bool is_aslr_enabled) { ...@@ -248,8 +248,6 @@ void* AllocWithMmap(size_t length, bool is_aslr_enabled) {
COMPILE_ASSERT(kAddressBits <= 8 * sizeof(void*), COMPILE_ASSERT(kAddressBits <= 8 * sizeof(void*),
address_bits_larger_than_pointer_size); address_bits_larger_than_pointer_size);
static SpinLock spinlock(SpinLock::LINKER_INITIALIZED);
#if defined(HAVE_MMAP) || defined(MADV_FREE) #if defined(HAVE_MMAP) || defined(MADV_FREE)
#ifdef HAVE_GETPAGESIZE #ifdef HAVE_GETPAGESIZE
static size_t pagesize = 0; static size_t pagesize = 0;
...@@ -638,6 +636,7 @@ void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size, ...@@ -638,6 +636,7 @@ void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size,
// Discard requests that overflow // Discard requests that overflow
if (size + alignment < size) return NULL; if (size + alignment < size) return NULL;
static SpinLock spinlock(SpinLock::LINKER_INITIALIZED);
SpinLockHolder lock_holder(&spinlock); SpinLockHolder lock_holder(&spinlock);
if (!system_alloc_inited) { if (!system_alloc_inited) {
......
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