From a3298dd3caba888618ba2269f94187c730a069e1 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Fri, 10 Sep 2010 11:57:12 -0700 Subject: [PATCH] Bug 592923 - Add --enable-profiling configure option r=ted, a2.0=bz --- config/autoconf.mk.in | 1 + configure.in | 45 ++++++++++++++++++++++++++++++------ js/src/Makefile.in | 12 +++++++++- js/src/config/autoconf.mk.in | 1 + js/src/configure.in | 38 +++++++++++++++++++++++++----- 5 files changed, 83 insertions(+), 14 deletions(-) diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in index 3f2b874193a..773656b6dbd 100644 --- a/config/autoconf.mk.in +++ b/config/autoconf.mk.in @@ -107,6 +107,7 @@ MOZ_IPC = @MOZ_IPC@ MOZ_IPDL_TESTS = @MOZ_IPDL_TESTS@ MOZ_LEAKY = @MOZ_LEAKY@ MOZ_MEMORY = @MOZ_MEMORY@ +MOZ_PROFILING = @MOZ_PROFILING@ MOZ_JPROF = @MOZ_JPROF@ MOZ_SHARK = @MOZ_SHARK@ MOZ_CALLGRIND = @MOZ_CALLGRIND@ diff --git a/configure.in b/configure.in index f52792dde11..68aa00f4fde 100644 --- a/configure.in +++ b/configure.in @@ -1826,6 +1826,14 @@ MOZ_ARG_DISABLE_BOOL(os2-high-mem, MOZ_OS2_HIGH_MEMORY=1 ) AC_SUBST(MOZ_OS2_HIGH_MEMORY) +dnl ======================================================== +dnl = Use profiling compile flags +dnl ======================================================== +MOZ_ARG_ENABLE_BOOL(profiling, +[ --enable-profiling Set compile flags necessary for using sampling profilers (e.g. shark, perf)], + MOZ_PROFILING=1, + MOZ_PROFILING= ) + dnl ======================================================== dnl System overrides of the defaults for host dnl ======================================================== @@ -2034,7 +2042,12 @@ case "$target" in *-darwin*) MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@' MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@' - MOZ_OPTIMIZE_FLAGS="-O3 -fomit-frame-pointer" + # If we're building with --enable-profiling, we need a frame pointer. + if test -z "$MOZ_PROFILING"; then + MOZ_OPTIMIZE_FLAGS="-O3 -fomit-frame-pointer" + else + MOZ_OPTIMIZE_FLAGS="-O3 -fno-omit-frame-pointer" + fi _PEDANTIC= CFLAGS="$CFLAGS -fpascal-strings -fno-common" CXXFLAGS="$CXXFLAGS -fpascal-strings -fno-common" @@ -2193,7 +2206,12 @@ ia64*-hpux*) # -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results. MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50" esac - MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fomit-frame-pointer $MOZ_OPTIMIZE_SIZE_TWEAK" + # If we're building with --enable-profiling, we need a frame pointer. + if test -z "$MOZ_PROFILING"; then + MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fomit-frame-pointer $MOZ_OPTIMIZE_SIZE_TWEAK" + else + MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-omit-frame-pointer $MOZ_OPTIMIZE_SIZE_TWEAK" + fi MOZ_DEBUG_FLAGS="-g" fi @@ -2385,7 +2403,12 @@ ia64*-hpux*) MOZ_DEBUG_FLAGS='-Zi' MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV' WARNINGS_AS_ERRORS='-WX' - MOZ_OPTIMIZE_FLAGS='-O1' + # If we're building with --enable-profiling, we need -Oy-, which forces a frame pointer. + if test -z "$MOZ_PROFILING"; then + MOZ_OPTIMIZE_FLAGS='-O1' + else + MOZ_OPTIMIZE_FLAGS='-O1 -Oy-' + fi MOZ_JS_STATIC_LIBS='$(LIBXUL_DIST)/lib/js_static.lib' MOZ_JS_SHARED_LIBS='$(LIBXUL_DIST)/lib/mozjs.lib' MOZ_FIX_LINK_PATHS= @@ -2827,7 +2850,12 @@ alpha*-*-osf*) TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"' MOZ_GFX_OPTIMIZE_MOBILE=1 - MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fomit-frame-pointer" + # If we're building with --enable-profiling, we need a frame pointer. + if test -z "$MOZ_PROFILING"; then + MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fomit-frame-pointer" + else + MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fno-omit-frame-pointer" + fi ;; esac @@ -7429,10 +7457,11 @@ dnl ======================================================== dnl jprof dnl ======================================================== MOZ_ARG_ENABLE_BOOL(jprof, -[ --enable-jprof Enable jprof profiling tool (needs mozilla/tools/jprof)], +[ --enable-jprof Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.], MOZ_JPROF=1, MOZ_JPROF= ) if test -n "$MOZ_JPROF"; then + MOZ_PROFILING=1 AC_DEFINE(MOZ_JPROF) fi @@ -7440,10 +7469,11 @@ dnl ======================================================== dnl shark dnl ======================================================== MOZ_ARG_ENABLE_BOOL(shark, -[ --enable-shark Enable shark remote profiling (needs CHUD framework)], +[ --enable-shark Enable shark remote profiling (needs CHUD framework). Implies --enable-profiling.], MOZ_SHARK=1, MOZ_SHARK= ) if test -n "$MOZ_SHARK"; then + MOZ_PROFILING=1 AC_DEFINE(MOZ_SHARK) fi @@ -7462,10 +7492,11 @@ dnl ======================================================== dnl vtune dnl ======================================================== MOZ_ARG_ENABLE_BOOL(vtune, -[ --enable-vtune Enable vtune profiling], +[ --enable-vtune Enable vtune profiling. Implies --enable-profiling.], MOZ_VTUNE=1, MOZ_VTUNE= ) if test -n "$MOZ_VTUNE"; then + MOZ_PROFILING=1 AC_DEFINE(MOZ_VTUNE) fi diff --git a/js/src/Makefile.in b/js/src/Makefile.in index 2c7aa86e883..8b7a244a12a 100644 --- a/js/src/Makefile.in +++ b/js/src/Makefile.in @@ -87,7 +87,17 @@ else MODULE_OPTIMIZE_FLAGS = -O2 -ip endif else # not INTEL_CXX -MODULE_OPTIMIZE_FLAGS = -O3 -fstrict-aliasing -fomit-frame-pointer + +MODULE_OPTIMIZE_FLAGS = -O3 -fstrict-aliasing + +# We normally want -fomit-frame-pointer, but we want an explicit +# -fno-omit-frame-pointer if we're using a sampling profiler. +ifndef MOZ_PROFILING +MODULE_OPTIMIZE_FLAGS += -fomit-frame-pointer +else +MODULE_OPTIMIZE_FLAGS += -fno-omit-frame-pointer +endif + endif else # not GNU_CXX ifeq ($(OS_ARCH),SunOS) diff --git a/js/src/config/autoconf.mk.in b/js/src/config/autoconf.mk.in index 9d0d689de10..fc3054663c1 100644 --- a/js/src/config/autoconf.mk.in +++ b/js/src/config/autoconf.mk.in @@ -86,6 +86,7 @@ MOZ_IMG_ENCODERS= @MOZ_IMG_ENCODERS@ MOZ_JSDEBUGGER = @MOZ_JSDEBUGGER@ MOZ_LEAKY = @MOZ_LEAKY@ MOZ_MEMORY = @MOZ_MEMORY@ +MOZ_PROFILING = @MOZ_PROFILING@ MOZ_JPROF = @MOZ_JPROF@ MOZ_SHARK = @MOZ_SHARK@ MOZ_CALLGRIND = @MOZ_CALLGRIND@ diff --git a/js/src/configure.in b/js/src/configure.in index 8a818ea2c50..db18025de3c 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -1546,6 +1546,14 @@ MOZ_ARG_DISABLE_BOOL(os2-high-mem, MOZ_OS2_HIGH_MEMORY=1 ) AC_SUBST(MOZ_OS2_HIGH_MEMORY) +dnl ======================================================== +dnl = Use profiling compile flags +dnl ======================================================== +MOZ_ARG_ENABLE_BOOL(profiling, +[ --enable-profiling Set compile flags necessary for using sampling profilers (e.g. shark, perf)], + MOZ_PROFILING=1, + MOZ_PROFILING= ) + dnl ======================================================== dnl System overrides of the defaults for host dnl ======================================================== @@ -1725,7 +1733,12 @@ case "$target" in *-darwin*) MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@' MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@' - MOZ_OPTIMIZE_FLAGS="-O3 -fomit-frame-pointer" + # If we're building with --enable-profiling, we need a frame pointer. + if test -z "$MOZ_PROFILING"; then + MOZ_OPTIMIZE_FLAGS="-O3 -fomit-frame-pointer" + else + MOZ_OPTIMIZE_FLAGS="-O3 -fno-omit-frame-pointer" + fi _PEDANTIC= CFLAGS="$CFLAGS -fpascal-strings -fno-common" CXXFLAGS="$CXXFLAGS -fpascal-strings -fno-common" @@ -1884,7 +1897,12 @@ ia64*-hpux*) # -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results. MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50" esac - MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fomit-frame-pointer $MOZ_OPTIMIZE_SIZE_TWEAK" + # If we're building with --enable-profiling, we need a frame pointer. + if test -z "$MOZ_PROFILING"; then + MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fomit-frame-pointer $MOZ_OPTIMIZE_SIZE_TWEAK" + else + MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-reorder-functions -fno-omit-frame-pointer $MOZ_OPTIMIZE_SIZE_TWEAK" + fi MOZ_DEBUG_FLAGS="-g" fi @@ -2091,7 +2109,12 @@ ia64*-hpux*) MOZ_DEBUG_FLAGS='-Zi' MOZ_DEBUG_LDFLAGS='-DEBUG -DEBUGTYPE:CV' WARNINGS_AS_ERRORS='-WX' - MOZ_OPTIMIZE_FLAGS='-O1' + # If we're building with --enable-profiling, we need -Oy-, which forces a frame pointer. + if test -z "$MOZ_PROFILING"; then + MOZ_OPTIMIZE_FLAGS='-O1' + else + MOZ_OPTIMIZE_FLAGS='-O1 -Oy-' + fi MOZ_JS_LIBS='$(libdir)/mozjs.lib' MOZ_FIX_LINK_PATHS= DYNAMIC_XPCOM_LIBS='$(LIBXUL_DIST)/lib/xpcom.lib $(LIBXUL_DIST)/lib/xpcom_core.lib' @@ -4473,10 +4496,11 @@ dnl ======================================================== dnl jprof dnl ======================================================== MOZ_ARG_ENABLE_BOOL(jprof, -[ --enable-jprof Enable jprof profiling tool (needs mozilla/tools/jprof)], +[ --enable-jprof Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.], MOZ_JPROF=1, MOZ_JPROF= ) if test -n "$MOZ_JPROF"; then + MOZ_PROFILING=1 AC_DEFINE(MOZ_JPROF) fi @@ -4484,10 +4508,11 @@ dnl ======================================================== dnl shark dnl ======================================================== MOZ_ARG_ENABLE_BOOL(shark, -[ --enable-shark Enable shark remote profiling (needs CHUD framework)], +[ --enable-shark Enable shark remote profiling (needs CHUD framework). Implies --enable-profiling.], MOZ_SHARK=1, MOZ_SHARK= ) if test -n "$MOZ_SHARK"; then + MOZ_PROFILING=1 AC_DEFINE(MOZ_SHARK) fi @@ -4506,10 +4531,11 @@ dnl ======================================================== dnl vtune dnl ======================================================== MOZ_ARG_ENABLE_BOOL(vtune, -[ --enable-vtune Enable vtune profiling], +[ --enable-vtune Enable vtune profiling. Implies --enable-profiling.], MOZ_VTUNE=1, MOZ_VTUNE= ) if test -n "$MOZ_VTUNE"; then + MOZ_PROFILING=1 AC_DEFINE(MOZ_VTUNE) fi