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

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

Issue 1762093002: Avoid PageMemoryRegion::m_numPages data race. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | third_party/WebKit/Source/platform/heap/PageMemory.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "wtf/Allocator.h" 9 #include "wtf/Allocator.h"
10 #include "wtf/Assertions.h" 10 #include "wtf/Assertions.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // A PageMemoryRegion represents a chunk of reserved virtual address 52 // A PageMemoryRegion represents a chunk of reserved virtual address
53 // space containing a number of blink heap pages. On Windows, reserved 53 // space containing a number of blink heap pages. On Windows, reserved
54 // virtual address space can only be given back to the system as a 54 // virtual address space can only be given back to the system as a
55 // whole. The PageMemoryRegion allows us to do that by keeping track 55 // whole. The PageMemoryRegion allows us to do that by keeping track
56 // of the number of pages using it in order to be able to release all 56 // of the number of pages using it in order to be able to release all
57 // of the virtual address space when there are no more pages using it. 57 // of the virtual address space when there are no more pages using it.
58 class PageMemoryRegion : public MemoryRegion { 58 class PageMemoryRegion : public MemoryRegion {
59 public: 59 public:
60 ~PageMemoryRegion(); 60 ~PageMemoryRegion();
61 61
62 void pageDeleted(Address page) 62 void pageDeleted(Address);
63 {
64 markPageUnused(page);
65 if (!--m_numPages)
66 delete this;
67 }
68 63
69 void markPageUsed(Address page) 64 void markPageUsed(Address page)
70 { 65 {
71 ASSERT(!m_inUse[index(page)]); 66 ASSERT(!m_inUse[index(page)]);
72 m_inUse[index(page)] = true; 67 m_inUse[index(page)] = true;
73 } 68 }
74 69
75 void markPageUnused(Address page) 70 void markPageUnused(Address page)
76 { 71 {
77 m_inUse[index(page)] = false; 72 m_inUse[index(page)] = false;
(...skipping 15 matching lines...) Expand all
93 if (!m_inUse[index(address)]) 88 if (!m_inUse[index(address)])
94 return nullptr; 89 return nullptr;
95 if (m_isLargePage) 90 if (m_isLargePage)
96 return pageFromObject(base()); 91 return pageFromObject(base());
97 return pageFromObject(address); 92 return pageFromObject(address);
98 } 93 }
99 94
100 private: 95 private:
101 PageMemoryRegion(Address base, size_t, unsigned numPages); 96 PageMemoryRegion(Address base, size_t, unsigned numPages);
102 97
103 unsigned index(Address address) 98 unsigned index(Address address) const
104 { 99 {
105 ASSERT(contains(address)); 100 ASSERT(contains(address));
106 if (m_isLargePage) 101 if (m_isLargePage)
107 return 0; 102 return 0;
108 size_t offset = blinkPageAddress(address) - base(); 103 size_t offset = blinkPageAddress(address) - base();
109 ASSERT(offset % blinkPageSize == 0); 104 ASSERT(offset % blinkPageSize == 0);
110 return offset / blinkPageSize; 105 return offset / blinkPageSize;
111 } 106 }
112 107
113 static PageMemoryRegion* allocate(size_t, unsigned numPages); 108 static PageMemoryRegion* allocate(size_t, unsigned numPages);
114 109
115 bool m_isLargePage; 110 const bool m_isLargePage;
111 // A thread owns a page, but not a region. Represent the in-use
112 // bitmap such that thread non-interference comes for free.
116 bool m_inUse[blinkPagesPerRegion]; 113 bool m_inUse[blinkPagesPerRegion];
117 unsigned m_numPages; 114 int m_numPages;
118 }; 115 };
119 116
120 // A RegionTree is a simple binary search tree of PageMemoryRegions sorted 117 // A RegionTree is a simple binary search tree of PageMemoryRegions sorted
121 // by base addresses. 118 // by base addresses.
122 class RegionTree { 119 class RegionTree {
123 USING_FAST_MALLOC(RegionTree); 120 USING_FAST_MALLOC(RegionTree);
124 public: 121 public:
125 explicit RegionTree(PageMemoryRegion* region) 122 explicit RegionTree(PageMemoryRegion* region)
126 : m_region(region) 123 : m_region(region)
127 , m_left(nullptr) 124 , m_left(nullptr)
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 private: 201 private:
205 PageMemory(PageMemoryRegion* reserved, const MemoryRegion& writable); 202 PageMemory(PageMemoryRegion* reserved, const MemoryRegion& writable);
206 203
207 PageMemoryRegion* m_reserved; 204 PageMemoryRegion* m_reserved;
208 MemoryRegion m_writable; 205 MemoryRegion m_writable;
209 }; 206 };
210 207
211 } // namespace blink 208 } // namespace blink
212 209
213 #endif 210 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/heap/PageMemory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698