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

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

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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #ifndef PageMemory_h 5 #ifndef PageMemory_h
6 #define PageMemory_h 6 #define PageMemory_h
7 7
8 #include "platform/heap/HeapPage.h" 8 #include "platform/heap/HeapPage.h"
9 #include "platform/wtf/Allocator.h" 9 #include "platform/wtf/Allocator.h"
10 #include "platform/wtf/Assertions.h" 10 #include "platform/wtf/Assertions.h"
(...skipping 16 matching lines...) Expand all
27 bool Contains(Address addr) const { 27 bool Contains(Address addr) const {
28 return base_ <= addr && addr < (base_ + size_); 28 return base_ <= addr && addr < (base_ + size_);
29 } 29 }
30 30
31 bool Contains(const MemoryRegion& other) const { 31 bool Contains(const MemoryRegion& other) const {
32 return Contains(other.base_) && Contains(other.base_ + other.size_ - 1); 32 return Contains(other.base_) && Contains(other.base_ + other.size_ - 1);
33 } 33 }
34 34
35 void Release(); 35 void Release();
36 WARN_UNUSED_RESULT bool Commit(); 36 WARN_UNUSED_RESULT bool Commit();
37 void Decommit(); 37 void Decommit(DecommitMemoryTiming);
38 38
39 Address Base() const { return base_; } 39 Address Base() const { return base_; }
40 size_t size() const { return size_; } 40 size_t size() const { return size_; }
41 41
42 private: 42 private:
43 Address base_; 43 Address base_;
44 size_t size_; 44 size_t size_;
45 }; 45 };
46 46
47 // A PageMemoryRegion represents a chunk of reserved virtual address 47 // A PageMemoryRegion represents a chunk of reserved virtual address
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // when allocating new pages, but crbug.com/649485 suggests that 173 // when allocating new pages, but crbug.com/649485 suggests that
174 // we do get out of sync somehow. 174 // we do get out of sync somehow.
175 // 175 //
176 // TODO(sof): consider removing check once bug has been diagnosed 176 // TODO(sof): consider removing check once bug has been diagnosed
177 // and addressed. 177 // and addressed.
178 CHECK(!ThreadState::Current()->IsAddressInHeapDoesNotContainCache( 178 CHECK(!ThreadState::Current()->IsAddressInHeapDoesNotContainCache(
179 WritableStart())); 179 WritableStart()));
180 return writable_.Commit(); 180 return writable_.Commit();
181 } 181 }
182 182
183 void Decommit() { 183 void Decommit(DecommitMemoryTiming decommit_hint) {
184 reserved_->MarkPageUnused(WritableStart()); 184 reserved_->MarkPageUnused(WritableStart());
185 writable_.Decommit(); 185 writable_.Decommit(decommit_hint);
186 } 186 }
187 187
188 void MarkUnused() { reserved_->MarkPageUnused(WritableStart()); } 188 void MarkUnused() { reserved_->MarkPageUnused(WritableStart()); }
189 189
190 PageMemoryRegion* Region() { return reserved_; } 190 PageMemoryRegion* Region() { return reserved_; }
191 191
192 Address WritableStart() { return writable_.Base(); } 192 Address WritableStart() { return writable_.Base(); }
193 193
194 static PageMemory* SetupPageMemoryInRegion(PageMemoryRegion*, 194 static PageMemory* SetupPageMemoryInRegion(PageMemoryRegion*,
195 size_t page_offset, 195 size_t page_offset,
(...skipping 12 matching lines...) Expand all
208 private: 208 private:
209 PageMemory(PageMemoryRegion* reserved, const MemoryRegion& writable); 209 PageMemory(PageMemoryRegion* reserved, const MemoryRegion& writable);
210 210
211 PageMemoryRegion* reserved_; 211 PageMemoryRegion* reserved_;
212 MemoryRegion writable_; 212 MemoryRegion writable_;
213 }; 213 };
214 214
215 } // namespace blink 215 } // namespace blink
216 216
217 #endif 217 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/HeapPage.cpp ('k') | third_party/WebKit/Source/platform/heap/PageMemory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698