Backed out 3 changesets (bug 799640) on the suspicion of regressing Tp5 by 50%
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 30 Nov 2012 16:05:13 -0500
changeset 124510 fd22236ffb15153cf28db0cf328098522d243425
parent 124509 d6529aa771822b00c8875e2d69c7cfa0fc8f1e8b
child 124511 6d1462fbb5395713e9ebbc92e5ead573521d4a00
push id297
push userlsblakk@mozilla.com
push dateTue, 26 Mar 2013 17:28:00 +0000
treeherdermozilla-release@64d7b45c34e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs799640
milestone20.0a1
backs out133c704dbcc68e7f573d3664f4e2107e2e4f2090
b130bb991d84db729555ad5b837dc3c5eb1a74a7
e47b059493cfb024e03b446701ede2e677d0f8bf
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
Backed out 3 changesets (bug 799640) on the suspicion of regressing Tp5 by 50% Backed out changeset 133c704dbcc6 (bug 799640) Backed out changeset b130bb991d84 (bug 799640) Backed out changeset e47b059493cf (bug 799640)
toolkit/components/startup/nsAppStartup.cpp
toolkit/xre/nsAppRunner.cpp
tools/profiler/JSAObjectBuilder.h
tools/profiler/JSCustomObjectBuilder.cpp
tools/profiler/JSCustomObjectBuilder.h
tools/profiler/JSObjectBuilder.cpp
tools/profiler/JSObjectBuilder.h
tools/profiler/Makefile.in
tools/profiler/TableTicker.cpp
tools/profiler/sps_sampler.h
xpcom/build/nsXPComInit.cpp
--- a/toolkit/components/startup/nsAppStartup.cpp
+++ b/toolkit/components/startup/nsAppStartup.cpp
@@ -21,17 +21,16 @@
 #include "nsIWindowWatcher.h"
 #include "nsIXULRuntime.h"
 #include "nsIXULWindow.h"
 #include "nsNativeCharsetUtils.h"
 #include "nsThreadUtils.h"
 #include "nsAutoPtr.h"
 #include "nsStringGlue.h"
 #include "mozilla/Preferences.h"
-#include "sampler.h"
 
 #include "prprf.h"
 #include "nsCRT.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsWidgetsCID.h"
 #include "nsAppShellCID.h"
 #include "nsXPCOMCIDInternal.h"
 #include "mozilla/Services.h"
@@ -383,17 +382,16 @@ nsAppStartup::Quit(uint32_t aMode)
   // Exit() method via nsAppExitEvent to allow one last pass
   // through any events in the queue. This guarantees a tidy cleanup.
   nsresult rv = NS_OK;
   bool postedExitEvent = false;
 
   if (mShuttingDown)
     return NS_OK;
 
-  SAMPLE_MARKER("Shutdown start");
   RecordShutdownStartTimeStamp();
 
   // If we're considering quitting, we will only do so if:
   if (ferocity == eConsiderQuit) {
     if (mConsiderQuitStopper == 0) {
       // there are no windows...
       ferocity = eAttemptQuit;
     }
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -1112,17 +1112,16 @@ ScopedXPCOMStartup::~ScopedXPCOMStartup(
     mozilla::MacAutoreleasePool pool;
 #endif
 
     nsCOMPtr<nsIAppStartup> appStartup (do_GetService(NS_APPSTARTUP_CONTRACTID));
     if (appStartup)
       appStartup->DestroyHiddenWindow();
 
     gDirServiceProvider->DoShutdown();
-    SAMPLE_MARKER("Shutdown early");
 
     WriteConsoleLog();
 
     NS_ShutdownXPCOM(mServiceManager);
     mServiceManager = nullptr;
   }
 }
 
@@ -3933,17 +3932,16 @@ XREMain::XRE_main(int argc, char* argv[]
     SaveFileToEnvIfUnset("XRE_PROFILE_PATH", mProfD);
     SaveFileToEnvIfUnset("XRE_PROFILE_LOCAL_PATH", mProfLD);
     SaveWordToEnvIfUnset("XRE_PROFILE_NAME", mProfileName);
 
 #ifdef MOZ_WIDGET_GTK
     MOZ_gdk_display_close(mGdkDisplay);
 #endif
 
-    SAMPLER_SHUTDOWN();
     rv = LaunchChild(mNativeApp, true);
 
 #ifdef MOZ_CRASHREPORTER
     if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER)
       CrashReporter::UnsetExceptionHandler();
 #endif
     return rv == NS_ERROR_LAUNCHED_CHILD_PROCESS ? 0 : 1;
   }
@@ -3956,18 +3954,16 @@ XREMain::XRE_main(int argc, char* argv[]
 
 #ifdef MOZ_CRASHREPORTER
   if (mAppData->flags & NS_XRE_ENABLE_CRASH_REPORTER)
       CrashReporter::UnsetExceptionHandler();
 #endif
 
   XRE_DeinitCommandLine();
 
-  SAMPLER_SHUTDOWN();
-
   return NS_FAILED(rv) ? 1 : 0;
 }
 
 #if defined(MOZ_METRO) && defined(XP_WIN)
 extern bool XRE_MetroCoreApplicationRun();
 static XREMain* xreMainPtr;
 
 // must be called by the thread we want as the main thread
@@ -4069,17 +4065,16 @@ XRE_mainMetro(int argc, char* argv[], co
   if (!XRE_MetroCoreApplicationRun()) {
     return 1;
   }
 
   // XRE_metroShutdown should have already been called on the worker
   // thread that called XRE_metroStartup.
   NS_ASSERTION(!xreMainPtr->mScopedXPCom,
                "XPCOM Shutdown hasn't occured, and we are exiting.");
-  SAMPLER_SHUTDOWN();
   return 0;
 }
 
 void SetWindowsEnvironment(WindowsEnvironmentType aEnvID);
 #endif // MOZ_METRO || !defined(XP_WIN)
 
 int
 XRE_main(int argc, char* argv[], const nsXREAppData* aAppData, uint32_t aFlags)
