Skip to content

Commit 8271cf9

Browse files
authored
Merge pull request #3041 from swiftwasm/main
[pull] swiftwasm from main
2 parents 54ae4a1 + 937e1a3 commit 8271cf9

File tree

82 files changed

+864
-320
lines changed

Some content is hidden

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

82 files changed

+864
-320
lines changed

CHANGELOG.md

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
11
CHANGELOG
22
=========
33

4-
<details>
5-
<summary>Note: This is in reverse chronological order, so newer entries are added to the top.</summary>
6-
7-
| Version | Released | Toolchain |
8-
| :--------------------- | :--------- | :---------- |
9-
| [Swift 5.5](#swift-55) | | |
10-
| [Swift 5.4](#swift-54) | | |
11-
| [Swift 5.3](#swift-53) | 2020-09-16 | Xcode 12.0 |
12-
| [Swift 5.2](#swift-52) | 2020-03-24 | Xcode 11.4 |
13-
| [Swift 5.1](#swift-51) | 2019-09-20 | Xcode 11.0 |
14-
| [Swift 5.0](#swift-50) | 2019-03-25 | Xcode 10.2 |
15-
| [Swift 4.2](#swift-42) | 2018-09-17 | Xcode 10.0 |
16-
| [Swift 4.1](#swift-41) | 2018-03-29 | Xcode 9.3 |
17-
| [Swift 4.0](#swift-40) | 2017-09-19 | Xcode 9.0 |
18-
| [Swift 3.1](#swift-31) | 2017-03-27 | Xcode 8.3 |
19-
| [Swift 3.0](#swift-30) | 2016-09-13 | Xcode 8.0 |
20-
| [Swift 2.2](#swift-22) | 2016-03-21 | Xcode 7.3 |
21-
| [Swift 2.1](#swift-21) | 2015-10-21 | Xcode 7.1 |
22-
| [Swift 2.0](#swift-20) | 2015-09-17 | Xcode 7.0 |
23-
| [Swift 1.2](#swift-12) | 2015-04-08 | Xcode 6.3 |
24-
| [Swift 1.1](#swift-11) | 2014-12-02 | Xcode 6.1.1 |
25-
| [Swift 1.0](#swift-10) | 2014-09-15 | Xcode 6.0 |
26-
27-
</details>
4+
_**Note:** This is in reverse chronological order, so newer entries are added to the top._
285

296
Swift 5.5
307
---------
318

9+
* [SE-0306][]:
10+
11+
Swift 5.5 includes support for actors, a new kind of type that isolates its instance data to protect it from concurrent access. Accesses to an actor's instance declarations from outside the must be asynchronous:
12+
13+
```swift
14+
actor Counter {
15+
var value = 0
16+
17+
func increment() {
18+
value = value + 1
19+
}
20+
}
21+
22+
func useCounter(counter: Counter) async {
23+
print(await counter.value) // interaction must be async
24+
await counter.increment() // interaction must be async
25+
}
26+
```
27+
3228
* The determination of whether a call to a `rethrows` function can throw now considers default arguments of `Optional` type.
3329

3430
In Swift 5.4, such default arguments were ignored entirely by `rethrows` checking. This meant that the following example was accepted:
@@ -173,11 +169,11 @@ Swift 5.5
173169

174170
The "for" loop can be used to traverse asynchronous sequences in asynchronous code:
175171

176-
```swift
172+
```swift
177173
for try await line in myFile.lines() {
178174
// Do something with each line
179175
}
180-
```
176+
```
181177

182178
Asynchronous for loops use asynchronous sequences, defined by the protocol
183179
`AsyncSequence` and its corresponding `AsyncIterator`.
@@ -187,6 +183,8 @@ Swift 5.5
187183
Swift 5.4
188184
---------
189185

186+
### 2021-04-26 (Xcode 12.5)
187+
190188
* Protocol conformance checking now considers `where` clauses when evaluating if a `typealias` is a suitable witness for an associated type requirement. The following code is now rejected:
191189

192190
```swift
@@ -8434,6 +8432,7 @@ Swift 1.0
84348432
[SE-0297]: <https://github.com/apple/swift-evolution/blob/main/proposals/0297-concurrency-objc.md>
84358433
[SE-0298]: <https://github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md>
84368434
[SE-0299]: <https://github.com/apple/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md>
8435+
[SE-0306]: <https://github.com/apple/swift-evolution/blob/main/proposals/0306-actors.md>
84378436

84388437
[SR-75]: <https://bugs.swift.org/browse/SR-75>
84398438
[SR-106]: <https://bugs.swift.org/browse/SR-106>

include/swift/ABI/Task.h

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ class TaskGroup;
3939
extern FullMetadata<DispatchClassMetadata> jobHeapMetadata;
4040

4141
/// A schedulable job.
42-
class alignas(2 * alignof(void*)) Job : public HeapObject {
42+
class alignas(2 * alignof(void*)) Job :
43+
// For async-let tasks, the refcount bits are initialized as "immortal"
44+
// because such a task is allocated with the parent's stack allocator.
45+
public HeapObject {
4346
public:
4447
// Indices into SchedulerPrivate, for use by the runtime.
4548
enum {
@@ -88,6 +91,14 @@ class alignas(2 * alignof(void*)) Job : public HeapObject {
8891
assert(isAsyncTask() && "wrong constructor for a non-task job");
8992
}
9093

94+
/// Create a job with "immortal" reference counts.
95+
/// Used for async let tasks.
96+
Job(JobFlags flags, TaskContinuationFunction *invoke,
97+
const HeapMetadata *metadata, InlineRefCounts::Immortal_t immortal)
98+
: HeapObject(metadata, immortal), Flags(flags), ResumeTask(invoke) {
99+
assert(isAsyncTask() && "wrong constructor for a non-task job");
100+
}
101+
91102
bool isAsyncTask() const {
92103
return Flags.isAsyncTask();
93104
}
@@ -201,6 +212,21 @@ class AsyncTask : public Job {
201212
assert(flags.isAsyncTask());
202213
}
203214

215+
/// Create a task with "immortal" reference counts.
216+
/// Used for async let tasks.
217+
AsyncTask(const HeapMetadata *metadata, InlineRefCounts::Immortal_t immortal,
218+
JobFlags flags,
219+
TaskContinuationFunction *run,
220+
AsyncContext *initialContext)
221+
: Job(flags, run, metadata, immortal),
222+
ResumeContext(initialContext),
223+
Status(ActiveTaskStatus()),
224+
Local(TaskLocal::Storage()) {
225+
assert(flags.isAsyncTask());
226+
}
227+
228+
~AsyncTask();
229+
204230
/// Given that we've already fully established the job context
205231
/// in the current thread, start running this task. To establish
206232
/// the job context correctly, call swift_job_run or

include/swift/AST/ASTMangler.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class ASTMangler : public Mangler {
186186
std::string
187187
mangleAutoDiffDerivativeFunction(const AbstractFunctionDecl *originalAFD,
188188
AutoDiffDerivativeFunctionKind kind,
189-
AutoDiffConfig config,
189+
const AutoDiffConfig &config,
190190
bool isVTableThunk = false);
191191

192192
/// Mangle the linear map (differential/pullback) for the given:
@@ -196,7 +196,7 @@ class ASTMangler : public Mangler {
196196
/// derivative generic signature.
197197
std::string mangleAutoDiffLinearMap(const AbstractFunctionDecl *originalAFD,
198198
AutoDiffLinearMapKind kind,
199-
AutoDiffConfig config);
199+
const AutoDiffConfig &config);
200200

201201
/// Mangle the linear map self parameter reordering thunk the given:
202202
/// - Mangled original function declaration.
@@ -210,7 +210,7 @@ class ASTMangler : public Mangler {
210210
/// Mangle a SIL differentiability witness.
211211
std::string mangleSILDifferentiabilityWitness(StringRef originalName,
212212
DifferentiabilityKind kind,
213-
AutoDiffConfig config);
213+
const AutoDiffConfig &config);
214214

215215
/// Mangle the AutoDiff generated declaration for the given:
216216
/// - Generated declaration kind: linear map struct or branching trace enum.
@@ -223,7 +223,7 @@ class ASTMangler : public Mangler {
223223
mangleAutoDiffGeneratedDeclaration(AutoDiffGeneratedDeclarationKind declKind,
224224
StringRef origFnName, unsigned bbId,
225225
AutoDiffLinearMapKind linearMapKind,
226-
AutoDiffConfig config);
226+
const AutoDiffConfig &config);
227227

228228
std::string mangleKeyPathGetterThunkHelper(const AbstractStorageDecl *property,
229229
GenericSignature signature,
@@ -453,7 +453,7 @@ class ASTMangler : public Mangler {
453453
const AbstractFunctionDecl *afd);
454454
void appendAutoDiffFunctionParts(StringRef op,
455455
Demangle::AutoDiffFunctionKind kind,
456-
AutoDiffConfig config);
456+
const AutoDiffConfig &config);
457457
void appendIndexSubset(IndexSubset *indexSubset);
458458
};
459459

include/swift/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5718,7 +5718,7 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
57185718
ArrayRef<AutoDiffConfig> getDerivativeFunctionConfigurations();
57195719

57205720
/// Add the given derivative function configuration.
5721-
void addDerivativeFunctionConfiguration(AutoDiffConfig config);
5721+
void addDerivativeFunctionConfiguration(const AutoDiffConfig &config);
57225722

57235723
protected:
57245724
// If a function has a body at all, we have either a parsed body AST node or

include/swift/AST/Module.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,6 @@ class ModuleDecl : public DeclContext, public TypeDecl {
594594
ObjCSelector selector,
595595
SmallVectorImpl<AbstractFunctionDecl *> &results) const;
596596

597-
Optional<Fingerprint>
598-
loadFingerprint(const IterableDeclContext *IDC) const;
599-
600597
/// Find all SPI names imported from \p importedModule by this module,
601598
/// collecting the identifiers in \p spiGroups.
602599
void lookupImportedSPIGroups(

include/swift/Basic/Features.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
LANGUAGE_FEATURE(StaticAssert, 0, "#assert", langOpts.EnableExperimentalStaticAssert)
3838
LANGUAGE_FEATURE(AsyncAwait, 296, "async/await", true)
3939
LANGUAGE_FEATURE(MarkerProtocol, 0, "@_marker protocol", true)
40-
LANGUAGE_FEATURE(Actors, 0, "actors", langOpts.EnableExperimentalConcurrency)
40+
LANGUAGE_FEATURE(Actors, 0, "actors", true)
4141
LANGUAGE_FEATURE(ConcurrentFunctions, 0, "@concurrent functions", true)
4242
LANGUAGE_FEATURE(RethrowsProtocol, 0, "@rethrows protocol", true)
4343
LANGUAGE_FEATURE(GlobalActors, 0, "Global actors", langOpts.EnableExperimentalConcurrency)

include/swift/Reflection/ReflectionContext.h

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -205,36 +205,7 @@ class ReflectionContext
205205
return false;
206206

207207
auto Slide = ImageStart.getAddressData() - Command->vmaddr;
208-
std::string Prefix = "__swift5";
209-
uint64_t RangeStart = UINT64_MAX;
210-
uint64_t RangeEnd = UINT64_MAX;
211208
auto SectionsBuf = reinterpret_cast<const char *>(Sections.get());
212-
for (unsigned I = 0; I < NumSect; ++I) {
213-
auto S = reinterpret_cast<typename T::Section *>(
214-
SectionsBuf + (I * sizeof(typename T::Section)));
215-
if (strncmp(S->sectname, Prefix.c_str(), strlen(Prefix.c_str())) != 0)
216-
continue;
217-
if (RangeStart == UINT64_MAX && RangeEnd == UINT64_MAX) {
218-
RangeStart = S->addr + Slide;
219-
RangeEnd = S->addr + S->size + Slide;
220-
continue;
221-
}
222-
RangeStart = std::min(RangeStart, (uint64_t)S->addr + Slide);
223-
RangeEnd = std::max(RangeEnd, (uint64_t)(S->addr + S->size + Slide));
224-
// Keep the range rounded to 8 byte alignment on both ends so we don't
225-
// introduce misaligned pointers mapping between local and remote
226-
// address space.
227-
RangeStart = RangeStart & ~7;
228-
RangeEnd = RangeEnd + 7 & ~7;
229-
}
230-
231-
if (RangeStart == UINT64_MAX && RangeEnd == UINT64_MAX)
232-
return false;
233-
234-
auto SectBuf = this->getReader().readBytes(RemoteAddress(RangeStart),
235-
RangeEnd - RangeStart);
236-
if (!SectBuf)
237-
return false;
238209

239210
auto findMachOSectionByName = [&](llvm::StringRef Name)
240211
-> std::pair<RemoteRef<void>, uint64_t> {
@@ -244,11 +215,13 @@ class ReflectionContext
244215
if (strncmp(S->sectname, Name.data(), strlen(Name.data())) != 0)
245216
continue;
246217
auto RemoteSecStart = S->addr + Slide;
247-
auto SectBufData = reinterpret_cast<const char *>(SectBuf.get());
248-
auto LocalSectStart =
249-
reinterpret_cast<const char *>(SectBufData + RemoteSecStart - RangeStart);
250-
251-
auto StartRef = RemoteRef<void>(RemoteSecStart, LocalSectStart);
218+
auto LocalSectBuf =
219+
this->getReader().readBytes(RemoteAddress(RemoteSecStart), S->size);
220+
if (!LocalSectBuf)
221+
return {nullptr, 0};
222+
223+
auto StartRef = RemoteRef<void>(RemoteSecStart, LocalSectBuf.get());
224+
savedBuffers.push_back(std::move(LocalSectBuf));
252225
return {StartRef, S->size};
253226
}
254227
return {nullptr, 0};
@@ -307,7 +280,6 @@ class ReflectionContext
307280
}
308281

309282
savedBuffers.push_back(std::move(Buf));
310-
savedBuffers.push_back(std::move(SectBuf));
311283
savedBuffers.push_back(std::move(Sections));
312284
return true;
313285
}

include/swift/SILOptimizer/Analysis/DifferentiableActivityAnalysis.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class DifferentiableActivityInfo {
207207
IndexSubset *resultIndices) const;
208208

209209
/// Returns true if the given value is active for the given config.
210-
bool isActive(SILValue value, AutoDiffConfig config) const {
210+
bool isActive(SILValue value, const AutoDiffConfig &config) const {
211211
return isActive(value, config.parameterIndices, config.resultIndices);
212212
}
213213

@@ -217,7 +217,7 @@ class DifferentiableActivityInfo {
217217
IndexSubset *resultIndices) const;
218218

219219
/// Returns the activity of the given value for the given config.
220-
Activity getActivity(SILValue value, AutoDiffConfig config) const {
220+
Activity getActivity(SILValue value, const AutoDiffConfig &config) const {
221221
return getActivity(value, config.parameterIndices, config.resultIndices);
222222
}
223223

@@ -227,7 +227,7 @@ class DifferentiableActivityInfo {
227227
llvm::raw_ostream &s = llvm::dbgs()) const;
228228

229229
/// Prints activity information for the config of the given value.
230-
void dump(SILValue value, AutoDiffConfig config,
230+
void dump(SILValue value, const AutoDiffConfig &config,
231231
llvm::raw_ostream &s = llvm::dbgs()) const {
232232
return dump(value, config.parameterIndices, config.resultIndices, s);
233233
}
@@ -238,7 +238,8 @@ class DifferentiableActivityInfo {
238238
llvm::raw_ostream &s = llvm::dbgs()) const;
239239

240240
/// Prints all activity information for the given config.
241-
void dump(AutoDiffConfig config, llvm::raw_ostream &s = llvm::dbgs()) const {
241+
void dump(const AutoDiffConfig &config,
242+
llvm::raw_ostream &s = llvm::dbgs()) const {
242243
return dump(config.parameterIndices, config.resultIndices, s);
243244
}
244245
};

include/swift/SILOptimizer/Differentiation/Common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ void collectAllActualResultsInTypeOrder(
121121
/// - The set of minimal parameter and result indices for differentiating the
122122
/// `apply` instruction.
123123
void collectMinimalIndicesForFunctionCall(
124-
ApplyInst *ai, AutoDiffConfig parentConfig,
124+
ApplyInst *ai, const AutoDiffConfig &parentConfig,
125125
const DifferentiableActivityInfo &activityInfo,
126126
SmallVectorImpl<SILValue> &results, SmallVectorImpl<unsigned> &paramIndices,
127127
SmallVectorImpl<unsigned> &resultIndices);

include/swift/SILOptimizer/Differentiation/LinearMapInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class LinearMapInfo {
149149

150150
explicit LinearMapInfo(ADContext &context, AutoDiffLinearMapKind kind,
151151
SILFunction *original, SILFunction *derivative,
152-
AutoDiffConfig config,
152+
const AutoDiffConfig &config,
153153
const DifferentiableActivityInfo &activityInfo,
154154
SILLoopInfo *loopInfo);
155155

0 commit comments

Comments
 (0)