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 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 void ThreadState::unlockThreadAttachMutex() | 1331 void ThreadState::unlockThreadAttachMutex() |
1332 { | 1332 { |
1333 threadAttachMutex().unlock(); | 1333 threadAttachMutex().unlock(); |
1334 } | 1334 } |
1335 | 1335 |
1336 void ThreadState::invokePreFinalizers() | 1336 void ThreadState::invokePreFinalizers() |
1337 { | 1337 { |
1338 ASSERT(checkThread()); | 1338 ASSERT(checkThread()); |
1339 ASSERT(!sweepForbidden()); | 1339 ASSERT(!sweepForbidden()); |
1340 TRACE_EVENT0("blink_gc", "ThreadState::invokePreFinalizers"); | 1340 TRACE_EVENT0("blink_gc", "ThreadState::invokePreFinalizers"); |
| 1341 |
1341 double startTime = WTF::currentTimeMS(); | 1342 double startTime = WTF::currentTimeMS(); |
| 1343 if (!m_orderedPreFinalizers.isEmpty()) { |
| 1344 SweepForbiddenScope forbiddenScope(this); |
| 1345 if (isMainThread()) |
| 1346 ScriptForbiddenScope::enter(); |
1342 | 1347 |
1343 if (isMainThread()) | 1348 // Call the prefinalizers in the opposite order to their registration. |
1344 ScriptForbiddenScope::enter(); | 1349 // |
| 1350 // The prefinalizer callback wrapper returns |true| when its associated |
| 1351 // object is unreachable garbage and the prefinalizer callback has run. |
| 1352 // The registered prefinalizer entry must then be removed and deleted. |
| 1353 // |
| 1354 auto it = --m_orderedPreFinalizers.end(); |
| 1355 bool done; |
| 1356 do { |
| 1357 auto entry = it; |
| 1358 done = it == m_orderedPreFinalizers.begin(); |
| 1359 if (!done) |
| 1360 --it; |
| 1361 if ((entry->second)(entry->first)) |
| 1362 m_orderedPreFinalizers.remove(entry); |
| 1363 } while (!done); |
1345 | 1364 |
1346 SweepForbiddenScope forbiddenScope(this); | 1365 if (isMainThread()) |
1347 Vector<PreFinalizer> deadPreFinalizers; | 1366 ScriptForbiddenScope::exit(); |
1348 // Call the pre-finalizers in the reverse order in which they | |
1349 // are registered. | |
1350 for (auto it = m_orderedPreFinalizers.rbegin(); it != m_orderedPreFinalizers
.rend(); ++it) { | |
1351 if (!(it->second)(it->first)) | |
1352 continue; | |
1353 deadPreFinalizers.append(*it); | |
1354 } | 1367 } |
1355 // FIXME: removeAll is inefficient. It can shrink repeatedly. | |
1356 m_orderedPreFinalizers.removeAll(deadPreFinalizers); | |
1357 | |
1358 if (isMainThread()) { | 1368 if (isMainThread()) { |
1359 ScriptForbiddenScope::exit(); | |
1360 double timeForInvokingPreFinalizers = WTF::currentTimeMS() - startTime; | 1369 double timeForInvokingPreFinalizers = WTF::currentTimeMS() - startTime; |
1361 Platform::current()->histogramCustomCounts("BlinkGC.TimeForInvokingPreFi
nalizers", timeForInvokingPreFinalizers, 1, 10 * 1000, 50); | 1370 Platform::current()->histogramCustomCounts("BlinkGC.TimeForInvokingPreFi
nalizers", timeForInvokingPreFinalizers, 1, 10 * 1000, 50); |
1362 } | 1371 } |
1363 } | 1372 } |
1364 | 1373 |
1365 void ThreadState::clearHeapAges() | 1374 void ThreadState::clearHeapAges() |
1366 { | 1375 { |
1367 memset(m_heapAges, 0, sizeof(size_t) * BlinkGC::NumberOfHeaps); | 1376 memset(m_heapAges, 0, sizeof(size_t) * BlinkGC::NumberOfHeaps); |
1368 memset(m_likelyToBePromptlyFreed.get(), 0, sizeof(int) * likelyToBePromptlyF
reedArraySize); | 1377 memset(m_likelyToBePromptlyFreed.get(), 0, sizeof(int) * likelyToBePromptlyF
reedArraySize); |
1369 m_currentHeapAges = 0; | 1378 m_currentHeapAges = 0; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 threadDump->addScalar("dead_count", "objects", totalDeadCount); | 1492 threadDump->addScalar("dead_count", "objects", totalDeadCount); |
1484 threadDump->addScalar("live_size", "bytes", totalLiveSize); | 1493 threadDump->addScalar("live_size", "bytes", totalLiveSize); |
1485 threadDump->addScalar("dead_size", "bytes", totalDeadSize); | 1494 threadDump->addScalar("dead_size", "bytes", totalDeadSize); |
1486 | 1495 |
1487 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c
reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); | 1496 WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->c
reateMemoryAllocatorDumpForCurrentGC(heapsDumpName); |
1488 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()-
>createMemoryAllocatorDumpForCurrentGC(classesDumpName); | 1497 WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()-
>createMemoryAllocatorDumpForCurrentGC(classesDumpName); |
1489 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners
hipEdge(classesDump->guid(), heapsDump->guid()); | 1498 BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->addOwners
hipEdge(classesDump->guid(), heapsDump->guid()); |
1490 } | 1499 } |
1491 | 1500 |
1492 } // namespace blink | 1501 } // namespace blink |
OLD | NEW |