Bug 686805 part 7 - Display linker stats on each Startup Timeline event. r=tglek,r=khuey
authorMike Hommey <mh+mozilla@glandium.org>
Wed, 22 Feb 2012 08:12:15 +0100
changeset 90261 fb7252059ce5c3d38c1c6ebda880463fc48a8007
parent 90260 240113669206870d57913ce3cef8126a677997f4
child 90262 0e2ee581bf9365e8b7f7933c72da7b57a8ecbaf5
push idunknown
push userunknown
push dateunknown
reviewerstglek, khuey
bugs686805
milestone13.0a1
Bug 686805 part 7 - Display linker stats on each Startup Timeline event. r=tglek,r=khuey
configure.in
other-licenses/android/Makefile.in
toolkit/components/startup/StartupTimeline.h
xpcom/glue/standalone/Makefile.in
xpcom/glue/standalone/nsGlueLinkingDlopen.cpp
--- a/configure.in
+++ b/configure.in
@@ -2920,16 +2920,19 @@ ia64*-hpux*)
 
 *-os2*)
     HOST_NSPR_MDCPUCFG='\"md/_os2.cfg\"'
     ;;
 
 esac
 
 AC_SUBST(MOZ_LINKER)
+if test -n "$MOZ_LINKER"; then
+  AC_DEFINE(MOZ_LINKER)
+fi
 AC_SUBST(MOZ_ENABLE_SZIP)
 
 dnl Only one oddball right now (QNX), but this gives us flexibility
 dnl if any other platforms need to override this in the future.
 AC_DEFINE_UNQUOTED(D_INO,$DIRENT_INO)
 
 dnl ========================================================
 dnl Any platform that doesn't have MKSHLIB_FORCE_ALL defined
--- a/other-licenses/android/Makefile.in
+++ b/other-licenses/android/Makefile.in
@@ -46,17 +46,16 @@ MODULE           = android
 LIBRARY_NAME     = android
 FORCE_STATIC_LIB = 1
 
 CSRCS =
 
 ifdef MOZ_OLD_LINKER
 DEFINES += \
   -DLINKER_DEBUG=0 \
-  -DMOZ_LINKER \
   -DLINKER_TEXT_BASE=0xB0001000 \
   -DLINKER_AREA_SIZE=0x01000000 \
   $(NULL)
 
 ifeq ($(CPU_ARCH),arm)
 DEFINES += -DANDROID_ARM_LINKER
 else
 ifeq ($(CPU_ARCH),x86)
--- a/toolkit/components/startup/StartupTimeline.h
+++ b/toolkit/components/startup/StartupTimeline.h
@@ -47,16 +47,28 @@ mozilla_StartupTimeline_Event(FIRST_LOAD
 #else
 
 #ifndef mozilla_StartupTimeline
 #define mozilla_StartupTimeline
 
 #include "prtime.h"
 #include "nscore.h"
 
+#ifdef MOZ_LINKER
+extern "C" {
+/* This symbol is resolved by the custom linker. The function it resolves
+ * to dumps some statistics about the linker at the key events recorded
+ * by the startup timeline. */
+extern void __moz_linker_stats(const char *str)
+NS_VISIBILITY_DEFAULT __attribute__((weak));
+} /* extern "C" */
+#else
+
+#endif
+
 namespace mozilla {
 
 class StartupTimeline {
 public:
   enum Event {
     #define mozilla_StartupTimeline_Event(ev, z) ev,
     #include "StartupTimeline.h"
     #undef mozilla_StartupTimeline_Event
@@ -68,21 +80,25 @@ public:
   }
 
   static const char *Describe(Event ev) {
     return sStartupTimelineDesc[ev];
   }
 
   static void Record(Event ev, PRTime when = PR_Now()) {
     sStartupTimeline[ev] = when;
+#ifdef MOZ_LINKER
+    if (__moz_linker_stats)
+      __moz_linker_stats(Describe(ev));
+#endif
   }
 
   static void RecordOnce(Event ev) {
     if (!HasRecord(ev))
-      sStartupTimeline[ev] = PR_Now();
+      Record(ev);
   }
 
   static bool HasRecord(Event ev) {
     return sStartupTimeline[ev];
   }
 
 private:
   static NS_EXTERNAL_VIS_(PRTime) sStartupTimeline[MAX_EVENT_ID];
--- a/xpcom/glue/standalone/Makefile.in
+++ b/xpcom/glue/standalone/Makefile.in
@@ -48,22 +48,16 @@ EXTRA_DEPS += $(srcdir)/../objs.mk
 MODULE		= xpcom
 LIBRARY_NAME	= xpcomglue
 DIST_INSTALL	= 1
 
 LOCAL_INCLUDES	= \
 		-I$(srcdir)/../../build \
 		$(NULL)
 
-ifdef MOZ_LINKER
-ifeq ($(OS_TARGET),Linux)
-DEFINES += -DMOZ_LINKER
-endif
-endif
-
 ifeq (Darwin,$(OS_ARCH))
 ifeq (uikit,$(MOZ_WIDGET_TOOLKIT))
 LINKSRC = nsGlueLinkingDlopen.cpp
 else
 LINKSRC = nsGlueLinkingOSX.cpp
 endif
 endif
 
--- a/xpcom/glue/standalone/nsGlueLinkingDlopen.cpp
+++ b/xpcom/glue/standalone/nsGlueLinkingDlopen.cpp
@@ -57,17 +57,17 @@
 
 #if defined(SUNOS4) || defined(NEXTSTEP) || \
     (defined(OPENBSD) || defined(NETBSD)) && !defined(__ELF__)
 #define LEADING_UNDERSCORE "_"
 #else
 #define LEADING_UNDERSCORE
 #endif
 
-#ifdef MOZ_LINKER
+#if defined(MOZ_LINKER) && !defined(ANDROID)
 extern "C" {
 NS_HIDDEN __typeof(dlopen) __wrap_dlopen;
 NS_HIDDEN __typeof(dlsym) __wrap_dlsym;
 NS_HIDDEN __typeof(dlclose) __wrap_dlclose;
 }
 
 #define dlopen __wrap_dlopen
 #define dlsym __wrap_dlsym