From f18d78dea035c5291984d1c468336d20dc0b47b7 Mon Sep 17 00:00:00 2001 From: Jiaxun Yang Date: Tue, 12 May 2020 12:40:06 +0800 Subject: Bug 1271968 - IonMonkey: MIPS: Make jit code in same 256 MB-aligned region Tag: #1542 --- js/src/jit/ProcessExecutableMemory.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'js/src/jit') diff --git a/js/src/jit/ProcessExecutableMemory.cpp b/js/src/jit/ProcessExecutableMemory.cpp index 71c2ab0dc..1ba5c4aae 100644 --- a/js/src/jit/ProcessExecutableMemory.cpp +++ b/js/src/jit/ProcessExecutableMemory.cpp @@ -589,7 +589,23 @@ static ProcessExecutableMemory execMemory; void* js::jit::AllocateExecutableMemory(size_t bytes, ProtectionSetting protection) { +#if defined(JS_CODEGEN_MIPS32) || defined(JS_CODEGEN_MIPS64) + // On MIPS, j/jal instructions to branch within the current + // 256 MB-aligned region. + void* allocation = nullptr; + js::Vector unused_maps; + for (;;) { + allocation = execMemory.allocate(bytes, protection); + if ((uintptr_t(allocation) >> 28) == (uintptr_t(allocation + bytes) >> 28)) + break; + unused_maps.append(allocation); + } + for (size_t i = 0; i < unused_maps.length(); i++) + DeallocateExecutableMemory(unused_maps[i], bytes); + return allocation; +#else return execMemory.allocate(bytes, protection); +#endif } void -- cgit v1.2.3