Bug 1306327 - Remove everything related to frozen functions from the XPCOM glue. r=bsmedberg
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 10 Jan 2017 17:12:43 +0900
changeset 462795 6b46b8d889dfcf921c7823655cf1b92c55451c2f
parent 462794 908c2d41eeaafc34697261866d36206bfe896e4b
child 462796 ac9b535141f31ad86545730a83c15655bf0aace7
child 462801 544ad41d3dcf9059a70aeae55a9dcce031f22b1c
push id41857
push userbmo:mh+mozilla@glandium.org
push dateWed, 18 Jan 2017 00:24:11 +0000
reviewersbsmedberg
bugs1306327
milestone53.0a1
Bug 1306327 - Remove everything related to frozen functions from the XPCOM glue. r=bsmedberg Now that nothing is using those functions, we can remove them and limit the scope of the standalone glue to initialize the new Bootstrap API.
js/src/devtools/rootAnalysis/annotations.js
xpcom/build/FrozenFunctions.cpp
xpcom/build/moz.build
xpcom/build/nsXPCOMPrivate.h
xpcom/glue/standalone/moz.build
xpcom/glue/standalone/nsXPCOMGlue.cpp
xpcom/glue/standalone/nsXPCOMGlue.h
xpcom/glue/standalone/staticruntime/moz.build
--- a/js/src/devtools/rootAnalysis/annotations.js
+++ b/js/src/devtools/rootAnalysis/annotations.js
@@ -58,17 +58,16 @@ function indirectCallCannotGC(fullCaller
 // Ignore calls through functions pointers with these types
 var ignoreClasses = {
     "JSStringFinalizer" : true,
     "SprintfState" : true,
     "SprintfStateStr" : true,
     "JSLocaleCallbacks" : true,
     "JSC::ExecutableAllocator" : true,
     "PRIOMethods": true,
-    "XPCOMFunctions" : true, // I'm a little unsure of this one
     "_MD_IOVector" : true,
     "malloc_table_t": true, // replace_malloc
     "malloc_hook_table_t": true, // replace_malloc
 };
 
 // Ignore calls through TYPE.FIELD, where TYPE is the class or struct name containing
 // a function pointer field named FIELD.
 var ignoreCallees = {
deleted file mode 100644
--- a/xpcom/build/FrozenFunctions.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* 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 "nsXPCOM.h"
-#include "nsXPCOMPrivate.h"
-#include "nsXPCOMStrings.h"
-#include "xptcall.h"
-
-#include <string.h>
-
-/**
- * Private Method to register an exit routine.  This method
- * used to allow you to setup a callback that will be called from
- * the NS_ShutdownXPCOM function after all services and
- * components have gone away. It was fatally flawed in that the component
- * DLL could be released before the exit function was called; it is now a
- * stub implementation that does nothing.
- */
-XPCOM_API(nsresult)
-NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine, uint32_t aPriority);
-
-XPCOM_API(nsresult)
-NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine);
-
-static const XPCOMFunctions kFrozenFunctions = {
-  XPCOM_GLUE_VERSION,
-  sizeof(XPCOMFunctions),
-  &NS_InitXPCOM2,
-  &NS_ShutdownXPCOM,
-  &NS_GetServiceManager,
-  &NS_GetComponentManager,
-  &NS_GetComponentRegistrar,
-  &NS_GetMemoryManager,
-  &NS_NewLocalFile,
-  &NS_NewNativeLocalFile,
-  &NS_RegisterXPCOMExitRoutine,
-  &NS_UnregisterXPCOMExitRoutine,
-
-  // these functions were added post 1.4
-  &NS_GetDebug,
-  nullptr,
-
-  // these functions were added post 1.6
-  &NS_StringContainerInit,
-  &NS_StringContainerFinish,
-  &NS_StringGetData,
-  &NS_StringSetData,
-  &NS_StringSetDataRange,
-  &NS_StringCopy,
-  &NS_CStringContainerInit,
-  &NS_CStringContainerFinish,
-  &NS_CStringGetData,
-  &NS_CStringSetData,
-  &NS_CStringSetDataRange,
-  &NS_CStringCopy,
-  &NS_CStringToUTF16,
-  &NS_UTF16ToCString,
-  &NS_StringCloneData,
-  &NS_CStringCloneData,
-
-  // these functions were added post 1.7 (post Firefox 1.0)
-  &moz_xmalloc,
-  &moz_xrealloc,
-  &free,
-  &NS_StringContainerInit2,
-  &NS_CStringContainerInit2,
-  &NS_StringGetMutableData,
-  &NS_CStringGetMutableData,
-  nullptr,
-
-  // these functions were added post 1.8
-  &NS_DebugBreak,
-  &NS_LogInit,
-  &NS_LogTerm,
-  &NS_LogAddRef,
-  &NS_LogRelease,
-  &NS_LogCtor,
-  &NS_LogDtor,
-  &NS_LogCOMPtrAddRef,
-  &NS_LogCOMPtrRelease,
-  &NS_GetXPTCallStub,
-  &NS_DestroyXPTCallStub,
-  &NS_InvokeByIndex,
-  nullptr,
-  nullptr,
-  &NS_StringSetIsVoid,
-  &NS_StringGetIsVoid,
-  &NS_CStringSetIsVoid,
-  &NS_CStringGetIsVoid,
-
-  // these functions were added post 1.9, but then made obsolete
-  nullptr,
-  nullptr,
-
-  &NS_CycleCollectorSuspect3,
-};
-
-EXPORT_XPCOM_API(nsresult)
-NS_GetFrozenFunctions(XPCOMFunctions* aFunctions, const char* /* aLibraryPath */)
-{
-  if (!aFunctions) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
-  if (aFunctions->version != XPCOM_GLUE_VERSION) {
-    return NS_ERROR_FAILURE;
-  }
-
-  uint32_t size = aFunctions->size;
-  if (size > sizeof(XPCOMFunctions)) {
-    size = sizeof(XPCOMFunctions);
-  }
-
-  size -= offsetof(XPCOMFunctions, init);
-
-  memcpy(&aFunctions->init, &kFrozenFunctions.init, size);
-
-  return NS_OK;
-}
-
-/*
- * Stubs for nsXPCOMPrivate.h
- */
-
-EXPORT_XPCOM_API(nsresult)
-NS_RegisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine, uint32_t aPriority)
-{
-  return NS_OK;
-}
-
-EXPORT_XPCOM_API(nsresult)
-NS_UnregisterXPCOMExitRoutine(XPCOMExitRoutine aExitRoutine)
-{
-  return NS_OK;
-}
--- a/xpcom/build/moz.build
+++ b/xpcom/build/moz.build
@@ -45,17 +45,16 @@ else:
     SOURCES += ['PoisonIOInterposerStub.cpp']
 
 include('../glue/objs.mozbuild')
 
 UNIFIED_SOURCES += xpcom_gluens_src_cppsrcs
 UNIFIED_SOURCES += xpcom_glue_src_cppsrcs
 
 UNIFIED_SOURCES += [
-    'FrozenFunctions.cpp',
     'IOInterposer.cpp',
     'LateWriteChecks.cpp',
     'MainThreadIOLogger.cpp',
     'nsXPCOMStrings.cpp',
     'Services.cpp',
     'XPCOMInit.cpp',
 ]
 
