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

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: Improve naming + optimize allocateOnHeapIndex() usage 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
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.cpp » ('j') | 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 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 gc-forbidden scope, conservative GCs will not
642 // be allowed 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 while its subclasses are being
646 // constructed.
647 template<typename U, typename V> friend class AllocateObjectTrait;
648 void enterGCForbiddenScope() { m_gcForbiddenCount++; }
649 void leaveGCForbiddenScope()
650 {
651 ASSERT(m_gcForbiddenCount > 0);
652 m_gcForbiddenCount--;
653 }
654
641 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific; 655 static WTF::ThreadSpecific<ThreadState*>* s_threadSpecific;
642 static uintptr_t s_mainThreadStackStart; 656 static uintptr_t s_mainThreadStackStart;
643 static uintptr_t s_mainThreadUnderestimatedStackSize; 657 static uintptr_t s_mainThreadUnderestimatedStackSize;
644 static SafePointBarrier* s_safePointBarrier; 658 static SafePointBarrier* s_safePointBarrier;
645 659
646 // We can't create a static member of type ThreadState here 660 // We can't create a static member of type ThreadState here
647 // because it will introduce global constructor and destructor. 661 // because it will introduce global constructor and destructor.
648 // We would like to manage lifetime of the ThreadState attached 662 // We would like to manage lifetime of the ThreadState attached
649 // to the main thread explicitly instead and still use normal 663 // to the main thread explicitly instead and still use normal
650 // constructor and destructor for the ThreadState class. 664 // constructor and destructor for the ThreadState class.
651 // For this we reserve static storage for the main ThreadState 665 // For this we reserve static storage for the main ThreadState
652 // and lazily construct ThreadState in it using placement new. 666 // and lazily construct ThreadState in it using placement new.
653 static uint8_t s_mainThreadStateStorage[]; 667 static uint8_t s_mainThreadStateStorage[];
654 668
655 ThreadIdentifier m_thread; 669 ThreadIdentifier m_thread;
656 OwnPtr<PersistentNode> m_persistents; 670 OwnPtr<PersistentNode> m_persistents;
657 StackState m_stackState; 671 StackState m_stackState;
658 intptr_t* m_startOfStack; 672 intptr_t* m_startOfStack;
659 intptr_t* m_endOfStack; 673 intptr_t* m_endOfStack;
660 void* m_safePointScopeMarker; 674 void* m_safePointScopeMarker;
661 Vector<Address> m_safePointStackCopy; 675 Vector<Address> m_safePointStackCopy;
662 bool m_atSafePoint; 676 bool m_atSafePoint;
663 Vector<Interruptor*> m_interruptors; 677 Vector<Interruptor*> m_interruptors;
664 bool m_hasPendingIdleTask; 678 bool m_hasPendingIdleTask;
665 bool m_didV8GCAfterLastGC; 679 bool m_didV8GCAfterLastGC;
666 bool m_sweepForbidden; 680 bool m_sweepForbidden;
667 size_t m_noAllocationCount; 681 size_t m_noAllocationCount;
682 size_t m_gcForbiddenCount;
668 size_t m_allocatedObjectSizeBeforeGC; 683 size_t m_allocatedObjectSizeBeforeGC;
669 BaseHeap* m_heaps[NumberOfHeaps]; 684 BaseHeap* m_heaps[NumberOfHeaps];
670 685
671 Vector<OwnPtr<CleanupTask>> m_cleanupTasks; 686 Vector<OwnPtr<CleanupTask>> m_cleanupTasks;
672 bool m_isTerminating; 687 bool m_isTerminating;
673 688
674 bool m_shouldFlushHeapDoesNotContainCache; 689 bool m_shouldFlushHeapDoesNotContainCache;
675 double m_collectionRate; 690 double m_collectionRate;
676 GCState m_gcState; 691 GCState m_gcState;
677 692
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 m_locked = false; 775 m_locked = false;
761 } 776 }
762 777
763 MutexBase& m_mutex; 778 MutexBase& m_mutex;
764 bool m_locked; 779 bool m_locked;
765 }; 780 };
766 781
767 } // namespace blink 782 } // namespace blink
768 783
769 #endif // ThreadState_h 784 #endif // ThreadState_h
OLDNEW
« no previous file with comments | « Source/platform/heap/Heap.h ('k') | Source/platform/heap/ThreadState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698