Modified: trunk/Source/WTF/ChangeLog (286848 => 286849)
--- trunk/Source/WTF/ChangeLog 2021-12-10 14:27:04 UTC (rev 286848)
+++ trunk/Source/WTF/ChangeLog 2021-12-10 14:28:35 UTC (rev 286849)
@@ -1,3 +1,16 @@
+2021-12-10 Keith Miller <keith_mil...@apple.com>
+
+ 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-10 Antti Koivisto <an...@apple.com>
[CSS Container Queries] Basic @container at-rule parsing support
Modified: trunk/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp (286848 => 286849)
--- trunk/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp 2021-12-10 14:27:04 UTC (rev 286848)
+++ trunk/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp 2021-12-10 14:28:35 UTC (rev 286849)
@@ -44,6 +44,10 @@
#endif // OS(DARWIN)
#endif // ENABLE(JIT_CAGE)
+#if OS(DARWIN)
+#include <wtf/spi/cocoa/MachVMSPI.h>
+#endif
+
namespace WTF {
void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages)
@@ -73,11 +77,36 @@
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;
+ const bool copy = false;
+ const int flags = VM_FLAGS_ANYWHERE;
+
+ void* aligned = nullptr;
+ 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 +124,7 @@
releaseDecommitted(alignedEnd, rightExtra);
return aligned;
+#endif
}
void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages)