mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[runtime] - switched most runtime code to use swift::Mutex and swift::Condition (see SR-946)
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "swift/Runtime/Concurrent.h"
|
||||
#include "swift/Runtime/HeapObject.h"
|
||||
#include "swift/Runtime/Metadata.h"
|
||||
#include "swift/Runtime/Mutex.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/PointerIntPair.h"
|
||||
@@ -34,7 +35,6 @@
|
||||
#endif
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <mutex>
|
||||
|
||||
using namespace swift;
|
||||
using namespace Demangle;
|
||||
@@ -107,11 +107,10 @@ static void _addImageTypeMetadataRecordsBlock(const uint8_t *records,
|
||||
struct TypeMetadataState {
|
||||
ConcurrentMap<TypeMetadataCacheEntry> Cache;
|
||||
std::vector<TypeMetadataSection> SectionsToScan;
|
||||
pthread_mutex_t SectionsToScanLock;
|
||||
Mutex SectionsToScanLock;
|
||||
|
||||
TypeMetadataState() {
|
||||
SectionsToScan.reserve(16);
|
||||
pthread_mutex_init(&SectionsToScanLock, nullptr);
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
_initializeCallbacksToInspectDylib();
|
||||
#else
|
||||
@@ -120,6 +119,7 @@ struct TypeMetadataState {
|
||||
SWIFT_TYPE_METADATA_SECTION);
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static Lazy<TypeMetadataState> TypeMetadataRecords;
|
||||
@@ -128,9 +128,8 @@ static void
|
||||
_registerTypeMetadataRecords(TypeMetadataState &T,
|
||||
const TypeMetadataRecord *begin,
|
||||
const TypeMetadataRecord *end) {
|
||||
pthread_mutex_lock(&T.SectionsToScanLock);
|
||||
ScopedLock guard(T.SectionsToScanLock);
|
||||
T.SectionsToScan.push_back(TypeMetadataSection{begin, end});
|
||||
pthread_mutex_unlock(&T.SectionsToScanLock);
|
||||
}
|
||||
|
||||
static void _addImageTypeMetadataRecordsBlock(const uint8_t *records,
|
||||
@@ -265,9 +264,9 @@ _typeByMangledName(const llvm::StringRef typeName) {
|
||||
return Value->getMetadata();
|
||||
|
||||
// Check type metadata records
|
||||
pthread_mutex_lock(&T.SectionsToScanLock);
|
||||
foundMetadata = _searchTypeMetadataRecords(T, typeName);
|
||||
pthread_mutex_unlock(&T.SectionsToScanLock);
|
||||
T.SectionsToScanLock.lock([&] {
|
||||
foundMetadata = _searchTypeMetadataRecords(T, typeName);
|
||||
});
|
||||
|
||||
// Check protocol conformances table. Note that this has no support for
|
||||
// resolving generic types yet.
|
||||
|
||||
Reference in New Issue
Block a user