--- a/xpcom/build/nsXPCOMPrivate.h
+++ b/xpcom/build/nsXPCOMPrivate.h
@@ -4,208 +4,31 @@
  * 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 nsXPCOMPrivate_h__
 #define nsXPCOMPrivate_h__
 
 #include "nscore.h"
 #include "nsXPCOM.h"
-#include "nsXPCOMStrings.h"
 #include "xptcall.h"
 
-class nsStringContainer;
-class nsCStringContainer;
-class nsPurpleBufferEntry;
-
 /**
  * During this shutdown notification all threads which run XPCOM code must
  * be joined.
  */
 #define NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID "xpcom-shutdown-threads"
 
 /**
  * During this shutdown notification all module loaders must unload XPCOM
  * modules.
  */
 #define NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID "xpcom-shutdown-loaders"
 
 // PUBLIC
-typedef nsresult   (*InitFunc)(nsIServiceManager** aResult,
-                               nsIFile* aBinDirectory,
-                               nsIDirectoryServiceProvider* aAppFileLocationProvider);
-typedef nsresult   (*ShutdownFunc)(nsIServiceManager* aServMgr);
-typedef nsresult   (*GetServiceManagerFunc)(nsIServiceManager** aResult);
-typedef nsresult   (*GetComponentManagerFunc)(nsIComponentManager** aResult);
-typedef nsresult   (*GetComponentRegistrarFunc)(nsIComponentRegistrar** aResult);
-typedef nsresult   (*GetMemoryManagerFunc)(nsIMemory** aResult);
-typedef nsresult   (*NewLocalFileFunc)(const nsAString& aPath,
-                                       bool aFollowLinks, nsIFile** aResult);
-typedef nsresult   (*NewNativeLocalFileFunc)(const nsACString& aPath,
-                                             bool aFollowLinks,
-                                             nsIFile** aResult);
-
-typedef nsresult   (*GetDebugFunc)(nsIDebug2** aResult);
-
-typedef nsresult   (*StringContainerInitFunc)(nsStringContainer&);
-typedef nsresult   (*StringContainerInit2Func)(nsStringContainer&,
-                                               const char16_t*,
-                                               uint32_t, uint32_t);
-typedef void       (*StringContainerFinishFunc)(nsStringContainer&);
-typedef uint32_t   (*StringGetDataFunc)(const nsAString&, const char16_t**,
-                                        bool*);
-typedef uint32_t   (*StringGetMutableDataFunc)(nsAString&, uint32_t,
-                                               char16_t**);
-typedef char16_t*  (*StringCloneDataFunc)(const nsAString&);
-typedef nsresult   (*StringSetDataFunc)(nsAString&, const char16_t*, uint32_t);
-typedef nsresult   (*StringSetDataRangeFunc)(nsAString&, uint32_t, uint32_t,
-                                             const char16_t*, uint32_t);
-typedef nsresult   (*StringCopyFunc)(nsAString&, const nsAString&);
-typedef void       (*StringSetIsVoidFunc)(nsAString&, const bool);
-typedef bool       (*StringGetIsVoidFunc)(const nsAString&);
-
-typedef nsresult   (*CStringContainerInitFunc)(nsCStringContainer&);
-typedef nsresult   (*CStringContainerInit2Func)(nsCStringContainer&,
-                                                const char*,
-                                                uint32_t, uint32_t);
-typedef void       (*CStringContainerFinishFunc)(nsCStringContainer&);
-typedef uint32_t   (*CStringGetDataFunc)(const nsACString&, const char**,
-                                         bool*);
-typedef uint32_t   (*CStringGetMutableDataFunc)(nsACString&, uint32_t, char**);
-typedef char*      (*CStringCloneDataFunc)(const nsACString&);
-typedef nsresult   (*CStringSetDataFunc)(nsACString&, const char*, uint32_t);
-typedef nsresult   (*CStringSetDataRangeFunc)(nsACString&, uint32_t, uint32_t,
-                                              const char*, uint32_t);
-typedef nsresult   (*CStringCopyFunc)(nsACString&, const nsACString&);
-typedef void       (*CStringSetIsVoidFunc)(nsACString&, const bool);
-typedef bool       (*CStringGetIsVoidFunc)(const nsACString&);
-
-typedef nsresult   (*CStringToUTF16)(const nsACString&, nsCStringEncoding,
-                                     nsAString&);
-typedef nsresult   (*UTF16ToCString)(const nsAString&, nsCStringEncoding,
-                                     nsACString&);
-
-typedef void*      (*AllocFunc)(size_t aSize);
-typedef void*      (*ReallocFunc)(void* aPtr, size_t aSize);
-typedef void       (*FreeFunc)(void* aPtr);
-
-typedef void       (*DebugBreakFunc)(uint32_t aSeverity,
-                                     const char* aStr, const char* aExpr,
-                                     const char* aFile, int32_t aLine);
-
-typedef void       (*xpcomVoidFunc)();
-typedef void       (*LogAddRefFunc)(void*, nsrefcnt, const char*, uint32_t);
-typedef void       (*LogReleaseFunc)(void*, nsrefcnt, const char*);
-typedef void       (*LogCtorFunc)(void*, const char*, uint32_t);
-typedef void       (*LogCOMPtrFunc)(void*, nsISupports*);
-
-typedef nsresult   (*GetXPTCallStubFunc)(REFNSIID, nsIXPTCProxy*,
-                                         nsISomeInterface**);
-typedef void       (*DestroyXPTCallStubFunc)(nsISomeInterface*);
-typedef nsresult   (*InvokeByIndexFunc)(nsISupports*, uint32_t, uint32_t,
-                                        nsXPTCVariant*);
-typedef bool       (*CycleCollectorFunc)(nsISupports*);
-typedef nsPurpleBufferEntry*
-                   (*CycleCollectorSuspect2Func)(void*,
-                                                 nsCycleCollectionParticipant*);
-typedef bool       (*CycleCollectorForget2Func)(nsPurpleBufferEntry*);
-typedef void       (*CycleCollectorSuspect3Func)(void*,
-                                                 nsCycleCollectionParticipant*,
-                                                 nsCycleCollectingAutoRefCnt*,
-                                                 bool*);
-// PRIVATE AND DEPRECATED
-typedef NS_CALLBACK_(nsresult, XPCOMExitRoutine)(void);
-
-typedef nsresult   (*RegisterXPCOMExitRoutineFunc)(XPCOMExitRoutine aExitRoutine,
-                                                   uint32_t aPriority);
-typedef nsresult   (*UnregisterXPCOMExitRoutineFunc)(XPCOMExitRoutine aExitRoutine);
-
-typedef struct XPCOMFunctions
-{
-  uint32_t version;
-  uint32_t size;
-
-  InitFunc init;
-  ShutdownFunc shutdown;
-  GetServiceManagerFunc getServiceManager;
-  GetComponentManagerFunc getComponentManager;
-  GetComponentRegistrarFunc getComponentRegistrar;
-  GetMemoryManagerFunc getMemoryManager;
-  NewLocalFileFunc newLocalFile;
-  NewNativeLocalFileFunc newNativeLocalFile;
-
-  RegisterXPCOMExitRoutineFunc registerExitRoutine;
-  UnregisterXPCOMExitRoutineFunc unregisterExitRoutine;
-
-  // Added for Mozilla 1.5
-  GetDebugFunc getDebug;
-  void* getTraceRefcnt;
-
-  // Added for Mozilla 1.7
-  StringContainerInitFunc stringContainerInit;
-  StringContainerFinishFunc stringContainerFinish;
-  StringGetDataFunc stringGetData;
-  StringSetDataFunc stringSetData;
-  StringSetDataRangeFunc stringSetDataRange;
-  StringCopyFunc stringCopy;
-  CStringContainerInitFunc cstringContainerInit;
-  CStringContainerFinishFunc cstringContainerFinish;
-  CStringGetDataFunc cstringGetData;
-  CStringSetDataFunc cstringSetData;
-  CStringSetDataRangeFunc cstringSetDataRange;
-  CStringCopyFunc cstringCopy;
-  CStringToUTF16 cstringToUTF16;
-  UTF16ToCString utf16ToCString;
-  StringCloneDataFunc stringCloneData;
-  CStringCloneDataFunc cstringCloneData;
-
-  // Added for Mozilla 1.8
-  AllocFunc allocFunc;
-  ReallocFunc reallocFunc;
-  FreeFunc freeFunc;
-  StringContainerInit2Func stringContainerInit2;
-  CStringContainerInit2Func cstringContainerInit2;
-  StringGetMutableDataFunc stringGetMutableData;
-  CStringGetMutableDataFunc cstringGetMutableData;
-  void* init3; // obsolete
-
-  // Added for Mozilla 1.9
-  DebugBreakFunc debugBreakFunc;
-  xpcomVoidFunc logInitFunc;
-  xpcomVoidFunc logTermFunc;
-  LogAddRefFunc logAddRefFunc;
-  LogReleaseFunc logReleaseFunc;
-  LogCtorFunc logCtorFunc;
-  LogCtorFunc logDtorFunc;
-  LogCOMPtrFunc logCOMPtrAddRefFunc;
-  LogCOMPtrFunc logCOMPtrReleaseFunc;
-  GetXPTCallStubFunc getXPTCallStubFunc;
-  DestroyXPTCallStubFunc destroyXPTCallStubFunc;
-  InvokeByIndexFunc invokeByIndexFunc;
-  CycleCollectorFunc cycleSuspectFunc; // obsolete: use cycleSuspect3Func
-  CycleCollectorFunc cycleForgetFunc; // obsolete
-  StringSetIsVoidFunc stringSetIsVoid;
-  StringGetIsVoidFunc stringGetIsVoid;
-  CStringSetIsVoidFunc cstringSetIsVoid;
-  CStringGetIsVoidFunc cstringGetIsVoid;
-
-  // Added for Mozilla 1.9.1
-  CycleCollectorSuspect2Func cycleSuspect2Func; // obsolete: use cycleSuspect3Func
-  CycleCollectorForget2Func cycleForget2Func; // obsolete
-
-  CycleCollectorSuspect3Func cycleSuspect3Func;
-
-} XPCOMFunctions;
-
-typedef nsresult (*GetFrozenFunctionsFunc)(XPCOMFunctions* aEntryPoints,
-                                           const char* aLibraryPath);
-XPCOM_API(nsresult) NS_GetFrozenFunctions(XPCOMFunctions* aEntryPoints,
-                                          const char* aLibraryPath);
-
-
 namespace mozilla {
 
 /**
  * Shutdown XPCOM. You must call this method after you are finished
  * using xpcom.
  *
  * @param aServMgr          The service manager which was returned by NS_InitXPCOM.
  *                          This will release servMgr.  You may pass null.
@@ -222,20 +45,16 @@ void SetICUMemoryFunctions();
 /**
  * C++ namespaced version of NS_LogTerm.
  */
 void LogTerm();
 
 } // namespace mozilla
 
 
