Bug 1423000 - Don't use a separate replace-malloc library for the minimal-logalloc test. r=njn
authorMike Hommey <mh+mozilla@glandium.org>
Sun, 03 Dec 2017 13:59:16 +0900
changeset 394974 eecbbe09235b0b63eb56702f096073fe6afc8db3
parent 394973 62a286838ec6e9e5e47f38a8992f7607eb3bd2f5
child 394975 fb91909e795aa37be434b56fcb69a9073573f572
push id56536
push usermh@glandium.org
push dateTue, 05 Dec 2017 04:04:39 +0000
treeherderautoland@1225ddb1e845 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1423000
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1423000 - Don't use a separate replace-malloc library for the minimal-logalloc test. r=njn Instead, only register a minimal set of functions when an environment variable is set.
memory/replace/logalloc/LogAlloc.cpp
memory/replace/logalloc/logalloc.mozbuild
memory/replace/logalloc/minimal/moz.build
memory/replace/logalloc/moz.build
memory/replace/logalloc/replay/Makefile.in
--- a/memory/replace/logalloc/LogAlloc.cpp
+++ b/memory/replace/logalloc/LogAlloc.cpp
@@ -83,17 +83,16 @@ replace_malloc(size_t aSize)
   MutexAutoLock lock(sMutex);
   void* ptr = sFuncs.malloc(aSize);
   if (ptr) {
     FdPrintf(sFd, "%zu %zu malloc(%zu)=%p\n", GetPid(), GetTid(), aSize, ptr);
   }
   return ptr;
 }
 