deleted file mode 100644
--- a/tools/profiler/JSAObjectBuilder.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#ifndef JSAOBJECTBUILDER_H
-#define JSAOBJECTBUILDER_H
-
-class JSCustomObject;
-class JSCustomArray;
-class nsAString;
-
-class JSAObjectBuilder
-{
-public:
-  virtual ~JSAObjectBuilder() = 0;
-
-  virtual void DefineProperty(JSCustomObject *aObject, const char *name, JSCustomObject *aValue) = 0;
-  virtual void DefineProperty(JSCustomObject *aObject, const char *name, JSCustomArray *aValue) = 0;
-  virtual void DefineProperty(JSCustomObject *aObject, const char *name, int value) = 0;
-  virtual void DefineProperty(JSCustomObject *aObject, const char *name, double value) = 0;
-  virtual void DefineProperty(JSCustomObject *aObject, const char *name, const char *value) = 0;
-  virtual void ArrayPush(JSCustomArray *aArray, int value) = 0;
-  virtual void ArrayPush(JSCustomArray *aArray, const char *value) = 0;
-  virtual void ArrayPush(JSCustomArray *aArray, JSCustomObject *aObject) = 0;
-  virtual JSCustomArray  *CreateArray() = 0;
-  virtual JSCustomObject *CreateObject() = 0;
-};
-
-#endif
deleted file mode 100644
--- a/tools/profiler/JSCustomObjectBuilder.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "JSCustomObjectBuilder.h"
-#include "nsStringGlue.h"
-#include "nsDataHashtable.h"
-#include "nsUTF8Utils.h"
-
-#if _MSC_VER
- #define snprintf _snprintf
-#endif
-
-// These are owned and deleted by JSCustomObject
-struct PropertyValue {
-  virtual ~PropertyValue() {}
-  virtual void SendToStream(std::ostream& stream) = 0;
-};
-
-template <typename T>
-struct finalizer_impl
-{
-  static void run(T) {}
-};
-
-template <typename T>
-struct finalizer_impl<T*>
-{
-  static void run(T* p) {
-    delete p;
-  }
-};
-
-template <>
-struct finalizer_impl<char *>
-{
-  static void run(char* p) {
-    free(p);
-  }
-};
-
-template <class T>
-class TemplatePropertyValue : public PropertyValue {
-public:
-  TemplatePropertyValue(T aValue)
-    : mValue(aValue)
-  {}
-
-  ~TemplatePropertyValue() {
-    finalizer_impl<T>::run(mValue);
-  }
-
-  virtual void SendToStream(std::ostream& stream);
-private:
-  T mValue;
-};
-
-// Escape a UTF8 string to a stream. When an illegal encoding
-// is found it will insert "INVALID" and the function will return.
-void EscapeToStream(std::ostream& stream, const char* str) {
-  stream << "\"";
-
-  size_t len = strlen(str);
-  const char* end = &str[len];
-  while (str < end) {
-    bool err;
-    const char* utf8CharStart = str;
-    uint32_t ucs4Char = UTF8CharEnumerator::NextChar(&str, end, &err);
-
-    if (err) {
-      // Encoding error
-      stream << "INVALID\"";
-      return;
-    }
-
-    // See http://www.ietf.org/rfc/rfc4627.txt?number=4627
-    // characters that must be escaped: quotation mark,
-    // reverse solidus, and the control characters
-    // (U+0000 through U+001F).
-    if (ucs4Char == '\"') {
-      stream << "\\\"";
-    } else if (ucs4Char == '\\') {
-      stream << "\\\\";
-    } else if (ucs4Char > 0xFF) {
-      PRUnichar chr[2];
-      ConvertUTF8toUTF16 encoder(chr);
-      encoder.write(utf8CharStart, str-utf8CharStart);
-      char escChar[13];
-      snprintf(escChar, mozilla::ArrayLength(escChar), "\\u%04X\\u%04X", chr[0], chr[1]);
-      stream << escChar;
-    } else if (ucs4Char < 0x1F || ucs4Char > 0xFF) {
-      char escChar[7];
-      snprintf(escChar, mozilla::ArrayLength(escChar), "\\u%04X", ucs4Char);
-      stream << escChar;
-    } else {
-      stream << char(ucs4Char);
-    }
-  }
-  stream << "\"";
-}
-
-class JSCustomObject {
-public:
-  JSCustomObject() {
-    mProperties.Init();
-  }
-  ~JSCustomObject();
-
-  friend std::ostream& operator<<(std::ostream& stream, JSCustomObject* entry);
-
-  template<class T>
-  void AddProperty(const char* aName, T aValue) {
-    mProperties.Put(nsDependentCString(aName), new TemplatePropertyValue<T>(aValue));
-  }
-
-  nsDataHashtable<nsCStringHashKey, PropertyValue*> mProperties;
-};
-
-class JSCustomArray {
-public:
-  nsTArray<PropertyValue*> mValues;
-
-  friend std::ostream& operator<<(std::ostream& stream, JSCustomArray* entry);
-
-  template<class T>
-  void AppendElement(T aValue) {
-    mValues.AppendElement(new TemplatePropertyValue<T>(aValue));
-  }
-};
-
-template <typename T>
-struct SendToStreamImpl
-{
-  static void run(std::ostream& stream, const T& t) {
-    stream << t;
-  }
-};
-
-template<typename T>
-struct SendToStreamImpl<T*>
-{
-  static void run(std::ostream& stream, T* t) {
-    stream << *t;
-  }
-};
-
-template <>
-struct SendToStreamImpl<char *>
-{
-  static void run(std::ostream& stream, char* p) {
-    EscapeToStream(stream, p);
-  }
-};
-
-template <>
-struct SendToStreamImpl<JSCustomObject*>
-{
-  static void run(std::ostream& stream, JSCustomObject* p) {
-    stream << p;
-  }
-};
-
-template <>
-struct SendToStreamImpl<JSCustomArray*>
-{
-  static void run(std::ostream& stream, JSCustomArray* p) {
-    stream << p;
-  }
-};
-
-template <class T> void
-TemplatePropertyValue<T>::SendToStream(std::ostream& stream)
-{
-  SendToStreamImpl<T>::run(stream, mValue);
-}
-
-struct JSONStreamClosure {
-  std::ostream& mStream;
-  bool mNeedsComma;
-};
-
-PLDHashOperator HashTableOutput(const nsACString& aKey, PropertyValue* aValue, void* stream)
-{
-  JSONStreamClosure& streamClosure = *(JSONStreamClosure*)stream;
-  if (streamClosure.mNeedsComma) {
-    streamClosure.mStream << ",";
-  }
-  streamClosure.mNeedsComma = true;
-  EscapeToStream(streamClosure.mStream, (const char*)aKey.BeginReading());
-  streamClosure.mStream << ":";
-  aValue->SendToStream(streamClosure.mStream);
-  return PLDHashOperator::PL_DHASH_NEXT;
-}
-
-std::ostream&
-operator<<(std::ostream& stream, JSCustomObject* entry)
-{
-  JSONStreamClosure streamClosure = {stream, false};
-  stream << "{";
-  entry->mProperties.EnumerateRead(HashTableOutput, &streamClosure);
-  stream << "}";
-  return stream;
-}
-
-std::ostream&
-operator<<(std::ostream& stream, JSCustomArray* entry)
-{
-  bool needsComma = false;
-  stream << "[";
-  for (int i = 0; i < entry->mValues.Length(); i++) {
-    if (needsComma) {
-      stream << ",";
-    }
-    entry->mValues[i]->SendToStream(stream);
-    needsComma = true;
-  }
-  stream << "]";
-  return stream;
-}
-
-PLDHashOperator HashTableFree(const nsACString& aKey, PropertyValue* aValue, void* stream)
-{
-  delete aValue;
-  return PLDHashOperator::PL_DHASH_NEXT;
-}
-
-JSCustomObject::~JSCustomObject()
-{
-  mProperties.EnumerateRead(HashTableFree, nullptr);
-}
-
-JSAObjectBuilder::~JSAObjectBuilder()
-{
-}
-
-JSCustomObjectBuilder::JSCustomObjectBuilder()
-{}
-
-void
-JSCustomObjectBuilder::DeleteObject(JSCustomObject* aObject)
-{
-  delete aObject;
-}
-
-void
-JSCustomObjectBuilder::Serialize(JSCustomObject* aObject, std::ostream& stream)
-{
-  stream << aObject;
-}
-
-void
-JSCustomObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, JSCustomObject *aValue)
-{
-  aObject->AddProperty(name, aValue);
-}
-
-void
-JSCustomObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, JSCustomArray *aValue)
-{
-  aObject->AddProperty(name, aValue);
-}
-
-void
-JSCustomObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, int aValue)
-{
-  aObject->AddProperty(name, aValue);
-}
-
-void
-JSCustomObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, double aValue)
-{
-  aObject->AddProperty(name, aValue);
-}
-
-void
-JSCustomObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, const char *aValue)
-{
-  // aValue copy will be freed by the property desctructor (template specialization)
-  aObject->AddProperty(name, strdup(aValue));
-}
-
-void
-JSCustomObjectBuilder::ArrayPush(JSCustomArray *aArray, int aValue)
-{
-  aArray->AppendElement(aValue);
-}
-
-void
-JSCustomObjectBuilder::ArrayPush(JSCustomArray *aArray, const char *aValue)
-{
-  // aValue copy will be freed by the property desctructor (template specialization)
-  aArray->AppendElement(strdup(aValue));
-}
-
-void
-JSCustomObjectBuilder::ArrayPush(JSCustomArray *aArray, JSCustomObject *aObject)
-{
-  aArray->AppendElement(aObject);
-}
-
-JSCustomArray*
-JSCustomObjectBuilder::CreateArray() {
-  return new JSCustomArray();
-}
-
-JSCustomObject*
-JSCustomObjectBuilder::CreateObject() {
-  return new JSCustomObject();
-}
-
deleted file mode 100644
--- a/tools/profiler/JSCustomObjectBuilder.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#ifndef JSCUSTOMOBJECTBUILDER_H
-#define JSCUSTOMOBJECTBUILDER_H
-
-#include <ostream>
-#include "JSAObjectBuilder.h"
-
-class JSCustomObject;
-class JSCustomArray;
-class JSCustomObjectBuilder;
-
-class JSCustomObjectBuilder : public JSAObjectBuilder
-{
-public:
-
-  // We need to ensure that this object lives on the stack so that GC sees it properly
-  JSCustomObjectBuilder();
-
-  void Serialize(JSCustomObject* aObject, std::ostream& stream);
-
-  void DefineProperty(JSCustomObject *aObject, const char *name, JSCustomObject *aValue);
-  void DefineProperty(JSCustomObject *aObject, const char *name, JSCustomArray *aValue);
-  void DefineProperty(JSCustomObject *aObject, const char *name, int value);
-  void DefineProperty(JSCustomObject *aObject, const char *name, double value);
-  void DefineProperty(JSCustomObject *aObject, const char *name, const char *value, size_t valueLength);
-  void DefineProperty(JSCustomObject *aObject, const char *name, const char *value);
-  void ArrayPush(JSCustomArray *aArray, int value);
-  void ArrayPush(JSCustomArray *aArray, const char *value);
-  void ArrayPush(JSCustomArray *aArray, JSCustomObject *aObject);
-  JSCustomArray  *CreateArray();
-  JSCustomObject *CreateObject();
-
-  // Delete this object and all of its descendant
-  void DeleteObject(JSCustomObject* aObject);
-
-private:
-  // This class can't be copied
-  JSCustomObjectBuilder(const JSCustomObjectBuilder&);
-  JSCustomObjectBuilder& operator=(const JSCustomObjectBuilder&);
-
-  void* operator new(size_t);
-  void* operator new[](size_t);
-  void operator delete(void*) {
-    // Since JSCustomObjectBuilder has a virtual destructor the compiler
-    // has to provide a destructor in the object file that will call
-    // operate delete in case there is a derived class since its
-    // destructor wont know how to free this instance.
-    abort();
-  }
-  void operator delete[](void*);
-};
-
-#endif
deleted file mode 100644
--- a/tools/profiler/JSObjectBuilder.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#include "jsapi.h"
-#include "nsStringGlue.h"
-#include "JSObjectBuilder.h"
-
-JSObjectBuilder::JSObjectBuilder(JSContext *aCx) : mCx(aCx), mOk(JS_TRUE)
-{}
-
-void
-JSObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, JSCustomArray *aValue)
-{
-  DefineProperty(aObject, name, (JSCustomObject*)aValue);
-}
-
-void
-JSObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, JSCustomObject *aValue)
-{
-  if (!mOk)
-    return;
-
-  mOk = JS_DefineProperty(mCx, (JSObject*)aObject, name, OBJECT_TO_JSVAL((JSObject*)aValue), nullptr, nullptr, JSPROP_ENUMERATE);
-}
-
-void
-JSObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, int value)
-{
-  if (!mOk)
-    return;
-
-  mOk = JS_DefineProperty(mCx, (JSObject*)aObject, name, INT_TO_JSVAL(value), nullptr, nullptr, JSPROP_ENUMERATE);
-}
-
-void
-JSObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, double value)
-{
-  if (!mOk)
-    return;
-
-  mOk = JS_DefineProperty(mCx, (JSObject*)aObject, name, DOUBLE_TO_JSVAL(value), nullptr, nullptr, JSPROP_ENUMERATE);
-}
-
-void
-JSObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, nsAString &value)
-{
-  if (!mOk)
-    return;
-
-  const nsString &flat = PromiseFlatString(value);
-  JSString *string = JS_NewUCStringCopyN(mCx, static_cast<const jschar*>(flat.get()), flat.Length());
-  if (!string)
-    mOk = JS_FALSE;
-
-  if (!mOk)
-    return;
-
-  mOk = JS_DefineProperty(mCx, (JSObject*)aObject, name, STRING_TO_JSVAL(string), nullptr, nullptr, JSPROP_ENUMERATE);
-}
-
-void
-JSObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, const char *value, size_t valueLength)
-{
-  if (!mOk)
-    return;
-
-  JSString *string = JS_InternStringN(mCx, value, valueLength);
-  if (!string) {
-    mOk = JS_FALSE;
-    return;
-  }
-
-  mOk = JS_DefineProperty(mCx, (JSObject*)aObject, name, STRING_TO_JSVAL(string), nullptr, nullptr, JSPROP_ENUMERATE); }
-
-void
-JSObjectBuilder::DefineProperty(JSCustomObject *aObject, const char *name, const char *value)
-{
-  DefineProperty(aObject, name, value, strlen(value));
-}
-
-void
-JSObjectBuilder::ArrayPush(JSCustomArray *aArray, int value)
-{
-  if (!mOk)
-    return;
-
-  jsval objval = INT_TO_JSVAL(value);
-  uint32_t length;
-  mOk = JS_GetArrayLength(mCx, (JSObject*)aArray, &length);
-
-  if (!mOk)
-    return;
-
-  mOk = JS_SetElement(mCx, (JSObject*)aArray, length, &objval);
-}
-
-void
-JSObjectBuilder::ArrayPush(JSCustomArray *aArray, const char *value)
-{
-  if (!mOk)
-    return;
-
-  JSString *string = JS_NewStringCopyN(mCx, value, strlen(value));
-  if (!string) {
-    mOk = JS_FALSE;
-    return;
-  }
-
-  jsval objval = STRING_TO_JSVAL(string);
-  uint32_t length;
-  mOk = JS_GetArrayLength(mCx, (JSObject*)aArray, &length);
-
-  if (!mOk)
-    return;
-
-  mOk = JS_SetElement(mCx, (JSObject*)aArray, length, &objval);
-}
-
-void
-JSObjectBuilder::ArrayPush(JSCustomArray *aArray, JSCustomObject *aObject)
-{
-  if (!mOk)
-    return;
-
-  jsval objval = OBJECT_TO_JSVAL((JSObject*)aObject); uint32_t length;
-  mOk = JS_GetArrayLength(mCx, (JSObject*)aArray, &length);
-
-  if (!mOk)
-    return;
-
-  mOk = JS_SetElement(mCx, (JSObject*)aArray, length, &objval);
-}
-
-JSCustomArray*
-JSObjectBuilder::CreateArray() {
-  JSCustomArray *array = (JSCustomArray*)JS_NewArrayObject(mCx, 0, nullptr);
-  if (!array)
-    mOk = JS_FALSE;
-
-  return array;
-}
-
-JSCustomObject*
-JSObjectBuilder::CreateObject() {
-  JSCustomObject *obj = (JSCustomObject*)JS_NewObject(mCx, nullptr, nullptr, nullptr);
-  if (!obj)
-    mOk = JS_FALSE;
-
-  return obj;
-}
-
--- a/tools/profiler/JSObjectBuilder.h
+++ b/tools/profiler/JSObjectBuilder.h
@@ -1,62 +1,153 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
-#ifndef JSOBJECTBUILDER_H
-#define JSOBJECTBUILDER_H
-
-#include "JSAObjectBuilder.h"
-
-class JSCustomObject;
-class JSCustomObjectBuilder;
-class JSContext;
-class nsAString;
+#include "jsapi.h"
 
 /* this is handy wrapper around JSAPI to make it more pleasant to use.
  * We collect the JSAPI errors and so that callers don't need to */
