summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorJiaxun Yang <jiaxun.yang@flygoat.com>2020-05-12 12:40:06 +0800
committerJiaxun Yang <jiaxun.yang@flygoat.com>2020-05-14 16:31:56 +0800
commit22a4c154bbfb2b293c15be4fad8fe55a668c90ec (patch)
tree8665eab69bac69e98ee1c3e247c5d410a7541a8b /js
parent001c41612562bf88ea738dfc0476ab6a50f9d106 (diff)
downloadUXP-22a4c154bbfb2b293c15be4fad8fe55a668c90ec.tar
UXP-22a4c154bbfb2b293c15be4fad8fe55a668c90ec.tar.gz
UXP-22a4c154bbfb2b293c15be4fad8fe55a668c90ec.tar.lz
UXP-22a4c154bbfb2b293c15be4fad8fe55a668c90ec.tar.xz
UXP-22a4c154bbfb2b293c15be4fad8fe55a668c90ec.zip
Bug 1271968 - IonMonkey: MIPS: Make jit code in same 256 MB-aligned region
Tag: #1542
Diffstat (limited to 'js')
-rw-r--r--js/src/jit/ProcessExecutableMemory.cpp16
1 files changed, 16 insertions, 0 deletions
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<void*, 8, SystemAllocPolicy> 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