Skip to content

Commit f074a65

Browse files
authored
Merge pull request #4120 from swiftwasm/main
[pull] swiftwasm from main
2 parents 4c367ee + 3df6b7c commit f074a65

Some content is hidden

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

50 files changed

+695
-807
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,12 @@ include(CMakePushCheckState)
534534

535535
# Print out path and version of any installed commands
536536
message(STATUS "CMake (${CMAKE_COMMAND}) Version: ${CMAKE_VERSION}")
537-
execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} --version
537+
if(XCODE)
538+
set(version_flag -version)
539+
else()
540+
set(version_flag --version)
541+
endif()
542+
execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} ${version_flag}
538543
OUTPUT_VARIABLE _CMAKE_MAKE_PROGRAM_VERSION
539544
OUTPUT_STRIP_TRAILING_WHITESPACE)
540545
message(STATUS "CMake Make Program (${CMAKE_MAKE_PROGRAM}) Version: ${_CMAKE_MAKE_PROGRAM_VERSION}")

docs/Lexicon.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ the AST level. See also [witness table](#witness-table).
137137
An edge in a control flow graph where the destination has multiple predecessors
138138
and the source has multiple successors.
139139

140+
## currency type
141+
142+
A type that's meant to be commonly passed around and stored, like `Array`, as
143+
opposed to a type that's useful for temporary/internal purposes but which you
144+
wouldn't normally use in an external interface, like `ArraySlice`. Having broad
145+
agreement about the currency type you use for a particular kind of data (e.g.
146+
using `Array` to pass around sequential collections) generally makes the whole
147+
ecosystem better by reducing artificial barriers to passing data from one system
148+
to another, and it gives algorithm writers an obvious target to ensure they
149+
optimize for. That's where the analogy to currency comes from: agreeing on a
150+
currency type improves the flow of information in a program in some of the same
151+
ways that agreeing on a currency improves the flow of trade in an economy.
152+
140153
## customization point
141154

142155
Informal term for a protocol requirement that has a default implementation,

docs/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ documentation, please create a thread on the Swift forums under the
131131
Describes the design of the optimizer pipeline.
132132
- [HighLevelSILOptimizations.rst](/docs/HighLevelSILOptimizations.rst):
133133
Describes how the optimizer understands the semantics of high-level
134-
operations on currency data types and optimizes accordingly.
134+
operations on [currency](/docs/Lexicon.md#currency-type) data types and
135+
optimizes accordingly.
135136
Includes a thorough discussion of the `@_semantics` attribute.
136137

137138
### SourceKit subsystems

include/swift/AST/ASTMangler.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ class ASTMangler : public Mangler {
365365
ModuleDecl *fromModule);
366366
void appendImplFunctionType(SILFunctionType *fn, GenericSignature sig,
367367
const ValueDecl *forDecl = nullptr);
368+
void appendOpaqueTypeArchetype(ArchetypeType *archetype,
369+
OpaqueTypeDecl *opaqueDecl,
370+
SubstitutionMap subs,
371+
GenericSignature sig,
372+
const ValueDecl *forDecl);
368373

369374
void appendContextOf(const ValueDecl *decl);
370375

include/swift/AST/GenericEnvironment.h

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "swift/AST/GenericSignature.h"
2424
#include "swift/Basic/Compiler.h"
2525
#include "swift/Basic/Debug.h"
26+
#include "swift/Basic/UUID.h"
2627
#include "llvm/ADT/ArrayRef.h"
2728
#include "llvm/Support/ErrorHandling.h"
2829
#include "llvm/Support/TrailingObjects.h"
@@ -50,6 +51,12 @@ class QueryInterfaceTypeSubstitutions {
5051
Type operator()(SubstitutableType *type) const;
5152
};
5253

54+
/// Extra data in a generic environment for an opened existentiak.
55+
struct OpenedGenericEnvironmentData {
56+
Type existential;
57+
UUID uuid;
58+
};
59+
5360
/// Describes the mapping between archetypes and interface types for the
5461
/// generic parameters of a DeclContext.
5562
///
@@ -60,7 +67,8 @@ class QueryInterfaceTypeSubstitutions {
6067
///
6168
class alignas(1 << DeclAlignInBits) GenericEnvironment final
6269
: private llvm::TrailingObjects<
63-
GenericEnvironment, OpaqueTypeDecl *, SubstitutionMap, Type> {
70+
GenericEnvironment, OpaqueTypeDecl *, SubstitutionMap,
71+
OpenedGenericEnvironmentData, Type> {
6472
public:
6573
enum class Kind {
6674
/// A normal generic environment, determined only by its generic
@@ -72,16 +80,20 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
7280
Opaque,
7381
};
7482

83+
class NestedTypeStorage;
84+
7585
private:
7686
mutable llvm::PointerIntPair<GenericSignature, 2, Kind> SignatureAndKind{
7787
GenericSignature(), Kind::Normal};
88+
NestedTypeStorage *nestedTypeStorage = nullptr;
7889

7990
friend TrailingObjects;
8091
friend OpaqueTypeArchetypeType;
8192

8293
size_t numTrailingObjects(OverloadToken<OpaqueTypeDecl *>) const;
8394
size_t numTrailingObjects(OverloadToken<SubstitutionMap>) const;
8495
size_t numTrailingObjects(OverloadToken<Type>) const;
96+
size_t numTrailingObjects(OverloadToken<OpenedGenericEnvironmentData>) const;
8597

8698
/// Retrieve the array containing the context types associated with the
8799
/// generic parameters, stored in parallel with the generic parameters of the
@@ -93,7 +105,12 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
93105
/// generic signature.
94106
ArrayRef<Type> getContextTypes() const;
95107

96-
explicit GenericEnvironment(GenericSignature signature, Kind kind);
108+
/// Get the nested type storage, allocating it if required.
109+
NestedTypeStorage &getOrCreateNestedTypeStorage();
110+
111+
explicit GenericEnvironment(GenericSignature signature);
112+
explicit GenericEnvironment(
113+
GenericSignature signature, Type existential, UUID uuid);
97114
explicit GenericEnvironment(
98115
GenericSignature signature, OpaqueTypeDecl *opaque, SubstitutionMap subs);
99116

@@ -102,6 +119,10 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
102119

103120
Type getOrCreateArchetypeFromInterfaceType(Type depType);
104121

122+
/// Add a mapping of a generic parameter to a specific type (which may be
123+
/// an archetype)
124+
void addMapping(GenericParamKey key, Type contextType);
125+
105126
/// Retrieve the mapping for the given generic parameter, if present.
106127
///
107128
/// This is only useful when lazily populating a generic environment.
@@ -116,6 +137,12 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
116137

117138
TypeArrayView<GenericTypeParamType> getGenericParams() const;
118139

140+
/// Retrieve the existential type for an opened existential environment.
141+
Type getOpenedExistentialType() const;
142+
143+
/// Retrieve the UUID for an opened existential environment.
144+
UUID getOpenedExistentialUUID() const;
145+
119146
/// Retrieve the opaque type declaration for a generic environment describing
120147
/// opaque types.
121148
OpaqueTypeDecl *getOpaqueTypeDecl() const;
@@ -130,18 +157,13 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
130157
GenericEnvironment *getIncomplete(GenericSignature signature);
131158

132159
/// Create a new generic environment for an opened existential.
133-
static GenericEnvironment *forOpenedExistential(
134-
GenericSignature signature, const OpenedArchetypeType *type);
160+
static GenericEnvironment *forOpenedExistential(Type existential, UUID uuid);
135161

136162
/// Create a new generic environment for an opaque type with the given set of
137163
/// outer substitutions.
138164
static GenericEnvironment *forOpaqueType(
139165
OpaqueTypeDecl *opaque, SubstitutionMap subs, AllocationArena arena);
140166

141-
/// Add a mapping of a generic parameter to a specific type (which may be
142-
/// an archetype)
143-
void addMapping(GenericParamKey key, Type contextType);
144-
145167
/// Make vanilla new/delete illegal.
146168
void *operator new(size_t Bytes) = delete;
147169
void operator delete(void *Data) = delete;

include/swift/AST/GenericSignature.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ class alignas(1 << TypeAlignInBits) GenericSignatureImpl final
390390

391391
bool isCanonicalTypeInContext(Type type) const;
392392

393+
bool isValidTypeInContext(Type type) const;
394+
393395
/// Retrieve the conformance access path used to extract the conformance of
394396
/// interface \c type to the given \c protocol.
395397
///

include/swift/AST/TypeNodes.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ ABSTRACT_TYPE(Substitutable, Type)
147147
ALWAYS_CANONICAL_TYPE(PrimaryArchetype, ArchetypeType)
148148
ALWAYS_CANONICAL_TYPE(OpaqueTypeArchetype, ArchetypeType)
149149
ALWAYS_CANONICAL_TYPE(OpenedArchetype, ArchetypeType)
150-
ALWAYS_CANONICAL_TYPE(NestedArchetype, ArchetypeType)
151150
ALWAYS_CANONICAL_TYPE(SequenceArchetype, ArchetypeType)
152151
TYPE_RANGE(Archetype, PrimaryArchetype, SequenceArchetype)
153152
TYPE(GenericTypeParam, SubstitutableType)

0 commit comments

Comments
 (0)