-// think hard before changing this
-#define XPCOM_GLUE_VERSION 1
-
-
 /* XPCOM Specific Defines
  *
  * XPCOM_DLL              - name of the loadable xpcom library on disk.
  * XUL_DLL                - name of the loadable XUL library on disk
  * XPCOM_SEARCH_KEY       - name of the environment variable that can be
  *                          modified to include additional search paths.
  * GRE_CONF_NAME          - Name of the GRE Configuration file
  */
--- a/xpcom/glue/standalone/moz.build
+++ b/xpcom/glue/standalone/moz.build
@@ -4,22 +4,18 @@
 # 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/.
 
 # On win we build two glue libs - glue linked to crt dlls here and in staticruntime we build
 # a statically linked glue lib.
 if CONFIG['OS_ARCH'] == 'WINNT':
     DIRS += ['staticruntime']
 
-include('../objs.mozbuild')
-
-SOURCES += xpcom_glue_src_cppsrcs
-
 SOURCES += [
-    '../nsStringAPI.cpp',
+    '../FileUtils.cpp',
     'nsXPCOMGlue.cpp',
 ]
 
 Library('xpcomglue')
 
 EXPORTS += [
     'nsXPCOMGlue.h',
 ]
--- a/xpcom/glue/standalone/nsXPCOMGlue.cpp
+++ b/xpcom/glue/standalone/nsXPCOMGlue.cpp
@@ -16,18 +16,16 @@
 
 #include "mozilla/FileUtils.h"
 #include "mozilla/Sprintf.h"
 
 using namespace mozilla;
 
 #define XPCOM_DEPENDENT_LIBS_LIST "dependentlibs.list"
 
