Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (278068 => 278069)
--- trunk/Source/_javascript_Core/ChangeLog 2021-05-26 00:29:02 UTC (rev 278068)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-05-26 00:37:19 UTC (rev 278069)
@@ -1,3 +1,23 @@
+2021-05-25 Chris Dumez <cdu...@apple.com>
+
+ Use UncheckedLock less in _javascript_Core
+ https://bugs.webkit.org/show_bug.cgi?id=226212
+
+ Reviewed by Saam Barati.
+
+ Use UncheckedLock less in _javascript_Core as it is being phased out in favor of Lock, which
+ enables Clang thread safety analysis.
+
+ * assembler/testmasm.cpp:
+ * dfg/DFGCommon.cpp:
+ * dynbench.cpp:
+ * heap/Heap.cpp:
+ * heap/Heap.h:
+ * inspector/remote/socket/RemoteInspectorSocketEndpoint.h:
+ * runtime/JSLock.cpp:
+ * runtime/JSLock.h:
+ * runtime/VM.h:
+
2021-05-25 Devin Rousso <drou...@apple.com>
[Modern Media Controls] REGRESSION(r254389) media controls needs the full list of language preferences for ordering tracks
Modified: trunk/Source/_javascript_Core/assembler/testmasm.cpp (278068 => 278069)
--- trunk/Source/_javascript_Core/assembler/testmasm.cpp 2021-05-26 00:29:02 UTC (rev 278068)
+++ trunk/Source/_javascript_Core/assembler/testmasm.cpp 2021-05-26 00:37:19 UTC (rev 278069)
@@ -153,7 +153,7 @@
using CPUState = Probe::CPUState;
-UncheckedLock crashLock;
+Lock crashLock;
typedef WTF::Function<void(CCallHelpers&)> Generator;
@@ -2568,7 +2568,8 @@
})); \
} while (false);
-void run(const char* filter)
+// Using WTF_IGNORES_THREAD_SAFETY_ANALYSIS because the function is still holding crashLock when exiting.
+void run(const char* filter) WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
JSC::initialize();
unsigned numberOfTests = 0;
Modified: trunk/Source/_javascript_Core/dfg/DFGCommon.cpp (278068 => 278069)
--- trunk/Source/_javascript_Core/dfg/DFGCommon.cpp 2021-05-26 00:29:02 UTC (rev 278068)
+++ trunk/Source/_javascript_Core/dfg/DFGCommon.cpp 2021-05-26 00:37:19 UTC (rev 278069)
@@ -35,9 +35,10 @@
const char* const tierName = "DFG ";
-static UncheckedLock crashLock;
+static Lock crashLock;
-void startCrashing()
+// Use WTF_IGNORES_THREAD_SAFETY_ANALYSIS since the function keeps holding the lock when returning.
+void startCrashing() WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
crashLock.lock();
}
Modified: trunk/Source/_javascript_Core/dynbench.cpp (278068 => 278069)
--- trunk/Source/_javascript_Core/dynbench.cpp 2021-05-26 00:29:02 UTC (rev 278068)
+++ trunk/Source/_javascript_Core/dynbench.cpp 2021-05-26 00:37:19 UTC (rev 278069)
@@ -40,7 +40,7 @@
namespace {
-UncheckedLock crashLock;
+Lock crashLock;
const char* nameFilter;
unsigned requestedIterationCount;
@@ -69,7 +69,8 @@
} // anonymous namespace
-int main(int argc, char** argv)
+// Use WTF_IGNORES_THREAD_SAFETY_ANALYSIS because the function keeps holding crashLock when returning.
+int main(int argc, char** argv) WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
if (argc >= 2) {
if (argv[1][0] == '-') {
Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (278068 => 278069)
--- trunk/Source/_javascript_Core/heap/Heap.cpp 2021-05-26 00:29:02 UTC (rev 278068)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp 2021-05-26 00:37:19 UTC (rev 278069)
@@ -2996,7 +2996,9 @@
dataLogIf(Options::logGC(), (MonotonicTime::now() - before).milliseconds(), "ms]\n");
}
-void Heap::preventCollection()
+// Use WTF_IGNORES_THREAD_SAFETY_ANALYSIS because this function conditionally locks m_collectContinuouslyLock,
+// which is not supported by analysis.
+void Heap::preventCollection() WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
if (!m_isSafeToCollect)
return;
@@ -3015,7 +3017,9 @@
RELEASE_ASSERT(!m_collectionScope);
}
-void Heap::allowCollection()
+// Use WTF_IGNORES_THREAD_SAFETY_ANALYSIS because this function conditionally unlocks m_collectContinuouslyLock,
+// which is not supported by analysis.
+void Heap::allowCollection() WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
if (!m_isSafeToCollect)
return;
Modified: trunk/Source/_javascript_Core/heap/Heap.h (278068 => 278069)
--- trunk/Source/_javascript_Core/heap/Heap.h 2021-05-26 00:29:02 UTC (rev 278068)
+++ trunk/Source/_javascript_Core/heap/Heap.h 2021-05-26 00:37:19 UTC (rev 278069)
@@ -768,8 +768,8 @@
#endif
bool m_parallelMarkersShouldExit { false };
- UncheckedLock m_collectContinuouslyLock;
- UncheckedCondition m_collectContinuouslyCondition;
+ Lock m_collectContinuouslyLock;
+ Condition m_collectContinuouslyCondition;
};
} // namespace JSC
Modified: trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorSocketEndpoint.h (278068 => 278069)
--- trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorSocketEndpoint.h 2021-05-26 00:29:02 UTC (rev 278068)
+++ trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorSocketEndpoint.h 2021-05-26 00:37:19 UTC (rev 278069)
@@ -182,9 +182,9 @@
bool isListening(ConnectionID);
int pollingTimeout();
- mutable UncheckedLock m_connectionsLock;
- HashMap<ConnectionID, std::unique_ptr<ClientConnection>> m_clients;
- HashMap<ConnectionID, std::unique_ptr<ListenerConnection>> m_listeners;
+ mutable Lock m_connectionsLock;
+ HashMap<ConnectionID, std::unique_ptr<ClientConnection>> m_clients WTF_GUARDED_BY_LOCK(m_connectionsLock);
+ HashMap<ConnectionID, std::unique_ptr<ListenerConnection>> m_listeners WTF_GUARDED_BY_LOCK(m_connectionsLock);
PlatformSocketType m_wakeupSendSocket { INVALID_SOCKET_VALUE };
PlatformSocketType m_wakeupReceiveSocket { INVALID_SOCKET_VALUE };
Modified: trunk/Source/_javascript_Core/runtime/JSLock.cpp (278068 => 278069)
--- trunk/Source/_javascript_Core/runtime/JSLock.cpp 2021-05-26 00:29:02 UTC (rev 278068)
+++ trunk/Source/_javascript_Core/runtime/JSLock.cpp 2021-05-26 00:37:19 UTC (rev 278069)
@@ -93,7 +93,9 @@
lock(1);
}
-void JSLock::lock(intptr_t lockCount)
+// Use WTF_IGNORES_THREAD_SAFETY_ANALYSIS because this function conditionally unlocks m_lock, which
+// is not supported by analysis.
+void JSLock::lock(intptr_t lockCount) WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
ASSERT(lockCount > 0);
#if USE(WEB_THREAD)
@@ -171,7 +173,9 @@
unlock(1);
}
-void JSLock::unlock(intptr_t unlockCount)
+// Use WTF_IGNORES_THREAD_SAFETY_ANALYSIS because this function conditionally unlocks m_lock, which
+// is not supported by analysis.
+void JSLock::unlock(intptr_t unlockCount) WTF_IGNORES_THREAD_SAFETY_ANALYSIS
{
RELEASE_ASSERT(currentThreadIsHoldingLock());
ASSERT(m_lockCount >= unlockCount);
Modified: trunk/Source/_javascript_Core/runtime/JSLock.h (278068 => 278069)
--- trunk/Source/_javascript_Core/runtime/JSLock.h 2021-05-26 00:29:02 UTC (rev 278068)
+++ trunk/Source/_javascript_Core/runtime/JSLock.h 2021-05-26 00:37:19 UTC (rev 278069)
@@ -138,7 +138,7 @@
unsigned dropAllLocks(DropAllLocks*);
void grabAllLocks(DropAllLocks*, unsigned lockCount);
- UncheckedLock m_lock;
+ Lock m_lock;
bool m_isWebThreadAware { false };
// We cannot make m_ownerThread an optional (instead of pairing it with an explicit
// m_hasOwnerThread) because currentThreadIsHoldingLock() may be called from a
Modified: trunk/Source/_javascript_Core/runtime/VM.h (278068 => 278069)
--- trunk/Source/_javascript_Core/runtime/VM.h 2021-05-26 00:29:02 UTC (rev 278068)
+++ trunk/Source/_javascript_Core/runtime/VM.h 2021-05-26 00:37:19 UTC (rev 278069)
@@ -1004,9 +1004,9 @@
#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
static constexpr size_t patternContextBufferSize = 8192; // Space allocated to save nested parenthesis context
UniqueArray<char> m_regExpPatternContexBuffer;
- UncheckedLock m_regExpPatternContextLock;
- char* acquireRegExpPatternContexBuffer();
- void releaseRegExpPatternContexBuffer();
+ Lock m_regExpPatternContextLock;
+ char* acquireRegExpPatternContexBuffer() WTF_ACQUIRES_LOCK(m_regExpPatternContextLock);
+ void releaseRegExpPatternContexBuffer() WTF_RELEASES_LOCK(m_regExpPatternContextLock);
#else
static constexpr size_t patternContextBufferSize = 0; // Space allocated to save nested parenthesis context
#endif
Modified: trunk/Source/WTF/ChangeLog (278068 => 278069)
--- trunk/Source/WTF/ChangeLog 2021-05-26 00:29:02 UTC (rev 278068)
+++ trunk/Source/WTF/ChangeLog 2021-05-26 00:37:19 UTC (rev 278069)
@@ -1,3 +1,15 @@
+2021-05-25 Chris Dumez <cdu...@apple.com>
+
+ Use UncheckedLock less in _javascript_Core
+ https://bugs.webkit.org/show_bug.cgi?id=226212
+
+ Reviewed by Saam Barati.
+
+ Add support for unlockEarly() to Locker<Lock> specialization, for consistency
+ with the generic Locker.
+
+ * wtf/Lock.h:
+
2021-05-25 Devin Rousso <drou...@apple.com>
[Modern Media Controls] REGRESSION(r254389) media controls needs the full list of language preferences for ordering tracks
Modified: trunk/Source/WTF/wtf/Lock.h (278068 => 278069)
--- trunk/Source/WTF/wtf/Lock.h 2021-05-26 00:29:02 UTC (rev 278068)
+++ trunk/Source/WTF/wtf/Lock.h 2021-05-26 00:37:19 UTC (rev 278069)
@@ -184,15 +184,24 @@
public:
explicit Locker(Lock& lock) WTF_ACQUIRES_LOCK(lock)
: m_lock(lock)
+ , m_isLocked(true)
{
m_lock.lock();
}
Locker(AdoptLockTag, Lock& lock) WTF_REQUIRES_LOCK(lock)
: m_lock(lock)
+ , m_isLocked(true)
{
}
~Locker() WTF_RELEASES_LOCK()
{
+ if (m_isLocked)
+ m_lock.unlock();
+ }
+ void unlockEarly() WTF_RELEASES_LOCK()
+ {
+ ASSERT(m_isLocked);
+ m_isLocked = false;
m_lock.unlock();
}
Locker(const Locker<Lock>&) = delete;
@@ -216,6 +225,7 @@
}
Lock& m_lock;
+ bool m_isLocked { false };
};
Locker(Lock&) -> Locker<Lock>;