-#ifndef LOGALLOC_MINIMAL
 static int
 replace_posix_memalign(void** aPtr, size_t aAlignment, size_t aSize)
 {
   MutexAutoLock lock(sMutex);
   int ret = sFuncs.posix_memalign(aPtr, aAlignment, aSize);
   if (ret == 0) {
     FdPrintf(sFd, "%zu %zu posix_memalign(%zu,%zu)=%p\n", GetPid(), GetTid(),
              aAlignment, aSize, *aPtr);
@@ -107,17 +106,16 @@ replace_aligned_alloc(size_t aAlignment,
   MutexAutoLock lock(sMutex);
   void* ptr = sFuncs.aligned_alloc(aAlignment, aSize);
   if (ptr) {
     FdPrintf(sFd, "%zu %zu aligned_alloc(%zu,%zu)=%p\n", GetPid(), GetTid(),
              aAlignment, aSize, ptr);
   }
   return ptr;
 }
-#endif
 
 static void*
 replace_calloc(size_t aNum, size_t aSize)
 {
   MutexAutoLock lock(sMutex);
   void* ptr = sFuncs.calloc(aNum, aSize);
   if (ptr) {
     FdPrintf(sFd, "%zu %zu calloc(%zu,%zu)=%p\n", GetPid(), GetTid(), aNum,
@@ -155,28 +153,26 @@ replace_memalign(size_t aAlignment, size
   void* ptr = sFuncs.memalign(aAlignment, aSize);
   if (ptr) {
     FdPrintf(sFd, "%zu %zu memalign(%zu,%zu)=%p\n", GetPid(), GetTid(),
              aAlignment, aSize, ptr);
   }
   return ptr;
 }
 
-#ifndef LOGALLOC_MINIMAL
 static void*
 replace_valloc(size_t aSize)
 {
   MutexAutoLock lock(sMutex);
   void* ptr = sFuncs.valloc(aSize);
   if (ptr) {
     FdPrintf(sFd, "%zu %zu valloc(%zu)=%p\n", GetPid(), GetTid(), aSize, ptr);
   }
   return ptr;
 }
-#endif
 
 static void
 replace_jemalloc_stats(jemalloc_stats_t* aStats)
 {
   MutexAutoLock lock(sMutex);
   sFuncs.jemalloc_stats(aStats);
   FdPrintf(sFd, "%zu %zu jemalloc_stats()\n", GetPid(), GetTid());
 }
@@ -238,21 +234,21 @@ replace_init(malloc_table_t* aTable, Rep
 
   sMutex.Init();
   static LogAllocBridge bridge;
   sFuncs = *aTable;
 #define MALLOC_FUNCS MALLOC_FUNCS_MALLOC_BASE
 #define MALLOC_DECL(name, ...) aTable->name = replace_ ## name;
 #include "malloc_decls.h"
   aTable->jemalloc_stats = replace_jemalloc_stats;
-#ifndef LOGALLOC_MINIMAL
-  aTable->posix_memalign = replace_posix_memalign;
-  aTable->aligned_alloc = replace_aligned_alloc;
-  aTable->valloc = replace_valloc;
-#endif
+  if (!getenv("MALLOC_LOG_MINIMAL")) {
+    aTable->posix_memalign = replace_posix_memalign;
+    aTable->aligned_alloc = replace_aligned_alloc;
+    aTable->valloc = replace_valloc;
+  }
   *aBridge = &bridge;
 
 #ifndef _WIN32
   /* When another thread has acquired a lock before forking, the child
    * process will inherit the lock state but the thread, being nonexistent
    * in the child process, will never release it, leading to a dead-lock
    * whenever the child process gets the lock. We thus need to ensure no
    * other thread is holding the lock before forking, by acquiring it
deleted file mode 100644
--- a/memory/replace/logalloc/logalloc.mozbuild
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-SOURCES += [
-    'FdPrintf.cpp',
-    'LogAlloc.cpp',
-]
-
-DisableStlWrapping()
-NO_PGO = True
-DEFINES['MOZ_NO_MOZALLOC'] = True
-
-LOCAL_INCLUDES += [
-    '/memory/build',
-]
-
-# Android doesn't have pthread_atfork, but we have our own in mozglue.
-if CONFIG['OS_TARGET'] == 'Android' and FORCE_SHARED_LIB:
-    USE_LIBS += [
-        'mozglue',
-    ]
deleted file mode 100644
--- a/memory/replace/logalloc/minimal/moz.build
+++ /dev/null
@@ -1,11 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-SharedLibrary('logalloc_minimal')
-
-include('../logalloc.mozbuild')
-
-DEFINES['LOGALLOC_MINIMAL'] = True
--- a/memory/replace/logalloc/moz.build
+++ b/memory/replace/logalloc/moz.build
@@ -1,14 +1,30 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 ReplaceMalloc('logalloc')
 
-include('logalloc.mozbuild')
+SOURCES += [
+    'FdPrintf.cpp',
+    'LogAlloc.cpp',
+]
+
+DisableStlWrapping()
+NO_PGO = True
+DEFINES['MOZ_NO_MOZALLOC'] = True
+
+LOCAL_INCLUDES += [
+    '/memory/build',
+]
+
+# Android doesn't have pthread_atfork, but we have our own in mozglue.
+if CONFIG['OS_TARGET'] == 'Android' and FORCE_SHARED_LIB:
+    USE_LIBS += [
+        'mozglue',
+    ]
 
 DIRS += [
-    'minimal',
     'replay',
 ]
--- a/memory/replace/logalloc/replay/Makefile.in
+++ b/memory/replace/logalloc/replay/Makefile.in
@@ -14,17 +14,16 @@ LOGALLOC_VAR = DYLD_INSERT_LIBRARIES
 else
 LOGALLOC_VAR = LD_PRELOAD
 endif
 endif
 
 ifndef MOZ_REPLACE_MALLOC_STATIC
 LOGALLOC = $(LOGALLOC_VAR)=$(CURDIR)/../$(DLL_PREFIX)logalloc$(DLL_SUFFIX)
 endif
-LOGALLOC_MINIMAL = $(LOGALLOC_VAR)=$(CURDIR)/../minimal/$(DLL_PREFIX)logalloc_minimal$(DLL_SUFFIX)
 
 expected_output.log: $(srcdir)/replay.log
 # The logalloc-replay program will only replay entries from the first pid,
 # so the expected output only contains entries beginning with "1 "
 	grep "^1 " $< > $@
 
 check:: $(srcdir)/replay.log expected_output.log $(srcdir)/expected_output_minimal.log
 # Test with MALLOC_LOG as a file descriptor number
@@ -33,11 +32,11 @@ check:: $(srcdir)/replay.log expected_ou
 # initializer in the STL allocates memory, which we obviously don't have
 # in expected_output.log.
 	MALLOC_LOG=1 $(LOGALLOC) ./$(PROGRAM) < $< | sed -n '/jemalloc_stats/,$$p' | $(PYTHON) $(srcdir)/logalloc_munge.py | diff -w - expected_output.log
 # Test with MALLOC_LOG as a file name
 	$(RM) test_output.log
 	MALLOC_LOG=test_output.log $(LOGALLOC) ./$(PROGRAM) < $<
 	sed -n '/jemalloc_stats/,$$p' test_output.log | $(PYTHON) $(srcdir)/logalloc_munge.py | diff -w - expected_output.log
 
-	MALLOC_LOG=1 $(LOGALLOC_MINIMAL) ./$(PROGRAM) < $< | sed -n '/jemalloc_stats/,$$p' | $(PYTHON) $(srcdir)/logalloc_munge.py | diff -w - $(srcdir)/expected_output_minimal.log
+	MALLOC_LOG=1 MALLOC_LOG_MINIMAL=1 $(LOGALLOC) ./$(PROGRAM) < $< | sed -n '/jemalloc_stats/,$$p' | $(PYTHON) $(srcdir)/logalloc_munge.py | diff -w - $(srcdir)/expected_output_minimal.log
 
 endif