[webkit-reviews] review granted: [Bug 31639] Add asserts to RefCounted to make sure ref/deref happens on the right thread. : [Attachment 91374] Patch
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Thu Apr 28 12:43:29 PDT 2011
Darin Adler <darin at apple.com> has granted David Levin <levin at chromium.org>'s
request for review:
Bug 31639: Add asserts to RefCounted to make sure ref/deref happens on the
right thread.
https://bugs.webkit.org/show_bug.cgi?id=31639
Attachment 91374: Patch
https://bugs.webkit.org/attachment.cgi?id=91374&action=review
------- Additional Comments from Darin Adler <darin at apple.com>
View in context: https://bugs.webkit.org/attachment.cgi?id=91374&action=review
> Source/JavaScriptCore/wtf/RefCounted.h:77
> + UNUSED_PARAM(&mutex);
> +#ifndef NDEBUG
> + m_verifier.setMutexMode(mutex);
> +#endif
We should only use UNUSED_PARAM when it’s actually unused. So it should be in
an #else. But, better, I suggest writing it like this:
void setMutexForVerifier(Mutex&);
...
#ifdef NDEBUG
inline void RefCountedBase::setMutexForVerifier(Mutex&)
{
}
#else
inline void RefCountedBase::setMutexForVerifier(Mutex& mutex)
{
m_verifier.setMutexMode(mutex);
}
#endif
Or like this:
#ifdef NDEBUG
void setMutexForVerifier(Mutex&) { }
#else
void setMutexForVerifier(Mutex& mutex)
{
m_verifier.setMutexMode(mutex);
}
#endif
> Source/JavaScriptCore/wtf/ThreadRestrictionVerifier.h:95
> + // Is it ok to use the object at this moment on the current thread?
Normally "ok" is spelled "OK".
> Source/JavaScriptCore/wtf/ThreadRestrictionVerifier.h:104
> + // isMainThread() is way faster than currentThread() on many
platforms, so use it first.
> + return (m_isOwnedByMainThread && isMainThread()) ||
(m_owningThread == currentThread());
If m_isOwnedByMainThread is false, then m_owningThread is not something we
should look at; sure, it’s initialized to 0, but I’m not sure that’s even
meaningful. So I suggest writing:
return m_isOwnedByMainThread ? isMainThread() : (m_owningThread ==
currentThread());
Or factoring the code some other way, but doing that same effective check. I
don’t think it’s good to look at m_owningThread at all if it wasn’t set to a
thread.
More information about the webkit-reviews
mailing list