Changeset 286804 in webkit
- Timestamp:
- Dec 9, 2021, 2:56:06 PM (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
r286783 r286804 1 2021-12-09 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-09 Antti Koivisto <antti@apple.com> 2 15 -
trunk/Source/WTF/wtf/posix/OSAllocatorPOSIX.cpp
r286345 r286804 39 39 #define MAP_EXECUTABLE_FOR_JIT MAP_JIT 40 40 #define MAP_EXECUTABLE_FOR_JIT_WITH_JIT_CAGE MAP_JIT 41 #include <wtf/spi/cocoa/MachVMSPI.h> 41 42 #else // OS(DARWIN) 42 43 #define MAP_EXECUTABLE_FOR_JIT 0 … … 74 75 } 75 76 76 77 // FIXME: Make a smarter version of this for Linux flavors that have aligned mmap.78 77 void* OSAllocator::reserveUncommittedAligned(size_t bytes, Usage usage, bool writable, bool executable, bool jitCageEnabled, bool includesGuardPages) 79 78 { 80 79 ASSERT(hasOneBitSet(bytes) && bytes >= pageSize()); 80 81 #if PLATFORM(MAC) || USE(APPLE_INTERNAL_SDK) 82 UNUSED_PARAM(usage); // Not supported for mach API. 83 ASSERT_UNUSED(includesGuardPages, !includesGuardPages); 84 ASSERT_UNUSED(jitCageEnabled, !jitCageEnabled); // Not supported for mach API. 85 vm_prot_t protections = VM_PROT_READ; 86 if (writable) 87 protections |= VM_PROT_WRITE; 88 if (executable) 89 protections |= VM_PROT_EXECUTE; 90 91 const vm_inherit_t childProcessInheritance = VM_INHERIT_DEFAULT; 92 93 void* aligned = nullptr; 94 const bool copy = false; 95 const int flags = VM_FLAGS_ANYWHERE; 96 97 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); 98 RELEASE_ASSERT(result == KERN_SUCCESS, result, bytes); 99 #if HAVE(MADV_FREE_REUSE) 100 if (aligned) { 101 // To support the "reserve then commit" model, we have to initially decommit. 102 while (madvise(aligned, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { } 103 } 104 #endif 105 106 return aligned; 107 #else 81 108 // Double the size so we can ensure enough mapped memory to get an aligned start. 82 109 size_t mappedSize = bytes * 2; … … 96 123 97 124 return aligned; 125 #endif 98 126 } 99 127
Note:
See TracChangeset
for help on using the changeset viewer.