-static XPCOMFunctions xpcomFunctions;
-
 #if defined(XP_WIN)
 #define READ_TEXTMODE L"rt"
 #else
 #define READ_TEXTMODE "r"
 #endif
 
 #if defined(XP_WIN)
 #include <windows.h>
@@ -110,22 +108,24 @@ GetLibHandle(pathstr_t aDependentLib)
 }
 
 static NSFuncPtr
 GetSymbol(LibHandleType aLibHandle, const char* aSymbol)
 {
   return (NSFuncPtr)dlsym(aLibHandle, aSymbol);
 }
 
+#ifndef MOZ_LINKER
 static void
 CloseLibHandle(LibHandleType aLibHandle)
 {
   dlclose(aLibHandle);
 }
 #endif
+#endif
 
 struct DependentLib
 {
   LibHandleType libHandle;
   DependentLib* next;
 };
 
 static DependentLib* sTop;
@@ -192,28 +192,30 @@ struct ScopedCloseFileTraits
   {
     if (aFile) {
       fclose(aFile);
     }
   }
 };
 typedef Scoped<ScopedCloseFileTraits> ScopedCloseFile;
 
+#ifndef MOZ_LINKER
 static void
 XPCOMGlueUnload()
 {
   while (sTop) {
     CloseLibHandle(sTop->libHandle);
 
     DependentLib* temp = sTop;
     sTop = sTop->next;
 
     delete temp;
   }
 }
+#endif
 
 #if defined(XP_WIN)
 // like strpbrk but finds the *last* char, not the first
 static const char*
 ns_strrpbrk(const char* string, const char* strCharSet)
 {
   const char* found = nullptr;
   for (; *string; ++string) {
@@ -225,36 +227,36 @@ ns_strrpbrk(const char* string, const ch
       }
     }
   }
 
   return found;
 }
 #endif
 
