Add asserts to RefCounted to make sure ref/deref happens on the right thread.
https://bugs.webkit.org/show_bug.cgi?id=31639
Reviewed by Darin Adler.
JavaScriptCore:
(JSC::Structure::Structure): Disable thread verification on this class since it uses addressOfCount().
(WTF::RefCountedBase::ref): Add ASSERT.
(WTF::RefCountedBase::hasOneRef): Ditto.
(WTF::RefCountedBase::refCount): Ditto.
(WTF::RefCountedBase::derefBase): Ditto.
(WTF::RefCountedBase::disableThreadVerification): delegate to ThreadVerifier method.
- wtf/ThreadVerifier.h: Added.
(WTF::ThreadVerifier::ThreadVerifier): New Debug-only class to verify that ref/deref of RefCounted is done on the same thread.
(WTF::ThreadVerifier::activate): Activates checks. Called when ref count becomes above 2.
(WTF::ThreadVerifier::deactivate): Deactivates checks. Called when ref count drops below 2.
(WTF::ThreadVerifier::disableThreadVerification): used on objects that should not be checked (StringImpl etc)
(WTF::ThreadVerifier::verifyThread):
JavaScriptGlue:
- ForwardingHeaders/wtf/ThreadVerifier.h: Added.
WebCore:
- loader/icon/IconRecord.cpp:
(WebCore::IconRecord::IconRecord): Disable thread verification for this class because of its cross-thread use in IconDatabase.
- platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::SharedBuffer): Ditto.
- platform/text/StringImpl.cpp:
(WebCore::StringImpl::StringImpl): Disable thread verification for this class, add FIXME to enforce proper usage via crossThreadString.
- ForwardingHeaders/wtf/ThreadVerifier.h: Added.
WebKit/mac:
- ForwardingHeaders/wtf/ThreadVerifier.h: Added.
WebKitTools:
- DumpRenderTree/ForwardingHeaders/wtf/ThreadVerifier.h: Added.