swift icon indicating copy to clipboard operation
swift copied to clipboard

[Concurrency] Eliminate StatusRecordLockRecord.

Open mikeash opened this issue 9 months ago • 9 comments

Draft PR, this still needs a Win32 implementation of RecursiveMutex.

Move to a recursive lock inline in the Task. This avoids the need to allocate a lock record and simplifies the code somewhat.

Change Task's OpaquePrivateStorage to compute its size at build time based on the sizes of its components, rather than having it be a fixed size. It appears that the fixed size was intended to be part of the ABI, but that didn't happen and we're free to change this size. We need to expand it slightly when using pthread_mutex as the recursive lock, as pthread_mutex is pretty big. Other recursive locks allow it to shrink slightly.

We don't have a recursive mutex in our Threading support code, so add a RecursiveMutex type.

rdar://113898653

mikeash avatar Mar 26 '25 18:03 mikeash

@swift-ci Please Build Toolchain Linux Platform

mikeash avatar Mar 26 '25 21:03 mikeash

@swift-ci Please Build Toolchain macOS Platform

mikeash avatar Mar 26 '25 21:03 mikeash

@swift-ci Please test Windows platform

al45tair avatar Mar 27 '25 15:03 al45tair

@swift-ci Please test Windows platform

al45tair avatar Mar 27 '25 18:03 al45tair

@swift-ci please test

mikeash avatar Mar 27 '25 19:03 mikeash

embedded/concurrency-leaks.swift fails because it checks for the lock record being allocated and destroyed. Removing those lines since that no longer happens.

mikeash avatar Mar 28 '25 14:03 mikeash

@swift-ci please test

mikeash avatar Mar 28 '25 14:03 mikeash

Windows failed due to an unrelated issue on main which is now fixed, retrying.

mikeash avatar Mar 28 '25 15:03 mikeash

@swift-ci please test windows platform

mikeash avatar Mar 28 '25 15:03 mikeash