Skip to content

Commit 0387798

Browse files
committed
Request evaluator: Use IntrusiveRefCntPtr instead of std::shared_ptr
We don't need the reference-counting used by AnyRequest to be atomic.
1 parent d61dad9 commit 0387798

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

include/swift/AST/AnyRequest.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/Basic/TypeID.h"
2121
#include "llvm/ADT/DenseMapInfo.h"
2222
#include "llvm/ADT/Hashing.h"
23+
#include "llvm/ADT/IntrusiveRefCntPtr.h"
2324
#include <string>
2425

2526
namespace llvm {
@@ -50,7 +51,7 @@ class DiagnosticEngine;
5051
///
5152
class AnyRequest {
5253
/// Abstract base class used to hold the specific request kind.
53-
class HolderBase {
54+
class HolderBase : public llvm::RefCountedBase<HolderBase> {
5455
public:
5556
/// The type ID of the request being stored.
5657
const uint64_t typeID;
@@ -128,7 +129,7 @@ class AnyRequest {
128129
} storageKind = StorageKind::Normal;
129130

130131
/// The data stored in this value.
131-
std::shared_ptr<HolderBase> stored;
132+
llvm::IntrusiveRefCntPtr<HolderBase> stored;
132133

133134
AnyRequest(StorageKind storageKind) : storageKind(storageKind) {
134135
assert(storageKind != StorageKind::Normal);
@@ -161,8 +162,9 @@ class AnyRequest {
161162
template<typename T>
162163
AnyRequest(T&& value) : storageKind(StorageKind::Normal) {
163164
using ValueType =
164-
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
165-
stored.reset(new Holder<ValueType>(std::forward<T>(value)));
165+
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
166+
stored = llvm::IntrusiveRefCntPtr<HolderBase>(
167+
new Holder<ValueType>(std::forward<T>(value)));
166168
}
167169

168170
/// Cast to a specific (known) type.

0 commit comments

Comments
 (0)