Skip to content

Commit d4e4aff

Browse files
authored
Merge pull request #4549 from apple/revert-4428-structural-type-metadata-caches
Revert "Metadata cache optimizations"
2 parents e92e00b + e065651 commit d4e4aff

File tree

4 files changed

+424
-547
lines changed

4 files changed

+424
-547
lines changed

include/swift/Runtime/Concurrent.h

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#include <stdio.h>
2020
#endif
2121

22-
namespace swift {
23-
2422
/// This is a node in a concurrent linked list.
2523
template <class ElemTy> struct ConcurrentListNode {
2624
ConcurrentListNode(ElemTy Elem) : Payload(Elem), Next(nullptr) {}
@@ -125,29 +123,6 @@ template <class ElemTy> struct ConcurrentList {
125123
std::atomic<ConcurrentListNode<ElemTy> *> First;
126124
};
127125

128-
template <class T, bool Delete> class AtomicMaybeOwningPointer;
129-
130-
template <class T>
131-
class AtomicMaybeOwningPointer<T, false> {
132-
public:
133-
std::atomic<T*> Value;
134-
constexpr AtomicMaybeOwningPointer(T *value) : Value(value) {}
135-
};
136-
137-
template <class T>
138-
class AtomicMaybeOwningPointer<T, true> {
139-
public:
140-
std::atomic<T*> Value;
141-
constexpr AtomicMaybeOwningPointer(T *value) : Value(value) {}
142-
143-
~AtomicMaybeOwningPointer() {
144-
// This can use relaxed memory order because the client has to ensure
145-
// that all accesses are safely completed and their effects fully
146-
// visible before destruction occurs anyway.
147-
::delete Value.load(std::memory_order_relaxed);
148-
}
149-
};
150-
151126
/// A concurrent map that is implemented using a binary tree. It supports
152127
/// concurrent insertions but does not support removals or rebalancing of
153128
/// the tree.
@@ -165,8 +140,7 @@ class AtomicMaybeOwningPointer<T, true> {
165140
/// /// where KeyTy is the type of the first argument to getOrInsert and
166141
/// /// ArgTys is the type of the remaining arguments.
167142
/// static size_t getExtraAllocationSize(KeyTy key, ArgTys...)
168-
template <class EntryTy, bool ProvideDestructor = true>
169-
class ConcurrentMap {
143+
template <class EntryTy> class ConcurrentMap {
170144
struct Node {
171145
std::atomic<Node*> Left;
172146
std::atomic<Node*> Right;
@@ -208,7 +182,7 @@ class ConcurrentMap {
208182
};
209183

210184
/// The root of the tree.
211-
AtomicMaybeOwningPointer<Node, ProvideDestructor> Root;
185+
std::atomic<Node*> Root;
212186

213187
/// This member stores the address of the last node that was found by the
214188
/// search procedure. We cache the last search to accelerate code that
@@ -221,14 +195,13 @@ class ConcurrentMap {
221195
ConcurrentMap(const ConcurrentMap &) = delete;
222196
ConcurrentMap &operator=(const ConcurrentMap &) = delete;
223197

224-
// ConcurrentMap<T, false> must have a trivial destructor.
225-
~ConcurrentMap() = default;
226-
227-
public:
198+
~ConcurrentMap() {
199+
::delete Root.load(std::memory_order_relaxed);
200+
}
228201

229202
#ifndef NDEBUG
230203
void dump() const {
231-
auto R = Root.Value.load(std::memory_order_acquire);
204+
auto R = Root.load(std::memory_order_acquire);
232205
printf("digraph g {\n"
233206
"graph [ rankdir = \"TB\"];\n"
234207
"node [ fontsize = \"16\" ];\n"
@@ -252,7 +225,7 @@ class ConcurrentMap {
252225
}
253226

254227
// Search the tree, starting from the root.
255-
Node *node = Root.Value.load(std::memory_order_acquire);
228+
Node *node = Root.load(std::memory_order_acquire);
256229
while (node) {
257230
int comparisonResult = node->Payload.compareWithKey(key);
258231
if (comparisonResult == 0) {
@@ -285,7 +258,7 @@ class ConcurrentMap {
285258
Node *newNode = nullptr;
286259

287260
// Start from the root.
288-
auto edge = &Root.Value;
261+
auto edge = &Root;
289262

290263
while (true) {
291264
// Load the edge.
@@ -340,6 +313,4 @@ class ConcurrentMap {
340313
}
341314
};
342315

343-
} // end namespace swift
344-
345316
#endif // SWIFT_RUNTIME_CONCURRENTUTILS_H

stdlib/public/runtime/Demangle.cpp

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -209,35 +209,10 @@ Demangle::NodePointer swift::_swift_buildDemanglingForMetadata(const Metadata *t
209209
}
210210
case MetadataKind::Tuple: {
211211
auto tuple = static_cast<const TupleTypeMetadata *>(type);
212-
const char *labels = tuple->Labels;
213212
auto tupleNode = NodeFactory::create(Node::Kind::NonVariadicTuple);
214213
for (unsigned i = 0, e = tuple->NumElements; i < e; ++i) {
215-
auto elt = NodeFactory::create(Node::Kind::TupleElement);
216-
217-
// Add a label child if applicable:
218-
if (labels) {
219-
// Look for the next space in the labels string.
220-
if (const char *space = strchr(labels, ' ')) {
221-
// If there is one, and the label isn't empty, add a label child.
222-
if (labels != space) {
223-
auto eltName =
224-
NodeFactory::create(Node::Kind::TupleElementName,
225-
std::string(labels, space));
226-
elt->addChild(std::move(eltName));
227-
}
228-
229-
// Skip past the space.
230-
labels = space + 1;
231-
}
232-
}
233-
234-
// Add the element type child.
235-
auto eltType =
236-
_swift_buildDemanglingForMetadata(tuple->getElement(i).Type);
237-
elt->addChild(std::move(eltType));
238-
239-
// Add the completed element to the tuple.
240-
tupleNode->addChild(std::move(elt));
214+
auto elt = _swift_buildDemanglingForMetadata(tuple->getElement(i).Type);
215+
tupleNode->addChild(elt);
241216
}
242217
return tupleNode;
243218
}

0 commit comments

Comments
 (0)