OLD | NEW |
---|---|
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 // point on will not trace objects on this thread's arenas. | 327 // point on will not trace objects on this thread's arenas. |
328 cleanupPages(); | 328 cleanupPages(); |
329 } | 329 } |
330 | 330 |
331 void ThreadState::cleanupMainThread() { | 331 void ThreadState::cleanupMainThread() { |
332 ASSERT(isMainThread()); | 332 ASSERT(isMainThread()); |
333 | 333 |
334 #if defined(LEAK_SANITIZER) | 334 #if defined(LEAK_SANITIZER) |
335 // See comment below, clear out most garbage before releasing static | 335 // See comment below, clear out most garbage before releasing static |
336 // persistents should some of the finalizers depend on touching | 336 // persistents should some of the finalizers depend on touching |
337 // these persistents. | 337 // these persistents. The clearing done includes the static persistents, |
338 // so as to make objects retained by these singletons also be eligible | |
339 // for garbage collection right away. | |
340 clearStaticPersistentNodes(); | |
haraken
2017/01/02 09:26:44
Hmm, I'm not quite sure if this helps.
In my unde
sof
2017/01/02 09:37:16
Hmm, that doesn't make a lot of sense, given the t
| |
338 collectAllGarbage(); | 341 collectAllGarbage(); |
339 #endif | 342 #endif |
340 | 343 |
341 releaseStaticPersistentNodes(); | 344 releaseStaticPersistentNodes(); |
342 | 345 |
343 #if defined(LEAK_SANITIZER) | 346 #if defined(LEAK_SANITIZER) |
344 // If LSan is about to perform leak detection, after having released all | 347 // If LSan is about to perform leak detection, after having released all |
345 // the registered static Persistent<> root references to global caches | 348 // the registered static Persistent<> root references to global caches |
346 // that Blink keeps, follow up with a round of GCs to clear out all | 349 // that Blink keeps, follow up with a round of GCs to clear out all |
347 // what they referred to. | 350 // what they referred to. |
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1493 PersistentClearCallback callback) { | 1496 PersistentClearCallback callback) { |
1494 #if defined(LEAK_SANITIZER) | 1497 #if defined(LEAK_SANITIZER) |
1495 if (m_disabledStaticPersistentsRegistration) | 1498 if (m_disabledStaticPersistentsRegistration) |
1496 return; | 1499 return; |
1497 #endif | 1500 #endif |
1498 | 1501 |
1499 ASSERT(!m_staticPersistents.contains(node)); | 1502 ASSERT(!m_staticPersistents.contains(node)); |
1500 m_staticPersistents.add(node, callback); | 1503 m_staticPersistents.add(node, callback); |
1501 } | 1504 } |
1502 | 1505 |
1506 #if defined(LEAK_SANITIZER) | |
1507 void ThreadState::clearStaticPersistentNodes() { | |
1508 HashMap<PersistentNode*, ThreadState::PersistentClearCallback> | |
1509 staticPersistents; | |
1510 staticPersistents.swap(m_staticPersistents); | |
1511 | |
1512 PersistentRegion* persistentRegion = getPersistentRegion(); | |
1513 for (const auto& it : staticPersistents) | |
1514 persistentRegion->clearPersistentNode(it.key, it.value); | |
1515 } | |
1516 #endif | |
1517 | |
1503 void ThreadState::releaseStaticPersistentNodes() { | 1518 void ThreadState::releaseStaticPersistentNodes() { |
1504 HashMap<PersistentNode*, ThreadState::PersistentClearCallback> | 1519 HashMap<PersistentNode*, ThreadState::PersistentClearCallback> |
1505 staticPersistents; | 1520 staticPersistents; |
1506 staticPersistents.swap(m_staticPersistents); | 1521 staticPersistents.swap(m_staticPersistents); |
1507 | 1522 |
1508 PersistentRegion* persistentRegion = getPersistentRegion(); | 1523 PersistentRegion* persistentRegion = getPersistentRegion(); |
1509 for (const auto& it : staticPersistents) | 1524 for (const auto& it : staticPersistents) |
1510 persistentRegion->releasePersistentNode(it.key, it.value); | 1525 persistentRegion->releasePersistentNode(it.key, it.value); |
1511 } | 1526 } |
1512 | 1527 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1877 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, | 1892 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, |
1878 BlinkGC::ForcedGC); | 1893 BlinkGC::ForcedGC); |
1879 size_t liveObjects = heap().heapStats().markedObjectSize(); | 1894 size_t liveObjects = heap().heapStats().markedObjectSize(); |
1880 if (liveObjects == previousLiveObjects) | 1895 if (liveObjects == previousLiveObjects) |
1881 break; | 1896 break; |
1882 previousLiveObjects = liveObjects; | 1897 previousLiveObjects = liveObjects; |
1883 } | 1898 } |
1884 } | 1899 } |
1885 | 1900 |
1886 } // namespace blink | 1901 } // namespace blink |
OLD | NEW |