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

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

Issue 367633002: [oilpan]: Don't enter safepoint in SafePointAwareMutexLocker if sweeping. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | « no previous file | no next file » | 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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 // leaveSafePoint method cannot complete without blocking, see 610 // leaveSafePoint method cannot complete without blocking, see
611 // SafePointBarrier::checkAndPark. 611 // SafePointBarrier::checkAndPark.
612 class SafePointAwareMutexLocker { 612 class SafePointAwareMutexLocker {
613 WTF_MAKE_NONCOPYABLE(SafePointAwareMutexLocker); 613 WTF_MAKE_NONCOPYABLE(SafePointAwareMutexLocker);
614 public: 614 public:
615 explicit SafePointAwareMutexLocker(Mutex& mutex) : m_mutex(mutex), m_locked( false) 615 explicit SafePointAwareMutexLocker(Mutex& mutex) : m_mutex(mutex), m_locked( false)
616 { 616 {
617 ThreadState* state = ThreadState::current(); 617 ThreadState* state = ThreadState::current();
618 do { 618 do {
619 bool leaveSafePoint = false; 619 bool leaveSafePoint = false;
620 if (!state->isAtSafePoint()) { 620 // We cannot enter a safepoint if we are currently sweeping. In that
621 // case we just try to acquire the lock without being at a safepoint .
622 // If another thread tries to do a GC at that time it might time out
623 // due to this thread not being at a safepoint and waiting on the lo ck.
haraken 2014/07/01 10:35:10 Would you elaborate on why this doesn't cause dead
624 if (!state->isSweepInProgress() && !state->isAtSafePoint()) {
621 state->enterSafePoint(ThreadState::HeapPointersOnStack, this); 625 state->enterSafePoint(ThreadState::HeapPointersOnStack, this);
622 leaveSafePoint = true; 626 leaveSafePoint = true;
623 } 627 }
624 m_mutex.lock(); 628 m_mutex.lock();
625 m_locked = true; 629 m_locked = true;
626 if (leaveSafePoint) { 630 if (leaveSafePoint) {
627 // When leaving the safepoint we might end up release the mutex 631 // When leaving the safepoint we might end up release the mutex
628 // if another thread is requesting a GC, see 632 // if another thread is requesting a GC, see
629 // SafePointBarrier::checkAndPark. This is the case where we 633 // SafePointBarrier::checkAndPark. This is the case where we
630 // loop around to reacquire the lock. 634 // loop around to reacquire the lock.
(...skipping 18 matching lines...) Expand all
649 m_locked = false; 653 m_locked = false;
650 } 654 }
651 655
652 Mutex& m_mutex; 656 Mutex& m_mutex;
653 bool m_locked; 657 bool m_locked;
654 }; 658 };
655 659
656 } 660 }
657 661
658 #endif // ThreadState_h 662 #endif // ThreadState_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698