Modified: trunk/Source/WTF/ChangeLog (286803 => 286804)
--- trunk/Source/WTF/ChangeLog 2021-12-09 22:47:24 UTC (rev 286803)
+++ trunk/Source/WTF/ChangeLog 2021-12-09 22:56:06 UTC (rev 286804)
@@ -1,3 +1,16 @@
+2021-12-09 Keith Miller <[email protected]>
+
+ Reduce maximum mmap size for Structure regions to help placate ios
+ https://bugs.webkit.org/show_bug.cgi?id=234091
+
+ Reviewed by Saam Barati.
+
+ Use mach_vm_map since that supports memory alignement so we don't have to map 2x desired address space then free then trim.
+
+ * wtf/PlatformHave.h:
+ * wtf/posix/OSAllocatorPOSIX.cpp:
+ (WTF::OSAllocator::reserveUncommittedAligned):
+
2021-12-09 Antti Koivisto <[email protected]>
Enable :focus-visible pseudo-class by default
Modified: trunk/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp (286803 => 286804)
--- trunk/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp 2021-12-09 22:47:24 UTC (rev 286803)
+++ trunk/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp 2021-12-09 22:56:06 UTC (rev 286804)
@@ -38,6 +38,7 @@
#if OS(DARWIN)
#define MAP_EXECUTABLE_FOR_JIT MAP_JIT
#define MAP_EXECUTABLE_FOR_JIT_WITH_JIT_CAGE MAP_JIT
+#include <wtf/spi/cocoa/MachVMSPI.h>
#else // OS(DARWIN)
#define MAP_EXECUTABLE_FOR_JIT 0
#define MAP_EXECUTABLE_FOR_JIT_WITH_JIT_CAGE 0
@@ -73,11 +74,37 @@
return result;
}
-
-// FIXME: Make a smarter version of this for Linux flavors that have aligned mmap.
void* OSAllocator::reserveUncommittedAligned(size_t bytes, Usage usage, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages)
{
ASSERT(hasOneBitSet(bytes) && bytes >= pageSize());
+
+#if PLATFORM(MAC) || USE(APPLE_INTERNAL_SDK)
+ UNUSED_PARAM(usage); // Not supported for mach API.
+ ASSERT_UNUSED(includesGuardPages, !includesGuardPages);
+ ASSERT_UNUSED(jitCageEnabled, !jitCageEnabled); // Not supported for mach API.
+ vm_prot_t protections = VM_PROT_READ;
+ if (writable)
+ protections |= VM_PROT_WRITE;
+ if (executable)
+ protections |= VM_PROT_EXECUTE;
+
+ const vm_inherit_t childProcessInheritance = VM_INHERIT_DEFAULT;
+
+ void* aligned = nullptr;
+ const bool copy = false;
+ const int flags = VM_FLAGS_ANYWHERE;
+
+ kern_return_t result = mach_vm_map(mach_task_self(), reinterpret_cast<mach_vm_address_t*>(&aligned), bytes, bytes - 1, flags, MEMORY_OBJECT_NULL, 0, copy, protections, protections, childProcessInheritance);
+ RELEASE_ASSERT(result == KERN_SUCCESS, result, bytes);
+#if HAVE(MADV_FREE_REUSE)
+ if (aligned) {
+ // To support the "reserve then commit" model, we have to initially decommit.
+ while (madvise(aligned, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { }
+ }
+#endif
+
+ return aligned;
+#else
// Double the size so we can ensure enough mapped memory to get an aligned start.
size_t mappedSize = bytes * 2;
char* mapped = reinterpret_cast<char*>(reserveUncommitted(mappedSize, usage, writable, executable, jitCageEnabled, includesGuardPages));
@@ -95,6 +122,7 @@
releaseDecommitted(alignedEnd, rightExtra);
return aligned;
+#endif
}
void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages)