Skip to content

Commit b024c81

Browse files
Merge pull request #4755 from swiftwasm/main
[pull] swiftwasm from main
2 parents 54bb646 + 9eb6dd3 commit b024c81

File tree

115 files changed

+1081
-4762
lines changed

Some content is hidden

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

115 files changed

+1081
-4762
lines changed

SwiftCompilerSources/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,6 @@ else()
295295
set(compatibility_libs
296296
"swiftCompatibility50-${platform}"
297297
"swiftCompatibility51-${platform}"
298-
"swiftCompatibility56-${platform}"
299-
"swiftCompatibilityConcurrency-${platform}"
300298
"swiftCompatibilityDynamicReplacements-${platform}")
301299

302300
list(APPEND b0_deps ${compatibility_libs})

docs/CppInteroperability/SwiftTypeRepresentationInC++.md

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ C++.
88

99
### Value Types
1010

11-
1) Primitive Swift types like `Int`, `Float` , `OpaquePointer`, `UnsafePointer<int>?` are mapped to primitive C++ types. `int` , `float`, `void *`, int `* _Nullable` .
11+
1) Primitive Swift types like `Int`, `Float` , `OpaquePointer`, `UnsafePointer<int>?` are mapped to primitive C++ types. `int` , `float`, `void *`, `int * _Nullable`.
1212

1313
* Debug info: Does C++ debug info suffices?
1414

