haikuwebkit/Source/WTF/wtf/RefCounted.cpp

29 lines
975 B
C++
Raw Permalink Normal View History

Add threading assertions to RefCounted https://bugs.webkit.org/show_bug.cgi?id=200507 Reviewed by Ryosuke Niwa. Source/JavaScriptCore: * dfg/DFGPlan.cpp: (JSC::DFG::Plan::Plan): Disable threading assertions for DFG::Plan::m_inlineCallFrames while the JSC team investigates. Source/WebKit: Enable new RefCounted threading assertions for WebKit2 (UIProcess + auxiliary processes). * Shared/AuxiliaryProcess.cpp: (WebKit::AuxiliaryProcess::initialize): * Shared/Cocoa/WebKit2InitializeCocoa.mm: (WebKit::runInitializationCode): * Shared/WebKit2Initialize.cpp: (WebKit::InitializeWebKit2): Source/WebKitLegacy/mac: * WebView/WebView.mm: (+[WebView initialize]): Enable new RefCounted threading assertions for WebKitLegacy. Source/WTF: Add threading assertions to RefCounted to try and catch unsafe concurrent ref'ing / derefing of RefCounted objects from several threads. If you hit these new assertions, it likely means you either need to: 1. Have your class subclass ThreadSafeRefCounted instead of RefCounted or 2. Make sure your objects always gets ref'd / deref'd from the same thread. These assertions already found several thread safety bugs in our code base, which I fixed via dependency bugs. These assertions are currently enabled in WebKit (UIProcess, child processes and WebKitLegacy), they do not apply other JavascriptCore API clients. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/RefCounted.cpp: Added. * wtf/RefCounted.h: (WTF::RefCountedBase::ref const): (WTF::RefCountedBase::disableThreadingChecks): (WTF::RefCountedBase::enableThreadingChecksGlobally): (WTF::RefCountedBase::RefCountedBase): (WTF::RefCountedBase::areThreadingCheckedEnabled const): (WTF::RefCountedBase::derefBase const): * wtf/SizeLimits.cpp: Canonical link: https://commits.webkit.org/214385@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248533 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-08-12 18:10:26 +00:00
/*
* Copyright (C) 2019 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
#include "config.h"
#include <wtf/RefCounted.h>
namespace WTF {
bool RefCountedBase::areThreadingChecksEnabledGlobally { false };
}