Bug 1271968 - IonMonkey: MIPS: Make jit code in same 256 MB-aligned region

Tag: #1542
This commit is contained in:
Jiaxun Yang 2020-05-12 12:40:06 +08:00 committed by Roy Tam
commit 1d29d6882c

View file

@ -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