@@ -29,13 +29,23 @@ class swift::String {
2929
```c++
3030
class Foundation::URL {
3131
...
32-
union {
33-
alignas(8) char buffer[8]; // Swift value is stored here.
34-
void *resilientPtr;
35-
};
32+
uintptr_t pointer; // pointer has alignment to compute buffer offset?
33+
alignas(N) char buffer[M]; // Swift value is stored here.
3634
};
3735
```
3836

37+
concrete examples:
38+
39+
```c++
40+
// representation for buffer aligned at 8:
41+
{/*pointer=*/0x3, ....}; // buffer is alignas(2^3 = 8)
42+
43+
// representation for buffer aligned at 16:
44+
{/*pointer=*/0x4, ....}; // buffer is alignas(2^4 = 16)
45+
46+
// where pointer < 10 for inline stores.
47+
```
48+
3949
* Debug info: ...
4050
4151
@@ -44,10 +54,8 @@ class Foundation::URL {
4454
```c++
4555
class CryptoKit::SHA256 {
4656
...
47-
union {
48-
alignas(8) char buffer[8];
49-
void *resilientPtr; // Swift value is stored on the heap pointed by this pointer.
50-
};
57+
uintptr_t pointer; // Swift value is stored on the heap pointed by this pointer.
58+
alignas(8) char buffer[8];
5159
};
5260
```
5361

@@ -66,15 +74,13 @@ class swift::Array<swift::Int> {
6674
* Debug info: ...
6775
6876
69-
6) Generic opaque-layout / resilient / opaque-layout template type params Swift value type, e.g. SHA256`?`, is mapped to a C++ class that stores the value boxed up on the heap, e.g.:
77+
6) Generic opaque-layout / resilient / opaque-layout template type params Swift value type, e.g. `SHA256?`, is mapped to a C++ class that stores the value boxed up on the heap, e.g.:
7078
7179
```c++
7280
class swift::Optional<CryptoKit::SHA256> {
7381
...
74-
union {
75-
alignas(8) char buffer[8];
76-
void *resilientPtr; // Swift value is stored on the heap pointed by this pointer.
77-
};
82+
uintptr_t pointer; // Swift value is stored on the heap pointed by this pointer.
83+
alignas(N) char buffer[M];
7884
}
7985
```
8086

docs/Lexicon.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ thunk helpers" sometimes seen in Swift backtraces come from.)
4949

5050
Broadly, an "access path" is a list of "accesses" which must be chained together
5151
to compute some output from an input. For instance, the generics system has a
52-
type called a `ConformanceAccessPath` which explains how to, for example,
52+
type called a `ConformancePath` which explains how to, for example,
5353
walk from `T: Collection` to `T: Sequence` to `T.Iterator: IteratorProtocol`.
5454
There are several different kinds of "access path" in different parts of the compiler,
5555
but they all follow this basic theme.

include/swift/AST/ASTMangler.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class NamedDecl;
2525
namespace swift {
2626

2727
class AbstractClosureExpr;
28-
class ConformanceAccessPath;
28+
class ConformancePath;
2929
class RootProtocolConformance;
3030

3131
namespace Mangle {
@@ -560,7 +560,7 @@ class ASTMangler : public Mangler {
560560
void appendConcreteProtocolConformance(
561561
const ProtocolConformance *conformance,
562562
GenericSignature sig);
563-
void appendDependentProtocolConformance(const ConformanceAccessPath &path,
563+
void appendDependentProtocolConformance(const ConformancePath &path,
564564
GenericSignature sig);
565565
void appendOpParamForLayoutConstraint(LayoutConstraint Layout);
566566

include/swift/AST/GenericSignature.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace rewriting {
7070
/// \c Sequence conformance of \c C (because \c Collection inherits
7171
/// \c Sequence). Finally, it extracts the conformance of the associated type
7272
/// \c Iterator to \c IteratorProtocol from the \c Sequence protocol.
73-
class ConformanceAccessPath {
73+
class ConformancePath {
7474
public:
7575
/// An entry in the conformance access path, which is described by the
7676
/// dependent type on which the conformance is stated as the protocol to
@@ -80,7 +80,7 @@ class ConformanceAccessPath {
8080
private:
8181
ArrayRef<Entry> path;
8282

83-
ConformanceAccessPath(ArrayRef<Entry> path) : path(path) {}
83+
ConformancePath(ArrayRef<Entry> path) : path(path) {}
8484

8585
friend class GenericSignatureImpl;
8686
friend class rewriting::RequirementMachine;
@@ -213,9 +213,9 @@ class GenericSignature {
213213
SmallVector<Requirement, 4>
214214
requirementsNotSatisfiedBy(GenericSignature otherSig) const;
215215

216-
/// Return the canonical version of the given type under this generic
216+
/// Return the reduced version of the given type under this generic
217217
/// signature.
218-
CanType getCanonicalTypeInContext(Type type) const;
218+
CanType getReducedType(Type type) const;
219219

220220
/// Check invariants.
221221
void verify() const;
@@ -383,7 +383,7 @@ class alignas(1 << TypeAlignInBits) GenericSignatureImpl final
383383
/// generic signature.
384384
///
385385
/// The type parameters must be known to not be concrete within the context.
386-
bool areSameTypeParameterInContext(Type type1, Type type2) const;
386+
bool areReducedTypeParametersEqual(Type type1, Type type2) const;
387387

388388
/// Determine if \c sig can prove \c requirement, meaning that it can deduce
389389
/// T: Foo or T == U (etc.) with the information it knows. This includes
@@ -392,26 +392,26 @@ class alignas(1 << TypeAlignInBits) GenericSignatureImpl final
392392
bool isRequirementSatisfied(
393393
Requirement requirement, bool allowMissing = false) const;
394394

395-
bool isCanonicalTypeInContext(Type type) const;
395+
bool isReducedType(Type type) const;
396396

397397
/// Determine whether the given type parameter is defined under this generic
398398
/// signature.
399-
bool isValidTypeInContext(Type type) const;
399+
bool isValidTypeParameter(Type type) const;
400400

401-
/// Retrieve the conformance access path used to extract the conformance of
401+
/// Retrieve the conformance path used to extract the conformance of
402402
/// interface \c type to the given \c protocol.
403403
///
404-
/// \param type The interface type whose conformance access path is to be
404+
/// \param type The type parameter whose conformance path is to be
405405
/// queried.
406406
/// \param protocol A protocol to which \c type conforms.
407407
///
408-
/// \returns the conformance access path that starts at a requirement of
408+
/// \returns the conformance path that starts at a requirement of
409409
/// this generic signature and ends at the conformance that makes \c type
410410
/// conform to \c protocol.
411411
///
412-
/// \seealso ConformanceAccessPath
413-
ConformanceAccessPath getConformanceAccessPath(Type type,
414-
ProtocolDecl *protocol) const;
412+
/// \seealso ConformancePath
413+
ConformancePath getConformancePath(Type type,
414+
ProtocolDecl *protocol) const;
415415

416416
/// Lookup a nested type with the given name within this type parameter.
417417
TypeDecl *lookupNestedType(Type type, Identifier name) const;
@@ -487,9 +487,9 @@ class alignas(1 << TypeAlignInBits) GenericSignatureImpl final
487487
SmallVector<Requirement, 4>
488488
requirementsNotSatisfiedBy(GenericSignature otherSig) const;
489489

490-
/// Return the canonical version of the given type under this generic
490+
/// Return the reduced version of the given type under this generic
491491
/// signature.
492-
CanType getCanonicalTypeInContext(Type type) const;
492+
CanType getReducedType(Type type) const;
493493
};
494494

495495
void simple_display(raw_ostream &out, GenericSignature sig);

include/swift/AST/Types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,9 @@ class alignas(1 << TypeAlignInBits) TypeBase
503503
return const_cast<TypeBase*>(this)->computeCanonicalType();
504504
}
505505

506-
/// getCanonicalType - Stronger canonicalization which folds away equivalent
506+
/// getReducedType - Stronger canonicalization which folds away equivalent
507507
/// associated types, or type parameters that have been made concrete.
508-
CanType getCanonicalType(GenericSignature sig);
508+
CanType getReducedType(GenericSignature sig);
509509

510510
/// Canonical protocol composition types are minimized only to a certain
511511
/// degree to preserve ABI compatibility. This routine enables performing

include/swift/Basic/Statistics.def

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,8 @@ FRONTEND_STATISTIC(Sema, NumRequirementMachineCompletionSteps)
230230
/// Number of new rules added by concrete term unification.
231231
FRONTEND_STATISTIC(Sema, NumRequirementMachineUnifiedConcreteTerms)
232232

233-
/// Number of generic signature builders constructed. Rough proxy for
234-
/// amount of work the GSB does analyzing type signatures.
235-
FRONTEND_STATISTIC(Sema, NumGenericSignatureBuilders)
236-
237-
/// Number of steps in the GSB's redundant requirements algorithm, which is in
238-
/// the worst-case exponential.
239-
FRONTEND_STATISTIC(Sema, NumRedundantRequirementSteps)
240-
241-
/// Number of conformance access paths we had to compute.
242-
FRONTEND_STATISTIC(Sema, NumConformanceAccessPathsRecorded)
233+
/// Number of conformance paths we had to compute.
234+
FRONTEND_STATISTIC(Sema, NumConformancePathsRecorded)
243235

244236
/// Number of lazy requirement signatures registered.
245237
FRONTEND_STATISTIC(Sema, NumLazyRequirementSignatures)

include/swift/Frontend/BackDeploymentLibs.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,5 @@ BACK_DEPLOYMENT_LIB((5, 0), all, "swiftCompatibility50")
2828
BACK_DEPLOYMENT_LIB((5, 1), all, "swiftCompatibility51")
2929
BACK_DEPLOYMENT_LIB((5, 0), executable, "swiftCompatibilityDynamicReplacements")
3030
BACK_DEPLOYMENT_LIB((5, 4), all, "swiftCompatibilityConcurrency")
31-
BACK_DEPLOYMENT_LIB((5, 6), all, "swiftCompatibility56")
3231

3332
#undef BACK_DEPLOYMENT_LIB

include/swift/SIL/AbstractionPattern.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ class AbstractionPattern {
514514
OrigType = origType;
515515
GenericSig = CanGenericSignature();
516516
if (OrigType->hasTypeParameter()) {
517-
assert(OrigType == signature.getCanonicalTypeInContext(origType));
517+
assert(OrigType == signature.getReducedType(origType));
518518
GenericSig = signature;
519519
}
520520
}

include/swift/SIL/SILGlobalVariable.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ class SILGlobalVariable
125125
return getLoweredTypeInContext(context).castTo<SILFunctionType>();
126126
}
127127

128+
void unsafeSetLoweredType(SILType newType) { LoweredType = newType; }
129+
void unsafeAppend(SILInstruction *i) { StaticInitializerBlock.push_back(i); }
130+
void unsafeRemove(SILInstruction *i, SILModule &mod) {
131+
StaticInitializerBlock.erase(i, mod);
132+
}
133+
128134
StringRef getName() const { return Name; }
129135

130136
void setDeclaration(bool isD) { IsDeclaration = isD; }

0 commit comments

Comments
 (0)