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

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

Issue 946163003: Prevent GCs when constructing GC mixin objects. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add assert Created 5 years, 10 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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 void cleanup(); 631 void cleanup();
632 void cleanupPages(); 632 void cleanupPages();
633 633
634 void unregisterPreFinalizerInternal(void*); 634 void unregisterPreFinalizerInternal(void*);
635 void invokePreFinalizers(Visitor&); 635 void invokePreFinalizers(Visitor&);
636 636
637 #if ENABLE(GC_PROFILING) 637 #if ENABLE(GC_PROFILING)
638 void snapshotFreeList(); 638 void snapshotFreeList();
639 #endif 639 #endif
640 640
641 // By entering a no-gc allowed scope, conservative GCs will not
642 // be forced while handling an out-of-line allocation request.
643 // Intended used when constructing subclasses of GC mixins, where
644 // the object being constructed cannot be safely traced & marked
645 // fully should a GC be allowed.
646 template<typename U, typename V> friend class AllocateObjectTrait;
647 void enterNoGCAllowedScope() { m_noGCAllowedCount++; }
haraken 2015/02/23 08:24:23 enterGCForbiddenScope ? (for consistency with Swee
sof 2015/02/23 10:29:02 Switched naming to align with that.
648 void leaveNoGCAllowedScope()
649 {
650 ASSERT(m_noGCAllowedCount > 0);
651 m_noGCAllowedCount--;
652 }
653
641 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific; 654 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific;
642 static uintptr_t s_mainThreadStackStart; 655 static uintptr_t s_mainThreadStackStart;
643 static uintptr_t s_mainThreadUnderestimatedStackSize; 656 static uintptr_t s_mainThreadUnderestimatedStackSize;
644 static SafePointBarrier* s_safePointBarrier; 657 static SafePointBarrier* s_safePointBarrier;
645 658
646 // We can't create a static member of type ThreadState here 659 // We can't create a static member of type ThreadState here
647 // because it will introduce global constructor and destructor. 660 // because it will introduce global constructor and destructor.
648 // We would like to manage lifetime of the ThreadState attached 661 // We would like to manage lifetime of the ThreadState attached
649 // to the main thread explicitly instead and still use normal 662 // to the main thread explicitly instead and still use normal
650 // constructor and destructor for the ThreadState class. 663 // constructor and destructor for the ThreadState class.
651 // For this we reserve static storage for the main ThreadState 664 // For this we reserve static storage for the main ThreadState
652 // and lazily construct ThreadState in it using placement new. 665 // and lazily construct ThreadState in it using placement new.
653 static uint8_t s_mainThreadStateStorage[]; 666 static uint8_t s_mainThreadStateStorage[];
654 667
655 ThreadIdentifier m_thread; 668 ThreadIdentifier m_thread;
656 OwnPtr<PersistentNode> m_persistents; 669 OwnPtr<PersistentNode> m_persistents;
657 StackState m_stackState; 670 StackState m_stackState;
658 intptr_t* m_startOfStack; 671 intptr_t* m_startOfStack;
659 intptr_t* m_endOfStack; 672 intptr_t* m_endOfStack;
660 void* m_safePointScopeMarker; 673 void* m_safePointScopeMarker;
661 Vector<Address> m_safePointStackCopy; 674 Vector<Address> m_safePointStackCopy;
662 bool m_atSafePoint; 675 bool m_atSafePoint;
663 Vector<Interruptor*> m_interruptors; 676 Vector<Interruptor*> m_interruptors;
664 bool m_hasPendingIdleTask; 677 bool m_hasPendingIdleTask;
665 bool m_didV8GCAfterLastGC; 678 bool m_didV8GCAfterLastGC;
666 bool m_sweepForbidden; 679 bool m_sweepForbidden;
667 size_t m_noAllocationCount; 680 size_t m_noAllocationCount;
681 size_t m_noGCAllowedCount;
668 size_t m_allocatedObjectSizeBeforeGC; 682 size_t m_allocatedObjectSizeBeforeGC;
669 BaseHeap* m_heaps[NumberOfHeaps]; 683 BaseHeap* m_heaps[NumberOfHeaps];
670 684
671 Vector<OwnPtr<CleanupTask>> m_cleanupTasks; 685 Vector<OwnPtr<CleanupTask>> m_cleanupTasks;
672 bool m_isTerminating; 686 bool m_isTerminating;
673 687
674 bool m_shouldFlushHeapDoesNotContainCache; 688 bool m_shouldFlushHeapDoesNotContainCache;
675 double m_collectionRate; 689 double m_collectionRate;
676 GCState m_gcState; 690 GCState m_gcState;
677 691
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 m_locked = false; 774 m_locked = false;
761 } 775 }
762 776
763 MutexBase& m_mutex; 777 MutexBase& m_mutex;
764 bool m_locked; 778 bool m_locked;
765 }; 779 };
766 780
767 } // namespace blink 781 } // namespace blink
768 782
769 #endif // ThreadState_h 783 #endif // ThreadState_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698