Changeset 286849 in webkit
- Timestamp:
- Dec 10, 2021, 6:28:35 AM (5 years ago)
- Location:
- trunk/Source/WTF
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
wtf/posix/OSAllocatorPOSIX.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r286845 r286849 1 2021-12-10 Keith Miller <keith_miller@apple.com> 2 3 Reduce maximum mmap size for Structure regions to help placate ios 4 https://bugs.webkit.org/show_bug.cgi?id=234091 5 6 Reviewed by Saam Barati. 7 8 Use mach_vm_map since that supports memory alignement so we don't have to map 2x desired address space then free then trim. 9 10 * wtf/PlatformHave.h: 11 * wtf/posix/OSAllocatorPOSIX.cpp: 12 (WTF::OSAllocator::reserveUncommittedAligned): 13 1 14 2021-12-10 Antti Koivisto <antti@apple.com> 2 15 -
trunk/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp
r286818 r286849 45 45 #endif // ENABLE(JIT_CAGE) 46 46 47 #if OS(DARWIN) 48 #include <wtf/spi/cocoa/MachVMSPI.h> 49 #endif 50 47 51 namespace WTF { 48 52 … … 74 78 } 75 79 76 77 // FIXME: Make a smarter version of this for Linux flavors that have aligned mmap.78 80 void* OSAllocator::reserveUncommittedAligned(size_t bytes, Usage usage, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages) 79 81 { 80 82 ASSERT(hasOneBitSet(bytes) && bytes >= pageSize()); 83 84 #if PLATFORM(MAC) || USE(APPLE_INTERNAL_SDK) 85 UNUSED_PARAM(usage); // Not supported for mach API. 86 ASSERT_UNUSED(includesGuardPages, !includesGuardPages); 87 ASSERT_UNUSED(jitCageEnabled, !jitCageEnabled); // Not supported for mach API. 88 vm_prot_t protections = VM_PROT_READ; 89 if (writable) 90 protections |= VM_PROT_WRITE; 91 if (executable) 92 protections |= VM_PROT_EXECUTE; 93 94 const vm_inherit_t childProcessInheritance = VM_INHERIT_DEFAULT; 95 const bool copy = false; 96 const int flags = VM_FLAGS_ANYWHERE; 97 98 void* aligned = nullptr; 99 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); 100 RELEASE_ASSERT(result == KERN_SUCCESS, result, bytes); 101 #if HAVE(MADV_FREE_REUSE) 102 if (aligned) { 103 // To support the "reserve then commit" model, we have to initially decommit. 104 while (madvise(aligned, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { } 105 } 106 #endif 107 108 return aligned; 109 #else 81 110 // Double the size so we can ensure enough mapped memory to get an aligned start. 82 111 size_t mappedSize = bytes * 2; … … 96 125 97 126 return aligned; 127 #endif 98 128 } 99 129
Note:
See TracChangeset
for help on using the changeset viewer.