0c6e01dc9d
https://bugs.webkit.org/show_bug.cgi?id=221614 <rdar://problem/74396781> Patch by Kimmo Kinnunen <kkinnunen@apple.com> on 2021-04-19 Reviewed by David Kilzer. PerformanceTests: Add -Wthread-safety to compile flags. * DecoderTest/Configurations/Base.xcconfig: Source/bmalloc: Add -Wthread-safety to compile flags. * Configurations/Base.xcconfig: Source/JavaScriptCore: Add -Wthread-safety to compile flags. * Configurations/Base.xcconfig: Source/WebCore: Add -Wthread-safety to compile flags. * Configurations/Base.xcconfig: Source/WebCore/PAL: Add -Wthread-safety to compile flags. * Configurations/Base.xcconfig: Source/WebInspectorUI: Add -Wthread-safety to compile flags. * Configurations/Base.xcconfig: Source/WebKit: Add -Wthread-safety to compile flags. * Configurations/Base.xcconfig: Source/WebKitLegacy/mac: Add -Wthread-safety to compile flags. * Configurations/Base.xcconfig: Source/WTF: Implement rudimentary support for clang thread safety analysis. The added macros can be used to declare which member variables or global variables are locked by which mutexes. The compiler will check statically that the mutexes are held correctly. The checking is intra procedural, not global. * Configurations/Base.xcconfig: Add -Wthread-safety to compile flags. * wtf/CheckedLock.h: Added. Add CheckedLock, a Lock variant that is amenable to static analysis. Add a Locker specialization for CheckedLock that is amenable to static analysis. Locker<CheckedLock> is a std::scoped_lock. The scoped_lock cannot be aliased, since it appears that (Apple's) libcxx is not compiled with thread safety analysis support enabled by default. New types are needed due Locker move constructor and conditional locking. The Locker has default usage pattern of: auto locker = holdLock(m_lock); This forces dynamism that removes the possibility of simple statical analysis that thread safety analysis capabilities "mutex" and "scoped_lock" currently implement. Most likely large fraction of call sites is due to historical lack of CTAD and as such can be converted to less general form. Once the pattern is not used by default, CheckedLock can be deleted and the move dynamism bits of Locker can be moved to some more specific type ("UncheckedLocker"). * wtf/ThreadSafetyAnalysis.h: Added. Add macro wrappers around clang "mutex" and "scoped_lock" capability attributes. Tools: * TestWebKitAPI/Configurations/Base.xcconfig: Add -Wthread-safety to compile flags. * TestWebKitAPI/CMakeLists.txt: * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/WTF/CheckedLock.cpp: Added. (TestWebKitAPI::TEST): Implement a test for testing that CheckedLock compiles. Canonical link: https://commits.webkit.org/236729@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@276247 268f45cc-cd09-0410-ab3c-d52691b4dbfc |
||
---|---|---|
.. | ||
Base.xcconfig | ||
CopyWTFHeaders.xcconfig | ||
DebugRelease.xcconfig | ||
SDKVariant.xcconfig | ||
WTF.xcconfig |