Changeset 220401 in webkit
- Timestamp:
- Aug 8, 2017 6:11:00 AM (7 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r220377 r220401 1 2017-08-06 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [Linux] Clear WasmMemory with madvice instead of memset 4 https://bugs.webkit.org/show_bug.cgi?id=175150 5 6 Reviewed by Filip Pizlo. 7 8 In Linux, zeroing pages with memset populates backing store. 9 Instead, we should use madvise with MADV_DONTNEED. It discards 10 pages. And if you access these pages, on-demand-zero-pages will 11 be shown. 12 13 We also commit grown pages in all OSes. 14 15 * wasm/WasmMemory.cpp: 16 (JSC::Wasm::commitZeroPages): 17 (JSC::Wasm::Memory::create): 18 (JSC::Wasm::Memory::grow): 19 1 20 2017-08-07 Robin Morisset <rmorisset@apple.com> 2 21 -
trunk/Source/JavaScriptCore/wasm/WasmMemory.cpp
r220352 r220401 256 256 } 257 257 258 static void commitZeroPages(void* startAddress, size_t sizeInBytes) 259 { 260 bool writable = true; 261 bool executable = false; 262 #if OS(LINUX) 263 // In Linux, MADV_DONTNEED clears backing pages with zero. Be Careful that MADV_DONTNEED shows different semantics in different OSes. 264 // For example, FreeBSD does not clear backing pages immediately. 265 while (madvise(startAddress, sizeInBytes, MADV_DONTNEED) == -1 && errno == EAGAIN) { } 266 OSAllocator::commit(startAddress, sizeInBytes, writable, executable); 267 #else 268 OSAllocator::commit(startAddress, sizeInBytes, writable, executable); 269 memset(startAddress, 0, sizeInBytes); 270 #endif 271 } 272 258 273 RefPtr<Memory> Memory::create(VM& vm, PageCount initial, PageCount maximum) 259 274 { … … 294 309 295 310 if (fastMemory) { 296 bool writable = true;297 bool executable = false;298 OSAllocator::commit(fastMemory, initialBytes, writable, executable);299 311 300 312 if (mprotect(fastMemory + initialBytes, Memory::fastMappedBytes() - initialBytes, PROT_NONE)) { … … 302 314 RELEASE_ASSERT_NOT_REACHED(); 303 315 } 304 305 memset(fastMemory, 0, initialBytes); 316 317 commitZeroPages(fastMemory, initialBytes); 318 306 319 return adoptRef(new Memory(fastMemory, initial, maximum, Memory::fastMappedBytes(), MemoryMode::Signaling)); 307 320 } … … 401 414 return false; 402 415 } 403 memset(startAddress, 0, extraBytes);416 commitZeroPages(startAddress, extraBytes); 404 417 m_size = desiredSize; 405 418 return true;
Note: See TracChangeset
for help on using the changeset viewer.