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

Side by Side Diff: third_party/WebKit/Source/platform/heap/PageMemory.cpp

Issue 2942233002: Add some support for promptly purging pages.
Patch Set: add MADV_FREE fallback Created 3 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/heap/PageMemory.h" 5 #include "platform/heap/PageMemory.h"
6 6
7 #include "platform/heap/Heap.h" 7 #include "platform/heap/Heap.h"
8 #include "platform/wtf/AddressSanitizer.h" 8 #include "platform/wtf/AddressSanitizer.h"
9 #include "platform/wtf/Assertions.h" 9 #include "platform/wtf/Assertions.h"
10 #include "platform/wtf/Atomics.h" 10 #include "platform/wtf/Atomics.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 void MemoryRegion::Release() { 14 void MemoryRegion::Release() {
15 WTF::FreePages(base_, size_); 15 WTF::FreePages(base_, size_);
16 } 16 }
17 17
18 bool MemoryRegion::Commit() { 18 bool MemoryRegion::Commit() {
19 WTF::RecommitSystemPages(base_, size_); 19 WTF::RecommitSystemPages(base_, size_);
20 return WTF::SetSystemPagesAccessible(base_, size_); 20 return WTF::SetSystemPagesAccessible(base_, size_);
21 } 21 }
22 22
23 void MemoryRegion::Decommit() { 23 void MemoryRegion::Decommit(DecommitMemoryTiming decommit_hint) {
24 ASAN_UNPOISON_MEMORY_REGION(base_, size_); 24 ASAN_UNPOISON_MEMORY_REGION(base_, size_);
25 WTF::DecommitSystemPages(base_, size_); 25 WTF::DecommitSystemPages(
26 base_, size_, decommit_hint == DecommitMemoryTiming::DecommitPromptly);
26 WTF::SetSystemPagesInaccessible(base_, size_); 27 WTF::SetSystemPagesInaccessible(base_, size_);
27 } 28 }
28 29
29 PageMemoryRegion::PageMemoryRegion(Address base, 30 PageMemoryRegion::PageMemoryRegion(Address base,
30 size_t size, 31 size_t size,
31 unsigned num_pages, 32 unsigned num_pages,
32 RegionTree* region_tree) 33 RegionTree* region_tree)
33 : MemoryRegion(base, size), 34 : MemoryRegion(base, size),
34 is_large_page_(num_pages == 1), 35 is_large_page_(num_pages == 1),
35 num_pages_(num_pages), 36 num_pages_(num_pages),
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 size_t allocation_size = payload_size + 2 * kBlinkGuardPageSize; 170 size_t allocation_size = payload_size + 2 * kBlinkGuardPageSize;
170 PageMemoryRegion* page_memory_region = 171 PageMemoryRegion* page_memory_region =
171 PageMemoryRegion::AllocateLargePage(allocation_size, region_tree); 172 PageMemoryRegion::AllocateLargePage(allocation_size, region_tree);
172 PageMemory* storage = 173 PageMemory* storage =
173 SetupPageMemoryInRegion(page_memory_region, 0, payload_size); 174 SetupPageMemoryInRegion(page_memory_region, 0, payload_size);
174 CHECK(storage->Commit()); 175 CHECK(storage->Commit());
175 return storage; 176 return storage;
176 } 177 }
177 178
178 } // namespace blink 179 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/PageMemory.h ('k') | third_party/WebKit/Source/platform/heap/PagePool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698