summaryrefslogtreecommitdiffstats
path: root/js/src/jit/ProcessExecutableMemory.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-05-19 22:14:43 +0200
committerGitHub <noreply@github.com>2020-05-19 22:14:43 +0200
commit750b4c3a11e6ed4d92598072899b02c549f17d26 (patch)
tree75e1ec3ab5ecec3a0ec29a176a3b46ef33609b76 /js/src/jit/ProcessExecutableMemory.cpp
parentffb32138cbe23dc275ec409770246739f9678cef (diff)
parent052a035958d43c3fb0a980c0c7a93ad2073afddf (diff)
downloadUXP-750b4c3a11e6ed4d92598072899b02c549f17d26.tar
UXP-750b4c3a11e6ed4d92598072899b02c549f17d26.tar.gz
UXP-750b4c3a11e6ed4d92598072899b02c549f17d26.tar.lz
UXP-750b4c3a11e6ed4d92598072899b02c549f17d26.tar.xz
UXP-750b4c3a11e6ed4d92598072899b02c549f17d26.zip
Merge pull request #1544 from FlyGoat/mips-upstream
Implements initial MIPS Support
Diffstat (limited to 'js/src/jit/ProcessExecutableMemory.cpp')
-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