-static GetFrozenFunctionsFunc
+static nsresult
 XPCOMGlueLoad(const char* aXPCOMFile)
 {
 #ifdef MOZ_LINKER
   if (!ReadDependentCB(aXPCOMFile)) {
-    return nullptr;
+    return NS_ERROR_FAILURE;
   }
 #else
   char xpcomDir[MAXPATHLEN];
 #ifdef XP_WIN
   const char* lastSlash = ns_strrpbrk(aXPCOMFile, "/\\");
 #elif XP_MACOSX
   // On OSX, the dependentlibs.list file lives under Contents/Resources.
   // However, the actual libraries listed in dependentlibs.list live under
   // Contents/MacOS. We want to read the list from Contents/Resources, then
   // load the libraries from Contents/MacOS.
   const char *tempSlash = strrchr(aXPCOMFile, '/');
   size_t tempLen = size_t(tempSlash - aXPCOMFile);
   if (tempLen > MAXPATHLEN) {
-    return nullptr;
+    return NS_ERROR_FAILURE;
   }
   char tempBuffer[MAXPATHLEN];
   memcpy(tempBuffer, aXPCOMFile, tempLen);
   tempBuffer[tempLen] = '\0';
   const char *slash = strrchr(tempBuffer, '/');
   tempLen = size_t(slash - tempBuffer);
   const char *lastSlash = aXPCOMFile + tempLen;
 #else
@@ -265,17 +267,17 @@ XPCOMGlueLoad(const char* aXPCOMFile)
     size_t len = size_t(lastSlash - aXPCOMFile);
 
     if (len > MAXPATHLEN - sizeof(XPCOM_FILE_PATH_SEPARATOR
 #ifdef XP_MACOSX
                                   "Resources"
                                   XPCOM_FILE_PATH_SEPARATOR
 #endif
                                   XPCOM_DEPENDENT_LIBS_LIST)) {
-      return nullptr;
+      return NS_ERROR_FAILURE;
     }
     memcpy(xpcomDir, aXPCOMFile, len);
     strcpy(xpcomDir + len, XPCOM_FILE_PATH_SEPARATOR
 #ifdef XP_MACOSX
                            "Resources"
                            XPCOM_FILE_PATH_SEPARATOR
 #endif
                            XPCOM_DEPENDENT_LIBS_LIST);
@@ -287,23 +289,23 @@ XPCOMGlueLoad(const char* aXPCOMFile)
 
   if (getenv("MOZ_RUN_GTEST")) {
     strcat(xpcomDir, ".gtest");
   }
 
   ScopedCloseFile flist;
   flist = TS_tfopen(xpcomDir, READ_TEXTMODE);
   if (!flist) {
-    return nullptr;
+    return NS_ERROR_FAILURE;
   }
 
 #ifdef XP_MACOSX
   tempLen = size_t(cursor - xpcomDir);
   if (tempLen > MAXPATHLEN - sizeof("MacOS" XPCOM_FILE_PATH_SEPARATOR) - 1) {
-    return nullptr;
+    return NS_ERROR_FAILURE;
   }
   strcpy(cursor, "MacOS" XPCOM_FILE_PATH_SEPARATOR);
   cursor += strlen(cursor);
 #endif
   *cursor = '\0';
 
   char buffer[MAXPATHLEN];
 
@@ -316,58 +318,27 @@ XPCOMGlueLoad(const char* aXPCOMFile)
     }
 
     // cut the trailing newline, if present
     if (buffer[l - 1] == '\n') {
       buffer[l - 1] = '\0';
     }
 
     if (l + size_t(cursor - xpcomDir) > MAXPATHLEN) {
-      return nullptr;
+      return NS_ERROR_FAILURE;
     }
 
     strcpy(cursor, buffer);
     if (!ReadDependentCB(xpcomDir)) {
       XPCOMGlueUnload();
-      return nullptr;
+      return NS_ERROR_FAILURE;
     }
   }
 #endif
-
-  GetFrozenFunctionsFunc sym =
-    (GetFrozenFunctionsFunc)GetSymbol(sTop->libHandle,
-                                      "NS_GetFrozenFunctions");
-
-  if (!sym) { // No symbol found.
-    XPCOMGlueUnload();
-    return nullptr;
-  }
-
-  return sym;
-}
-
-nsresult
-XPCOMGlueLoadXULFunctions(const nsDynamicFunctionLoad* aSymbols)
-{
-  // We don't null-check sXULLibHandle because this might work even
-  // if it is null (same as RTLD_DEFAULT)
-
-  nsresult rv = NS_OK;
-  while (aSymbols->functionName) {
-    char buffer[512];
-    SprintfLiteral(buffer, "%s", aSymbols->functionName);
-
-    *aSymbols->function = (NSFuncPtr)GetSymbol(sTop->libHandle, buffer);
-    if (!*aSymbols->function) {
-      rv = NS_ERROR_LOSS_OF_SIGNIFICANT_DATA;
-    }
-
-    ++aSymbols;
-  }
-  return rv;
+  return NS_OK;
 }
 
 #if defined(MOZ_WIDGET_GTK) && (defined(MOZ_MEMORY) || defined(__FreeBSD__) || defined(__NetBSD__))
 #define MOZ_GSLICE_INIT
 #endif
 
 #ifdef MOZ_GSLICE_INIT
 #include <glib.h>
@@ -403,547 +374,37 @@ public:
     }
   }
 
 private:
   bool mHadGSlice;
 };
 #endif
 
