Skip to content

Commit 08be6b2

Browse files
authored
Merge pull request #2898 from swiftwasm/main
[pull] swiftwasm from main
2 parents 07e7655 + 2c0b8ac commit 08be6b2

File tree

146 files changed

+2793
-1186
lines changed

Some content is hidden

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

146 files changed

+2793
-1186
lines changed

benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ set(SWIFT_BENCH_MODULES
158158
single-source/RemoveWhere
159159
single-source/ReversedCollections
160160
single-source/RomanNumbers
161+
single-source/SIMDRandomMask
161162
single-source/SIMDReduceInteger
162163
single-source/SequenceAlgos
163164
single-source/SetTests
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
//===--- SIMDRandomMask.swift ---------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2021 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import TestsUtils
14+
15+
public let SIMDRandomMask = [
16+
BenchmarkInfo(
17+
name: "SIMDRandomMask.Int8x16",
18+
runFunction: run_SIMDRandomMaskInt8x16,
19+
tags: [.validation, .SIMD]
20+
),
21+
BenchmarkInfo(
22+
name: "SIMDRandomMask.Int8x64",
23+
runFunction: run_SIMDRandomMaskInt8x64,
24+
tags: [.validation, .SIMD]
25+
),
26+
BenchmarkInfo(
27+
name: "SIMDRandomMask.Int64x2",
28+
runFunction: run_SIMDRandomMaskInt64x2,
29+
tags: [.validation, .SIMD]
30+
),
31+
BenchmarkInfo(
32+
name: "SIMDRandomMask.Int64x8",
33+
runFunction: run_SIMDRandomMaskInt64x8,
34+
tags: [.validation, .SIMD]
35+
),
36+
BenchmarkInfo(
37+
name: "SIMDRandomMask.Int64x64",
38+
runFunction: run_SIMDRandomMaskInt64x64,
39+
tags: [.validation, .SIMD]
40+
)
41+
]
42+
43+
@inline(never)
44+
public func run_SIMDRandomMaskInt8x16(_ N: Int) {
45+
var g = SplitMix64(seed: 0)
46+
var accum = SIMDMask<SIMD16<Int8>>()
47+
for _ in 0 ..< 10000*N {
48+
accum .^= SIMDMask.random(using: &g)
49+
}
50+
blackHole(accum)
51+
}
52+
53+
@inline(never)
54+
public func run_SIMDRandomMaskInt8x64(_ N: Int) {
55+
var g = SplitMix64(seed: 0)
56+
var accum = SIMDMask<SIMD64<Int8>>()
57+
for _ in 0 ..< 10000*N {
58+
accum .^= SIMDMask.random(using: &g)
59+
}
60+
blackHole(accum)
61+
}
62+
63+
@inline(never)
64+
public func run_SIMDRandomMaskInt64x2(_ N: Int) {
65+
var g = SplitMix64(seed: 0)
66+
var accum = SIMDMask<SIMD2<Int64>>()
67+
for _ in 0 ..< 10000*N {
68+
accum .^= SIMDMask.random(using: &g)
69+
}
70+
blackHole(accum)
71+
}
72+
73+
@inline(never)
74+
public func run_SIMDRandomMaskInt64x8(_ N: Int) {
75+
var g = SplitMix64(seed: 0)
76+
var accum = SIMDMask<SIMD8<Int64>>()
77+
for _ in 0 ..< 10000*N {
78+
accum .^= SIMDMask.random(using: &g)
79+
}
80+
blackHole(accum)
81+
}
82+
83+
@inline(never)
84+
public func run_SIMDRandomMaskInt64x64(_ N: Int) {
85+
var g = SplitMix64(seed: 0)
86+
var accum = SIMDMask<SIMD64<Int64>>()
87+
for _ in 0 ..< 10000*N {
88+
accum .^= SIMDMask.random(using: &g)
89+
}
90+
blackHole(accum)
91+
}
92+

benchmark/utils/main.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ import ReduceInto
156156
import RemoveWhere
157157
import ReversedCollections
158158
import RomanNumbers
159+
import SIMDRandomMask
159160
import SIMDReduceInteger
160161
import SequenceAlgos
161162
import SetTests
@@ -353,6 +354,7 @@ registerBenchmark(ReduceInto)
353354
registerBenchmark(RemoveWhere)
354355
registerBenchmark(ReversedCollections)
355356
registerBenchmark(RomanNumbers)
357+
registerBenchmark(SIMDRandomMask)
356358
registerBenchmark(SIMDReduceInteger)
357359
registerBenchmark(SequenceAlgos)
358360
registerBenchmark(SetTests)

include/swift/ABI/TaskStatus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class TaskGroupTaskStatusRecord : public TaskStatusRecord {
254254
/// subsequently used.
255255
class CancellationNotificationStatusRecord : public TaskStatusRecord {
256256
public:
257-
using FunctionType = void (void *);
257+
using FunctionType = SWIFT_CC(swift) void (SWIFT_CONTEXT void *);
258258

259259
private:
260260
FunctionType * __ptrauth_swift_cancellation_notification_function Function;

include/swift/AST/ActorIsolation.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,17 @@ class raw_ostream;
2424
}
2525

2626
namespace swift {
27-
class ClassDecl;
27+
class DeclContext;
28+
class NominalTypeDecl;
2829
class SubstitutionMap;
29-
class Type;
3030

3131
/// Determine whether the given types are (canonically) equal, declared here
3232
/// to avoid having to include Types.h.
3333
bool areTypesEqual(Type type1, Type type2);
3434

35+
/// Determine whether the given type is suitable as a concurrent value type.
36+
bool isSendableType(const DeclContext *dc, Type type);
37+
3538
/// Describes the actor isolation of a given declaration, which determines
3639
/// the actors with which it can interact.
3740
class ActorIsolation {

include/swift/AST/Attr.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,15 @@ class DeclAttribute : public AttributeBase {
110110
union {
111111
uint64_t OpaqueBits;
112112

113-
SWIFT_INLINE_BITFIELD_BASE(DeclAttribute, bitmax(NumDeclAttrKindBits,8)+1+1,
113+
SWIFT_INLINE_BITFIELD_BASE(DeclAttribute, bitmax(NumDeclAttrKindBits,8)+1+1+1,
114114
Kind : bitmax(NumDeclAttrKindBits,8),
115115
// Whether this attribute was implicitly added.
116116
Implicit : 1,
117117

118-
Invalid : 1
118+
Invalid : 1,
119+
120+
/// Whether the attribute was created by an access note.
121+
AddedByAccessNote : 1
119122
);
120123

121124
SWIFT_INLINE_BITFIELD(ObjCAttr, DeclAttribute, 1+1+1,
@@ -191,6 +194,7 @@ class DeclAttribute : public AttributeBase {
191194
Bits.DeclAttribute.Kind = static_cast<unsigned>(DK);
192195
Bits.DeclAttribute.Implicit = Implicit;
193196
Bits.DeclAttribute.Invalid = false;
197+
Bits.DeclAttribute.AddedByAccessNote = false;
194198
}
195199

196200
private:
@@ -329,6 +333,18 @@ class DeclAttribute : public AttributeBase {
329333

330334
bool isValid() const { return !isInvalid(); }
331335

336+
337+
/// Determine whether this attribute was added by an access note. If it was,
338+
/// the compiler will generally recover from failures involving this attribute
339+
/// as though it is not present.
340+
bool getAddedByAccessNote() const {
341+
return Bits.DeclAttribute.AddedByAccessNote;
342+
}
343+
344+
void setAddedByAccessNote(bool accessNote = true) {
345+
Bits.DeclAttribute.AddedByAccessNote = accessNote;
346+
}
347+
332348
/// Returns the address of the next pointer field.
333349
/// Used for object deserialization.
334350
DeclAttribute **getMutableNext() {

include/swift/AST/Decl.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,62 @@ class PatternBindingDecl final : public Decl,
16821682
return const_cast<PatternBindingDecl*>(this)->getMutablePatternList();
16831683
}
16841684

1685+
/// Clean up walking the initializers for the pattern
1686+
class InitIterator {
1687+
1688+
const PatternBindingDecl &decl;
1689+
unsigned currentPatternEntryIndex;
1690+
1691+
void next() { ++currentPatternEntryIndex; }
1692+
1693+
public:
1694+
using value_type = Expr *;
1695+
using pointer = value_type;
1696+
using reference = value_type;
1697+
using difference_type = unsigned;
1698+
1699+
InitIterator(const PatternBindingDecl &decl, unsigned start = 0)
1700+
: decl(decl), currentPatternEntryIndex(start) {}
1701+
1702+
InitIterator &operator++() {
1703+
next();
1704+
return *this;
1705+
}
1706+
1707+
InitIterator operator++(int) {
1708+
InitIterator newIterator(decl, currentPatternEntryIndex);
1709+
newIterator.next();
1710+
return newIterator;
1711+
}
1712+
1713+
pointer operator->() { return decl.getInit(currentPatternEntryIndex); }
1714+
1715+
pointer operator*() { return decl.getInit(currentPatternEntryIndex); }
1716+
1717+
difference_type operator-(const InitIterator &other) {
1718+
return currentPatternEntryIndex - other.currentPatternEntryIndex;
1719+
}
1720+
1721+
bool operator==(const InitIterator &other) const {
1722+
return &decl == &other.decl &&
1723+
currentPatternEntryIndex == other.currentPatternEntryIndex;
1724+
}
1725+
1726+
bool operator!=(const InitIterator &other) const {
1727+
return !(*this == other);
1728+
}
1729+
};
1730+
1731+
InitIterator beginInits() const { return InitIterator(*this); }
1732+
1733+
InitIterator endInits() const {
1734+
return InitIterator(*this, getNumPatternEntries());
1735+
}
1736+
1737+
llvm::iterator_range<InitIterator> initializers() const {
1738+
return llvm::make_range(beginInits(), endInits());
1739+
}
1740+
16851741
void setInitStringRepresentation(unsigned i, StringRef str) {
16861742
getMutablePatternList()[i].setInitStringRepresentation(str);
16871743
}

include/swift/AST/DiagnosticsSema.def

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3377,6 +3377,9 @@ ERROR(attr_completion_handler_async_ambiguous_function,none,
33773377
ERROR(attr_completion_handler_async_no_suitable_function,none,
33783378
"no corresponding async function named %0", (DeclNameRef))
33793379

3380+
WARNING(warn_use_async_alternative,none,
3381+
"consider using asynchronous alternative function",())
3382+
33803383
//------------------------------------------------------------------------------
33813384
// MARK: Type Check Expressions
33823385
//------------------------------------------------------------------------------
@@ -4311,6 +4314,8 @@ ERROR(asynchandler_noescape_closure_parameter,none,
43114314
ERROR(asynchandler_mutating,none,
43124315
"'@asyncHandler' function cannot be 'mutating'",
43134316
())
4317+
ERROR(asynchandler_removed,none,
4318+
"'@asyncHandler' has been removed from the language", ())
43144319

43154320
ERROR(objc_ambiguous_async_convention,none,
43164321
"%0 overrides or implements protocol requirements for Objective-C "
@@ -4827,7 +4832,7 @@ ERROR(objc_extension_not_class,none,
48274832
"'@objc' can only be applied to an extension of a class", ())
48284833

48294834
// If you change this, also change enum ObjCReason
4830-
#define OBJC_ATTR_SELECT "select{marked @_cdecl|marked dynamic|marked @objc|marked @IBOutlet|marked @IBAction|marked @IBSegueAction|marked @NSManaged|a member of an @objc protocol|implicitly @objc|an @objc override|an implementation of an @objc requirement|marked @IBInspectable|marked @GKInspectable|in an @objc extension of a class (without @nonobjc)}"
4835+
#define OBJC_ATTR_SELECT "select{marked @_cdecl|marked dynamic|marked @objc|marked @IBOutlet|marked @IBAction|marked @IBSegueAction|marked @NSManaged|a member of an @objc protocol|implicitly @objc|an @objc override|an implementation of an @objc requirement|marked @IBInspectable|marked @GKInspectable|in an @objc extension of a class (without @nonobjc)|marked @objc by an access note}"
48314836

48324837
WARNING(attribute_meaningless_when_nonobjc,none,
48334838
"'@%0' attribute is meaningless on a property that cannot be "

include/swift/AST/GenericSignature.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,6 @@ class alignas(1 << TypeAlignInBits) GenericSignatureImpl final
362362
/// Return the canonical version of the given type under this generic
363363
/// signature.
364364
CanType getCanonicalTypeInContext(Type type) const;
365-
CanType getCanonicalTypeInContext(Type type,
366-
GenericSignatureBuilder &builder) const;
367365

368366
bool isCanonicalTypeInContext(Type type) const;
369367
bool isCanonicalTypeInContext(Type type,

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ class GenericSignatureBuilder {
270270
struct CachedNestedType {
271271
unsigned numConformancesPresent;
272272
CanType superclassPresent;
273+
CanType concreteTypePresent;
273274
llvm::TinyPtrVector<TypeDecl *> types;
274275
};
275276

@@ -613,6 +614,10 @@ class GenericSignatureBuilder {
613614
/// because the type \c Dictionary<K,V> cannot be formed without it.
614615
void inferRequirements(ModuleDecl &module, ParameterList *params);
615616

617+
GenericSignature rebuildSignatureWithoutRedundantRequirements(
618+
bool allowConcreteGenericParams,
619+
bool buildingRequirementSignature) &&;
620+
616621
/// Finalize the set of requirements and compute the generic
617622
/// signature.
618623
///
@@ -793,6 +798,13 @@ class GenericSignatureBuilder {
793798
/// Simplify the given dependent type down to its canonical representation.
794799
Type getCanonicalTypeParameter(Type type);
795800

801+
/// Replace any non-canonical dependent types in the given type with their
802+
/// canonical representation. This is not a canonical type in the AST sense;
803+
/// type sugar is preserved. The GenericSignature::getCanonicalTypeInContext()
804+
/// method combines this with a subsequent getCanonicalType() call.
805+
Type getCanonicalTypeInContext(Type type,
806+
TypeArrayView<GenericTypeParamType> genericParams);
807+
796808
/// Verify the correctness of the given generic signature.
797809
///
798810
/// This routine will test that the given generic signature is both minimal

include/swift/AST/TypeCheckRequests.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2936,6 +2936,26 @@ class ConditionalRequirementsRequest
29362936
bool isCached() const { return true; }
29372937
};
29382938

2939+
class TypeCheckCompletionHandlerAsyncAttrRequest
2940+
: public SimpleRequest<TypeCheckCompletionHandlerAsyncAttrRequest,
2941+
bool(AbstractFunctionDecl *,
2942+
CompletionHandlerAsyncAttr *),
2943+
RequestFlags::Cached> {
2944+
public:
2945+
using SimpleRequest::SimpleRequest;
2946+
2947+
private:
2948+
friend SimpleRequest;
2949+
2950+
bool evaluate(Evaluator &evaluator,
2951+
AbstractFunctionDecl *attachedFucntionDecl,
2952+
CompletionHandlerAsyncAttr *attr) const;
2953+
2954+
public:
2955+
// Caching
2956+
bool isCached() const { return true; }
2957+
};
2958+
29392959
void simple_display(llvm::raw_ostream &out, Type value);
29402960
void simple_display(llvm::raw_ostream &out, const TypeRepr *TyR);
29412961
void simple_display(llvm::raw_ostream &out, ImplicitMemberAction action);

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,6 @@ SWIFT_REQUEST(TypeChecker, SynthesizeMainFunctionRequest,
323323
SWIFT_REQUEST(TypeChecker, GetImplicitSendableRequest,
324324
NormalProtocolConformance *(NominalTypeDecl *),
325325
Cached, NoLocationInfo)
326+
SWIFT_REQUEST(TypeChecker, TypeCheckCompletionHandlerAsyncAttrRequest,
327+
bool (AbstractFunctionDecl *, CompletionHandlerAsyncAttr *),
328+
Cached, NoLocationInfo)

include/swift/Basic/FileTypes.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ TYPE("index-unit-output-path", IndexUnitOutputPath, "", "")
8383
TYPE("yaml-opt-record", YAMLOptRecord, "opt.yaml", "")
8484
TYPE("bitstream-opt-record",BitstreamOptRecord, "opt.bitstream", "")
8585

86+
TYPE("symbol-graph-output-path", SymbolGraphOutputPath, "", "")
87+
8688
// Overlay files declare wrapper modules, called "separately-imported overlays",
8789
// that should be automatically imported when a particular module is imported.
8890
// Cross-import directories conditionalize overlay files so they only take

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ namespace swift {
250250
/// Enable experimental concurrency model.
251251
bool EnableExperimentalConcurrency = false;
252252

253+
/// Enable experimental asyncHandler support.
254+
bool EnableExperimentalAsyncHandler = false;
255+
253256
/// Enable experimental flow-sensitive concurrent captures.
254257
bool EnableExperimentalFlowSensitiveConcurrentCaptures = false;
255258

0 commit comments

Comments
 (0)