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

Side by Side Diff: Source/wtf/Partitions.cpp

Issue 1041103002: PartitionAlloc: Centralize Partition allocators into one place (Part 1) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "WTF.h" 32 #include "wtf/Partitions.h"
33 33
34 #include "wtf/DefaultAllocator.h" 34 #include "wtf/DefaultAllocator.h"
35 #include "wtf/FastMalloc.h" 35 #include "wtf/FastMalloc.h"
36 36
37 namespace WTF { 37 namespace WTF {
38 38
39 extern void initializeThreading(); 39 extern void initializeThreading();
40 40
41 bool s_initialized; 41 bool s_initialized;
42 bool s_shutdown; 42 bool s_shutdown;
43 bool Partitions::s_initialized; 43 bool Partitions::s_initialized;
44
44 PartitionAllocatorGeneric Partitions::m_bufferAllocator; 45 PartitionAllocatorGeneric Partitions::m_bufferAllocator;
46 SizeSpecificPartitionAllocator<3328> Partitions::m_objectModelAllocator;
47 SizeSpecificPartitionAllocator<1024> Partitions::m_renderingAllocator;
45 48
46 void initialize(TimeFunction currentTimeFunction, TimeFunction monotonicallyIncr easingTimeFunction) 49 void initialize(TimeFunction currentTimeFunction, TimeFunction monotonicallyIncr easingTimeFunction)
47 { 50 {
48 // WTF, and Blink in general, cannot handle being re-initialized, even if sh utdown first. 51 // WTF, and Blink in general, cannot handle being re-initialized, even if sh utdown first.
49 // Make that explicit here. 52 // Make that explicit here.
50 ASSERT(!s_initialized); 53 ASSERT(!s_initialized);
51 ASSERT(!s_shutdown); 54 ASSERT(!s_shutdown);
52 s_initialized = true; 55 s_initialized = true;
53 Partitions::initialize(); 56 Partitions::initialize();
54 setCurrentTimeFunction(currentTimeFunction); 57 setCurrentTimeFunction(currentTimeFunction);
(...skipping 14 matching lines...) Expand all
69 return s_shutdown; 72 return s_shutdown;
70 } 73 }
71 74
72 void Partitions::initialize() 75 void Partitions::initialize()
73 { 76 {
74 static int lock = 0; 77 static int lock = 0;
75 // Guard against two threads hitting here in parallel. 78 // Guard against two threads hitting here in parallel.
76 spinLockLock(&lock); 79 spinLockLock(&lock);
77 if (!s_initialized) { 80 if (!s_initialized) {
78 m_bufferAllocator.init(); 81 m_bufferAllocator.init();
82 m_objectModelAllocator.init();
83 m_renderingAllocator.init();
79 s_initialized = true; 84 s_initialized = true;
80 } 85 }
81 spinLockUnlock(&lock); 86 spinLockUnlock(&lock);
82 } 87 }
83 88
84 void Partitions::shutdown() 89 void Partitions::shutdown()
85 { 90 {
86 fastMallocShutdown(); 91 fastMallocShutdown();
92
93 // We could ASSERT here for a memory leak within the partition, but it leads
94 // to very hard to diagnose ASSERTs, so it's best to leave leak checking for
95 // the valgrind and heapcheck bots, which run without partitions.
96 (void) m_renderingAllocator.shutdown();
97 (void) m_objectModelAllocator.shutdown();
87 m_bufferAllocator.shutdown(); 98 m_bufferAllocator.shutdown();
Chris Evans 2015/03/30 18:41:36 Nit: we're also ignoring a fairly useful return co
haraken 2015/03/30 23:06:18 Done.
88 } 99 }
89 100
90 } // namespace WTF 101 } // namespace WTF
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698