Backout 746513dca667 (Bug 765357) due to xpcshell orange (linux, mac).
authorBenoit Girard <b56girard@gmail.com>
Sun, 24 Jun 2012 21:00:21 -0400
changeset 97553 61b4a68e24c9920a348b105ea0a3cf25776bebb9
parent 97552 67398aacf866f9e5c8e328e934620118cb50fc0b
child 97554 c659521a7a9a04d1db76e1e0e1f3e8b4d9d5486c
push idunknown
push userunknown
push dateunknown
bugs765357
milestone16.0a1
backs out746513dca667ec109c627f0a5b38726dd014001d
Backout 746513dca667 (Bug 765357) due to xpcshell orange (linux, mac).
testing/xpcshell/xpcshell.ini
tools/profiler/Makefile.in
tools/profiler/TableTicker.cpp
tools/profiler/nsIProfiler.idl
tools/profiler/nsProfiler.cpp
tools/profiler/tests/head_profiler.js
tools/profiler/tests/test_get_features.js
tools/profiler/tests/test_run.js
tools/profiler/tests/test_shared_library.js
tools/profiler/tests/test_start.js
tools/profiler/tests/xpcshell.ini
--- a/testing/xpcshell/xpcshell.ini
+++ b/testing/xpcshell/xpcshell.ini
@@ -119,10 +119,8 @@ run-if.config = ipc
 [include:modules/libpref/test/unit_ipc/xpcshell.ini]
 [include:netwerk/test/unit_ipc/xpcshell.ini]
 [include:netwerk/cookie/test/unit_ipc/xpcshell.ini]
 [include:toolkit/components/contentprefs/tests/unit_ipc/xpcshell.ini]
 [include:uriloader/exthandler/tests/unit_ipc/xpcshell.ini]
 
 [include:modules/libmar/tests/unit/xpcshell.ini]
 skip-if = os == "android"
-
-[include:tools/profiler/tests/xpcshell.ini]
--- a/tools/profiler/Makefile.in
+++ b/tools/profiler/Makefile.in
@@ -3,19 +3,16 @@
 # 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/.
 
 DEPTH       = ../..
 topsrcdir	  = @top_srcdir@
 srcdir      = @srcdir@
 VPATH       = $(srcdir)
-relativesrcdir = tools/profiler
-
-XPCSHELL_TESTS = tests
 
 include $(DEPTH)/config/autoconf.mk
 
 EXPORTS = sampler.h
 
 ifdef MOZ_ENABLE_PROFILER_SPS
 EXPORTS += \
   sps_sampler.h \
--- a/tools/profiler/TableTicker.cpp
+++ b/tools/profiler/TableTicker.cpp
@@ -234,19 +234,20 @@ public:
 
     JSObject *profile = b.CreateObject();
     JSObject *samples = b.CreateArray();
     b.DefineProperty(profile, "samples", samples);
 
     JSObject *sample = NULL;
     JSObject *frames = NULL;
 
-    int readPos = mReadPos;
-    while (readPos != mLastFlushPos) {
-      ProfileEntry entry = mEntries[readPos];
+    int oldReadPos = mReadPos;
+    while (mReadPos != mLastFlushPos) {
+      ProfileEntry entry = mEntries[mReadPos];
+      mReadPos = (mReadPos + 1) % mEntrySize;
       switch (entry.mTagName) {
         case 's':
           sample = b.CreateObject();
           b.DefineProperty(sample, "name", (const char*)entry.mTagData);
           frames = b.CreateArray();
           b.DefineProperty(sample, "frames", frames);
           b.ArrayPush(samples, sample);
           break;
@@ -261,18 +262,18 @@ public:
               // extend 32-bit addresses starting with 0xFXXXXXX.
               unsigned long long pc = (unsigned long long)(uintptr_t)entry.mTagPtr;
               snprintf(tagBuff, 1024, "%#llx", pc);
               b.DefineProperty(frame, "location", tagBuff);
               b.ArrayPush(frames, frame);
             }
           }
       }
-      readPos = (readPos + 1) % mEntrySize;
     }
+    mReadPos = oldReadPos;
 
     return profile;
   }
 
   ProfileStack* GetStack()
   {
     return mStack;
   }
@@ -760,53 +761,44 @@ const char** mozilla_sampler_get_feature
 
   return features;
 }
 
 // Values are only honored on the first start
 void mozilla_sampler_start(int aProfileEntries, int aInterval,
                            const char** aFeatures, uint32_t aFeatureCount)
 {
-  if (!stack_key_initialized)
-    mozilla_sampler_init();
-
   ProfileStack *stack = tlsStack.get();
   if (!stack) {
     ASSERT(false);
     return;
   }
 
   mozilla_sampler_stop();
 
   TableTicker *t = new TableTicker(aInterval, aProfileEntries, stack,
                                    aFeatures, aFeatureCount);
   tlsTicker.set(t);
   t->Start();
 }
 
 void mozilla_sampler_stop()
 {
-  if (!stack_key_initialized)
-    mozilla_sampler_init();
-
   TableTicker *t = tlsTicker.get();
   if (!t) {
     return;
   }
 
   t->Stop();
   delete t;
   tlsTicker.set(NULL);
 }
 
 bool mozilla_sampler_is_active()
 {
-  if (!stack_key_initialized)
-    mozilla_sampler_init();
-
   TableTicker *t = tlsTicker.get();
   if (!t) {
     return false;
   }
 
   return t->IsActive();
 }
 
