Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: third_party/WebKit/Source/wtf/PageAllocator.cpp

Issue 1390963003: Implement discardSystemPages on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 void discardSystemPages(void* addr, size_t len) 237 void discardSystemPages(void* addr, size_t len)
238 { 238 {
239 ASSERT(!(len & kSystemPageOffsetMask)); 239 ASSERT(!(len & kSystemPageOffsetMask));
240 #if OS(POSIX) 240 #if OS(POSIX)
241 // On POSIX, the implementation detail is that discard and decommit are the 241 // On POSIX, the implementation detail is that discard and decommit are the
242 // same, and lead to pages that are returned to the system immediately and 242 // same, and lead to pages that are returned to the system immediately and
243 // get replaced with zeroed pages when touched. So we just call 243 // get replaced with zeroed pages when touched. So we just call
244 // decommitSystemPages() here to avoid code duplication. 244 // decommitSystemPages() here to avoid code duplication.
245 decommitSystemPages(addr, len); 245 decommitSystemPages(addr, len);
246 #else 246 #else
247 (void) addr; 247 // On Windows discarded pages are not returned to the system immediately and
248 (void) len; 248 // not guaranteed to be zeroed when returned to the application.
249 // TODO(cevans): implement this using MEM_RESET for Windows, once we've 249 using DiscardVirtualMemoryFunction = DWORD(WINAPI*)(PVOID virtualAddress, SI ZE_T size);
250 // decided that the semantics are a match. 250 static DiscardVirtualMemoryFunction discardVirtualMemory = reinterpret_cast< DiscardVirtualMemoryFunction>(-1);
251 if (discardVirtualMemory == reinterpret_cast<DiscardVirtualMemoryFunction>(- 1))
252 discardVirtualMemory = reinterpret_cast<DiscardVirtualMemoryFunction>(Ge tProcAddress(GetModuleHandle(L"Kernel32.dll"), "DiscardVirtualMemory"));
253 // Use DiscardVirtualMemory when available because it releases faster than M EM_RESET.
254 DWORD ret = 1;
255 if (discardVirtualMemory)
256 ret = discardVirtualMemory(addr, len);
257 // DiscardVirtualMemory is buggy in Win10 SP0, so fall back to MEM_RESET on failure.
258 if (ret) {
259 void* ret = VirtualAlloc(addr, len, MEM_RESET, PAGE_READWRITE);
260 RELEASE_ASSERT(ret);
261 }
251 #endif 262 #endif
252 } 263 }
253 264
254 } // namespace WTF 265 } // namespace WTF
255 266
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698