Changeset 111234 in webkit
- Timestamp:
- Mar 19, 2012 1:39:15 PM (12 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r111223 r111234 1 2012-03-19 Yong Li <yoli@rim.com> 2 3 [BlackBerry] Implement OSAllocator::commit/decommit in the correct way 4 https://bugs.webkit.org/show_bug.cgi?id=77013 5 6 We should use mmap(PROT_NONE, MAP_LAZY) instead of posix_madvise() to 7 implement memory decommitting for QNX. 8 9 Reviewed by Rob Buis. 10 11 * wtf/OSAllocatorPosix.cpp: 12 (WTF::OSAllocator::reserveUncommitted): 13 (WTF::OSAllocator::commit): 14 (WTF::OSAllocator::decommit): 15 1 16 2012-03-19 Gavin Barraclough <barraclough@apple.com> 2 17 -
trunk/Source/JavaScriptCore/wtf/OSAllocatorPosix.cpp
r110874 r111234 37 37 void* OSAllocator::reserveUncommitted(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages) 38 38 { 39 #if OS(QNX) 40 // Reserve memory with PROT_NONE and MAP_LAZY so it isn't committed now. 41 void* result = mmap(0, bytes, PROT_NONE, MAP_LAZY | MAP_PRIVATE | MAP_ANON, -1, 0); 42 if (result == MAP_FAILED) 43 CRASH(); 44 #else // OS(QNX) 45 39 46 void* result = reserveAndCommit(bytes, usage, writable, executable, includesGuardPages); 40 #if OS(QNX) 41 posix_madvise(result, bytes, POSIX_MADV_DONTNEED); 42 #elif OS(LINUX) 47 #if OS(LINUX) 43 48 madvise(result, bytes, MADV_DONTNEED); 44 49 #elif HAVE(MADV_FREE_REUSE) … … 46 51 while (madvise(result, bytes, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN) { } 47 52 #endif 53 54 #endif // OS(QNX) 55 48 56 return result; 49 57 } … … 123 131 } 124 132 125 void OSAllocator::commit(void* address, size_t bytes, bool , bool)133 void OSAllocator::commit(void* address, size_t bytes, bool writable, bool executable) 126 134 { 127 135 #if OS(QNX) 128 posix_madvise(address, bytes, POSIX_MADV_WILLNEED); 136 int protection = PROT_READ; 137 if (writable) 138 protection |= PROT_WRITE; 139 if (executable) 140 protection |= PROT_EXEC; 141 if (MAP_FAILED == mmap(address, bytes, protection, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0)) 142 CRASH(); 129 143 #elif OS(LINUX) 144 UNUSED_PARAM(writable); 145 UNUSED_PARAM(executable); 130 146 madvise(address, bytes, MADV_WILLNEED); 131 147 #elif HAVE(MADV_FREE_REUSE) 148 UNUSED_PARAM(writable); 149 UNUSED_PARAM(executable); 132 150 while (madvise(address, bytes, MADV_FREE_REUSE) == -1 && errno == EAGAIN) { } 133 151 #else … … 135 153 UNUSED_PARAM(address); 136 154 UNUSED_PARAM(bytes); 155 UNUSED_PARAM(writable); 156 UNUSED_PARAM(executable); 137 157 #endif 138 158 } … … 141 161 { 142 162 #if OS(QNX) 143 posix_madvise(address, bytes, POSIX_MADV_DONTNEED); 163 // Use PROT_NONE and MAP_LAZY to decommit the pages. 164 mmap(address, bytes, PROT_NONE, MAP_FIXED | MAP_LAZY | MAP_PRIVATE | MAP_ANON, -1, 0); 144 165 #elif OS(LINUX) 145 166 madvise(address, bytes, MADV_DONTNEED);
Note: See TracChangeset
for help on using the changeset viewer.