-class JSObjectBuilder : public JSAObjectBuilder
+class JSObjectBuilder
 {
-public:
-  // We need to ensure that this object lives on the stack so that GC sees it properly
-  explicit JSObjectBuilder(JSContext *aCx);
-  ~JSObjectBuilder() {}
+  public:
+
+  void DefineProperty(JSObject *aObject, const char *name, JSObject *aValue)
+  {
+    if (!mOk)
+      return;
+
+    mOk = JS_DefineProperty(mCx, aObject, name, OBJECT_TO_JSVAL(aValue), NULL, NULL, JSPROP_ENUMERATE);
+  }
+
+  void DefineProperty(JSObject *aObject, const char *name, int value)
+  {
+    if (!mOk)
+      return;
+
+    mOk = JS_DefineProperty(mCx, aObject, name, INT_TO_JSVAL(value), NULL, NULL, JSPROP_ENUMERATE);
+  }
+
+  void DefineProperty(JSObject *aObject, const char *name, double value)
+  {
+    if (!mOk)
+      return;
+
+    mOk = JS_DefineProperty(mCx, aObject, name, DOUBLE_TO_JSVAL(value), NULL, NULL, JSPROP_ENUMERATE);
+  }
+
+  void DefineProperty(JSObject *aObject, const char *name, nsAString &value)
+  {
+    if (!mOk)
+      return;
+
+    const nsString &flat = PromiseFlatString(value);
+    JSString *string = JS_NewUCStringCopyN(mCx, static_cast<const jschar*>(flat.get()), flat.Length());
+    if (!string)
+      mOk = JS_FALSE;
+
+    if (!mOk)
+      return;
+
+    mOk = JS_DefineProperty(mCx, aObject, name, STRING_TO_JSVAL(string), NULL, NULL, JSPROP_ENUMERATE);
+  }
+
+  void DefineProperty(JSObject *aObject, const char *name, const char *value, size_t valueLength)
+  {
+    if (!mOk)
+      return;
+
+    JSString *string = JS_InternStringN(mCx, value, valueLength);
+    if (!string) {
+      mOk = JS_FALSE;
+      return;
+    }
+
+    mOk = JS_DefineProperty(mCx, aObject, name, STRING_TO_JSVAL(string), NULL, NULL, JSPROP_ENUMERATE);
+  }
+
+  void DefineProperty(JSObject *aObject, const char *name, const char *value)
+  {
+    DefineProperty(aObject, name, value, strlen(value));
+  }
+
+  void ArrayPush(JSObject *aArray, int value)
+  {
+    if (!mOk)
+      return;
 
-  void DefineProperty(JSCustomObject *aObject, const char *name, JSCustomObject *aValue);
-  void DefineProperty(JSCustomObject *aObject, const char *name, JSCustomArray *aValue);
-  void DefineProperty(JSCustomObject *aObject, const char *name, int value);
-  void DefineProperty(JSCustomObject *aObject, const char *name, double value);
-  void DefineProperty(JSCustomObject *aObject, const char *name, nsAString &value);
-  void DefineProperty(JSCustomObject *aObject, const char *name, const char *value, size_t valueLength);
-  void DefineProperty(JSCustomObject *aObject, const char *name, const char *value);
-  void ArrayPush(JSCustomArray *aArray, int value);
-  void ArrayPush(JSCustomArray *aArray, const char *value);
-  void ArrayPush(JSCustomArray *aArray, JSCustomArray *aObject);
-  void ArrayPush(JSCustomArray *aArray, JSCustomObject *aObject);
-  JSCustomArray *CreateArray();
-  JSCustomObject *CreateObject();
+    jsval objval = INT_TO_JSVAL(value);
+    uint32_t length;
+    mOk = JS_GetArrayLength(mCx, aArray, &length);
+
+    if (!mOk)
+      return;
+
+    mOk = JS_SetElement(mCx, aArray, length, &objval);
+  }
+
+  void ArrayPush(JSObject *aArray, const char *value)
+  {
+    if (!mOk)
+      return;
+
+    JSString *string = JS_NewStringCopyN(mCx, value, strlen(value));
+    if (!string) {
+      mOk = JS_FALSE;
+      return;
+    }
+
+    jsval objval = STRING_TO_JSVAL(string);
+    uint32_t length;
+    mOk = JS_GetArrayLength(mCx, aArray, &length);
+
+    if (!mOk)
+      return;
+
+    mOk = JS_SetElement(mCx, aArray, length, &objval);
+  }
 
-  JSObject* GetJSObject(JSCustomObject* aObject) { return (JSObject*)aObject; }
+  void ArrayPush(JSObject *aArray, JSObject *aObject)
+  {
+    if (!mOk)
+      return;
 
-private:
-  JSObjectBuilder(const JSObjectBuilder&);
-  JSObjectBuilder& operator=(const JSObjectBuilder&);
+    jsval objval = OBJECT_TO_JSVAL(aObject);
+    uint32_t length;
+    mOk = JS_GetArrayLength(mCx, aArray, &length);
+
+    if (!mOk)
+      return;
+
+    mOk = JS_SetElement(mCx, aArray, length, &objval);
+  }
 
-  void* operator new(size_t);
-  void* operator new[](size_t);
-  void operator delete(void*) {
-    // Since JSObjectBuilder has a virtual destructor the compiler
-    // has to provide a destructor in the object file that will call
-    // operate delete in case there is a derived class since its
-    // destructor wont know how to free this instance.
-    abort();
+  JSObject *CreateArray() {
+    JSObject *array = JS_NewArrayObject(mCx, 0, NULL);
+    if (!array)
+      mOk = JS_FALSE;
+
+    return array;
   }
-  void operator delete[](void*);
+
+  JSObject *CreateObject() {
+    JSObject *obj = JS_NewObject(mCx, NULL, NULL, NULL);
+    if (!obj)
+      mOk = JS_FALSE;
+
+    return obj;
+  }
+
+
+  // We need to ensure that this object lives on the stack so that GC sees it properly
+  JSObjectBuilder(JSContext *aCx) : mCx(aCx), mOk(JS_TRUE)
+  {
+  }
+  private:
+  JSObjectBuilder(JSObjectBuilder&);
 
   JSContext *mCx;
   JSObject *mObj;
-  int mOk;
+  JSBool mOk;
 };
 
-#endif
 
--- a/tools/profiler/Makefile.in
+++ b/tools/profiler/Makefile.in
@@ -58,18 +58,16 @@ LIBRARY_NAME    = profiler
 EXPORT_LIBRARY  = 1
 LIBXUL_LIBRARY  = 1
 IS_COMPONENT    = 1
 
 CPPSRCS		= \
   nsProfilerFactory.cpp \
   nsProfiler.cpp \
   TableTicker.cpp \
-  JSObjectBuilder.cpp \
-  JSCustomObjectBuilder.cpp \
   $(NULL)
 
 XPIDLSRCS = \
   nsIProfiler.idl \
   $(NULL)
 
 EXTRA_JS_MODULES = \
   Profiler.jsm \
--- a/tools/profiler/TableTicker.cpp
+++ b/tools/profiler/TableTicker.cpp
@@ -1,28 +1,28 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/. */
 
 #include <string>
 #include <stdio.h>
+#include <iostream>
 #include <fstream>
 #include <sstream>
 #include "sps_sampler.h"
 #include "platform.h"
 #include "nsXULAppAPI.h"
 #include "nsThreadUtils.h"
 #include "prenv.h"
 #include "shared-libraries.h"
 #include "mozilla/StackWalk.h"
 
 // JSON
 #include "JSObjectBuilder.h"
-#include "JSCustomObjectBuilder.h"
 #include "nsIJSRuntimeService.h"
 
 // Meta
 #include "nsXPCOM.h"
 #include "nsXPCOMCID.h"
 #include "nsIHttpProtocolHandler.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIXULRuntime.h"
@@ -302,41 +302,27 @@ public:
       }
 
       aCallback(entry, tagStringData);
 
       readPos = (readPos + incBy) % mEntrySize;
     }
   }
 
