Bug 830765 - Remove the unneeded code which tracks the list of loaded modules because it is unused and can cause multi-second hangs; r=sicking a=removes-code-from-libxul

This commit is contained in:
Ehsan Akhgari 2013-01-21 15:55:31 -05:00
Родитель 9f8c41d2ca
Коммит ba773446f9
4 изменённых файлов: 0 добавлений и 106 удалений

Просмотреть файл

@ -436,8 +436,6 @@ continue_loading:
printf_stderr("LdrLoadDll: continuing load... ('%S')\n", moduleFileName->Buffer);
#endif
NS_SetHasLoadedNewDLLs();
if (gInXPCOMLoadOnMainThread && NS_IsMainThread()) {
// Check to ensure that the DLL has ASLR.
full_fname = getFullPath(filePath, fname);

Просмотреть файл

@ -15,10 +15,6 @@
#include "mozilla/widget/AudioSession.h"
#include "mozilla/HangMonitor.h"
// For skidmark code
#include <windows.h>
#include <tlhelp32.h>
const PRUnichar* kAppShellEventId = L"nsAppShell:EventID";
const PRUnichar* kTaskbarButtonEventId = L"TaskbarButtonCreated";
@ -147,84 +143,10 @@ nsAppShell::Init()
return nsBaseAppShell::Init();
}
/**
* This is some temporary code to keep track of where in memory dlls are
* loaded. This is useful in case someone calls into a dll that has been
* unloaded. This code lets us see which dll used to be loaded at the given
* called address.
*/
#if defined(_MSC_VER) && defined(_M_IX86)
#define LOADEDMODULEINFO_STRSIZE 23
#define NUM_LOADEDMODULEINFO 250
struct LoadedModuleInfo {
void* mStartAddr;
void* mEndAddr;
char mName[LOADEDMODULEINFO_STRSIZE + 1];
};
static LoadedModuleInfo* sLoadedModules = 0;
static void
CollectNewLoadedModules()
{
HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
MODULEENTRY32W module;
// Take a snapshot of all modules in our process.
hModuleSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0);
if (hModuleSnap == INVALID_HANDLE_VALUE)
return;
// Set the size of the structure before using it.
module.dwSize = sizeof(MODULEENTRY32W);
// Now walk the module list of the process,
// and display information about each module
bool done = !Module32FirstW(hModuleSnap, &module);
while (!done) {
NS_LossyConvertUTF16toASCII moduleName(module.szModule);
bool found = false;
uint32_t i;
for (i = 0; i < NUM_LOADEDMODULEINFO &&
sLoadedModules[i].mStartAddr; ++i) {
if (sLoadedModules[i].mStartAddr == module.modBaseAddr &&
!strcmp(moduleName.get(),
sLoadedModules[i].mName)) {
found = true;
break;
}
}
if (!found && i < NUM_LOADEDMODULEINFO) {
sLoadedModules[i].mStartAddr = module.modBaseAddr;
sLoadedModules[i].mEndAddr = module.modBaseAddr + module.modBaseSize;
strncpy(sLoadedModules[i].mName, moduleName.get(),
LOADEDMODULEINFO_STRSIZE);
sLoadedModules[i].mName[LOADEDMODULEINFO_STRSIZE] = 0;
}
done = !Module32NextW(hModuleSnap, &module);
}
uint32_t i;
for (i = 0; i < NUM_LOADEDMODULEINFO &&
sLoadedModules[i].mStartAddr; ++i) {}
CloseHandle(hModuleSnap);
}
#endif // defined(_MSC_VER) && defined(_M_IX86)
NS_IMETHODIMP
nsAppShell::Run(void)
{
#if defined(_MSC_VER) && defined(_M_IX86)
LoadedModuleInfo modules[NUM_LOADEDMODULEINFO];
memset(modules, 0, sizeof(modules));
sLoadedModules = modules;
#endif
// Ignore failure; failing to start the application is not exactly an
// appropriate response to failing to start an audio session.
mozilla::widget::StartAudioSession();
@ -233,11 +155,6 @@ nsAppShell::Run(void)
mozilla::widget::StopAudioSession();
#if defined(_MSC_VER) && defined(_M_IX86)
// Don't forget to null this out!
sLoadedModules = nullptr;
#endif
return rv;
}
@ -295,13 +212,6 @@ nsAppShell::ScheduleNativeEventCallback()
bool
nsAppShell::ProcessNextNativeEvent(bool mayWait)
{
#if defined(_MSC_VER) && defined(_M_IX86)
if (sXPCOMHasLoadedNewDLLs && sLoadedModules) {
sXPCOMHasLoadedNewDLLs = false;
CollectNewLoadedModules();
}
#endif
// Notify ipc we are spinning a (possibly nested) gecko event loop.
mozilla::ipc::RPCChannel::NotifyGeckoEventDispatch();

Просмотреть файл

@ -592,12 +592,3 @@ NS_ErrorAccordingToNSPR()
////////////////////////////////////////////////////////////////////////////////
#ifdef XP_WIN
bool sXPCOMHasLoadedNewDLLs = false;
NS_EXPORT void
NS_SetHasLoadedNewDLLs()
{
sXPCOMHasLoadedNewDLLs = true;
}
#endif

Просмотреть файл

@ -223,9 +223,4 @@ inline bool NS_ERROR_GET_SEVERITY(nsresult err) {
#pragma warning(disable: 4275) /* non dll-interface class 'nsISupports' used as base for dll-interface class 'nsIRDFNode' */
#endif
#if defined(XP_WIN) && defined(__cplusplus)
extern bool sXPCOMHasLoadedNewDLLs;
NS_EXPORT void NS_SetHasLoadedNewDLLs();
#endif
#endif