Changeset 86906 in webkit
- Timestamp:
- May 19, 2011 4:46:16 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r86883 r86906 1 2011-05-19 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Gavin Barraclough. 4 5 Add guard pages to each end of the memory region used by the fixedvm allocator 6 https://bugs.webkit.org/show_bug.cgi?id=61150 7 8 Add mechanism to notify the OSAllocator that pages at either end of an 9 allocation should be considered guard pages. Update PageReservation, 10 PageAllocation, etc to handle this. 11 12 * JavaScriptCore.exp: 13 * jit/ExecutableAllocatorFixedVMPool.cpp: 14 (JSC::FixedVMPoolAllocator::FixedVMPoolAllocator): 15 * wtf/OSAllocator.h: 16 * wtf/OSAllocatorPosix.cpp: 17 (WTF::OSAllocator::reserveUncommitted): 18 (WTF::OSAllocator::reserveAndCommit): 19 * wtf/PageAllocation.h: 20 (WTF::PageAllocation::PageAllocation): 21 * wtf/PageAllocationAligned.h: 22 (WTF::PageAllocationAligned::PageAllocationAligned): 23 * wtf/PageBlock.h: 24 (WTF::PageBlock::PageBlock): 25 * wtf/PageReservation.h: 26 (WTF::PageReservation::reserve): 27 (WTF::PageReservation::reserveWithGuardPages): 28 Add a new function to make a reservation that will add guard 29 pages to the ends of an allocation. 30 (WTF::PageReservation::PageReservation): 31 1 32 2011-05-19 Oliver Hunt <oliver@apple.com> 2 33 -
trunk/Source/JavaScriptCore/JavaScriptCore.exp
r86837 r86906 376 376 __ZN3WTF10fastMallocEm 377 377 __ZN3WTF10fastStrDupEPKc 378 __ZN3WTF11OSAllocator16reserveAndCommitEmNS0_5UsageEbb 378 __ZN3WTF11OSAllocator16reserveAndCommitEmNS0_5UsageEbbb 379 379 __ZN3WTF11OSAllocator18releaseDecommittedEPvm 380 380 __ZN3WTF11commentAtomE -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r86850 r86906 286 286 ?releaseStack@MarkStack@JSC@@CAXPAXI@Z 287 287 ?reportExtraMemoryCostSlowCase@Heap@JSC@@AAEXI@Z 288 ?reserveAndCommit@OSAllocator@WTF@@SAPAXIW4Usage@12@_N1 @Z288 ?reserveAndCommit@OSAllocator@WTF@@SAPAXIW4Usage@12@_N11@Z 289 289 ?reserveCapacity@StringBuilder@WTF@@QAEXI@Z 290 290 ?reset@ParserArena@JSC@@QAEXXZ -
trunk/Source/JavaScriptCore/jit/ExecutableAllocatorFixedVMPool.cpp
r77145 r86906 410 410 ASSERT(PageTables1GB::size() == 1024 * 1024 * 1024); 411 411 412 m_reservation = PageReservation::reserve (FixedVMPoolPageTables::size(), OSAllocator::JSJITCodePages, EXECUTABLE_POOL_WRITABLE, true);412 m_reservation = PageReservation::reserveWithGuardPages(FixedVMPoolPageTables::size(), OSAllocator::JSJITCodePages, EXECUTABLE_POOL_WRITABLE, true); 413 413 #if !ENABLE(INTERPRETER) 414 414 if (!isValid()) -
trunk/Source/JavaScriptCore/wtf/OSAllocator.h
r79126 r86906 46 46 // releaseDecommitted should be called on a region of VM allocated by a single reservation, 47 47 // the memory must all currently be in a decommitted state. 48 static void* reserveUncommitted(size_t, Usage = UnknownUsage, bool writable = true, bool executable = false );48 static void* reserveUncommitted(size_t, Usage = UnknownUsage, bool writable = true, bool executable = false, bool includesGuardPages = false); 49 49 static void releaseDecommitted(void*, size_t); 50 50 … … 58 58 // decommitAndRelease should be called on a region of VM allocated by a single reservation, 59 59 // the memory must all currently be in a committed state. 60 static void* reserveAndCommit(size_t, Usage = UnknownUsage, bool writable = true, bool executable = false );60 static void* reserveAndCommit(size_t, Usage = UnknownUsage, bool writable = true, bool executable = false, bool includesGuardPages = false); 61 61 static void decommitAndRelease(void* base, size_t size); 62 62 -
trunk/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp
r85041 r86906 27 27 #include "OSAllocator.h" 28 28 29 #include "PageAllocation.h" 29 30 #include <errno.h> 30 31 #include <sys/mman.h> … … 34 35 namespace WTF { 35 36 36 void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable )37 void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) 37 38 { 38 void* result = reserveAndCommit(bytes, usage, writable, executable );39 void* result = reserveAndCommit(bytes, usage, writable, executable, includesGuardPages); 39 40 #if HAVE(MADV_FREE_REUSE) 40 41 // To support the "reserve then commit" model, we have to initially decommit. … … 44 45 } 45 46 46 void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable )47 void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) 47 48 { 48 49 // All POSIX reservations start out logically committed. … … 64 65 #if (OS(DARWIN) && CPU(X86_64)) 65 66 if (executable) { 67 ASSERT(includesGuardPages); 66 68 // Cook up an address to allocate at, using the following recipe: 67 69 // 17 bits of zero, stay in userspace kids. … … 84 86 if (result == MAP_FAILED) 85 87 CRASH(); 88 if (includesGuardPages) { 89 mprotect(result, pageSize(), PROT_NONE); 90 mprotect(static_cast<char*>(result) + bytes - pageSize(), pageSize(), PROT_NONE); 91 } 86 92 return result; 87 93 } -
trunk/Source/JavaScriptCore/wtf/OSAllocatorSymbian.cpp
r79126 r86906 75 75 76 76 // Reserve memory and return the base address of the region 77 void* OSAllocator::reserveUncommitted(size_t reservationSize, Usage usage, bool , bool executable )77 void* OSAllocator::reserveUncommitted(size_t reservationSize, Usage usage, bool , bool executable, bool) 78 78 { 79 79 void* base = 0; … … 111 111 } 112 112 113 void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable )113 void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool) 114 114 { 115 115 void* base = reserveUncommitted(bytes, usage, writable, executable); -
trunk/Source/JavaScriptCore/wtf/PageAllocation.h
r76409 r86906 118 118 private: 119 119 PageAllocation(void* base, size_t size) 120 : PageBlock(base, size )120 : PageBlock(base, size, false) 121 121 { 122 122 } -
trunk/Source/JavaScriptCore/wtf/PageAllocationAligned.h
r74431 r86906 49 49 #if OS(DARWIN) 50 50 PageAllocationAligned(void* base, size_t size) 51 : PageBlock(base, size )51 : PageBlock(base, size, false) 52 52 { 53 53 } 54 54 #else 55 55 PageAllocationAligned(void* base, size_t size, void* reservationBase, size_t reservationSize) 56 : PageBlock(base, size )57 , m_reservation(reservationBase, reservationSize )56 : PageBlock(base, size, false) 57 , m_reservation(reservationBase, reservationSize, false) 58 58 { 59 59 } -
trunk/Source/JavaScriptCore/wtf/PageBlock.h
r74431 r86906 38 38 PageBlock(); 39 39 PageBlock(const PageBlock&); 40 PageBlock(void*, size_t );40 PageBlock(void*, size_t, bool hasGuardPages); 41 41 42 42 void* base() const { return m_base; } … … 52 52 53 53 private: 54 void* m_realBase; 54 55 void* m_base; 55 56 size_t m_size; … … 57 58 58 59 inline PageBlock::PageBlock() 59 : m_base(0) 60 : m_realBase(0) 61 , m_base(0) 60 62 , m_size(0) 61 63 { … … 63 65 64 66 inline PageBlock::PageBlock(const PageBlock& other) 65 : m_base(other.m_base) 67 : m_realBase(other.m_realBase) 68 , m_base(other.m_base) 66 69 , m_size(other.m_size) 67 70 { 68 71 } 69 72 70 inline PageBlock::PageBlock(void* base, size_t size) 71 : m_base(base) 73 inline PageBlock::PageBlock(void* base, size_t size, bool hasGuardPages) 74 : m_realBase(base) 75 , m_base(static_cast<char*>(base) + (hasGuardPages ? pageSize() : 0)) 72 76 , m_size(size) 73 77 { -
trunk/Source/JavaScriptCore/wtf/PageReservation.h
r77145 r86906 105 105 { 106 106 ASSERT(isPageAligned(size)); 107 return PageReservation(OSAllocator::reserveUncommitted(size, usage, writable, executable), size, writable, executable); 107 return PageReservation(OSAllocator::reserveUncommitted(size, usage, writable, executable), size, writable, executable, false); 108 } 109 110 static PageReservation reserveWithGuardPages(size_t size, OSAllocator::Usage usage = OSAllocator::UnknownUsage, bool writable = true, bool executable = false) 111 { 112 ASSERT(isPageAligned(size)); 113 return PageReservation(OSAllocator::reserveUncommitted(size + pageSize() * 2, usage, writable, executable, true), size, writable, executable, true); 108 114 } 109 115 … … 124 130 125 131 private: 126 PageReservation(void* base, size_t size, bool writable, bool executable )127 : PageBlock(base, size )132 PageReservation(void* base, size_t size, bool writable, bool executable, bool hasGuardPages) 133 : PageBlock(base, size, hasGuardPages) 128 134 , m_committed(0) 129 135 , m_writable(writable)
Note: See TracChangeset
for help on using the changeset viewer.