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

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

Issue 2657443005: Migrate WTF::HashSet::add() to ::insert() [part 1 of N] (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
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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 m_freePagePool(WTF::wrapUnique(new FreePagePool)), 208 m_freePagePool(WTF::wrapUnique(new FreePagePool)),
209 m_orphanedPagePool(WTF::wrapUnique(new OrphanedPagePool)), 209 m_orphanedPagePool(WTF::wrapUnique(new OrphanedPagePool)),
210 m_markingStack(CallbackStack::create()), 210 m_markingStack(CallbackStack::create()),
211 m_postMarkingCallbackStack(CallbackStack::create()), 211 m_postMarkingCallbackStack(CallbackStack::create()),
212 m_globalWeakCallbackStack(CallbackStack::create()), 212 m_globalWeakCallbackStack(CallbackStack::create()),
213 m_ephemeronStack(CallbackStack::create()) { 213 m_ephemeronStack(CallbackStack::create()) {
214 if (ThreadState::current()->isMainThread()) 214 if (ThreadState::current()->isMainThread())
215 s_mainThreadHeap = this; 215 s_mainThreadHeap = this;
216 216
217 MutexLocker locker(ThreadHeap::allHeapsMutex()); 217 MutexLocker locker(ThreadHeap::allHeapsMutex());
218 allHeaps().add(this); 218 allHeaps().insert(this);
219 } 219 }
220 220
221 ThreadHeap::~ThreadHeap() { 221 ThreadHeap::~ThreadHeap() {
222 MutexLocker locker(ThreadHeap::allHeapsMutex()); 222 MutexLocker locker(ThreadHeap::allHeapsMutex());
223 allHeaps().remove(this); 223 allHeaps().remove(this);
224 } 224 }
225 225
226 RecursiveMutex& ThreadHeap::allHeapsMutex() { 226 RecursiveMutex& ThreadHeap::allHeapsMutex() {
227 DEFINE_THREAD_SAFE_STATIC_LOCAL(RecursiveMutex, mutex, (new RecursiveMutex)); 227 DEFINE_THREAD_SAFE_STATIC_LOCAL(RecursiveMutex, mutex, (new RecursiveMutex));
228 return mutex; 228 return mutex;
229 } 229 }
230 230
231 HashSet<ThreadHeap*>& ThreadHeap::allHeaps() { 231 HashSet<ThreadHeap*>& ThreadHeap::allHeaps() {
232 DEFINE_STATIC_LOCAL(HashSet<ThreadHeap*>, heaps, ()); 232 DEFINE_STATIC_LOCAL(HashSet<ThreadHeap*>, heaps, ());
233 return heaps; 233 return heaps;
234 } 234 }
235 235
236 void ThreadHeap::attach(ThreadState* thread) { 236 void ThreadHeap::attach(ThreadState* thread) {
237 MutexLocker locker(m_threadAttachMutex); 237 MutexLocker locker(m_threadAttachMutex);
238 m_threads.add(thread); 238 m_threads.insert(thread);
239 } 239 }
240 240
241 void ThreadHeap::detach(ThreadState* thread) { 241 void ThreadHeap::detach(ThreadState* thread) {
242 ASSERT(ThreadState::current() == thread); 242 ASSERT(ThreadState::current() == thread);
243 bool isLastThread = false; 243 bool isLastThread = false;
244 { 244 {
245 // Grab the threadAttachMutex to ensure only one thread can shutdown at 245 // Grab the threadAttachMutex to ensure only one thread can shutdown at
246 // a time and that no other thread can do a global GC. It also allows 246 // a time and that no other thread can do a global GC. It also allows
247 // safe iteration of the m_threads set which happens as part of 247 // safe iteration of the m_threads set which happens as part of
248 // thread local GC asserts. We enter a safepoint while waiting for the 248 // thread local GC asserts. We enter a safepoint while waiting for the
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize()); 677 ProcessHeap::decreaseTotalMarkedObjectSize(m_stats.markedObjectSize());
678 678
679 m_stats.reset(); 679 m_stats.reset();
680 for (ThreadState* state : m_threads) 680 for (ThreadState* state : m_threads)
681 state->resetHeapCounters(); 681 state->resetHeapCounters();
682 } 682 }
683 683
684 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr; 684 ThreadHeap* ThreadHeap::s_mainThreadHeap = nullptr;
685 685
686 } // namespace blink 686 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698