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 22 matching lines...) Expand all Loading... | |
33 | 33 |
34 #include "platform/ScriptForbiddenScope.h" | 34 #include "platform/ScriptForbiddenScope.h" |
35 #include "platform/TraceEvent.h" | 35 #include "platform/TraceEvent.h" |
36 #include "platform/heap/AddressSanitizer.h" | 36 #include "platform/heap/AddressSanitizer.h" |
37 #include "platform/heap/CallbackStack.h" | 37 #include "platform/heap/CallbackStack.h" |
38 #include "platform/heap/Handle.h" | 38 #include "platform/heap/Handle.h" |
39 #include "platform/heap/Heap.h" | 39 #include "platform/heap/Heap.h" |
40 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
41 #include "public/platform/WebThread.h" | 41 #include "public/platform/WebThread.h" |
42 #include "wtf/ThreadingPrimitives.h" | 42 #include "wtf/ThreadingPrimitives.h" |
43 #if ENABLE(GC_PROFILE_HEAP) | 43 #if ENABLE(GC_PROFILE_HEAP) || ENABLE(GC_PROFILE_FREE_LIST) |
44 #include "platform/TracedValue.h" | 44 #include "platform/TracedValue.h" |
45 #endif | 45 #endif |
46 | 46 |
47 #if OS(WIN) | 47 #if OS(WIN) |
48 #include <stddef.h> | 48 #include <stddef.h> |
49 #include <windows.h> | 49 #include <windows.h> |
50 #include <winnt.h> | 50 #include <winnt.h> |
51 #elif defined(__GLIBC__) | 51 #elif defined(__GLIBC__) |
52 extern "C" void* __libc_stack_end; // NOLINT | 52 extern "C" void* __libc_stack_end; // NOLINT |
53 #endif | 53 #endif |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 const GCInfo* ThreadState::findGCInfo(Address address) | 612 const GCInfo* ThreadState::findGCInfo(Address address) |
613 { | 613 { |
614 BaseHeapPage* page = pageFromAddress(address); | 614 BaseHeapPage* page = pageFromAddress(address); |
615 if (page) { | 615 if (page) { |
616 return page->findGCInfo(address); | 616 return page->findGCInfo(address); |
617 } | 617 } |
618 return 0; | 618 return 0; |
619 } | 619 } |
620 #endif | 620 #endif |
621 | 621 |
622 #if ENABLE(GC_PROFILE_FREE_LIST) | |
623 | |
624 void ThreadState::snapshotFreeListIfNecessary() | |
keishi
2015/01/27 08:59:00
Call when a snapshot could be recorded to the trac
| |
625 { | |
626 //bool gcTracingEnabled; | |
627 //TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); | |
628 //if (!gcTracingEnabled) | |
629 // return; | |
630 const double kRecordInterval = 0.010; // seconds | |
631 static double nextRecordTime = monotonicallyIncreasingTime() + kRecordInterv al; | |
632 if (monotonicallyIncreasingTime() > nextRecordTime) { | |
633 snapshotFreeList(); | |
634 nextRecordTime = monotonicallyIncreasingTime() + kRecordInterval; | |
635 } | |
636 } | |
637 | |
638 void ThreadState::snapshotFreeList() | |
keishi
2015/01/27 08:59:00
Records the stats from the heap.
| |
639 { | |
640 RefPtr<TracedValue> json = TracedValue::create(); | |
641 | |
642 #define SNAPSHOT_FREE_LIST(HeapType) \ | |
643 { \ | |
644 json->beginDictionary(); \ | |
645 json->setString("name", #HeapType); \ | |
646 m_heaps[HeapType##Heap]->snapshotFreeList(json.get()); \ | |
647 json->endDictionary(); \ | |
648 json->beginDictionary(); \ | |
649 json->setString("name", #HeapType"NonFinalized"); \ | |
650 m_heaps[HeapType##HeapNonFinalized]->snapshotFreeList(json.get()); \ | |
651 json->endDictionary(); \ | |
652 } | |
653 json->beginArray("heaps"); | |
654 SNAPSHOT_FREE_LIST(General1); | |
655 SNAPSHOT_FREE_LIST(General2); | |
656 SNAPSHOT_FREE_LIST(General3); | |
657 SNAPSHOT_FREE_LIST(General4); | |
658 SNAPSHOT_FREE_LIST(VectorBacking); | |
659 SNAPSHOT_FREE_LIST(HashTableBacking); | |
660 FOR_EACH_TYPED_HEAP(SNAPSHOT_FREE_LIST); | |
661 json->endArray(); | |
662 #undef SNAPSHOT_FREE_LIST | |
663 | |
664 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("blink_gc", "FreeList", this, json.relea se()); | |
665 } | |
666 | |
667 #endif | |
668 | |
622 #if ENABLE(GC_PROFILE_HEAP) | 669 #if ENABLE(GC_PROFILE_HEAP) |
623 size_t ThreadState::SnapshotInfo::getClassTag(const GCInfo* gcinfo) | 670 size_t ThreadState::SnapshotInfo::getClassTag(const GCInfo* gcinfo) |
624 { | 671 { |
625 HashMap<const GCInfo*, size_t>::AddResult result = classTags.add(gcinfo, cla ssTags.size()); | 672 HashMap<const GCInfo*, size_t>::AddResult result = classTags.add(gcinfo, cla ssTags.size()); |
626 if (result.isNewEntry) { | 673 if (result.isNewEntry) { |
627 liveCount.append(0); | 674 liveCount.append(0); |
628 deadCount.append(0); | 675 deadCount.append(0); |
629 liveSize.append(0); | 676 liveSize.append(0); |
630 deadSize.append(0); | 677 deadSize.append(0); |
631 generations.append(Vector<int, 8>()); | 678 generations.append(Vector<int, 8>()); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1008 m_safePointStackCopy.resize(slotCount); | 1055 m_safePointStackCopy.resize(slotCount); |
1009 for (size_t i = 0; i < slotCount; ++i) { | 1056 for (size_t i = 0; i < slotCount; ++i) { |
1010 m_safePointStackCopy[i] = from[i]; | 1057 m_safePointStackCopy[i] = from[i]; |
1011 } | 1058 } |
1012 } | 1059 } |
1013 | 1060 |
1014 void ThreadState::performPendingSweep() | 1061 void ThreadState::performPendingSweep() |
1015 { | 1062 { |
1016 if (!sweepRequested()) | 1063 if (!sweepRequested()) |
1017 return; | 1064 return; |
1018 | 1065 Heap::reportSweepingStats(); |
keishi
2015/01/27 08:59:00
Report stats on the objects that will be sweeped.
| |
1019 #if ENABLE(GC_PROFILE_HEAP) | 1066 #if ENABLE(GC_PROFILE_HEAP) |
1020 // We snapshot the heap prior to sweeping to get numbers for both resources | 1067 // We snapshot the heap prior to sweeping to get numbers for both resources |
1021 // that have been allocated since the last GC and for resources that are | 1068 // that have been allocated since the last GC and for resources that are |
1022 // going to be freed. | 1069 // going to be freed. |
1023 bool gcTracingEnabled; | 1070 bool gcTracingEnabled; |
1024 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); | 1071 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); |
1025 if (gcTracingEnabled) | 1072 if (gcTracingEnabled) |
1026 snapshot(); | 1073 snapshot(); |
1027 #endif | 1074 #endif |
1028 | 1075 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1083 m_lowCollectionRate = Heap::markedObjectSize() > (allocatedObjectSizeBef oreSweeping / 2); | 1130 m_lowCollectionRate = Heap::markedObjectSize() > (allocatedObjectSizeBef oreSweeping / 2); |
1084 | 1131 |
1085 if (Platform::current()) { | 1132 if (Platform::current()) { |
1086 Platform::current()->histogramCustomCounts("BlinkGC.PerformPendingSweep" , WTF::currentTimeMS() - timeStamp, 0, 10 * 1000, 50); | 1133 Platform::current()->histogramCustomCounts("BlinkGC.PerformPendingSweep" , WTF::currentTimeMS() - timeStamp, 0, 10 * 1000, 50); |
1087 } | 1134 } |
1088 | 1135 |
1089 if (isMainThread()) { | 1136 if (isMainThread()) { |
1090 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(samplingState); | 1137 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(samplingState); |
1091 ScriptForbiddenScope::exit(); | 1138 ScriptForbiddenScope::exit(); |
1092 } | 1139 } |
1140 #if ENABLE(GC_PROFILE_FREE_LIST) | |
1141 snapshotFreeListIfNecessary(); | |
1142 #endif | |
1093 } | 1143 } |
1094 | 1144 |
1095 void ThreadState::addInterruptor(Interruptor* interruptor) | 1145 void ThreadState::addInterruptor(Interruptor* interruptor) |
1096 { | 1146 { |
1097 SafePointScope scope(HeapPointersOnStack, SafePointScope::AllowNesting); | 1147 SafePointScope scope(HeapPointersOnStack, SafePointScope::AllowNesting); |
1098 | 1148 |
1099 { | 1149 { |
1100 MutexLocker locker(threadAttachMutex()); | 1150 MutexLocker locker(threadAttachMutex()); |
1101 m_interruptors.append(interruptor); | 1151 m_interruptors.append(interruptor); |
1102 } | 1152 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1163 return gcInfo; | 1213 return gcInfo; |
1164 } | 1214 } |
1165 } | 1215 } |
1166 if (needLockForIteration) | 1216 if (needLockForIteration) |
1167 threadAttachMutex().unlock(); | 1217 threadAttachMutex().unlock(); |
1168 return 0; | 1218 return 0; |
1169 } | 1219 } |
1170 #endif | 1220 #endif |
1171 | 1221 |
1172 } // namespace blink | 1222 } // namespace blink |
OLD | NEW |