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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 RELEASE_ASSERT(gcState() == NoGCScheduled); | 324 RELEASE_ASSERT(gcState() == NoGCScheduled); |
325 | 325 |
326 // Add pages to the orphaned page pool to ensure any global GCs from this | 326 // Add pages to the orphaned page pool to ensure any global GCs from this |
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) | |
335 // See comment below, clear out most garbage before releasing static | |
336 // persistents should some of the finalizers depend on touching | |
337 // these persistents. | |
338 collectAllGarbage(); | |
339 #endif | |
340 | |
341 releaseStaticPersistentNodes(); | 334 releaseStaticPersistentNodes(); |
342 | 335 |
343 #if defined(LEAK_SANITIZER) | |
344 // If LSan is about to perform leak detection, after having released all | |
345 // the registered static Persistent<> root references to global caches | |
346 // that Blink keeps, follow up with a round of GCs to clear out all | |
347 // what they referred to. | |
348 // | |
349 // This is not needed for caches over non-Oilpan objects, as they're | |
350 // not scanned by LSan due to being held in non-global storage | |
351 // ("static" references inside functions/methods.) | |
352 collectAllGarbage(); | |
353 #endif | |
354 | |
355 // Finish sweeping before shutting down V8. Otherwise, some destructor | 336 // Finish sweeping before shutting down V8. Otherwise, some destructor |
356 // may access V8 and cause crashes. | 337 // may access V8 and cause crashes. |
357 completeSweep(); | 338 completeSweep(); |
358 | 339 |
359 // It is unsafe to trigger GCs after this point because some | 340 // It is unsafe to trigger GCs after this point because some |
360 // destructor may access already-detached V8 and cause crashes. | 341 // destructor may access already-detached V8 and cause crashes. |
361 // Also it is useless. So we forbid GCs. | 342 // Also it is useless. So we forbid GCs. |
362 enterGCForbiddenScope(); | 343 enterGCForbiddenScope(); |
363 } | 344 } |
364 | 345 |
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 PersistentClearCallback callback) { | 1474 PersistentClearCallback callback) { |
1494 #if defined(LEAK_SANITIZER) | 1475 #if defined(LEAK_SANITIZER) |
1495 if (m_disabledStaticPersistentsRegistration) | 1476 if (m_disabledStaticPersistentsRegistration) |
1496 return; | 1477 return; |
1497 #endif | 1478 #endif |
1498 | 1479 |
1499 ASSERT(!m_staticPersistents.contains(node)); | 1480 ASSERT(!m_staticPersistents.contains(node)); |
1500 m_staticPersistents.add(node, callback); | 1481 m_staticPersistents.add(node, callback); |
1501 } | 1482 } |
1502 | 1483 |
| 1484 #if defined(LEAK_SANITIZER) |
| 1485 void ThreadState::clearStaticPersistentNodes() { |
| 1486 HashMap<PersistentNode*, ThreadState::PersistentClearCallback> |
| 1487 staticPersistents; |
| 1488 staticPersistents.swap(m_staticPersistents); |
| 1489 |
| 1490 PersistentRegion* persistentRegion = getPersistentRegion(); |
| 1491 for (const auto& it : staticPersistents) |
| 1492 persistentRegion->clearPersistentNode(it.key, it.value); |
| 1493 } |
| 1494 #endif |
| 1495 |
1503 void ThreadState::releaseStaticPersistentNodes() { | 1496 void ThreadState::releaseStaticPersistentNodes() { |
1504 HashMap<PersistentNode*, ThreadState::PersistentClearCallback> | 1497 HashMap<PersistentNode*, ThreadState::PersistentClearCallback> |
1505 staticPersistents; | 1498 staticPersistents; |
1506 staticPersistents.swap(m_staticPersistents); | 1499 staticPersistents.swap(m_staticPersistents); |
1507 | 1500 |
1508 PersistentRegion* persistentRegion = getPersistentRegion(); | 1501 PersistentRegion* persistentRegion = getPersistentRegion(); |
1509 for (const auto& it : staticPersistents) | 1502 for (const auto& it : staticPersistents) |
1510 persistentRegion->releasePersistentNode(it.key, it.value); | 1503 persistentRegion->releasePersistentNode(it.key, it.value); |
1511 } | 1504 } |
1512 | 1505 |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, | 1870 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, |
1878 BlinkGC::ForcedGC); | 1871 BlinkGC::ForcedGC); |
1879 size_t liveObjects = heap().heapStats().markedObjectSize(); | 1872 size_t liveObjects = heap().heapStats().markedObjectSize(); |
1880 if (liveObjects == previousLiveObjects) | 1873 if (liveObjects == previousLiveObjects) |
1881 break; | 1874 break; |
1882 previousLiveObjects = liveObjects; | 1875 previousLiveObjects = liveObjects; |
1883 } | 1876 } |
1884 } | 1877 } |
1885 | 1878 |
1886 } // namespace blink | 1879 } // namespace blink |
OLD | NEW |