Skip to content

Commit 8a6b5ac

Browse files
authored
Merge pull request #3893 from swiftwasm/main
2 parents 5492814 + 17f1cf9 commit 8a6b5ac

File tree

106 files changed

+1810
-918
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+1810
-918
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,10 @@ option(SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED
450450
"Enable experimental distributed actors and functions"
451451
FALSE)
452452

453+
option(SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING
454+
"Enable experimental string processing"
455+
FALSE)
456+
453457
option(SWIFT_ENABLE_DISPATCH
454458
"Enable use of libdispatch"
455459
TRUE)
@@ -1002,6 +1006,7 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
10021006
message(STATUS "Differentiable Programming Support: ${SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING}")
10031007
message(STATUS "Concurrency Support: ${SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY}")
10041008
message(STATUS "Distributed Support: ${SWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED}")
1009+
message(STATUS "String Processing Support: ${SWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING}")
10051010
message(STATUS "")
10061011
else()
10071012
message(STATUS "Not building Swift standard library, SDK overlays, and runtime")

include/swift/AST/Attr.def

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -635,15 +635,8 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(nonisolated, Nonisolated,
635635
APIBreakingToAdd | APIStableToRemove,
636636
112)
637637

638-
CONTEXTUAL_SIMPLE_DECL_ATTR(_unsafeSendable, UnsafeSendable,
639-
OnParam | UserInaccessible |
640-
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove,
641-
113)
642-
643-
CONTEXTUAL_SIMPLE_DECL_ATTR(_unsafeMainActor, UnsafeMainActor,
644-
OnParam | UserInaccessible |
645-
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIBreakingToRemove,
646-
114)
638+
// 113 was experimental _unsafeSendable and is now unused
639+
// 114 was experimental _unsafeMainActor and is now unused
647640