--- a/tools/profiler/nsIProfiler.idl
+++ b/tools/profiler/nsIProfiler.idl
@@ -3,17 +3,17 @@
  * 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/. */
  
 #include "nsISupports.idl"
 
 [scriptable, uuid(e388fded-1321-41af-a988-861a2bc5cfc3)]
 interface nsIProfiler : nsISupports
 {
-  void StartProfiler(in PRUint32 aEntries, in PRUint32 aInterval,
+  void StartProfiler(in PRUint32 aInterval, in PRUint32 aEntries,
                       [array, size_is(aFeatureCount)] in string aFeatures,
                       in PRUint32 aFeatureCount);
   void StopProfiler();
   string GetProfile();
   [implicit_jscontext]
   jsval getProfileData();
   boolean IsActive();
   void GetResponsivenessTimes(out PRUint32 aCount, [retval, array, size_is(aCount)] out double aResult);
--- a/tools/profiler/nsProfiler.cpp
+++ b/tools/profiler/nsProfiler.cpp
@@ -21,20 +21,20 @@ NS_IMPL_ISUPPORTS1(nsProfiler, nsIProfil
 
 
 nsProfiler::nsProfiler()
 {
 }
 
 
 NS_IMETHODIMP
-nsProfiler::StartProfiler(PRUint32 aEntries, PRUint32 aInterval,
+nsProfiler::StartProfiler(PRUint32 aInterval, PRUint32 aEntries,
                           const char** aFeatures, PRUint32 aFeatureCount)
 {
-  SAMPLER_START(aEntries, aInterval, aFeatures, aFeatureCount);
+  SAMPLER_START(aInterval, aEntries, aFeatures, aFeatureCount);
 #ifdef MOZ_INSTRUMENT_EVENT_LOOP
   mozilla::InitEventTracing();
 #endif
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsProfiler::StopProfiler()
deleted file mode 100644
--- a/tools/profiler/tests/head_profiler.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/* 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/. */
-
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
deleted file mode 100644
--- a/tools/profiler/tests/test_get_features.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/* 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/. */
-  
-function run_test() {
-  // If we can't get the profiler component then assume gecko was
-  // built without it and pass all the tests
-  var profilerCc = Cc["@mozilla.org/tools/profiler;1"];
-  if (!profilerCc)
-    return;
-
-  var profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
-  if (!profiler)
-    return;
-
-  var profilerFeatures = profiler.GetFeatures([]);
-  do_check_true(profilerFeatures != null);
-}
deleted file mode 100644
--- a/tools/profiler/tests/test_run.js
+++ /dev/null
@@ -1,48 +0,0 @@
-/* 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/. */
-
-function run_test() {
-  // If we can't get the profiler component then assume gecko was
-  // built without it and pass all the tests
-  var profilerCc = Cc["@mozilla.org/tools/profiler;1"];
-  if (!profilerCc)
-    return;
-
-  var profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
-  if (!profiler)
-    return;
-
-  do_check_true(!profiler.IsActive());
-
-  profiler.StartProfiler(1000, 10, [], 0);
-
-  do_check_true(profiler.IsActive());
-
-  do_test_pending();
-
-  do_timeout(1000, function wait() {
-    // Check responsiveness
-    var resp = profiler.GetResponsivenessTimes({});
-    do_check_true(resp.length > 10);
-
-    // Check text profile format
-    var profileStr = profiler.GetProfile();
-    do_check_true(profileStr.length > 10);
-
-    // check json profile format
-    var profileObj = profiler.getProfileData();
-    do_check_neq(profileObj, null);
-    do_check_neq(profileObj.threads, null);
-    do_check_true(profileObj.threads.length >= 1);
-    do_check_neq(profileObj.threads[0].samples, null);
-    // NOTE: The number of samples will be empty since we
-    //       don't have any labels in the xpcshell code
-
-    profiler.StopProfiler();
-    do_check_true(!profiler.IsActive());
-    do_test_finished();
-  });
-
-
-}
deleted file mode 100644
--- a/tools/profiler/tests/test_shared_library.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/* 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/. */
-
-function run_test() {
-  // If we can't get the profiler component then assume gecko was
-  // built without it and pass all the tests
-  var profilerCc = Cc["@mozilla.org/tools/profiler;1"];
-  if (!profilerCc)
-    return;
-
-  var profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
-  if (!profiler)
-    return;
-
-  var sharedStr = profiler.getSharedLibraryInformation();
-  sharedStr = sharedStr.toLowerCase();
-
-  // Let's not hardcode anything too specific
-  // just some sanity checks.
-  do_check_neq(sharedStr.indexOf("name"), -1);
-  do_check_neq(sharedStr.indexOf("start"), -1);
-  do_check_neq(sharedStr.indexOf("end"), -1);
-  do_check_neq(sharedStr.indexOf("offset"), -1);
-}
deleted file mode 100644
--- a/tools/profiler/tests/test_start.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/* 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/. */
-  
-function run_test() {
-  // If we can't get the profiler component then assume gecko was
-  // built without it and pass all the tests
-  var profilerCc = Cc["@mozilla.org/tools/profiler;1"];
-  if (!profilerCc)
-    return;
-
-  var profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
-  if (!profiler)
-    return;
-
-  do_check_true(!profiler.IsActive());
-
-  profiler.StartProfiler(10, 100, [], 0);
-
-  do_check_true(profiler.IsActive());
-
-  profiler.StopProfiler();
-
-  do_check_true(!profiler.IsActive());
-}
deleted file mode 100644
--- a/tools/profiler/tests/xpcshell.ini
+++ /dev/null
@@ -1,8 +0,0 @@
-[DEFAULT]
-head = head_profiler.js
-tail =
-
-[test_start.js]
-[test_get_features.js]
-[test_shared_library.js]
-[test_run.js]