Skip to content

Commit

Permalink
Bug 1371435 - Backed out changeset 5b6d169feb92. r=froydnj
Browse files Browse the repository at this point in the history
CRITICAL_SECTIONs have useful debug info that we'd like to keep around at least
on nightly, rather than having diverging signatures on crash stats we'd like to
just keep a unified implementation. As we didn't see significant perf
improvements after landing we're going to just back this out.
  • Loading branch information
EricRahm committed Jun 28, 2017
1 parent 31923a2 commit efbd680
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
8 changes: 4 additions & 4 deletions mozglue/misc/ConditionVariable_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ mozilla::detail::ConditionVariableImpl::notify_all()
void
mozilla::detail::ConditionVariableImpl::wait(MutexImpl& lock)
{
SRWLOCK* srwlock = &lock.platformData()->lock;
bool r = SleepConditionVariableSRW(&platformData()->cv_, srwlock, INFINITE, 0);
CRITICAL_SECTION* cs = &lock.platformData()->criticalSection;
bool r = SleepConditionVariableCS(&platformData()->cv_, cs, INFINITE);
MOZ_RELEASE_ASSERT(r);
}

mozilla::detail::CVStatus
mozilla::detail::ConditionVariableImpl::wait_for(MutexImpl& lock,
const mozilla::TimeDuration& rel_time)
{
SRWLOCK* srwlock = &lock.platformData()->lock;
CRITICAL_SECTION* cs = &lock.platformData()->criticalSection;

// Note that DWORD is unsigned, so we have to be careful to clamp at 0.
// If rel_time is Forever, then ToMilliseconds is +inf, which evaluates as
Expand All @@ -75,7 +75,7 @@ mozilla::detail::ConditionVariableImpl::wait_for(MutexImpl& lock,
? INFINITE
: static_cast<DWORD>(msecd);

BOOL r = SleepConditionVariableSRW(&platformData()->cv_, srwlock, msec, 0);
BOOL r = SleepConditionVariableCS(&platformData()->cv_, cs, msec);
if (r)
return CVStatus::NoTimeout;
MOZ_RELEASE_ASSERT(GetLastError() == ERROR_TIMEOUT);
Expand Down
2 changes: 1 addition & 1 deletion mozglue/misc/MutexPlatformData_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

struct mozilla::detail::MutexImpl::PlatformData
{
SRWLOCK lock;
CRITICAL_SECTION criticalSection;
};

#endif // MutexPlatformData_windows_h
21 changes: 18 additions & 3 deletions mozglue/misc/Mutex_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,38 @@

mozilla::detail::MutexImpl::MutexImpl()
{
InitializeSRWLock(&platformData()->lock);
// This number was adopted from NSPR.
const static DWORD LockSpinCount = 1500;

#if defined(RELEASE_OR_BETA)
// Vista and later automatically allocate and subsequently leak a debug info
// object for each critical section that we allocate unless we tell the
// system not to do that.
DWORD flags = CRITICAL_SECTION_NO_DEBUG_INFO;
#else
DWORD flags = 0;
#endif // defined(RELEASE_OR_BETA)

BOOL r = InitializeCriticalSectionEx(&platformData()->criticalSection,
LockSpinCount, flags);
MOZ_RELEASE_ASSERT(r);
}

mozilla::detail::MutexImpl::~MutexImpl()
{
DeleteCriticalSection(&platformData()->criticalSection);
}

void
mozilla::detail::MutexImpl::lock()
{
AcquireSRWLockExclusive(&platformData()->lock);
EnterCriticalSection(&platformData()->criticalSection);
}

void
mozilla::detail::MutexImpl::unlock()
{
ReleaseSRWLockExclusive(&platformData()->lock);
LeaveCriticalSection(&platformData()->criticalSection);
}

mozilla::detail::MutexImpl::PlatformData*
Expand Down

0 comments on commit efbd680

Please sign in to comment.