Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: Source/platform/heap/ThreadState.cpp

Issue 717923005: Profile FreeList Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 585
586 #if ENABLE(GC_PROFILE_MARKING) 586 #if ENABLE(GC_PROFILE_MARKING)
587 const GCInfo* ThreadState::findGCInfo(Address address) 587 const GCInfo* ThreadState::findGCInfo(Address address)
588 { 588 {
589 if (BaseHeapPage* page = findPageFromAddress(address)) 589 if (BaseHeapPage* page = findPageFromAddress(address))
590 return page->findGCInfo(address); 590 return page->findGCInfo(address);
591 return nullptr; 591 return nullptr;
592 } 592 }
593 #endif 593 #endif
594 594
595 #if ENABLE(GC_PROFILE_FREE_LIST)
596
597 void ThreadState::snapshotFreeListIfNecessary()
598 {
599 //bool gcTracingEnabled;
600 //TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled);
601 //if (!gcTracingEnabled)
602 // return;
603 const double kRecordInterval = 0.010; // seconds
604 static double nextRecordTime = monotonicallyIncreasingTime() + kRecordInterv al;
605 if (monotonicallyIncreasingTime() > nextRecordTime) {
606 snapshotFreeList();
607 nextRecordTime = monotonicallyIncreasingTime() + kRecordInterval;
608 }
609 }
610
611 void ThreadState::snapshotFreeList()
612 {
613 RefPtr<TracedValue> json = TracedValue::create();
614
615 #define SNAPSHOT_FREE_LIST(HeapType) \
616 { \
617 json->beginDictionary(); \
618 json->setString("name", #HeapType); \
619 m_heaps[HeapType##Heap]->snapshotFreeList(json.get()); \
620 json->endDictionary(); \
621 }
622 json->beginArray("heaps");
623 SNAPSHOT_FREE_LIST(General);
624 SNAPSHOT_FREE_LIST(VectorBacking);
625 SNAPSHOT_FREE_LIST(HashTableBacking);
626 FOR_EACH_TYPED_HEAP(SNAPSHOT_FREE_LIST);
627 json->endArray();
628 #undef SNAPSHOT_FREE_LIST
629
630 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("blink_gc", "FreeList", this, json.relea se());
631 }
632
633 #endif
634
595 #if ENABLE(GC_PROFILE_HEAP) 635 #if ENABLE(GC_PROFILE_HEAP)
596 size_t ThreadState::SnapshotInfo::getClassTag(const GCInfo* gcinfo) 636 size_t ThreadState::SnapshotInfo::getClassTag(const GCInfo* gcinfo)
597 { 637 {
598 HashMap<const GCInfo*, size_t>::AddResult result = classTags.add(gcinfo, cla ssTags.size()); 638 HashMap<const GCInfo*, size_t>::AddResult result = classTags.add(gcinfo, cla ssTags.size());
599 if (result.isNewEntry) { 639 if (result.isNewEntry) {
600 liveCount.append(0); 640 liveCount.append(0);
601 deadCount.append(0); 641 deadCount.append(0);
602 liveSize.append(0); 642 liveSize.append(0);
603 deadSize.append(0); 643 deadSize.append(0);
604 generations.append(Vector<int, 8>()); 644 generations.append(Vector<int, 8>());
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 m_heaps[i]->prepareForSweep(); 947 m_heaps[i]->prepareForSweep();
908 } 948 }
909 949
910 void ThreadState::prepareHeapForTermination() 950 void ThreadState::prepareHeapForTermination()
911 { 951 {
912 checkThread(); 952 checkThread();
913 for (int i = 0; i < NumberOfHeaps; ++i) 953 for (int i = 0; i < NumberOfHeaps; ++i)
914 m_heaps[i]->prepareHeapForTermination(); 954 m_heaps[i]->prepareHeapForTermination();
915 } 955 }
916 956
917 #if ENABLE(ASSERT) 957 #if ENABLE(ASSERT) || ENABLE(GC_PROFILE_MARKING)
918 BaseHeapPage* ThreadState::findPageFromAddress(Address address) 958 BaseHeapPage* ThreadState::findPageFromAddress(Address address)
919 { 959 {
920 for (int i = 0; i < NumberOfHeaps; ++i) { 960 for (int i = 0; i < NumberOfHeaps; ++i) {
921 if (BaseHeapPage* page = m_heaps[i]->findPageFromAddress(address)) 961 if (BaseHeapPage* page = m_heaps[i]->findPageFromAddress(address))
922 return page; 962 return page;
923 } 963 }
924 return nullptr; 964 return nullptr;
925 } 965 }
926 #endif 966 #endif
927 967
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 m_safePointStackCopy[i] = from[i]; 1073 m_safePointStackCopy[i] = from[i];
1034 } 1074 }
1035 } 1075 }
1036 1076
1037 void ThreadState::postGCProcessing() 1077 void ThreadState::postGCProcessing()
1038 { 1078 {
1039 checkThread(); 1079 checkThread();
1040 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled) 1080 if (gcState() != EagerSweepScheduled && gcState() != LazySweepScheduled)
1041 return; 1081 return;
1042 1082
1083 Heap::reportSweepingStats();
1084
1043 m_didV8GCAfterLastGC = false; 1085 m_didV8GCAfterLastGC = false;
1044 1086
1045 #if ENABLE(GC_PROFILE_HEAP) 1087 #if ENABLE(GC_PROFILE_HEAP)
1046 // We snapshot the heap prior to sweeping to get numbers for both resources 1088 // We snapshot the heap prior to sweeping to get numbers for both resources
1047 // that have been allocated since the last GC and for resources that are 1089 // that have been allocated since the last GC and for resources that are
1048 // going to be freed. 1090 // going to be freed.
1049 bool gcTracingEnabled; 1091 bool gcTracingEnabled;
1050 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled); 1092 TRACE_EVENT_CATEGORY_GROUP_ENABLED("blink_gc", &gcTracingEnabled);
1051 if (gcTracingEnabled) 1093 if (gcTracingEnabled)
1052 snapshot(); 1094 snapshot();
(...skipping 30 matching lines...) Expand all
1083 } else { 1125 } else {
1084 // The default behavior is lazy sweeping. 1126 // The default behavior is lazy sweeping.
1085 setGCState(Sweeping); 1127 setGCState(Sweeping);
1086 } 1128 }
1087 #else 1129 #else
1088 // FIXME: For now, we disable lazy sweeping in non-oilpan builds 1130 // FIXME: For now, we disable lazy sweeping in non-oilpan builds
1089 // to avoid unacceptable behavior regressions on trunk. 1131 // to avoid unacceptable behavior regressions on trunk.
1090 setGCState(Sweeping); 1132 setGCState(Sweeping);
1091 completeSweep(); 1133 completeSweep();
1092 #endif 1134 #endif
1135
1136 #if ENABLE(GC_PROFILE_FREE_LIST)
1137 snapshotFreeListIfNecessary();
1138 #endif
1093 } 1139 }
1094 1140
1095 void ThreadState::addInterruptor(Interruptor* interruptor) 1141 void ThreadState::addInterruptor(Interruptor* interruptor)
1096 { 1142 {
1097 checkThread(); 1143 checkThread();
1098 SafePointScope scope(HeapPointersOnStack, SafePointScope::AllowNesting); 1144 SafePointScope scope(HeapPointersOnStack, SafePointScope::AllowNesting);
1099 { 1145 {
1100 MutexLocker locker(threadAttachMutex()); 1146 MutexLocker locker(threadAttachMutex());
1101 m_interruptors.append(interruptor); 1147 m_interruptors.append(interruptor);
1102 } 1148 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 return gcInfo; 1210 return gcInfo;
1165 } 1211 }
1166 } 1212 }
1167 if (needLockForIteration) 1213 if (needLockForIteration)
1168 threadAttachMutex().unlock(); 1214 threadAttachMutex().unlock();
1169 return nullptr; 1215 return nullptr;
1170 } 1216 }
1171 #endif 1217 #endif
1172 1218
1173 } // namespace blink 1219 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/heap/ThreadState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698