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

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

Issue 371623002: [oilpan]: Make thread shutdown more robust. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review feedback Created 6 years, 5 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
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
43 43
44 namespace WebCore { 44 namespace WebCore {
45 45
46 class BaseHeap; 46 class BaseHeap;
47 class BaseHeapPage; 47 class BaseHeapPage;
48 class FinalizedHeapObjectHeader; 48 class FinalizedHeapObjectHeader;
49 struct GCInfo; 49 struct GCInfo;
50 class HeapContainsCache; 50 class HeapContainsCache;
51 class HeapObjectHeader; 51 class HeapObjectHeader;
52 class PageMemory;
52 class PersistentNode; 53 class PersistentNode;
53 class Visitor; 54 class Visitor;
54 class SafePointBarrier; 55 class SafePointBarrier;
55 class SafePointAwareMutexLocker; 56 class SafePointAwareMutexLocker;
56 template<typename Header> class ThreadHeap; 57 template<typename Header> class ThreadHeap;
57 class CallbackStack; 58 class CallbackStack;
58 59
59 typedef uint8_t* Address; 60 typedef uint8_t* Address;
60 61
61 typedef void (*FinalizationCallback)(void*); 62 typedef void (*FinalizationCallback)(void*);
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 static const GCInfo* findGCInfoFromAllThreads(Address); 501 static const GCInfo* findGCInfoFromAllThreads(Address);
501 #endif 502 #endif
502 503
503 void pushWeakObjectPointerCallback(void*, WeakPointerCallback); 504 void pushWeakObjectPointerCallback(void*, WeakPointerCallback);
504 bool popAndInvokeWeakPointerCallback(Visitor*); 505 bool popAndInvokeWeakPointerCallback(Visitor*);
505 506
506 void getStats(HeapStats&); 507 void getStats(HeapStats&);
507 HeapStats& stats() { return m_stats; } 508 HeapStats& stats() { return m_stats; }
508 HeapStats& statsAfterLastGC() { return m_statsAfterLastGC; } 509 HeapStats& statsAfterLastGC() { return m_statsAfterLastGC; }
509 510
511 void setupHeapsForShutdown();
512 void visitLocalRoots(Visitor*);
513
510 private: 514 private:
511 explicit ThreadState(); 515 explicit ThreadState();
512 ~ThreadState(); 516 ~ThreadState();
513 517
514 friend class SafePointBarrier; 518 friend class SafePointBarrier;
515 friend class SafePointAwareMutexLocker; 519 friend class SafePointAwareMutexLocker;
516 520
517 void enterSafePoint(StackState, void*); 521 void enterSafePoint(StackState, void*);
518 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope(); 522 NO_SANITIZE_ADDRESS void copyStackUntilSafePointScope();
519 void clearSafePointScopeMarker() 523 void clearSafePointScopeMarker()
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 { 654 {
651 ASSERT(m_locked); 655 ASSERT(m_locked);
652 m_mutex.unlock(); 656 m_mutex.unlock();
653 m_locked = false; 657 m_locked = false;
654 } 658 }
655 659
656 Mutex& m_mutex; 660 Mutex& m_mutex;
657 bool m_locked; 661 bool m_locked;
658 }; 662 };
659 663
664 // Common header for heap pages. Needs to be defined before class Visitor.
Mads Ager (chromium) 2014/07/08 08:24:56 Our file setup is becoming really messy. :-\ This
wibling-chromium 2014/07/08 13:39:48 Agree. I was more thinking about going in the oppo
665 class BaseHeapPage {
666 public:
667 BaseHeapPage(PageMemory*, const GCInfo*, ThreadState*);
668 virtual ~BaseHeapPage() { }
669
670 // Check if the given address points to an object in this
671 // heap page. If so, find the start of that object and mark it
672 // using the given Visitor. Otherwise do nothing. The pointer must
673 // be within the same aligned blinkPageSize as the this-pointer.
674 //
675 // This is used during conservative stack scanning to
676 // conservatively mark all objects that could be referenced from
677 // the stack.
678 virtual void checkAndMarkPointer(Visitor*, Address) = 0;
679 virtual bool contains(Address) = 0;
680
681 #if ENABLE(GC_TRACING)
682 virtual const GCInfo* findGCInfo(Address) = 0;
683 #endif
684
685 Address address() { return reinterpret_cast<Address>(this); }
686 PageMemory* storage() const { return m_storage; }
687 ThreadState* threadState() const { return m_threadState; }
688 const GCInfo* gcInfo() { return m_gcInfo; }
689 virtual bool isLargeObject() { return false; }
690 virtual void markOrphaned()
691 {
692 m_threadState = 0;
693 m_shuttingDown = false;
694 m_traced = false;
695 }
696 bool orphaned() { return !m_threadState; }
697 bool shuttingDown() { return m_shuttingDown; }
698 void setShutdown() { m_shuttingDown = true; }
699 bool traced() { return m_traced; }
700 void setTraced() { m_traced = true; }
701 bool reuseMemory() { return m_reuseMemory; }
702 void clearReuseMemory() { m_reuseMemory = false; }
703 void setReuseMemory() { m_reuseMemory = true; }
haraken 2014/07/08 05:44:51 Instead of introducing clearReuseMemory and setReu
Mads Ager (chromium) 2014/07/08 08:24:56 We already have this information. We have the virt
wibling-chromium 2014/07/08 13:39:48 Done.
wibling-chromium 2014/07/08 13:39:48 I got rid of this and used isLargeObject as sugges
704
705 private:
706 // Accessor to silence unused warnings for the m_padding field.
707 intptr_t padding() const { return m_padding; }
708
709 PageMemory* m_storage;
710 const GCInfo* m_gcInfo;
711 ThreadState* m_threadState;
712 bool m_shuttingDown;
713 bool m_traced;
714 bool m_reuseMemory;
Mads Ager (chromium) 2014/07/08 08:24:56 Are you sure we are maintaining correct alignment
wibling-chromium 2014/07/08 13:39:48 No, I will spend some time to make sure it is okay
715 // Pointer sized integer to ensure proper alignment of the
716 // HeapPage header. This can be used as a bit field if we need
717 // to associate more information with pages.
718 intptr_t m_padding;
719 };
720
660 } 721 }
661 722
662 #endif // ThreadState_h 723 #endif // ThreadState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698