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

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

Issue 2695233002: Remove ThreadHeap::allHeaps() (Closed)
Patch Set: 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/Heap.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 /* 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 : m_regionTree(WTF::makeUnique<RegionTree>()), 149 : m_regionTree(WTF::makeUnique<RegionTree>()),
150 m_heapDoesNotContainCache(WTF::wrapUnique(new HeapDoesNotContainCache)), 150 m_heapDoesNotContainCache(WTF::wrapUnique(new HeapDoesNotContainCache)),
151 m_safePointBarrier(WTF::makeUnique<SafePointBarrier>()), 151 m_safePointBarrier(WTF::makeUnique<SafePointBarrier>()),
152 m_freePagePool(WTF::wrapUnique(new PagePool)), 152 m_freePagePool(WTF::wrapUnique(new PagePool)),
153 m_markingStack(CallbackStack::create()), 153 m_markingStack(CallbackStack::create()),
154 m_postMarkingCallbackStack(CallbackStack::create()), 154 m_postMarkingCallbackStack(CallbackStack::create()),
155 m_globalWeakCallbackStack(CallbackStack::create()), 155 m_globalWeakCallbackStack(CallbackStack::create()),
156 m_ephemeronStack(CallbackStack::create()) { 156 m_ephemeronStack(CallbackStack::create()) {
157 if (ThreadState::current()->isMainThread()) 157 if (ThreadState::current()->isMainThread())
158 s_mainThreadHeap = this; 158 s_mainThreadHeap = this;
159
160 MutexLocker locker(ThreadHeap::allHeapsMutex());
161 allHeaps().insert(this);
162 } 159 }
163 160
164 ThreadHeap::~ThreadHeap() { 161 ThreadHeap::~ThreadHeap() {
165 MutexLocker locker(ThreadHeap::allHeapsMutex());
166 allHeaps().remove(this);
167 }
168
169 RecursiveMutex& ThreadHeap::allHeapsMutex() {
170 DEFINE_THREAD_SAFE_STATIC_LOCAL(RecursiveMutex, mutex, (new RecursiveMutex));
171 return mutex;
172 }
173
174 HashSet<ThreadHeap*>& ThreadHeap::allHeaps() {
175 DEFINE_STATIC_LOCAL(HashSet<ThreadHeap*>, heaps, ());
176 return heaps;
177 } 162 }
178 163
179 void ThreadHeap::attach(ThreadState* thread) { 164 void ThreadHeap::attach(ThreadState* thread) {
180 MutexLocker locker(m_threadAttachMutex); 165 MutexLocker locker(m_threadAttachMutex);
181 m_threads.insert(thread); 166 m_threads.insert(thread);
182 } 167 }
183 168
184 void ThreadHeap::detach(ThreadState* thread) { 169 void ThreadHeap::detach(ThreadState* thread) {
185 ASSERT(ThreadState::current() == thread); 170 ASSERT(ThreadState::current() == thread);
186 bool isLastThread = false; 171 bool isLastThread = false;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize()); 573 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize());
589 574
590 m_stats.reset(); 575 m_stats.reset();
591 for (ThreadState* state : m_threads) 576 for (ThreadState* state : m_threads)
592 state->resetHeapCounters(); 577 state->resetHeapCounters();
593 } 578 }
594 579
595 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr; 580 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr;
596 581
597 } // namespace blink 582 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Heap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698