-  void ToStreamAsJSON(std::ostream& stream)
-  {
-    JSCustomObjectBuilder b;
-    JSCustomObject *profile = b.CreateObject();
-    BuildJSObject(b, profile);
-    b.Serialize(profile, stream);
-    b.DeleteObject(profile);
-  }
-
-  JSCustomObject *ToJSObject(JSContext *aCx)
+  JSObject *ToJSObject(JSContext *aCx)
   {
     JSObjectBuilder b(aCx);
-    JSCustomObject *profile = b.CreateObject();
-    BuildJSObject(b, profile);
 
-    return profile;
-  }
-
-  void BuildJSObject(JSAObjectBuilder& b, JSCustomObject* profile) {
-    JSCustomArray *samples = b.CreateArray();
+    JSObject *profile = b.CreateObject();
+    JSObject *samples = b.CreateArray();
     b.DefineProperty(profile, "samples", samples);
 
-    JSCustomObject *sample = nullptr;
-    JSCustomArray *frames = nullptr;
-    JSCustomArray *marker = nullptr;
+    JSObject *sample = NULL;
+    JSObject *frames = NULL;
+    JSObject *marker = NULL;
 
     int readPos = mReadPos;
     while (readPos != mLastFlushPos) {
       // Number of tag consumed
       int incBy = 1;
       ProfileEntry entry = mEntries[readPos];
 
       // Read ahead to the next tag, if it's a 'd' tag process it now
@@ -391,17 +377,17 @@ public:
               b.DefineProperty(sample, "time", entry.mTagFloat);
             }
           }
           break;
         case 'c':
         case 'l':
           {
             if (sample) {
-              JSCustomObject *frame = b.CreateObject();
+              JSObject *frame = b.CreateObject();
               if (entry.mTagName == 'l') {
                 // Bug 753041
                 // We need a double cast here to tell GCC that we don't want to sign
                 // extend 32-bit addresses starting with 0xFXXXXXX.
                 unsigned long long pc = (unsigned long long)(uintptr_t)entry.mTagPtr;
                 snprintf(tagBuff, DYNAMIC_MAX_STRING, "%#llx", pc);
                 b.DefineProperty(frame, "location", tagBuff);
               } else {
@@ -415,16 +401,18 @@ public:
                 }
               }
               b.ArrayPush(frames, frame);
             }
           }
       }
       readPos = (readPos + incBy) % mEntrySize;
     }
