mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1262731
- Add JS_InitWithFailureDiagnostic(). r=sfink.
This will help identify the cause of some Firefox start-up crashes when JS initialization fails. --HG-- extra : rebase_source : 3ed3c5e60f487e0ca11dc13bab93aa820ca8273f
This commit is contained in:
parent
7dd242bb39
commit
dbc9af380e
@ -61,6 +61,14 @@ JS_SetICUMemoryFunctions(JS_ICUAllocFn allocFn,
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_Init(void);
|
||||
|
||||
/**
|
||||
* A variant of JS_Init. On success it returns nullptr. On failure it returns a
|
||||
* pointer to a string literal that describes how initialization failed, which
|
||||
* can be useful for debugging purposes.
|
||||
*/
|
||||
extern JS_PUBLIC_API(const char*)
|
||||
JS_InitWithFailureDiagnostic(void);
|
||||
|
||||
/**
|
||||
* Destroy free-standing resources allocated by SpiderMonkey, not associated
|
||||
* with any runtime, context, or other structure.
|
||||
|
@ -119,7 +119,7 @@ class DateTimeInfo
|
||||
}
|
||||
};
|
||||
|
||||
friend bool ::JS_Init();
|
||||
friend const char* ::JS_InitWithFailureDiagnostic();
|
||||
|
||||
// Initialize global date/time tracking state. This operation occurs
|
||||
// during, and is restricted to, SpiderMonkey initialization.
|
||||
|
@ -59,8 +59,8 @@ CheckMessageParameterCounts()
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_Init(void)
|
||||
JS_PUBLIC_API(const char*)
|
||||
JS_InitWithFailureDiagnostic(void)
|
||||
{
|
||||
MOZ_ASSERT(libraryInitState == InitState::Uninitialized,
|
||||
"must call JS_Init once before any JSAPI operation except "
|
||||
@ -76,18 +76,18 @@ JS_Init(void)
|
||||
|
||||
using js::TlsPerThreadData;
|
||||
if (!TlsPerThreadData.init())
|
||||
return false;
|
||||
return "JS_InitWithFailureDiagnostic: TlsPerThreadData.init() failed";
|
||||
|
||||
#if defined(DEBUG) || defined(JS_OOM_BREAKPOINT)
|
||||
if (!js::oom::InitThreadType())
|
||||
return false;
|
||||
return "JS_InitWithFailureDiagnostic: js::oom::InitThreadType() failed";
|
||||
js::oom::SetThreadType(js::oom::THREAD_TYPE_MAIN);
|
||||
#endif
|
||||
|
||||
js::jit::ExecutableAllocator::initStatic();
|
||||
|
||||
if (!js::jit::InitializeIon())
|
||||
return false;
|
||||
return "JS_InitWithFailureDiagnostic: js::jit::InitializeIon() failed";
|
||||
|
||||
js::DateTimeInfo::init();
|
||||
|
||||
@ -95,20 +95,27 @@ JS_Init(void)
|
||||
UErrorCode err = U_ZERO_ERROR;
|
||||
u_init(&err);
|
||||
if (U_FAILURE(err))
|
||||
return false;
|
||||
return "JS_InitWithFailureDiagnostic: u_init() failed";
|
||||
#endif // EXPOSE_INTL_API
|
||||
|
||||
if (!js::CreateHelperThreadsState())
|
||||
return false;
|
||||
return "JS_InitWithFailureDiagnostic: js::CreateHelperThreadState() failed";
|
||||
|
||||
if (!FutexRuntime::initialize())
|
||||
return false;
|
||||
return "JS_InitWithFailureDiagnostic: FutexRuntime::initialize() failed";
|
||||
|
||||
if (!js::gcstats::Statistics::initialize())
|
||||
return false;
|
||||
return "JS_InitWithFailureDiagnostic: js::gcstats::Statistics::initialize() failed";
|
||||
|
||||
libraryInitState = InitState::Running;
|
||||
return true;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_Init(void)
|
||||
{
|
||||
const char* failure = JS_InitWithFailureDiagnostic();
|
||||
return !failure;
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(void)
|
||||
|
@ -704,8 +704,9 @@ NS_InitXPCOM2(nsIServiceManager** aResult,
|
||||
#endif
|
||||
|
||||
// Initialize the JS engine.
|
||||
if (!JS_Init()) {
|
||||
NS_RUNTIMEABORT("JS_Init failed");
|
||||
const char* jsInitFailureReason = JS_InitWithFailureDiagnostic();
|
||||
if (jsInitFailureReason) {
|
||||
NS_RUNTIMEABORT(jsInitFailureReason);
|
||||
}
|
||||
|
||||
rv = nsComponentManagerImpl::gComponentManager->Init();
|
||||
|
Loading…
Reference in New Issue
Block a user