memory/build/jemalloc_config.c
author Guilherme Goncalves <guilherme.p.gonc@gmail.com>
Tue, 23 Dec 2014 07:44:00 -0500
changeset 221381 a0315fb0c4f91e2611fd5f9993bba246ac8cc791
parent 221377 495ecf1836228489f3780ea28e289427cba75da6
child 240984 63895748c94e5e1ee77fa1334c0ae5dc358abaeb
permissions -rw-r--r--
Bug 1108045 - Junk memory with jemalloc3. r=glandium

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifdef MOZ_JEMALLOC3

#define MOZ_JEMALLOC_IMPL

#include "mozmemory_wrap.h"
#include "mozilla/Types.h"

/* Override some jemalloc defaults */
#ifdef MOZ_B2G
/* we tolerate around 4MiB of dirty pages on most platforms, except for B2G,
 * where our limit is 1MiB
 */
#define MOZ_MALLOC_PLATFORM_OPTIONS ",lg_dirty_mult:8"
#else
#define MOZ_MALLOC_PLATFORM_OPTIONS ",lg_dirty_mult:6"
#endif

#ifdef DEBUG
#define MOZ_MALLOC_BUILD_OPTIONS ",junk:true"
#else
#define MOZ_MALLOC_BUILD_OPTIONS ",junk:free"
#endif

#define MOZ_MALLOC_OPTIONS "narenas:1,lg_chunk:20,tcache:false"
MFBT_DATA const char * je_(malloc_conf) =
  MOZ_MALLOC_OPTIONS MOZ_MALLOC_PLATFORM_OPTIONS MOZ_MALLOC_BUILD_OPTIONS;

#ifdef ANDROID
#include <android/log.h>

static void
_je_malloc_message(void *cbopaque, const char *s)
{
  __android_log_print(ANDROID_LOG_INFO, "GeckoJemalloc", "%s", s);
}

void (*je_(malloc_message))(void *, const char *s) = _je_malloc_message;
#endif

#endif /* MOZ_JEMALLOC3 */

/* Provide an abort function for use in jemalloc code */
#include <mozilla/Assertions.h>

void moz_abort() {
  MOZ_CRASH();
}