+
+    return profile;
   }
 
   ProfileStack* GetStack()
   {
     return mStack;
   }
 private:
   // Circular buffer 'Keep One Slot Open' implementation
@@ -480,27 +468,25 @@ class TableTicker: public Sampler {
 
   virtual void HandleSaveRequest();
 
   ThreadProfile* GetPrimaryThreadProfile()
   {
     return &mPrimaryThreadProfile;
   }
 
-  void ToStreamAsJSON(std::ostream& stream);
   JSObject *ToJSObject(JSContext *aCx);
-  JSCustomObject *GetMetaJSCustomObject(JSAObjectBuilder& b);
+  JSObject *GetMetaJSObject(JSObjectBuilder& b);
 
   const bool ProfileJS() { return mProfileJS; }
 
 private:
   // Not implemented on platforms which do not support backtracing
   void doBacktrace(ThreadProfile &aProfile, TickSample* aSample);
 
-  void BuildJSObject(JSAObjectBuilder& b, JSCustomObject* profile);
 private:
   // This represent the application's main thread (SAMPLER_INIT)
   ThreadProfile mPrimaryThreadProfile;
   TimeStamp mStartTime;
   bool mSaveRequested;
   bool mUseStackWalk;
   bool mJankOnly;
   bool mProfileJS;
@@ -522,16 +508,17 @@ WriteCallback(const jschar *buf, uint32_
  * to be sure that it is not being modified while saving.
  */
 class SaveProfileTask : public nsRunnable {
 public:
   SaveProfileTask() {}
 
   NS_IMETHOD Run() {
     TableTicker *t = tlsTicker.get();
+
     // Pause the profiler during saving.
     // This will prevent us from recording sampling
     // regarding profile saving. This will also
     // prevent bugs caused by the circular buffer not
     // being thread safe. Bug 750989.
     t->SetPaused(true);
 
     // Get file path
@@ -551,17 +538,17 @@ public:
     if (NS_FAILED(rv))
       return rv;
 
     rv = tmpFile->GetNativePath(tmpPath);
     if (NS_FAILED(rv))
       return rv;
 #endif
 
-    // Create a JSContext to run a JSCustomObjectBuilder :(
+    // Create a JSContext to run a JSObjectBuilder :(
     // Based on XPCShellEnvironment
     JSRuntime *rt;
     JSContext *cx;
     nsCOMPtr<nsIJSRuntimeService> rtsvc = do_GetService("@mozilla.org/js/xpc/RuntimeService;1");
     if (!rtsvc || NS_FAILED(rtsvc->GetRuntime(&rt)) || !rt) {
       LOG("failed to get RuntimeService");
       return NS_ERROR_FAILURE;;
     }
@@ -583,49 +570,52 @@ public:
 
       std::ofstream stream;
       stream.open(tmpPath.get());
       // Pause the profiler during saving.
       // This will prevent us from recording sampling
       // regarding profile saving. This will also
       // prevent bugs caused by the circular buffer not
       // being thread safe. Bug 750989.
+      t->SetPaused(true);
       if (stream.is_open()) {
         JSAutoCompartment autoComp(cx, obj);
         JSObject* profileObj = mozilla_sampler_get_profile_data(cx);
         jsval val = OBJECT_TO_JSVAL(profileObj);
         JS_Stringify(cx, &val, nullptr, JSVAL_NULL, WriteCallback, &stream);
         stream.close();
         LOGF("Saved to %s", tmpPath.get());
       } else {
         LOG("Fail to open profile log file.");
       }
     }
     JS_EndRequest(cx);
     JS_DestroyContext(cx);
 
+    t->SetPaused(false);
+
     return NS_OK;
   }
 };
 
 void TableTicker::HandleSaveRequest()
 {
   if (!mSaveRequested)
     return;
   mSaveRequested = false;
 
   // TODO: Use use the ipc/chromium Tasks here to support processes
   // without XPCOM.
   nsCOMPtr<nsIRunnable> runnable = new SaveProfileTask();
   NS_DispatchToMainThread(runnable);
 }
 
-JSCustomObject* TableTicker::GetMetaJSCustomObject(JSAObjectBuilder& b)
+JSObject* TableTicker::GetMetaJSObject(JSObjectBuilder& b)
 {
-  JSCustomObject *meta = b.CreateObject();
+  JSObject *meta = b.CreateObject();
 
   b.DefineProperty(meta, "version", 2);
   b.DefineProperty(meta, "interval", interval());
   b.DefineProperty(meta, "stackwalk", mUseStackWalk);
   b.DefineProperty(meta, "jank", mJankOnly);
   b.DefineProperty(meta, "processType", XRE_GetProcessType());
 
   nsresult res;
@@ -666,54 +656,40 @@ JSCustomObject* TableTicker::GetMetaJSCu
     res = appInfo->GetName(string);
     if (!NS_FAILED(res))
       b.DefineProperty(meta, "product", string.Data());
   }
 
   return meta;
 }
 
