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

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

Issue 2683373002: Remove a redundant template from PagePool (Closed)
Patch Set: temp Created 3 years, 10 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 | « third_party/WebKit/Source/platform/heap/PagePool.h ('k') | 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 // 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 #include "platform/heap/PagePool.h" 5 #include "platform/heap/PagePool.h"
6 6
7 #include "platform/heap/Heap.h" 7 #include "platform/heap/Heap.h"
8 #include "platform/heap/PageMemory.h" 8 #include "platform/heap/PageMemory.h"
9 #include "wtf/Assertions.h" 9 #include "wtf/Assertions.h"
10 10
11 namespace blink { 11 namespace blink {
12 12
13 FreePagePool::~FreePagePool() { 13 PagePool::PagePool() {
14 for (int i = 0; i < BlinkGC::NumberOfArenas; ++i) {
15 m_pool[i] = nullptr;
16 }
17 }
18
19 PagePool::~PagePool() {
14 for (int index = 0; index < BlinkGC::NumberOfArenas; ++index) { 20 for (int index = 0; index < BlinkGC::NumberOfArenas; ++index) {
15 while (PoolEntry* entry = m_pool[index]) { 21 while (PoolEntry* entry = m_pool[index]) {
16 m_pool[index] = entry->next; 22 m_pool[index] = entry->next;
17 PageMemory* memory = entry->data; 23 PageMemory* memory = entry->data;
18 ASSERT(memory); 24 ASSERT(memory);
19 delete memory; 25 delete memory;
20 delete entry; 26 delete entry;
21 } 27 }
22 } 28 }
23 } 29 }
24 30
25 void FreePagePool::addFreePage(int index, PageMemory* memory) { 31 void PagePool::add(int index, PageMemory* memory) {
26 // When adding a page to the pool we decommit it to ensure it is unused 32 // When adding a page to the pool we decommit it to ensure it is unused
27 // while in the pool. This also allows the physical memory, backing the 33 // while in the pool. This also allows the physical memory, backing the
28 // page, to be given back to the OS. 34 // page, to be given back to the OS.
29 memory->decommit(); 35 memory->decommit();
30 MutexLocker locker(m_mutex[index]); 36 MutexLocker locker(m_mutex[index]);
31 PoolEntry* entry = new PoolEntry(memory, m_pool[index]); 37 PoolEntry* entry = new PoolEntry(memory, m_pool[index]);
32 m_pool[index] = entry; 38 m_pool[index] = entry;
33 } 39 }
34 40
35 PageMemory* FreePagePool::takeFreePage(int index) { 41 PageMemory* PagePool::take(int index) {
36 MutexLocker locker(m_mutex[index]); 42 MutexLocker locker(m_mutex[index]);
37 while (PoolEntry* entry = m_pool[index]) { 43 while (PoolEntry* entry = m_pool[index]) {
38 m_pool[index] = entry->next; 44 m_pool[index] = entry->next;
39 PageMemory* memory = entry->data; 45 PageMemory* memory = entry->data;
40 ASSERT(memory); 46 ASSERT(memory);
41 delete entry; 47 delete entry;
42 if (memory->commit()) 48 if (memory->commit())
43 return memory; 49 return memory;
44 50
45 // We got some memory, but failed to commit it, try again. 51 // We got some memory, but failed to commit it, try again.
46 delete memory; 52 delete memory;
47 } 53 }
48 return nullptr; 54 return nullptr;
49 } 55 }
50 56
51 } // namespace blink 57 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/PagePool.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698