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

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

Issue 2614883006: Change PartitionAlloc to Chromium naming style. (Closed)
Patch Set: Rebase and fix some names. Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/CallbackStack.h" 5 #include "platform/heap/CallbackStack.h"
6 #include "wtf/PtrUtil.h" 6 #include "wtf/PtrUtil.h"
7 #include "wtf/allocator/Partitions.h" 7 #include "wtf/allocator/Partitions.h"
8 8
9 namespace blink { 9 namespace blink {
10 10
11 CallbackStackMemoryPool& CallbackStackMemoryPool::instance() { 11 CallbackStackMemoryPool& CallbackStackMemoryPool::instance() {
12 DEFINE_STATIC_LOCAL(CallbackStackMemoryPool, memoryPool, ()); 12 DEFINE_STATIC_LOCAL(CallbackStackMemoryPool, memoryPool, ());
13 return memoryPool; 13 return memoryPool;
14 } 14 }
15 15
16 void CallbackStackMemoryPool::initialize() { 16 void CallbackStackMemoryPool::initialize() {
17 m_freeListFirst = 0; 17 m_freeListFirst = 0;
18 for (size_t index = 0; index < kPooledBlockCount - 1; ++index) { 18 for (size_t index = 0; index < kPooledBlockCount - 1; ++index) {
19 m_freeListNext[index] = index + 1; 19 m_freeListNext[index] = index + 1;
20 } 20 }
21 m_freeListNext[kPooledBlockCount - 1] = -1; 21 m_freeListNext[kPooledBlockCount - 1] = -1;
22 m_pooledMemory = static_cast<CallbackStack::Item*>( 22 m_pooledMemory = static_cast<CallbackStack::Item*>(
23 WTF::allocPages(nullptr, kBlockBytes * kPooledBlockCount, 23 WTF::AllocPages(nullptr, kBlockBytes * kPooledBlockCount,
24 WTF::kPageAllocationGranularity, WTF::PageAccessible)); 24 WTF::kPageAllocationGranularity, WTF::PageAccessible));
25 CHECK(m_pooledMemory); 25 CHECK(m_pooledMemory);
26 } 26 }
27 27
28 void CallbackStackMemoryPool::shutdown() { 28 void CallbackStackMemoryPool::shutdown() {
29 WTF::freePages(m_pooledMemory, kBlockBytes * kPooledBlockCount); 29 WTF::FreePages(m_pooledMemory, kBlockBytes * kPooledBlockCount);
30 m_pooledMemory = nullptr; 30 m_pooledMemory = nullptr;
31 m_freeListFirst = 0; 31 m_freeListFirst = 0;
32 } 32 }
33 33
34 CallbackStack::Item* CallbackStackMemoryPool::allocate() { 34 CallbackStack::Item* CallbackStackMemoryPool::allocate() {
35 MutexLocker locker(m_mutex); 35 MutexLocker locker(m_mutex);
36 // Allocate from a free list if available. 36 // Allocate from a free list if available.
37 if (m_freeListFirst != -1) { 37 if (m_freeListFirst != -1) {
38 size_t index = m_freeListFirst; 38 size_t index = m_freeListFirst;
39 DCHECK(0 <= index && index < CallbackStackMemoryPool::kPooledBlockCount); 39 DCHECK(0 <= index && index < CallbackStackMemoryPool::kPooledBlockCount);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 bool CallbackStack::hasCallbackForObject(const void* object) { 208 bool CallbackStack::hasCallbackForObject(const void* object) {
209 for (Block* current = m_first; current; current = current->next()) { 209 for (Block* current = m_first; current; current = current->next()) {
210 if (current->hasCallbackForObject(object)) 210 if (current->hasCallbackForObject(object))
211 return true; 211 return true;
212 } 212 }
213 return false; 213 return false;
214 } 214 }
215 #endif 215 #endif
216 216
217 } // namespace blink 217 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698