-void TableTicker::ToStreamAsJSON(std::ostream& stream)
-{
-  JSCustomObjectBuilder b;
-  JSCustomObject* profile = b.CreateObject();
-  BuildJSObject(b, profile);
-  b.Serialize(profile, stream);
-  b.DeleteObject(profile);
-}
-
 JSObject* TableTicker::ToJSObject(JSContext *aCx)
 {
   JSObjectBuilder b(aCx);
-  JSCustomObject* profile = b.CreateObject();
-  BuildJSObject(b, profile);
-  JSObject* jsProfile = b.GetJSObject(profile);
 
-  return jsProfile;
-}
+  JSObject *profile = b.CreateObject();
 
-void TableTicker::BuildJSObject(JSAObjectBuilder& b, JSCustomObject* profile)
-{
   // Put shared library info
   b.DefineProperty(profile, "libs", GetSharedLibraryInfoString().c_str());
 
   // Put meta data
-  JSCustomObject *meta = GetMetaJSCustomObject(b);
+  JSObject *meta = GetMetaJSObject(b);
   b.DefineProperty(profile, "meta", meta);
 
   // Lists the samples for each ThreadProfile
-  JSCustomArray *threads = b.CreateArray();
+  JSObject *threads = b.CreateArray();
   b.DefineProperty(profile, "threads", threads);
 
   // For now we only have one thread
   SetPaused(true);
-  JSCustomObject* threadSamples = b.CreateObject();
-  GetPrimaryThreadProfile()->BuildJSObject(b, threadSamples);
+  JSObject* threadSamples = GetPrimaryThreadProfile()->ToJSObject(aCx);
   b.ArrayPush(threads, threadSamples);
   SetPaused(false);
+
+  return profile;
 }
 
 static
 void addProfileEntry(volatile StackEntry &entry, ThreadProfile &aProfile,
                      ProfileStack *stack, void *lastpc)
 {
   int lineno = -1;
 
@@ -1081,31 +1057,18 @@ void mozilla_sampler_init()
 #if defined(XP_WIN) || defined(XP_MACOSX)
                          , "stackwalk"
 #endif
                          };
   mozilla_sampler_start(PROFILE_DEFAULT_ENTRY, PROFILE_DEFAULT_INTERVAL,
                         features, sizeof(features)/sizeof(const char*));
 }
 
