Bug 1752099 part 5 - Move executable memory initialization into InitializeJit. r=lth

This makes it a bit easier to reason about the ordering of these.

Depends on D137026

Differential Revision: https://phabricator.services.mozilla.com/D137027
This commit is contained in:
Jan de Mooij 2022-01-31 10:23:58 +00:00
parent ad9f1b55ce
commit 09e4065954
3 changed files with 17 additions and 11 deletions

View File

@ -116,10 +116,22 @@ bool jit::InitializeJit() {
JitOptions.supportsUnalignedAccesses =
MacroAssembler::SupportsUnalignedAccesses();
if (HasJitBackend()) {
if (!InitProcessExecutableMemory()) {
return false;
}
}
CheckPerf();
return true;
}
void jit::ShutdownJit() {
if (HasJitBackend() && !JSRuntime::hasLiveRuntimes()) {
ReleaseProcessExecutableMemory();
}
}
bool jit::JitSupportsWasmSimd() {
#if defined(ENABLE_WASM_SIMD)
return js::jit::MacroAssembler::SupportsWasmSimd();

View File

@ -146,8 +146,9 @@ class JitContext {
#endif
};
// Process-wide initialization of JIT data structures.
// Process-wide initialization and shutdown of JIT data structures.
[[nodiscard]] bool InitializeJit();
void ShutdownJit();
// Get and set the current JIT context.
JitContext* GetJitContext();

View File

@ -176,10 +176,6 @@ JS_PUBLIC_API const char* JS::detail::InitWithFailureDiagnostic(
js::coverage::InitLCov();
if (js::jit::HasJitBackend()) {
RETURN_IF_FAIL(js::jit::InitProcessExecutableMemory());
}
RETURN_IF_FAIL(js::MemoryProtectionExceptionHandler::install());
RETURN_IF_FAIL(js::jit::InitializeJit());
@ -306,12 +302,9 @@ JS_PUBLIC_API void JS_ShutDown(void) {
js::FinishDateTimeState();
if (!JSRuntime::hasLiveRuntimes()) {
if (js::jit::HasJitBackend()) {
js::jit::ReleaseProcessExecutableMemory();
}
MOZ_ASSERT(!js::LiveMappedBufferCount());
}
js::jit::ShutdownJit();
MOZ_ASSERT_IF(!JSRuntime::hasLiveRuntimes(), !js::LiveMappedBufferCount());
js::ShutDownMallocAllocator();