648641
SIMPLE_DECL_ATTR(_implicitSelfCapture, ImplicitSelfCapture,
649642
OnParam | UserInaccessible |
@@ -695,6 +688,12 @@ SIMPLE_DECL_ATTR(_noAllocation, NoAllocation,
695688
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
696689
124)
697690

691+
SIMPLE_DECL_ATTR(_predatesConcurrency, PredatesConcurrency,
692+
OnFunc | OnConstructor | OnProtocol | OnGenericType | OnVar | OnSubscript |
693+
OnEnumElement | UserInaccessible |
694+
ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
695+
125)
696+
698697
// If you're adding a new underscored attribute here, please document it in
699698
// docs/ReferenceGuides/UnderscoredAttributes.md.
700699

include/swift/AST/Decl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,9 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
883883
/// but should behave like a top-level declaration. This is used by lldb.
884884
void setHoisted(bool hoisted = true) { Bits.Decl.Hoisted = hoisted; }
885885

886+
/// Whether this declaration predates the introduction of concurrency.
887+
bool predatesConcurrency() const;
888+
886889
public:
887890
bool escapedFromIfConfig() const {
888891
return Bits.Decl.EscapedFromIfConfig;

include/swift/AST/DiagnosticsParse.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1719,6 +1719,10 @@ ERROR(sil_inst_autodiff_invalid_witness_generic_signature,PointsToFirstBadToken,
17191719
"parameters as original function generic signature '%1'",
17201720
(StringRef, StringRef))
17211721

1722+
WARNING(warn_attr_unsafe_removed,none,
1723+
"'%0' attribute has been removed in favor of @_predatesConcurrency",
1724+
(StringRef))
1725+
17221726
//------------------------------------------------------------------------------
17231727
// MARK: Generics parsing diagnostics
17241728
//------------------------------------------------------------------------------

include/swift/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ LANGUAGE_FEATURE(BuiltinBuildMainExecutor, 0, "MainActor executor building built
5656
LANGUAGE_FEATURE(BuiltinCreateAsyncTaskInGroup, 0, "MainActor executor building builtin", true)
5757
LANGUAGE_FEATURE(BuiltinMove, 0, "Builtin.move()", true)
5858
LANGUAGE_FEATURE(BuiltinCopy, 0, "Builtin.copy()", true)
59+
LANGUAGE_FEATURE(BuiltinStackAlloc, 0, "Builtin.stackAlloc", true)
5960
LANGUAGE_FEATURE(SpecializeAttributeWithAvailability, 0, "@_specialize attribute with availability", true)
6061

6162
#undef LANGUAGE_FEATURE

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ namespace swift {
145145
version::Version PackageDescriptionVersion;
146146

147147
/// Enable experimental string processing
148-
bool EnableExperimentalRegex = false;
148+
bool EnableExperimentalStringProcessing = false;
149149

150150
/// Disable API availability checking.
151151
bool DisableAvailabilityChecking = false;

include/swift/Demangling/Demangle.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ class Node {
243243
return getChild(getNumChildren() - 1);
244244
}
245245
NodePointer getChild(size_t index) const {
246-
assert(getNumChildren() > index);
246+
if (index >= getNumChildren())
247+
return nullptr;
247248
return begin()[index];
248249
}
249250

include/swift/Option/FrontendOptions.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ def disable_deserialization_recovery :
475475
Flag<["-"], "disable-deserialization-recovery">,
476476
HelpText<"Don't attempt to recover from missing xrefs (etc) in swiftmodules">;
477477

478-
def enable_experimental_regex :
479-
Flag<["-"], "enable-experimental-regex">,
478+
def enable_experimental_string_processing :
479+
Flag<["-"], "enable-experimental-string-processing">,
480480
HelpText<"Enable experimental string processing">;
481481

482482
def disable_availability_checking : Flag<["-"],

include/swift/Reflection/ReflectionContext.h

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ class ReflectionContext
131131
ChunkKind Kind;
132132
};
133133

134+
struct AsyncTaskSlabInfo {
135+
StoredPointer NextSlab;
136+
StoredSize SlabSize;
137+
std::vector<AsyncTaskAllocationChunk> Chunks;
138+
};
139+
134140
explicit ReflectionContext(std::shared_ptr<MemoryReader> reader)
135141
: super(std::move(reader), *this)
136142
{}
@@ -1346,44 +1352,45 @@ class ReflectionContext
13461352
return llvm::None;
13471353
}
13481354

1349-
llvm::Optional<std::string> iterateAsyncTaskAllocations(
1350-
StoredPointer AsyncTaskPtr,
1351-
std::function<void(StoredPointer, unsigned, AsyncTaskAllocationChunk[])>
1352-
Call) {
1353-
using AsyncTask = AsyncTask<Runtime>;
1355+
std::pair<llvm::Optional<std::string>, AsyncTaskSlabInfo>
1356+
asyncTaskSlabAllocations(StoredPointer SlabPtr) {
13541357
using StackAllocator = StackAllocator<Runtime>;
1358+
auto SlabBytes = getReader().readBytes(
1359+
RemoteAddress(SlabPtr), sizeof(typename StackAllocator::Slab));
1360+
auto Slab = reinterpret_cast<const typename StackAllocator::Slab *>(
1361+
SlabBytes.get());
1362+
if (!Slab)
1363+
return {std::string("failure reading slab"), {}};
1364+
1365+
// For now, we won't try to walk the allocations in the slab, we'll just
1366+
// provide the whole thing as one big chunk.
1367+
size_t HeaderSize =
1368+
llvm::alignTo(sizeof(*Slab), llvm::Align(MaximumAlignment));
1369+
AsyncTaskAllocationChunk Chunk;
1370+
1371+
Chunk.Start = SlabPtr + HeaderSize;
1372+
Chunk.Length = Slab->CurrentOffset;
1373+
Chunk.Kind = AsyncTaskAllocationChunk::ChunkKind::Unknown;
1374+
1375+
// Total slab size is the slab's capacity plus the slab struct itself.
1376+
StoredPointer SlabSize = Slab->Capacity + sizeof(*Slab);
1377+
1378+
return {llvm::None, {Slab->Next, SlabSize, {Chunk}}};
1379+
}
1380+
1381+
std::pair<llvm::Optional<std::string>, StoredPointer>
1382+
asyncTaskSlabPtr(StoredPointer AsyncTaskPtr) {
1383+
using AsyncTask = AsyncTask<Runtime>;
13551384

13561385
auto AsyncTaskBytes =
13571386
getReader().readBytes(RemoteAddress(AsyncTaskPtr), sizeof(AsyncTask));
13581387
auto *AsyncTaskObj =
13591388
reinterpret_cast<const AsyncTask *>(AsyncTaskBytes.get());
13601389
if (!AsyncTaskObj)
1361-
return std::string("failure reading async task");
1390+
return {std::string("failure reading async task"), 0};
13621391

13631392
StoredPointer SlabPtr = AsyncTaskObj->PrivateStorage.Allocator.FirstSlab;
1364-
while (SlabPtr) {
1365-
auto SlabBytes = getReader().readBytes(
1366-
RemoteAddress(SlabPtr), sizeof(typename StackAllocator::Slab));
1367-
auto Slab = reinterpret_cast<const typename StackAllocator::Slab *>(
1368-
SlabBytes.get());
1369-
if (!Slab)
1370-
return std::string("failure reading slab");
1371-
1372-
// For now, we won't try to walk the allocations in the slab, we'll just
1373-
// provide the whole thing as one big chunk.
1374-
size_t HeaderSize =
1375-
llvm::alignTo(sizeof(*Slab), llvm::Align(alignof(std::max_align_t)));
1376-
AsyncTaskAllocationChunk Chunk;
1377-
1378-
Chunk.Start = SlabPtr + HeaderSize;
1379-
Chunk.Length = Slab->CurrentOffset;
1380-
Chunk.Kind = AsyncTaskAllocationChunk::ChunkKind::Unknown;
1381-
Call(SlabPtr, 1, &Chunk);
1382-
1383-
SlabPtr = Slab->Next;
1384-
}
1385-
1386-
return llvm::None;
1393+
return {llvm::None, SlabPtr};
13871394
}
13881395

13891396
private:

include/swift/Reflection/RuntimeInternals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct StackAllocator {
8686
bool FirstSlabIsPreallocated;
8787

8888
struct Slab {
89+
typename Runtime::StoredPointer Metadata;
8990
typename Runtime::StoredPointer Next;
9091
uint32_t Capacity;
9192
uint32_t CurrentOffset;

0 commit comments

Comments
 (0)