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

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

Issue 415083002: [oilpan]: fix deadlock when leaving a safepoint and sweeping. (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
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | Source/wtf/ThreadingPrimitives.h » ('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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 }; 611 };
612 612
613 // The SafePointAwareMutexLocker is used to enter a safepoint while waiting for 613 // The SafePointAwareMutexLocker is used to enter a safepoint while waiting for
614 // a mutex lock. It also ensures that the lock is not held while waiting for a G C 614 // a mutex lock. It also ensures that the lock is not held while waiting for a G C
615 // to complete in the leaveSafePoint method, by releasing the lock if the 615 // to complete in the leaveSafePoint method, by releasing the lock if the
616 // leaveSafePoint method cannot complete without blocking, see 616 // leaveSafePoint method cannot complete without blocking, see
617 // SafePointBarrier::checkAndPark. 617 // SafePointBarrier::checkAndPark.
618 class SafePointAwareMutexLocker { 618 class SafePointAwareMutexLocker {
619 WTF_MAKE_NONCOPYABLE(SafePointAwareMutexLocker); 619 WTF_MAKE_NONCOPYABLE(SafePointAwareMutexLocker);
620 public: 620 public:
621 explicit SafePointAwareMutexLocker(Mutex& mutex, ThreadState::StackState sta ckState = ThreadState::HeapPointersOnStack) 621 explicit SafePointAwareMutexLocker(MutexBase& mutex, ThreadState::StackState stackState = ThreadState::HeapPointersOnStack)
622 : m_mutex(mutex) 622 : m_mutex(mutex)
623 , m_locked(false) 623 , m_locked(false)
624 { 624 {
625 ThreadState* state = ThreadState::current(); 625 ThreadState* state = ThreadState::current();
626 do { 626 do {
627 bool leaveSafePoint = false; 627 bool leaveSafePoint = false;
628 // We cannot enter a safepoint if we are currently sweeping. In that 628 // We cannot enter a safepoint if we are currently sweeping. In that
629 // case we just try to acquire the lock without being at a safepoint . 629 // case we just try to acquire the lock without being at a safepoint .
630 // If another thread tries to do a GC at that time it might time out 630 // If another thread tries to do a GC at that time it might time out
631 // due to this thread not being at a safepoint and waiting on the lo ck. 631 // due to this thread not being at a safepoint and waiting on the lo ck.
(...skipping 22 matching lines...) Expand all
654 private: 654 private:
655 friend class SafePointBarrier; 655 friend class SafePointBarrier;
656 656
657 void reset() 657 void reset()
658 { 658 {
659 ASSERT(m_locked); 659 ASSERT(m_locked);
660 m_mutex.unlock(); 660 m_mutex.unlock();
661 m_locked = false; 661 m_locked = false;
662 } 662 }
663 663
664 Mutex& m_mutex; 664 MutexBase& m_mutex;
665 bool m_locked; 665 bool m_locked;
666 }; 666 };
667 667
668 // Common header for heap pages. Needs to be defined before class Visitor. 668 // Common header for heap pages. Needs to be defined before class Visitor.
669 class BaseHeapPage { 669 class BaseHeapPage {
670 public: 670 public:
671 BaseHeapPage(PageMemory*, const GCInfo*, ThreadState*); 671 BaseHeapPage(PageMemory*, const GCInfo*, ThreadState*);
672 virtual ~BaseHeapPage() { } 672 virtual ~BaseHeapPage() { }
673 673
674 // Check if the given address points to an object in this 674 // Check if the given address points to an object in this
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // HeapPage header. We use some of the bits to determine 712 // HeapPage header. We use some of the bits to determine
713 // whether the page is part of a terminting thread or 713 // whether the page is part of a terminting thread or
714 // if the page is traced after being terminated (orphaned). 714 // if the page is traced after being terminated (orphaned).
715 uintptr_t m_terminating : 1; 715 uintptr_t m_terminating : 1;
716 uintptr_t m_tracedAfterOrphaned : 1; 716 uintptr_t m_tracedAfterOrphaned : 1;
717 }; 717 };
718 718
719 } 719 }
720 720
721 #endif // ThreadState_h 721 #endif // ThreadState_h
OLDNEW
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | Source/wtf/ThreadingPrimitives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698