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

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

Issue 1149673002: Adding blink gc memory dump infrastructure for thread specific dumps. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebasing for primiano's future changes. Created 5 years, 7 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
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 16 matching lines...) Expand all
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef ThreadState_h 31 #ifndef ThreadState_h
32 #define ThreadState_h 32 #define ThreadState_h
33 33
34 #include "platform/PlatformExport.h" 34 #include "platform/PlatformExport.h"
35 #include "platform/heap/AddressSanitizer.h" 35 #include "platform/heap/AddressSanitizer.h"
36 #include "platform/heap/ThreadingTraits.h" 36 #include "platform/heap/ThreadingTraits.h"
37 #include "public/platform/WebMemoryDumpProvider.h"
37 #include "public/platform/WebThread.h" 38 #include "public/platform/WebThread.h"
38 #include "wtf/Forward.h" 39 #include "wtf/Forward.h"
39 #include "wtf/HashMap.h" 40 #include "wtf/HashMap.h"
40 #include "wtf/HashSet.h" 41 #include "wtf/HashSet.h"
41 #include "wtf/PassOwnPtr.h" 42 #include "wtf/PassOwnPtr.h"
42 #include "wtf/ThreadSpecific.h" 43 #include "wtf/ThreadSpecific.h"
43 #include "wtf/Threading.h" 44 #include "wtf/Threading.h"
44 #include "wtf/ThreadingPrimitives.h" 45 #include "wtf/ThreadingPrimitives.h"
45 #include "wtf/text/WTFString.h" 46 #include "wtf/text/WTFString.h"
46 47
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 const size_t numberOfGenerationsToTrack = 8; 158 const size_t numberOfGenerationsToTrack = 8;
158 const size_t maxHeapObjectAge = numberOfGenerationsToTrack - 1; 159 const size_t maxHeapObjectAge = numberOfGenerationsToTrack - 1;
159 160
160 struct AgeCounts { 161 struct AgeCounts {
161 int ages[numberOfGenerationsToTrack]; 162 int ages[numberOfGenerationsToTrack];
162 AgeCounts() { std::fill(ages, ages + numberOfGenerationsToTrack, 0); } 163 AgeCounts() { std::fill(ages, ages + numberOfGenerationsToTrack, 0); }
163 }; 164 };
164 typedef HashMap<String, AgeCounts> ClassAgeCountsMap; 165 typedef HashMap<String, AgeCounts> ClassAgeCountsMap;
165 #endif 166 #endif
166 167
167 class PLATFORM_EXPORT ThreadState { 168 class PLATFORM_EXPORT ThreadState : public WebMemoryDumpProvider {
Primiano Tucci (use gerrit) 2015/05/21 18:43:10 We discussed this offline (there is a thread in th
ssid 2015/05/22 13:34:07 Done.
168 WTF_MAKE_NONCOPYABLE(ThreadState); 169 WTF_MAKE_NONCOPYABLE(ThreadState);
169 public: 170 public:
170 // When garbage collecting we need to know whether or not there 171 // When garbage collecting we need to know whether or not there
171 // can be pointers to Blink GC managed objects on the stack for 172 // can be pointers to Blink GC managed objects on the stack for
172 // each thread. When threads reach a safe point they record 173 // each thread. When threads reach a safe point they record
173 // whether or not they have pointers on the stack. 174 // whether or not they have pointers on the stack.
174 enum StackState { 175 enum StackState {
175 NoHeapPointersOnStack, 176 NoHeapPointersOnStack,
176 HeapPointersOnStack 177 HeapPointersOnStack
177 }; 178 };
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // Visit local thread stack and trace all pointers conservatively. 451 // Visit local thread stack and trace all pointers conservatively.
451 void visitStack(Visitor*); 452 void visitStack(Visitor*);
452 453
453 // Visit the asan fake stack frame corresponding to a slot on the 454 // Visit the asan fake stack frame corresponding to a slot on the
454 // real machine stack if there is one. 455 // real machine stack if there is one.
455 void visitAsanFakeStackForPointer(Visitor*, Address); 456 void visitAsanFakeStackForPointer(Visitor*, Address);
456 457
457 // Visit all persistents allocated on this thread. 458 // Visit all persistents allocated on this thread.
458 void visitPersistents(Visitor*); 459 void visitPersistents(Visitor*);
459 460
461 // Takes dump of memory statistics when tracing is enabled with memory
462 // category.
463 void dumpMemoryIfNecessary();
Primiano Tucci (use gerrit) 2015/05/21 18:43:10 Had a second thought about this, please don't hate
ssid 2015/05/22 13:34:07 Haha now there is no need to think about it. :) Pe
464
460 #if ENABLE(GC_PROFILING) 465 #if ENABLE(GC_PROFILING)
461 const GCInfo* findGCInfo(Address); 466 const GCInfo* findGCInfo(Address);
462 static const GCInfo* findGCInfoFromAllThreads(Address); 467 static const GCInfo* findGCInfoFromAllThreads(Address);
463 468
464 struct SnapshotInfo { 469 struct SnapshotInfo {
465 ThreadState* state; 470 ThreadState* state;
466 471
467 size_t freeSize; 472 size_t freeSize;
468 size_t pageCount; 473 size_t pageCount;
469 474
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 return m_heaps[heapIndex]; 607 return m_heaps[heapIndex];
603 } 608 }
604 BaseHeap* expandedVectorBackingHeap(size_t gcInfoIndex); 609 BaseHeap* expandedVectorBackingHeap(size_t gcInfoIndex);
605 static bool isVectorHeapIndex(int heapIndex) 610 static bool isVectorHeapIndex(int heapIndex)
606 { 611 {
607 return Vector1HeapIndex <= heapIndex && heapIndex <= Vector4HeapIndex; 612 return Vector1HeapIndex <= heapIndex && heapIndex <= Vector4HeapIndex;
608 } 613 }
609 void allocationPointAdjusted(int heapIndex); 614 void allocationPointAdjusted(int heapIndex);
610 void promptlyFreed(size_t gcInfoIndex); 615 void promptlyFreed(size_t gcInfoIndex);
611 616
617 // WebMemoryDumpProvider implementation.
618 bool onMemoryDump(WebProcessMemoryDump*) override;
Primiano Tucci (use gerrit) 2015/05/21 18:43:10 This should go away from here, as per discussion u
ssid 2015/05/22 13:34:07 Done.
619
612 private: 620 private:
613 ThreadState(); 621 ThreadState();
614 ~ThreadState(); 622 ~ThreadState();
615 623
616 void enterSafePoint(StackState, void*); 624 void enterSafePoint(StackState, void*);
617 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); 625 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope();
618 void clearSafePointScopeMarker() 626 void clearSafePointScopeMarker()
619 { 627 {
620 m_safePointStackCopy.clear(); 628 m_safePointStackCopy.clear();
621 m_safePointScopeMarker = nullptr; 629 m_safePointScopeMarker = nullptr;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 707
700 v8::Isolate* m_isolate; 708 v8::Isolate* m_isolate;
701 void (*m_traceDOMWrappers)(v8::Isolate*, Visitor*); 709 void (*m_traceDOMWrappers)(v8::Isolate*, Visitor*);
702 710
703 #if defined(ADDRESS_SANITIZER) 711 #if defined(ADDRESS_SANITIZER)
704 void* m_asanFakeStack; 712 void* m_asanFakeStack;
705 #endif 713 #endif
706 714
707 Vector<PageMemoryRegion*> m_allocatedRegionsSinceLastGC; 715 Vector<PageMemoryRegion*> m_allocatedRegionsSinceLastGC;
708 716
717 OwnPtr<WebProcessMemoryDump> m_lastProcessMemoryDump;
Primiano Tucci (use gerrit) 2015/05/21 18:43:10 And this should be just one, shared by all the Thr
ssid 2015/05/22 13:34:07 Done.
718
709 #if ENABLE(GC_PROFILING) 719 #if ENABLE(GC_PROFILING)
710 double m_nextFreeListSnapshotTime; 720 double m_nextFreeListSnapshotTime;
711 #endif 721 #endif
712 // Ideally we want to allocate an array of size |gcInfoTableMax| but it will 722 // Ideally we want to allocate an array of size |gcInfoTableMax| but it will
713 // waste memory. Thus we limit the array size to 2^8 and share one entry 723 // waste memory. Thus we limit the array size to 2^8 and share one entry
714 // with multiple types of vectors. This won't be an issue in practice, 724 // with multiple types of vectors. This won't be an issue in practice,
715 // since there will be less than 2^8 types of objects in common cases. 725 // since there will be less than 2^8 types of objects in common cases.
716 static const int likelyToBePromptlyFreedArraySize = (1 << 8); 726 static const int likelyToBePromptlyFreedArraySize = (1 << 8);
717 static const int likelyToBePromptlyFreedArrayMask = likelyToBePromptlyFreedA rraySize - 1; 727 static const int likelyToBePromptlyFreedArrayMask = likelyToBePromptlyFreedA rraySize - 1;
718 OwnPtr<int[]> m_likelyToBePromptlyFreed; 728 OwnPtr<int[]> m_likelyToBePromptlyFreed;
(...skipping 12 matching lines...) Expand all
731 }; 741 };
732 742
733 template<> class ThreadStateFor<AnyThread> { 743 template<> class ThreadStateFor<AnyThread> {
734 public: 744 public:
735 static ThreadState* state() { return ThreadState::current(); } 745 static ThreadState* state() { return ThreadState::current(); }
736 }; 746 };
737 747
738 } // namespace blink 748 } // namespace blink
739 749
740 #endif // ThreadState_h 750 #endif // ThreadState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698