Skip to content

Commit eb6e74a

Browse files
committed
Handle demangling/remangling for concurrency-related builtin types.
Fixes rdar://75990281.
1 parent 6c11713 commit eb6e74a

File tree

6 files changed

+41
-1
lines changed

6 files changed

+41
-1
lines changed

include/swift/Runtime/BuiltinTypes.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ BUILTIN_TYPE(BB, "Builtin.UnsafeValueBuffer")
6060
// shaped like AnyObject (normal mangling yXl).
6161
BUILTIN_POINTER_TYPE(BO, "Builtin.UnknownObject")
6262

63+
BUILTIN_POINTER_TYPE(Bc, "Builtin.RawUnsafeContinuation")
64+
BUILTIN_TYPE(BD, "Builtin.DefaultActorStorage")
65+
BUILTIN_TYPE(Be, "Builtin.Executor")
66+
BUILTIN_POINTER_TYPE(Bj, "Builtin.Job")
67+
6368
// Int8 vector types
6469
BUILTIN_VECTOR_TYPE(Bi8_, Int8, 2)
6570
BUILTIN_VECTOR_TYPE(Bi8_, Int8, 3)

lib/Demangling/Demangler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,10 @@ NodePointer Demangler::demangleBuiltinType() {
11461146
Ty = createNode(Node::Kind::BuiltinTypeName,
11471147
BUILTIN_TYPE_NAME_UNSAFEVALUEBUFFER);
11481148
break;
1149+
case 'e':
1150+
Ty = createNode(Node::Kind::BuiltinTypeName,
1151+
BUILTIN_TYPE_NAME_EXECUTOR);
1152+
break;
11491153
case 'f': {
11501154
int size = demangleIndex() - 1;
11511155
if (size <= 0 || size > maxTypeSize)

lib/Demangling/Remangler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ void Remangler::mangleBuiltinTypeName(Node *node) {
753753
Buffer << 'j';
754754
} else if (text == BUILTIN_TYPE_NAME_DEFAULTACTORSTORAGE) {
755755
Buffer << 'D';
756+
} else if (text == BUILTIN_TYPE_NAME_EXECUTOR) {
757+
Buffer << 'e';
756758
} else if (text == BUILTIN_TYPE_NAME_SILTOKEN) {
757759
Buffer << 't';
758760
} else if (text == BUILTIN_TYPE_NAME_INTLITERAL) {

lib/IRGen/MetadataRequest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,7 @@ namespace {
17451745
llvm_unreachable("error type should not appear in IRGen");
17461746
}
17471747

1748-
// These types are artificial types used for for internal purposes and
1748+
// These types are artificial types used for internal purposes and
17491749
// should never appear in a metadata request.
17501750
#define INTERNAL_ONLY_TYPE(ID) \
17511751
MetadataResponse visit##ID##Type(Can##ID##Type type, \

stdlib/public/runtime/KnownMetadata.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
#include <cstring>
2323
#include <climits>
2424

25+
namespace swift {
26+
class AsyncTask;
27+
class Job;
28+
}
29+
2530
using namespace swift;
2631
using namespace metadataimpl;
2732

@@ -80,6 +85,19 @@ namespace ctypes {
8085
/// with this, but the type isn't copyable, so most of the value
8186
/// operations are meaningless.
8287
using BB = ValueBuffer;
88+
89+
// Types that are defined in the _Concurrency library
90+
91+
// Default actor storage type.
92+
struct BD {
93+
void *storage[NumWords_DefaultActor];
94+
};
95+
96+
// ExecutorRef type.
97+
struct Be {
98+
HeapObject *Identity;
99+
uintptr_t Implementation;
100+
};
83101
}
84102
}
85103

@@ -94,6 +112,12 @@ namespace pointer_types {
94112
/// The value-witness table for BridgeObject.
95113
using Bb = BridgeObjectBox;
96114

115+
// RawUnsafeContinuation type.
116+
using Bc = RawPointerBox;
117+
118+
// Job type.
119+
using Bj = RawPointerBox;
120+
97121
#if SWIFT_OBJC_INTEROP
98122
/*** Objective-C pointers *************************************************/
99123

test/Runtime/demangleToMetadata.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ DemangleToMetadataTests.test("demangle built-in types") {
244244
expectEqual(Builtin.FPIEEE64.self, _typeByName("Bf64_")!)
245245

246246
expectEqual(Builtin.Vec4xFPIEEE32.self, _typeByName("Bf32_Bv4_")!)
247+
248+
expectEqual(Builtin.RawUnsafeContinuation.self, _typeByName("Bc")!)
249+
expectEqual(Builtin.Executor.self, _typeByName("Be")!)
250+
expectNotNil(_typeByName("BD"))
251+
expectEqual(Builtin.Job.self, _typeByName("Bj")!)
247252
}
248253

249254
class CG4<T: P1, U: P2> {

0 commit comments

Comments
 (0)