-void mozilla_sampler_shutdown()
+void mozilla_sampler_deinit()
 {
-  TableTicker *t = tlsTicker.get();
-  if (t) {
-    const char *val = PR_GetEnv("MOZ_PROFILER_SHUTDOWN");
-    if (val) {
-      std::ofstream stream;
-      stream.open(val);
-      if (stream.is_open()) {
-        t->ToStreamAsJSON(stream);
-        stream.close();
-      }
-    }
-  }
-
   mozilla_sampler_stop();
   // We can't delete the Stack because we can be between a
   // sampler call_enter/call_exit point.
   // TODO Need to find a safe time to delete Stack
 }
 
 void mozilla_sampler_save()
 {
--- a/tools/profiler/sps_sampler.h
+++ b/tools/profiler/sps_sampler.h
@@ -3,52 +3,51 @@
  * 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 <stdlib.h>
 #include <signal.h>
 #include <stdarg.h>
 #include "mozilla/ThreadLocal.h"
 #include "nscore.h"
+#include "jsapi.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Util.h"
 #include "nsAlgorithm.h"
 
-
 /* QT has a #define for the word "slots" and jsfriendapi.h has a struct with
  * this variable name, causing compilation problems. Alleviate this for now by
  * removing this #define */
 #ifdef MOZ_WIDGET_QT
 #undef slots
 #endif
 #include "jsfriendapi.h"
 
 using mozilla::TimeStamp;
 using mozilla::TimeDuration;
 
 struct ProfileStack;
 class TableTicker;
-class JSCustomObject;
 
 extern mozilla::ThreadLocal<ProfileStack *> tlsStack;
 extern mozilla::ThreadLocal<TableTicker *> tlsTicker;
 extern bool stack_key_initialized;
 
 #ifndef SAMPLE_FUNCTION_NAME
 # ifdef __GNUC__
 #  define SAMPLE_FUNCTION_NAME __FUNCTION__
 # elif defined(_MSC_VER)
 #  define SAMPLE_FUNCTION_NAME __FUNCTION__
 # else
 #  define SAMPLE_FUNCTION_NAME __func__  // defined in C99, supported in various C++ compilers. Just raw function name.
 # endif
 #endif
 
 #define SAMPLER_INIT() mozilla_sampler_init()
-#define SAMPLER_SHUTDOWN() mozilla_sampler_shutdown()
+#define SAMPLER_DEINIT() mozilla_sampler_deinit()
 #define SAMPLER_START(entries, interval, features, featureCount) mozilla_sampler_start(entries, interval, features, featureCount)
 #define SAMPLER_STOP() mozilla_sampler_stop()
 #define SAMPLER_IS_ACTIVE() mozilla_sampler_is_active()
 #define SAMPLER_RESPONSIVENESS(time) mozilla_sampler_responsiveness(time)
 #define SAMPLER_GET_RESPONSIVENESS() mozilla_sampler_get_responsiveness()
 #define SAMPLER_FRAME_NUMBER(frameNumber) mozilla_sampler_frame_number(frameNumber)
 #define SAMPLER_SAVE() mozilla_sampler_save()
 #define SAMPLER_GET_PROFILE() mozilla_sampler_get_profile()
@@ -168,17 +167,16 @@ bool mozilla_sampler_is_active();
 void mozilla_sampler_responsiveness(TimeStamp time);
 void mozilla_sampler_frame_number(int frameNumber);
 const double* mozilla_sampler_get_responsiveness();
 void mozilla_sampler_save();
 char* mozilla_sampler_get_profile();
 JSObject *mozilla_sampler_get_profile_data(JSContext *aCx);
 const char** mozilla_sampler_get_features();
 void mozilla_sampler_init();
-void mozilla_sampler_shutdown();
 
 void mozilla_sampler_print_location();
 
 namespace mozilla {
 
 class NS_STACK_CLASS SamplerStackFrameRAII {
 public:
   // we only copy the strings at save time, so to take multiple parameters we'd need to copy them then.
--- a/xpcom/build/nsXPComInit.cpp
+++ b/xpcom/build/nsXPComInit.cpp
@@ -613,17 +613,16 @@ ShutdownXPCOM(nsIServiceManager* servMgr
         nsComponentManagerImpl::gComponentManager->FreeServices();
     }
 
     // Release the directory service
     NS_IF_RELEASE(nsDirectoryService::gService);
 
     nsCycleCollector_shutdown();
 
-    SAMPLE_MARKER("Shutdown xpcom");
     mozilla::PoisonWrite();
 
     if (moduleLoaders) {
         bool more;
         nsCOMPtr<nsISupports> el;
         while (NS_SUCCEEDED(moduleLoaders->HasMoreElements(&more)) &&
                more) {
             moduleLoaders->GetNext(getter_AddRefs(el));