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

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

Issue 1881933005: Oilpan: Add ThreadState cleanup callbacks for static thread-specific persistent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // GC. 285 // GC.
286 SafePointAwareMutexLocker locker(threadAttachMutex(), BlinkGC::NoHeapPoi ntersOnStack); 286 SafePointAwareMutexLocker locker(threadAttachMutex(), BlinkGC::NoHeapPoi ntersOnStack);
287 287
288 // Finish sweeping. 288 // Finish sweeping.
289 completeSweep(); 289 completeSweep();
290 290
291 // From here on ignore all conservatively discovered 291 // From here on ignore all conservatively discovered
292 // pointers into the heap owned by this thread. 292 // pointers into the heap owned by this thread.
293 m_isTerminating = true; 293 m_isTerminating = true;
294 294
295 // Invoke the cleanup hooks. This gives an opportunity to release any
296 // persistent handles that may exist, e.g. in thread-specific static
297 // locals.
298 for (const OwnPtr<SameThreadClosure>& hook : m_cleanupHooks)
299 (*hook)();
300
295 // Set the terminate flag on all heap pages of this thread. This is used to 301 // Set the terminate flag on all heap pages of this thread. This is used to
296 // ensure we don't trace pages on other threads that are not part of the 302 // ensure we don't trace pages on other threads that are not part of the
297 // thread local GC. 303 // thread local GC.
298 prepareForThreadStateTermination(); 304 prepareForThreadStateTermination();
299 305
300 ProcessHeap::crossThreadPersistentRegion().prepareForThreadStateTerminat ion(this); 306 ProcessHeap::crossThreadPersistentRegion().prepareForThreadStateTerminat ion(this);
301 307
302 // Do thread local GC's as long as the count of thread local Persistents 308 // Do thread local GC's as long as the count of thread local Persistents
303 // changes and is above zero. 309 // changes and is above zero.
304 int oldCount = -1; 310 int oldCount = -1;
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 void ThreadState::addInterruptor(PassOwnPtr<BlinkGCInterruptor> interruptor) 1358 void ThreadState::addInterruptor(PassOwnPtr<BlinkGCInterruptor> interruptor)
1353 { 1359 {
1354 ASSERT(checkThread()); 1360 ASSERT(checkThread());
1355 SafePointScope scope(BlinkGC::HeapPointersOnStack); 1361 SafePointScope scope(BlinkGC::HeapPointersOnStack);
1356 { 1362 {
1357 MutexLocker locker(threadAttachMutex()); 1363 MutexLocker locker(threadAttachMutex());
1358 m_interruptors.append(interruptor); 1364 m_interruptors.append(interruptor);
1359 } 1365 }
1360 } 1366 }
1361 1367
1368 void ThreadState::registerCleanupHook(PassOwnPtr<SameThreadClosure> hook)
1369 {
1370 ASSERT(checkThread());
1371 ASSERT(!isTerminating());
1372 m_cleanupHooks.append(hook);
1373 }
1374
1362 #if defined(LEAK_SANITIZER) 1375 #if defined(LEAK_SANITIZER)
1363 void ThreadState::registerStaticPersistentNode(PersistentNode* node) 1376 void ThreadState::registerStaticPersistentNode(PersistentNode* node)
1364 { 1377 {
1365 if (m_disabledStaticPersistentsRegistration) 1378 if (m_disabledStaticPersistentsRegistration)
1366 return; 1379 return;
1367 1380
1368 ASSERT(!m_staticPersistents.contains(node)); 1381 ASSERT(!m_staticPersistents.contains(node));
1369 m_staticPersistents.add(node); 1382 m_staticPersistents.add(node);
1370 } 1383 }
1371 1384
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 threadDump->addScalar("dead_count", "objects", totalDeadCount); 1564 threadDump->addScalar("dead_count", "objects", totalDeadCount);
1552 threadDump->addScalar("live_size", "bytes", totalLiveSize); 1565 threadDump->addScalar("live_size", "bytes", totalLiveSize);
1553 threadDump->addScalar("dead_size", "bytes", totalDeadSize); 1566 threadDump->addScalar("dead_size", "bytes", totalDeadSize);
1554 1567
1555 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); 1568 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c reateMemoryAllocatorDumpForCurrentGC(heapsDumpName);
1556 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()- >createMemoryAllocatorDumpForCurrentGC(classesDumpName); 1569 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()- >createMemoryAllocatorDumpForCurrentGC(classesDumpName);
1557 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners hipEdge(classesDump->guid(), heapsDump->guid()); 1570 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners hipEdge(classesDump->guid(), heapsDump->guid());
1558 } 1571 }
1559 1572
1560 } // namespace blink 1573 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698