Bug 764021 - Cleanup Android use of StartupTimeline. r=blassey
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 19 Jun 2012 09:16:33 +0200
changeset 97002 31e9fbf97eb113f24f59e6d17dc61b2ab473136c
parent 97001 86cf33eb20091690db75b83a676c61c95c04579a
child 97003 e2a44838954acb29f353d2f6c08f54ccf614176e
push id10817
push usermh@glandium.org
push dateTue, 19 Jun 2012 07:16:59 +0000
treeherdermozilla-inbound@31e9fbf97eb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey
bugs764021
milestone16.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 764021 - Cleanup Android use of StartupTimeline. r=blassey
mozglue/android/APKOpen.cpp
--- a/mozglue/android/APKOpen.cpp
+++ b/mozglue/android/APKOpen.cpp
@@ -57,31 +57,32 @@ extern "C" {
  * would fix the original problem. On older NDKs, it is not a problem
  * either because the way __dso_handle was used was already broken (and
  * the custom linker works around it).
  */
   NS_EXPORT __attribute__((weak)) void *__dso_handle;
 }
 
 typedef int mozglueresult;
+typedef int64_t MOZTime;
 
 enum StartupEvent {
 #define mozilla_StartupTimeline_Event(ev, z) ev,
 #include "StartupTimeline.h"
 #undef mozilla_StartupTimeline_Event
   MAX_STARTUP_EVENT_ID
 };
 
 using namespace mozilla;
 
-static uint64_t *sStartupTimeline;
-
-void StartupTimeline_Record(StartupEvent ev, struct timeval *tm)
+static MOZTime MOZ_Now()
 {
-  sStartupTimeline[ev] = (((uint64_t)tm->tv_sec * 1000000LL) + (uint64_t)tm->tv_usec);
+  struct timeval tm;
+  gettimeofday(&tm, 0);
+  return (((MOZTime)tm.tv_sec * 1000000LL) + (MOZTime)tm.tv_usec);
 }
 
 static struct mapping_info * lib_mapping = NULL;
 
 NS_EXPORT const struct mapping_info *
 getLibraryMapping()
 {
   return lib_mapping;
@@ -664,18 +665,17 @@ loadGeckoLibs(const char *apkName)
   chdir(getenv("GRE_HOME"));
 
 #ifdef MOZ_OLD_LINKER
   struct stat status;
   if (!stat(apkName, &status))
     apk_mtime = status.st_mtime;
 #endif
 
-  struct timeval t0, t1;
-  gettimeofday(&t0, 0);
+  MOZTime t0 = MOZ_Now();
   struct rusage usage1;
   getrusage(RUSAGE_THREAD, &usage1);
   
   RefPtr<Zip> zip = new Zip(apkName);
 
 #ifdef MOZ_CRASHREPORTER
   file_ids = (char *)extractBuf("lib.id", zip);
 #endif
@@ -737,28 +737,28 @@ loadGeckoLibs(const char *apkName)
   GETFUNC(notifyListCreated);
   GETFUNC(notifyGotNextMessage);
   GETFUNC(notifyReadingMessageListFailed);
   GETFUNC(notifyFilePickerResult);
   GETFUNC(getSurfaceBits);
   GETFUNC(onFullScreenPluginHidden);
   GETFUNC(getNextMessageFromQueue);
 #undef GETFUNC
-  sStartupTimeline = (uint64_t *) (uintptr_t) __wrap_dlsym(xul_handle, "_ZN7mozilla15StartupTimeline16sStartupTimelineE");
-  gettimeofday(&t1, 0);
+  void (*XRE_StartupTimelineRecord)(int, MOZTime) = (void (*)(int, MOZTime)) __wrap_dlsym(xul_handle, "XRE_StartupTimelineRecord");
+  MOZTime t1 = MOZ_Now();
   struct rusage usage2;
   getrusage(RUSAGE_THREAD, &usage2);
   __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Loaded libs in %ldms total, %ldms user, %ldms system, %ld faults",
-                      (t1.tv_sec - t0.tv_sec)*1000 + (t1.tv_usec - t0.tv_usec)/1000, 
+                      (t1 - t0) / 1000,
                       (usage2.ru_utime.tv_sec - usage1.ru_utime.tv_sec)*1000 + (usage2.ru_utime.tv_usec - usage1.ru_utime.tv_usec)/1000,
                       (usage2.ru_stime.tv_sec - usage1.ru_stime.tv_sec)*1000 + (usage2.ru_stime.tv_usec - usage1.ru_stime.tv_usec)/1000,
                       usage2.ru_majflt-usage1.ru_majflt);
 
-  StartupTimeline_Record(LINKER_INITIALIZED, &t0);
-  StartupTimeline_Record(LIBRARIES_LOADED, &t1);
+  XRE_StartupTimelineRecord(LINKER_INITIALIZED, t0);
+  XRE_StartupTimelineRecord(LIBRARIES_LOADED, t1);
   return SUCCESS;
 }
 
 static int loadSQLiteLibs(const char *apkName)
 {
   chdir(getenv("GRE_HOME"));
 
 #ifdef MOZ_OLD_LINKER