Chromium Code Reviews| 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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 663 json->pushInteger(info.generations[i][j]); | 663 json->pushInteger(info.generations[i][j]); |
| 664 json->endArray(); | 664 json->endArray(); |
| 665 json->endDictionary(); | 665 json->endDictionary(); |
| 666 } | 666 } |
| 667 json->endArray(); | 667 json->endArray(); |
| 668 json->setInteger("liveSize", liveSize); | 668 json->setInteger("liveSize", liveSize); |
| 669 json->setInteger("deadSize", deadSize); | 669 json->setInteger("deadSize", deadSize); |
| 670 | 670 |
| 671 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("blink_gc", "ThreadState", this, json.re lease()); | 671 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("blink_gc", "ThreadState", this, json.re lease()); |
| 672 } | 672 } |
| 673 | |
| 674 void ThreadState::incrementMarkedObjectsAge() | |
| 675 { | |
| 676 for (int i = 0; i < NumberOfHeaps; ++i) | |
| 677 m_heaps[i]->incrementMarkedObjectsAge(); | |
| 678 } | |
| 673 #endif | 679 #endif |
| 674 | 680 |
| 675 void ThreadState::pushWeakPointerCallback(void* object, WeakPointerCallback call back) | 681 void ThreadState::pushWeakPointerCallback(void* object, WeakPointerCallback call back) |
| 676 { | 682 { |
| 677 CallbackStack::Item* slot = m_weakCallbackStack->allocateEntry(); | 683 CallbackStack::Item* slot = m_weakCallbackStack->allocateEntry(); |
| 678 *slot = CallbackStack::Item(object, callback); | 684 *slot = CallbackStack::Item(object, callback); |
| 679 } | 685 } |
| 680 | 686 |
| 681 bool ThreadState::popAndInvokeWeakPointerCallback(Visitor* visitor) | 687 bool ThreadState::popAndInvokeWeakPointerCallback(Visitor* visitor) |
| 682 { | 688 { |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 983 makeConsistentForSweeping(); | 989 makeConsistentForSweeping(); |
| 984 prepareRegionTree(); | 990 prepareRegionTree(); |
| 985 flushHeapDoesNotContainCacheIfNeeded(); | 991 flushHeapDoesNotContainCacheIfNeeded(); |
| 986 if (isMainThread()) | 992 if (isMainThread()) |
| 987 m_allocatedObjectSizeBeforeGC = Heap::allocatedObjectSize() + Heap::mark edObjectSize(); | 993 m_allocatedObjectSizeBeforeGC = Heap::allocatedObjectSize() + Heap::mark edObjectSize(); |
| 988 } | 994 } |
| 989 | 995 |
| 990 void ThreadState::postGC(GCType gcType) | 996 void ThreadState::postGC(GCType gcType) |
| 991 { | 997 { |
| 992 ASSERT(isInGC()); | 998 ASSERT(isInGC()); |
| 999 | |
| 1000 #if ENABLE(GC_PROFILING) | |
| 1001 // We snapshot the heap prior to sweeping to get numbers for both resources | |
| 1002 // that have been allocated since the last GC and for resources that are | |
| 1003 // going to be freed. | |
| 1004 bool gcTracingEnabled; | |
| 1005 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); | |
| 1006 | |
| 1007 if (gcTracingEnabled) { | |
| 1008 bool disabledByDefaultGCTracingEnabled; | |
| 1009 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink_gc") , &disabledByDefaultGCTracingEnabled); | |
| 1010 | |
| 1011 snapshot(); | |
| 1012 if (disabledByDefaultGCTracingEnabled) | |
| 1013 collectAndReportMarkSweepStats(); | |
| 1014 incrementMarkedObjectsAge(); | |
| 1015 } | |
| 1016 #endif | |
| 1017 | |
| 993 setGCState(gcType == GCWithSweep ? EagerSweepScheduled : LazySweepScheduled) ; | 1018 setGCState(gcType == GCWithSweep ? EagerSweepScheduled : LazySweepScheduled) ; |
| 994 for (int i = 0; i < NumberOfHeaps; i++) | 1019 for (int i = 0; i < NumberOfHeaps; i++) |
| 995 m_heaps[i]->prepareForSweep(); | 1020 m_heaps[i]->prepareForSweep(); |
| 996 } | 1021 } |
| 997 | 1022 |
| 998 void ThreadState::prepareHeapForTermination() | 1023 void ThreadState::prepareHeapForTermination() |
| 999 { | 1024 { |
| 1000 checkThread(); | 1025 checkThread(); |
| 1001 for (int i = 0; i < NumberOfHeaps; ++i) | 1026 for (int i = 0; i < NumberOfHeaps; ++i) |
| 1002 m_heaps[i]->prepareHeapForTermination(); | 1027 m_heaps[i]->prepareHeapForTermination(); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1123 } | 1148 } |
| 1124 | 1149 |
| 1125 void ThreadState::postGCProcessing() | 1150 void ThreadState::postGCProcessing() |
| 1126 { | 1151 { |
| 1127 checkThread(); | 1152 checkThread(); |
| 1128 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled) | 1153 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled) |
| 1129 return; | 1154 return; |
| 1130 | 1155 |
| 1131 m_didV8GCAfterLastGC = false; | 1156 m_didV8GCAfterLastGC = false; |
| 1132 | 1157 |
| 1133 #if ENABLE(GC_PROFILING) | |
| 1134 // We snapshot the heap prior to sweeping to get numbers for both resources | |
| 1135 // that have been allocated since the last GC and for resources that are | |
| 1136 // going to be freed. | |
| 1137 bool gcTracingEnabled; | |
| 1138 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); | |
| 1139 if (gcTracingEnabled) | |
| 1140 snapshot(); | |
| 1141 #endif | |
| 1142 | |
| 1143 { | 1158 { |
| 1144 if (isMainThread()) | 1159 if (isMainThread()) |
| 1145 ScriptForbiddenScope::enter(); | 1160 ScriptForbiddenScope::enter(); |
| 1146 | 1161 |
| 1147 SweepForbiddenScope forbiddenScope(this); | 1162 SweepForbiddenScope forbiddenScope(this); |
| 1148 { | 1163 { |
| 1149 // Disallow allocation during weak processing. | 1164 // Disallow allocation during weak processing. |
| 1150 NoAllocationScope noAllocationScope(this); | 1165 NoAllocationScope noAllocationScope(this); |
| 1151 { | 1166 { |
| 1152 TRACE_EVENT0("blink_gc", "ThreadState::threadLocalWeakProcessing "); | 1167 TRACE_EVENT0("blink_gc", "ThreadState::threadLocalWeakProcessing "); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1293 SNAPSHOT_FREE_LIST(VectorBacking); | 1308 SNAPSHOT_FREE_LIST(VectorBacking); |
| 1294 SNAPSHOT_FREE_LIST(InlineVectorBacking); | 1309 SNAPSHOT_FREE_LIST(InlineVectorBacking); |
| 1295 SNAPSHOT_FREE_LIST(HashTableBacking); | 1310 SNAPSHOT_FREE_LIST(HashTableBacking); |
| 1296 FOR_EACH_TYPED_HEAP(SNAPSHOT_FREE_LIST); | 1311 FOR_EACH_TYPED_HEAP(SNAPSHOT_FREE_LIST); |
| 1297 json->endArray(); | 1312 json->endArray(); |
| 1298 | 1313 |
| 1299 #undef SNAPSHOT_FREE_LIST | 1314 #undef SNAPSHOT_FREE_LIST |
| 1300 | 1315 |
| 1301 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), " FreeList", this, json.release()); | 1316 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), " FreeList", this, json.release()); |
| 1302 } | 1317 } |
| 1318 | |
| 1319 void ThreadState::collectAndReportMarkSweepStats() const | |
| 1320 { | |
| 1321 if (!isMainThread()) | |
|
haraken
2015/02/06 06:39:20
Why do we need to have the isMainThread check? Thr
Yuta Kitamura
2015/02/06 07:45:45
The reason is that data from non-main thread makes
haraken
2015/02/06 07:51:50
Thanks, makes sense.
keishi
2015/02/06 08:21:07
All records in the trace json file have tid fields
| |
| 1322 return; | |
| 1323 | |
| 1324 ClassAgeCountsMap markingClassAgeCounts; | |
| 1325 for (int i = 0; i < NumberOfHeaps; ++i) | |
| 1326 m_heaps[i]->countMarkedObjects(markingClassAgeCounts); | |
| 1327 reportMarkSweepStats("MarkingStats", markingClassAgeCounts); | |
| 1328 | |
| 1329 ClassAgeCountsMap sweepingClassAgeCounts; | |
| 1330 for (int i = 0; i < NumberOfHeaps; ++i) | |
| 1331 m_heaps[i]->countObjectsToSweep(sweepingClassAgeCounts); | |
| 1332 reportMarkSweepStats("SweepingStats", sweepingClassAgeCounts); | |
| 1333 } | |
| 1334 | |
| 1335 void ThreadState::reportMarkSweepStats(const char* statsName, const ClassAgeCoun tsMap& classAgeCounts) const | |
| 1336 { | |
| 1337 RefPtr<TracedValue> json = TracedValue::create(); | |
| 1338 for (ClassAgeCountsMap::const_iterator it = classAgeCounts.begin(), end = cl assAgeCounts.end(); it != end; ++it) { | |
| 1339 json->beginArray(it->key.ascii().data()); | |
| 1340 for (size_t age = 0; age <= maxHeapObjectAge; ++age) | |
| 1341 json->pushInteger(it->value.ages[age]); | |
| 1342 json->endArray(); | |
| 1343 } | |
| 1344 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), s tatsName, this, json.release()); | |
| 1345 } | |
| 1303 #endif | 1346 #endif |
| 1304 | 1347 |
| 1305 } // namespace blink | 1348 } // namespace blink |
| OLD | NEW |