Bug 1062473: Use mozalloc's moz_malloc_size_of in the JS shell, not our own custom copy. r=glandium

This commit is contained in:
Jim Blandy 2015-04-13 16:11:32 -07:00
parent b7bb528df0
commit 3b2e239893
5 changed files with 35 additions and 46 deletions

View File

@ -243,6 +243,7 @@ def check_style():
# - "js/src/vm/String.h" -> "vm/String.h"
mfbt_inclnames = set() # type: set(inclname)
mozalloc_inclnames = set() # type: set(inclname)
js_names = dict() # type: dict(filename, inclname)
# Select the appropriate files.
@ -251,6 +252,10 @@ def check_style():
inclname = 'mozilla/' + filename.split('/')[-1]
mfbt_inclnames.add(inclname)
if filename.startswith('memory/mozalloc/') and filename.endswith('.h'):
inclname = 'mozilla/' + filename.split('/')[-1]
mozalloc_inclnames.add(inclname)
if filename.startswith('js/public/') and filename.endswith('.h'):
inclname = 'js/' + filename[len('js/public/'):]
js_names[filename] = inclname
@ -261,13 +266,13 @@ def check_style():
inclname = filename[len('js/src/'):]
js_names[filename] = inclname
all_inclnames = mfbt_inclnames | set(js_names.values())
all_inclnames = mfbt_inclnames | mozalloc_inclnames | set(js_names.values())
edges = dict() # type: dict(inclname, set(inclname))
# We don't care what's inside the MFBT files, but because they are
# #included from JS files we have to add them to the inclusion graph.
for inclname in mfbt_inclnames:
# We don't care what's inside the MFBT and MOZALLOC files, but because they
# are #included from JS files we have to add them to the inclusion graph.
for inclname in mfbt_inclnames | mozalloc_inclnames:
edges[inclname] = set()
# Process all the JS files.

View File

@ -99,7 +99,9 @@ case $cmd in
cp -t ${tgtpath}/memory -dRp \
${TOPSRCDIR}/memory/moz.build \
${TOPSRCDIR}/memory/build \
${TOPSRCDIR}/memory/fallible \
${TOPSRCDIR}/memory/jemalloc \
${TOPSRCDIR}/memory/mozalloc \
${TOPSRCDIR}/memory/mozjemalloc
# remove *.pyc and *.pyo files if any

View File

@ -10,6 +10,7 @@
#include "mozilla/Atomics.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/GuardObjects.h"
#include "mozilla/mozalloc.h"
#include "mozilla/PodOperations.h"
#ifdef XP_WIN
@ -6088,26 +6089,6 @@ DummyPreserveWrapperCallback(JSContext* cx, JSObject* obj)
return true;
}
size_t
ShellMallocSizeOf(const void* constPtr)
{
// Match the type that all the library functions we might use here expect.
void* ptr = (void*) constPtr;
if (!ptr)
return 0;
#if defined(HAVE_MALLOC_USABLE_SIZE)
return malloc_usable_size(ptr);
#elif defined(HAVE_MALLOC_SIZE)
return malloc_size(ptr);
#elif HAVE__MSIZE
return _msize(ptr);
#else
return 0;
#endif
}
int
main(int argc, char** argv, char** envp)
{
@ -6362,7 +6343,7 @@ main(int argc, char** argv, char** envp)
JS_SetNativeStackQuota(rt, gMaxStackSize);
JS::dbg::SetDebuggerMallocSizeOf(rt, ShellMallocSizeOf);
JS::dbg::SetDebuggerMallocSizeOf(rt, moz_malloc_size_of);
if (!offThreadState.init())
return 1;

View File

@ -4,13 +4,23 @@
# 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/.
DIRS += ['mozjemalloc']
DIRS += [
'mozalloc',
'fallible',
]
if CONFIG['MOZ_JEMALLOC3'] or CONFIG['MOZ_REPLACE_MALLOC']:
if not CONFIG['MOZ_NATIVE_JEMALLOC']:
DIRS += ['jemalloc']
if not CONFIG['JS_STANDALONE']:
DIRS += ['volatile']
DIRS += ['build']
if CONFIG['MOZ_MEMORY']:
DIRS += [
'build',
'mozjemalloc',
]
if CONFIG['MOZ_REPLACE_MALLOC']:
DIRS += ['replace']
if CONFIG['MOZ_JEMALLOC3'] or CONFIG['MOZ_REPLACE_MALLOC']:
if not CONFIG['MOZ_NATIVE_JEMALLOC']:
DIRS += ['jemalloc']
if CONFIG['MOZ_REPLACE_MALLOC']:
DIRS += ['replace']

View File

@ -34,23 +34,14 @@ if not CONFIG['JS_STANDALONE']:
if not CONFIG['LIBXUL_SDK']:
DIRS += [
'mozglue',
'mfbt',
'config/external/zlib',
'memory',
'mfbt',
'mozglue',
]
if CONFIG['MOZ_MEMORY']:
DIRS += ['memory']
if not CONFIG['JS_STANDALONE']:
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
DIRS += ['other-licenses/android']
DIRS += [
'memory/fallible',
'memory/mozalloc',
'memory/volatile',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
DIRS += ['other-licenses/android']
if not CONFIG['JS_STANDALONE']:
DIRS += ['xpcom/xpidl']