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 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, | 1858 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, |
1878 BlinkGC::ForcedGC); | 1859 BlinkGC::ForcedGC); |
1879 size_t liveObjects = heap().heapStats().markedObjectSize(); | 1860 size_t liveObjects = heap().heapStats().markedObjectSize(); |
1880 if (liveObjects == previousLiveObjects) | 1861 if (liveObjects == previousLiveObjects) |
1881 break; | 1862 break; |
1882 previousLiveObjects = liveObjects; | 1863 previousLiveObjects = liveObjects; |
1883 } | 1864 } |
1884 } | 1865 } |
1885 | 1866 |
1886 } // namespace blink | 1867 } // namespace blink |
OLD | NEW |