-nsresult
-XPCOMGlueStartup(const char* aXPCOMFile)
+namespace mozilla {
+
+Bootstrap::UniquePtr
+GetBootstrap(const char* aXPCOMFile)
 {
 #ifdef MOZ_GSLICE_INIT
   GSliceInit gSliceInit;
 #endif
-  xpcomFunctions.version = XPCOM_GLUE_VERSION;
-  xpcomFunctions.size    = sizeof(XPCOMFunctions);
 
   if (!aXPCOMFile) {
     aXPCOMFile = XPCOM_DLL;
   }
 
-  GetFrozenFunctionsFunc func = XPCOMGlueLoad(aXPCOMFile);
-  if (!func) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  nsresult rv = (*func)(&xpcomFunctions, nullptr);
-  if (NS_FAILED(rv)) {
-    XPCOMGlueUnload();
-    return rv;
-  }
-
-  return NS_OK;
-}
-
-namespace mozilla {
-
-Bootstrap::UniquePtr
-GetBootstrap(const char* aXPCOMFile)
-{
-  if (NS_FAILED(XPCOMGlueStartup(aXPCOMFile))) {
+  if (NS_FAILED(XPCOMGlueLoad(aXPCOMFile))) {
     return nullptr;
   }
 
   GetBootstrapType func = (GetBootstrapType)GetSymbol(sTop->libHandle, "XRE_GetBootstrap");
   if (!func) {
     return nullptr;
   }
 
   Bootstrap::UniquePtr b;
   (*func)(b);
 
   return b;
 }
 
 } // namespace mozilla
-
-XPCOM_API(nsresult)
-NS_InitXPCOM2(nsIServiceManager** aResult,
-              nsIFile* aBinDirectory,
-              nsIDirectoryServiceProvider* aAppFileLocationProvider)
-{
-  if (!xpcomFunctions.init) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.init(aResult, aBinDirectory, aAppFileLocationProvider);
-}
-
-XPCOM_API(nsresult)
-NS_ShutdownXPCOM(nsIServiceManager* aServMgr)
-{
-  if (!xpcomFunctions.shutdown) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.shutdown(aServMgr);
-}
-
-XPCOM_API(nsresult)
-NS_GetServiceManager(nsIServiceManager** aResult)
-{
-  if (!xpcomFunctions.getServiceManager) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.getServiceManager(aResult);
-}
-
-XPCOM_API(nsresult)
-NS_GetComponentManager(nsIComponentManager** aResult)
-{
-  if (!xpcomFunctions.getComponentManager) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.getComponentManager(aResult);
-}
-
-XPCOM_API(nsresult)
-NS_GetComponentRegistrar(nsIComponentRegistrar** aResult)
-{
-  if (!xpcomFunctions.getComponentRegistrar) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.getComponentRegistrar(aResult);
-}
-
-XPCOM_API(nsresult)
-NS_GetMemoryManager(nsIMemory** aResult)
-{
-  if (!xpcomFunctions.getMemoryManager) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.getMemoryManager(aResult);
-}
-
-XPCOM_API(nsresult)
-NS_NewLocalFile(const nsAString& aPath, bool aFollowLinks, nsIFile** aResult)
-{
-  if (!xpcomFunctions.newLocalFile) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.newLocalFile(aPath, aFollowLinks, aResult);
-}
-
-XPCOM_API(nsresult)
-NS_NewNativeLocalFile(const nsACString& aPath, bool aFollowLinks,
-                      nsIFile** aResult)
-{
-  if (!xpcomFunctions.newNativeLocalFile) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.newNativeLocalFile(aPath, aFollowLinks, aResult);
-}
-
-XPCOM_API(nsresult)
-NS_GetDebug(nsIDebug2** aResult)
-{
-  if (!xpcomFunctions.getDebug) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.getDebug(aResult);
-}
-
-
-XPCOM_API(nsresult)
-NS_StringContainerInit(nsStringContainer& aStr)
-{
-  if (!xpcomFunctions.stringContainerInit) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.stringContainerInit(aStr);
-}
-
-XPCOM_API(nsresult)
-NS_StringContainerInit2(nsStringContainer& aStr, const char16_t* aData,
-                        uint32_t aDataLength, uint32_t aFlags)
-{
-  if (!xpcomFunctions.stringContainerInit2) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.stringContainerInit2(aStr, aData, aDataLength, aFlags);
-}
-
-XPCOM_API(void)
-NS_StringContainerFinish(nsStringContainer& aStr)
-{
-  if (xpcomFunctions.stringContainerFinish) {
-    xpcomFunctions.stringContainerFinish(aStr);
-  }
-}
-
-XPCOM_API(uint32_t)
-NS_StringGetData(const nsAString& aStr, const char16_t** aBuf, bool* aTerm)
-{
-  if (!xpcomFunctions.stringGetData) {
-    *aBuf = nullptr;
-    return 0;
-  }
-  return xpcomFunctions.stringGetData(aStr, aBuf, aTerm);
-}
-
-XPCOM_API(uint32_t)
-NS_StringGetMutableData(nsAString& aStr, uint32_t aLen, char16_t** aBuf)
-{
-  if (!xpcomFunctions.stringGetMutableData) {
-    *aBuf = nullptr;
-    return 0;
-  }
-  return xpcomFunctions.stringGetMutableData(aStr, aLen, aBuf);
-}
-
-XPCOM_API(char16_t*)
-NS_StringCloneData(const nsAString& aStr)
-{
-  if (!xpcomFunctions.stringCloneData) {
-    return nullptr;
-  }
-  return xpcomFunctions.stringCloneData(aStr);
-}
-
-XPCOM_API(nsresult)
-NS_StringSetData(nsAString& aStr, const char16_t* aBuf, uint32_t aCount)
-{
-  if (!xpcomFunctions.stringSetData) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-
-  return xpcomFunctions.stringSetData(aStr, aBuf, aCount);
-}
-
-XPCOM_API(nsresult)
-NS_StringSetDataRange(nsAString& aStr, uint32_t aCutStart, uint32_t aCutLength,
-                      const char16_t* aBuf, uint32_t aCount)
-{
-  if (!xpcomFunctions.stringSetDataRange) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.stringSetDataRange(aStr, aCutStart, aCutLength, aBuf,
-                                           aCount);
-}
-
-XPCOM_API(nsresult)
-NS_StringCopy(nsAString& aDest, const nsAString& aSrc)
-{
-  if (!xpcomFunctions.stringCopy) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.stringCopy(aDest, aSrc);
-}
-
-XPCOM_API(void)
-NS_StringSetIsVoid(nsAString& aStr, const bool aIsVoid)
-{
-  if (xpcomFunctions.stringSetIsVoid) {
-    xpcomFunctions.stringSetIsVoid(aStr, aIsVoid);
-  }
-}
-
-XPCOM_API(bool)
-NS_StringGetIsVoid(const nsAString& aStr)
-{
-  if (!xpcomFunctions.stringGetIsVoid) {
-    return false;
-  }
-  return xpcomFunctions.stringGetIsVoid(aStr);
-}
-
-XPCOM_API(nsresult)
-NS_CStringContainerInit(nsCStringContainer& aStr)
-{
-  if (!xpcomFunctions.cstringContainerInit) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.cstringContainerInit(aStr);
-}
-
-XPCOM_API(nsresult)
-NS_CStringContainerInit2(nsCStringContainer& aStr, const char* aData,
-                         uint32_t aDataLength, uint32_t aFlags)
-{
-  if (!xpcomFunctions.cstringContainerInit2) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.cstringContainerInit2(aStr, aData, aDataLength, aFlags);
-}
-
-XPCOM_API(void)
-NS_CStringContainerFinish(nsCStringContainer& aStr)
-{
-  if (xpcomFunctions.cstringContainerFinish) {
-    xpcomFunctions.cstringContainerFinish(aStr);
-  }
-}
-
-XPCOM_API(uint32_t)
-NS_CStringGetData(const nsACString& aStr, const char** aBuf, bool* aTerm)
-{
-  if (!xpcomFunctions.cstringGetData) {
-    *aBuf = nullptr;
-    return 0;
-  }
-  return xpcomFunctions.cstringGetData(aStr, aBuf, aTerm);
-}
-
-XPCOM_API(uint32_t)
-NS_CStringGetMutableData(nsACString& aStr, uint32_t aLen, char** aBuf)
-{
-  if (!xpcomFunctions.cstringGetMutableData) {
-    *aBuf = nullptr;
-    return 0;
-  }
-  return xpcomFunctions.cstringGetMutableData(aStr, aLen, aBuf);
-}
-
-XPCOM_API(char*)
-NS_CStringCloneData(const nsACString& aStr)
-{
-  if (!xpcomFunctions.cstringCloneData) {
-    return nullptr;
-  }
-  return xpcomFunctions.cstringCloneData(aStr);
-}
-
-XPCOM_API(nsresult)
-NS_CStringSetData(nsACString& aStr, const char* aBuf, uint32_t aCount)
-{
-  if (!xpcomFunctions.cstringSetData) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.cstringSetData(aStr, aBuf, aCount);
-}
-
-XPCOM_API(nsresult)
-NS_CStringSetDataRange(nsACString& aStr, uint32_t aCutStart,
-                       uint32_t aCutLength, const char* aBuf, uint32_t aCount)
-{
-  if (!xpcomFunctions.cstringSetDataRange) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.cstringSetDataRange(aStr, aCutStart, aCutLength, aBuf,
-                                            aCount);
-}
-
-XPCOM_API(nsresult)
-NS_CStringCopy(nsACString& aDest, const nsACString& aSrc)
-{
-  if (!xpcomFunctions.cstringCopy) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.cstringCopy(aDest, aSrc);
-}
-
-XPCOM_API(void)
-NS_CStringSetIsVoid(nsACString& aStr, const bool aIsVoid)
-{
-  if (xpcomFunctions.cstringSetIsVoid) {
-    xpcomFunctions.cstringSetIsVoid(aStr, aIsVoid);
-  }
-}
-
-XPCOM_API(bool)
-NS_CStringGetIsVoid(const nsACString& aStr)
-{
-  if (!xpcomFunctions.cstringGetIsVoid) {
-    return false;
-  }
-  return xpcomFunctions.cstringGetIsVoid(aStr);
-}
-
-XPCOM_API(nsresult)
-NS_CStringToUTF16(const nsACString& aSrc, nsCStringEncoding aSrcEncoding,
-                  nsAString& aDest)
-{
-  if (!xpcomFunctions.cstringToUTF16) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.cstringToUTF16(aSrc, aSrcEncoding, aDest);
-}
-
-XPCOM_API(nsresult)
-NS_UTF16ToCString(const nsAString& aSrc, nsCStringEncoding aDestEncoding,
-                  nsACString& aDest)
-{
-  if (!xpcomFunctions.utf16ToCString) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  return xpcomFunctions.utf16ToCString(aSrc, aDestEncoding, aDest);
-}
-
-XPCOM_API(void*)
-NS_Alloc(size_t aSize)
-{
-  if (!xpcomFunctions.allocFunc) {
-    return nullptr;
-  }
-  return xpcomFunctions.allocFunc(aSize);
-}
-
-XPCOM_API(void*)
-NS_Realloc(void* aPtr, size_t aSize)
-{
-  if (!xpcomFunctions.reallocFunc) {
-    return nullptr;
-  }
-  return xpcomFunctions.reallocFunc(aPtr, aSize);
-}
-
-XPCOM_API(void)
-NS_Free(void* aPtr)
-{
-  if (xpcomFunctions.freeFunc) {
-    xpcomFunctions.freeFunc(aPtr);
-  }
-}
-
-XPCOM_API(void)
-NS_DebugBreak(uint32_t aSeverity, const char* aStr, const char* aExpr,
-              const char* aFile, int32_t aLine)
-{
-  if (xpcomFunctions.debugBreakFunc) {
-    xpcomFunctions.debugBreakFunc(aSeverity, aStr, aExpr, aFile, aLine);
-  }
-}
-
-XPCOM_API(void)
-NS_LogInit()
-{
-  if (xpcomFunctions.logInitFunc) {
-    xpcomFunctions.logInitFunc();
-  }
-}
-
-XPCOM_API(void)
-NS_LogTerm()
-{
-  if (xpcomFunctions.logTermFunc) {
-    xpcomFunctions.logTermFunc();
-  }
-}
-
-XPCOM_API(void)
-NS_LogAddRef(void* aPtr, nsrefcnt aNewRefCnt,
-             const char* aTypeName, uint32_t aInstanceSize)
-{
-  if (xpcomFunctions.logAddRefFunc)
-    xpcomFunctions.logAddRefFunc(aPtr, aNewRefCnt,
-                                 aTypeName, aInstanceSize);
-}
-
-XPCOM_API(void)
-NS_LogRelease(void* aPtr, nsrefcnt aNewRefCnt, const char* aTypeName)
-{
-  if (xpcomFunctions.logReleaseFunc) {
-    xpcomFunctions.logReleaseFunc(aPtr, aNewRefCnt, aTypeName);
-  }
-}
-
-XPCOM_API(void)
-NS_LogCtor(void* aPtr, const char* aTypeName, uint32_t aInstanceSize)
-{
-  if (xpcomFunctions.logCtorFunc) {
-    xpcomFunctions.logCtorFunc(aPtr, aTypeName, aInstanceSize);
-  }
-}
-
-XPCOM_API(void)
-NS_LogDtor(void* aPtr, const char* aTypeName, uint32_t aInstanceSize)
-{
-  if (xpcomFunctions.logDtorFunc) {
-    xpcomFunctions.logDtorFunc(aPtr, aTypeName, aInstanceSize);
-  }
-}
-
-XPCOM_API(void)
-NS_LogCOMPtrAddRef(void* aCOMPtr, nsISupports* aObject)
-{
-  if (xpcomFunctions.logCOMPtrAddRefFunc) {
-    xpcomFunctions.logCOMPtrAddRefFunc(aCOMPtr, aObject);
-  }
-}
-
-XPCOM_API(void)
-NS_LogCOMPtrRelease(void* aCOMPtr, nsISupports* aObject)
-{
-  if (xpcomFunctions.logCOMPtrReleaseFunc) {
-    xpcomFunctions.logCOMPtrReleaseFunc(aCOMPtr, aObject);
-  }
-}
-
-XPCOM_API(nsresult)
-NS_GetXPTCallStub(REFNSIID aIID, nsIXPTCProxy* aOuter,
-                  nsISomeInterface** aStub)
-{
-  if (!xpcomFunctions.getXPTCallStubFunc) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-
-  return xpcomFunctions.getXPTCallStubFunc(aIID, aOuter, aStub);
-}
-
-XPCOM_API(void)
-NS_DestroyXPTCallStub(nsISomeInterface* aStub)
-{
-  if (xpcomFunctions.destroyXPTCallStubFunc) {
-    xpcomFunctions.destroyXPTCallStubFunc(aStub);
-  }
-}
-
-XPCOM_API(nsresult)
-NS_InvokeByIndex(nsISupports* aThat, uint32_t aMethodIndex,
-                 uint32_t aParamCount, nsXPTCVariant* aParams)
-{
-  if (!xpcomFunctions.invokeByIndexFunc) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-
-  return xpcomFunctions.invokeByIndexFunc(aThat, aMethodIndex,
-                                          aParamCount, aParams);
-}
-
-XPCOM_API(bool)
-NS_CycleCollectorSuspect(nsISupports* aObj)
-{
-  if (!xpcomFunctions.cycleSuspectFunc) {
-    return false;
-  }
-
-  return xpcomFunctions.cycleSuspectFunc(aObj);
-}
-
-XPCOM_API(bool)
-NS_CycleCollectorForget(nsISupports* aObj)
-{
-  if (!xpcomFunctions.cycleForgetFunc) {
-    return false;
-  }
-
-  return xpcomFunctions.cycleForgetFunc(aObj);
-}
-
-XPCOM_API(nsPurpleBufferEntry*)
-NS_CycleCollectorSuspect2(void* aObj, nsCycleCollectionParticipant* aCp)
-{
-  if (!xpcomFunctions.cycleSuspect2Func) {
-    return nullptr;
-  }
-
-  return xpcomFunctions.cycleSuspect2Func(aObj, aCp);
-}
-
-XPCOM_API(void)
-NS_CycleCollectorSuspect3(void* aObj, nsCycleCollectionParticipant* aCp,
-                          nsCycleCollectingAutoRefCnt* aRefCnt,
-                          bool* aShouldDelete)
-{
-  if (xpcomFunctions.cycleSuspect3Func) {
-    xpcomFunctions.cycleSuspect3Func(aObj, aCp, aRefCnt, aShouldDelete);
-  }
-}
-
-XPCOM_API(bool)
-NS_CycleCollectorForget2(nsPurpleBufferEntry* aEntry)
-{
-  if (!xpcomFunctions.cycleForget2Func) {
-    return false;
-  }
-
-  return xpcomFunctions.cycleForget2Func(aEntry);
-}
--- a/xpcom/glue/standalone/nsXPCOMGlue.h
+++ b/xpcom/glue/standalone/nsXPCOMGlue.h
@@ -8,45 +8,18 @@
 #define nsXPCOMGlue_h__
 
 #include "nscore.h"
 
 #ifdef XPCOM_GLUE
 
 #include "mozilla/Bootstrap.h"
 
-/**
- * The following functions are only available in the standalone glue.
- */
-
-/**
- * Initialize the XPCOM glue by dynamically linking against the XPCOM
- * shared library indicated by xpcomFile.
- */
-extern "C" NS_HIDDEN_(nsresult) XPCOMGlueStartup(const char* aXPCOMFile);
-
 typedef void (*NSFuncPtr)();
 
-struct nsDynamicFunctionLoad
-{
-  const char* functionName;
-  NSFuncPtr* function;
-};
-
-/**
- * Dynamically load functions from libxul.
- *
- * @throws NS_ERROR_NOT_INITIALIZED if XPCOMGlueStartup() was not called or
- *         if the libxul DLL was not found.
- * @throws NS_ERROR_LOSS_OF_SIGNIFICANT_DATA if only some of the required
- *         functions were found.
- */
-extern "C" NS_HIDDEN_(nsresult)
-XPCOMGlueLoadXULFunctions(const nsDynamicFunctionLoad* aSymbols);
-
 namespace mozilla {
 
 /**
  * Initialize the XPCOM glue by dynamically linking against the XPCOM
  * shared library indicated by xpcomFile and return a Bootstrap instance.
  */
 NS_HIDDEN_(Bootstrap::UniquePtr) GetBootstrap(const char* aXPCOMFile);
 
--- a/xpcom/glue/standalone/staticruntime/moz.build
+++ b/xpcom/glue/standalone/staticruntime/moz.build
@@ -1,20 +1,16 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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('../../objs.mozbuild')
-
-SOURCES += xpcom_glue_src_cppsrcs
-
 SOURCES += [
-    '../../nsStringAPI.cpp',
+    '../../FileUtils.cpp',
     '../nsXPCOMGlue.cpp',
 ]
 
 Library('xpcomglue_staticruntime')
 
 SDK_LIBRARY = True
 
 # create a static lib