Skip to content

Commit 4b504e3

Browse files
committed
---
yaml --- r: 348505 b: refs/heads/master c: 5b3fdba h: refs/heads/master i: 348503: aac7f3c
1 parent c1d34f4 commit 4b504e3

Some content is hidden

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

48 files changed

+245
-664
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 6aecd4546404132f8ca28289c59f436a3885d919
2+
refs/heads/master: 5b3fdba240e8ba9b7ed43fab9ad19f6f1afad570
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/AST/ASTContext.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ namespace swift {
6868
class InFlightDiagnostic;
6969
class IterableDeclContext;
7070
class LazyContextData;
71-
class LazyGenericContextData;
7271
class LazyIterableDeclContextData;
7372
class LazyMemberLoader;
7473
class LazyResolver;
@@ -817,15 +816,6 @@ class ASTContext final {
817816
LazyContextData *getOrCreateLazyContextData(const DeclContext *decl,
818817
LazyMemberLoader *lazyLoader);
819818

820-
/// Get the lazy function data for the given generic context.
821-
///
822-
/// \param lazyLoader If non-null, the lazy loader to use when creating the
823-
/// function data. The pointer must either be null or be consistent
824-
/// across all calls for the same \p func.
825-
LazyGenericContextData *getOrCreateLazyGenericContextData(
826-
const GenericContext *dc,
827-
LazyMemberLoader *lazyLoader);
828-
829819
/// Get the lazy iterable context for the given iterable declaration context.
830820
///
831821
/// \param lazyLoader If non-null, the lazy loader to use when creating the
@@ -876,12 +866,6 @@ class ASTContext final {
876866
GenericSignatureBuilder *getOrCreateGenericSignatureBuilder(
877867
CanGenericSignature sig);
878868

879-
/// Retrieve or create the canonical generic environment of a canonical
880-
/// generic signature builder.
881-
GenericEnvironment *getOrCreateCanonicalGenericEnvironment(
882-
GenericSignatureBuilder *builder,
883-
GenericSignature *sig);
884-
885869
/// Retrieve a generic signature with a single unconstrained type parameter,
886870
/// like `<T>`.
887871
CanGenericSignature getSingleGenericParameterSignature() const;

trunk/include/swift/AST/Decl.h

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,18 +1482,11 @@ class alignas(8) _GenericContext {
14821482
/// moves the trailing where clause into the generic parameter list.
14831483
TrailingWhereClause *TrailingWhere = nullptr;
14841484

1485-
/// The generic signature or environment of this declaration.
1486-
///
1487-
/// When this declaration stores only a signature, the generic
1488-
/// environment will be lazily loaded.
1489-
mutable llvm::PointerUnion<GenericSignature *, GenericEnvironment *>
1490-
GenericSigOrEnv;
1485+
/// The generic signature of this declaration.
1486+
GenericSignature *GenericSig = nullptr;
14911487
};
14921488

14931489
class GenericContext : private _GenericContext, public DeclContext {
1494-
/// Lazily populate the generic environment.
1495-
GenericEnvironment *getLazyGenericEnvironmentSlow() const;
1496-
14971490
protected:
14981491
GenericContext(DeclContextKind Kind, DeclContext *Parent)
14991492
: _GenericContext(), DeclContext(Kind, Parent) { }
@@ -1542,17 +1535,8 @@ class GenericContext : private _GenericContext, public DeclContext {
15421535
/// Retrieve the generic requirements.
15431536
ArrayRef<Requirement> getGenericRequirements() const;
15441537

1545-
/// Set a lazy generic environment.
1546-
void setLazyGenericEnvironment(LazyMemberLoader *lazyLoader,
1547-
GenericSignature *genericSig,
1548-
uint64_t genericEnvData);
1549-
1550-
/// Whether this generic context has a lazily-created generic environment
1551-
/// that has not yet been constructed.
1552-
bool hasLazyGenericEnvironment() const;
1553-
1554-
/// Set the generic context of this context.
1555-
void setGenericEnvironment(GenericEnvironment *genericEnv);
1538+
/// Set the generic signature of this context.
1539+
void setGenericSignature(GenericSignature *genericSig);
15561540

15571541
/// Retrieve the position of any where clause for this context's
15581542
/// generic parameters.

trunk/include/swift/AST/DeclContext.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,6 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
360360
/// of its parents.
361361
GenericEnvironment *getGenericEnvironmentOfContext() const;
362362

363-
/// Whether the context has a generic environment that will be constructed
364-
/// on first access (but has not yet been constructed).
365-
bool contextHasLazyGenericEnvironment() const;
366-
367363
/// Map an interface type to a contextual type within this context.
368364
Type mapTypeIntoContext(Type type) const;
369365

trunk/include/swift/AST/GenericEnvironment.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
5959
: private llvm::TrailingObjects<GenericEnvironment, Type> {
6060
GenericSignature *Signature = nullptr;
6161
GenericSignatureBuilder *Builder = nullptr;
62-
DeclContext *OwningDC = nullptr;
6362

6463
friend TrailingObjects;
6564

@@ -98,18 +97,6 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
9897
GenericEnvironment *getIncomplete(GenericSignature *signature,
9998
GenericSignatureBuilder *builder);
10099

101-
/// Set the owning declaration context for this generic environment.
102-
void setOwningDeclContext(DeclContext *owningDC);
103-
104-
/// Retrieve the declaration context that owns this generic environment, if
105-
/// there is one.
106-
///
107-
/// Note that several generic environments may refer to the same declaration
108-
/// context, because non-generic declarations nested within generic ones
109-
/// inherit the enclosing generic environment. In such cases, the owning
110-
/// context is the outermost context.
111-
DeclContext *getOwningDeclContext() const { return OwningDC; }
112-
113100
/// Add a mapping of a generic parameter to a specific type (which may be
114101
/// an archetype)
115102
void addMapping(GenericParamKey key, Type contextType);

trunk/include/swift/AST/GenericSignature.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class GenericSignatureBuilder;
3232
class ProtocolConformanceRef;
3333
class ProtocolType;
3434
class SubstitutionMap;
35+
class GenericEnvironment;
3536

3637
/// An access path used to find a particular protocol conformance within
3738
/// a generic signature.
@@ -101,6 +102,8 @@ class alignas(1 << TypeAlignInBits) GenericSignature final
101102
unsigned NumGenericParams;
102103
unsigned NumRequirements;
103104

105+
GenericEnvironment *GenericEnv = nullptr;
106+
104107
// Make vanilla new/delete illegal.
105108
void *operator new(size_t Bytes) = delete;
106109
void operator delete(void *Data) = delete;
@@ -132,9 +135,6 @@ class alignas(1 << TypeAlignInBits) GenericSignature final
132135
static ASTContext &getASTContext(TypeArrayView<GenericTypeParamType> params,
133136
ArrayRef<Requirement> requirements);
134137

135-
/// Retrieve the generic signature builder for the given generic signature.
136-
GenericSignatureBuilder *getGenericSignatureBuilder();
137-
138138
void buildConformanceAccessPath(
139139
SmallVectorImpl<ConformanceAccessPath::Entry> &path,
140140
ArrayRef<Requirement> reqs,
@@ -218,10 +218,13 @@ class alignas(1 << TypeAlignInBits) GenericSignature final
218218
/// Canonicalize the components of a generic signature.
219219
CanGenericSignature getCanonicalSignature() const;
220220

221-
/// Create a new generic environment that provides fresh contextual types
221+
/// Retrieve the generic signature builder for the given generic signature.
222+
GenericSignatureBuilder *getGenericSignatureBuilder();
223+
224+
/// Returns the generic environment that provides fresh contextual types
222225
/// (archetypes) that correspond to the interface types in this generic
223226
/// signature.
224-
GenericEnvironment *createGenericEnvironment();
227+
GenericEnvironment *getGenericEnvironment();
225228

226229
/// Uniquing for the ASTContext.
227230
void Profile(llvm::FoldingSetNodeID &ID) {

trunk/include/swift/AST/LazyResolver.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,8 @@ class LazyContextData {
8585
LazyMemberLoader *loader;
8686
};
8787

88-
/// Context data for generic contexts.
89-
class LazyGenericContextData : public LazyContextData {
90-
public:
91-
/// The context data used for loading the generic environment.
92-
uint64_t genericEnvData = 0;
93-
};
94-
9588
/// Context data for iterable decl contexts.
96-
class LazyIterableDeclContextData : public LazyGenericContextData {
89+
class LazyIterableDeclContextData : public LazyContextData {
9790
public:
9891
/// The context data used for loading all of the members of the iterable
9992
/// context.
@@ -145,10 +138,6 @@ class alignas(void*) LazyMemberLoader {
145138
virtual Type loadAssociatedTypeDefault(const AssociatedTypeDecl *ATD,
146139
uint64_t contextData) = 0;
147140

148-
/// Returns the generic environment.
149-
virtual GenericEnvironment *loadGenericEnvironment(const DeclContext *decl,
150-
uint64_t contextData) = 0;
151-
152141
/// Loads the requirement signature for a protocol.
153142
virtual void
154143
loadRequirementSignature(const ProtocolDecl *proto, uint64_t contextData,

trunk/include/swift/AST/Type.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,6 @@ class CanGenericSignature {
604604
explicit CanGenericSignature(GenericSignature *Signature);
605605
ArrayRef<CanTypeWrapper<GenericTypeParamType>> getGenericParams() const;
606606

607-
/// Retrieve the canonical generic environment associated with this
608-
/// generic signature.
609-
GenericEnvironment *getGenericEnvironment() const;
610-
611607
GenericSignature *operator->() const {
612608
return Signature;
613609
}
@@ -620,7 +616,7 @@ class CanGenericSignature {
620616
return Signature;
621617
}
622618

623-
bool operator==(const swift::CanGenericSignature& other) {
619+
bool operator==(const swift::CanGenericSignature &other) {
624620
return Signature == other.Signature;
625621
}
626622
};

trunk/include/swift/Basic/Statistics.def

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,6 @@ FRONTEND_STATISTIC(Sema, NumFunctionsTypechecked)
249249
/// amount of work the GSB does analyzing type signatures.
250250
FRONTEND_STATISTIC(Sema, NumGenericSignatureBuilders)
251251

252-
/// Number of lazy generic environments registered.
253-
FRONTEND_STATISTIC(Sema, NumLazyGenericEnvironments)
254-
255-
/// Number of lazy generic environments deserialized.
256-
FRONTEND_STATISTIC(Sema, NumLazyGenericEnvironmentsLoaded)
257-
258252
/// Number of lazy requirement signatures registered.
259253
FRONTEND_STATISTIC(Sema, NumLazyRequirementSignatures)
260254

trunk/lib/AST/ASTContext.cpp

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,6 @@ FOR_KNOWN_FOUNDATION_TYPES(CACHE_FOUNDATION_DECL)
370370
llvm::DenseMap<GenericSignature *, std::unique_ptr<GenericSignatureBuilder>>
371371
GenericSignatureBuilders;
372372

373-
/// Canonical generic environments for canonical generic signatures.
374-
///
375-
/// The keys are the generic signature builders in
376-
/// \c GenericSignatureBuilders.
377-
llvm::DenseMap<GenericSignatureBuilder *, GenericEnvironment *>
378-
CanonicalGenericEnvironments;
379-
380373
/// The set of function types.
381374
llvm::FoldingSet<FunctionType> FunctionTypes;
382375

@@ -1623,22 +1616,6 @@ GenericSignatureBuilder *ASTContext::getOrCreateGenericSignatureBuilder(
16231616
return builder;
16241617
}
16251618

1626-
GenericEnvironment *ASTContext::getOrCreateCanonicalGenericEnvironment(
1627-
GenericSignatureBuilder *builder,
1628-
GenericSignature *sig) {
1629-
auto arena = getArena(sig);
1630-
auto &canonicalGenericEnvironments =
1631-
getImpl().getArena(arena).CanonicalGenericEnvironments;
1632-
1633-
auto known = canonicalGenericEnvironments.find(builder);
1634-
if (known != canonicalGenericEnvironments.end())
1635-
return known->second;
1636-
1637-
auto env = sig->createGenericEnvironment();
1638-
canonicalGenericEnvironments[builder] = env;
1639-
return env;
1640-
}
1641-
16421619
Optional<llvm::TinyPtrVector<ValueDecl *>>
16431620
OverriddenDeclsRequest::getCachedResult() const {
16441621
auto decl = std::get<0>(getStorage());
@@ -1993,10 +1970,10 @@ LazyContextData *ASTContext::getOrCreateLazyContextData(
19931970
assert(lazyLoader && "Queried lazy data for non-lazy iterable context");
19941971
if (isa<ProtocolDecl>(dc))
19951972
entry = Allocate<LazyProtocolData>();
1996-
else if (isa<NominalTypeDecl>(dc) || isa<ExtensionDecl>(dc))
1973+
else {
1974+
assert(isa<NominalTypeDecl>(dc) || isa<ExtensionDecl>(dc));
19971975
entry = Allocate<LazyIterableDeclContextData>();
1998-
else
1999-
entry = Allocate<LazyGenericContextData>();
1976+
}
20001977

20011978
entry->loader = lazyLoader;
20021979
return entry;
@@ -2015,13 +1992,6 @@ LazyIterableDeclContextData *ASTContext::getOrCreateLazyIterableContextData(
20151992
lazyLoader);
20161993
}
20171994

2018-
LazyGenericContextData *ASTContext::getOrCreateLazyGenericContextData(
2019-
const GenericContext *dc,
2020-
LazyMemberLoader *lazyLoader) {
2021-
return (LazyGenericContextData *)getOrCreateLazyContextData(dc,
2022-
lazyLoader);
2023-
}
2024-
20251995
bool ASTContext::hasDelayedConformanceErrors() const {
20261996
for (const auto &entry : getImpl().DelayedConformanceDiags) {
20271997
auto &diagnostics = entry.getSecond();
@@ -3653,7 +3623,8 @@ OpaqueTypeArchetypeType::get(OpaqueTypeDecl *Decl,
36533623

36543624
// Create a generic environment and bind the opaque archetype to the
36553625
// opaque interface type from the decl's signature.
3656-
auto env = signature->createGenericEnvironment();
3626+
auto *builder = signature->getGenericSignatureBuilder();
3627+
auto *env = GenericEnvironment::getIncomplete(signature, builder);
36573628
env->addMapping(GenericParamKey(opaqueInterfaceTy), newOpaque);
36583629
newOpaque->Environment = env;
36593630

@@ -3726,7 +3697,8 @@ GenericEnvironment *OpenedArchetypeType::getGenericEnvironment() const {
37263697
// Create a generic environment to represent the opened type.
37273698
auto signature = ctx.getExistentialSignature(Opened->getCanonicalType(),
37283699
nullptr);
3729-
auto env = signature->createGenericEnvironment();
3700+
auto *builder = signature->getGenericSignatureBuilder();
3701+
auto *env = GenericEnvironment::getIncomplete(signature, builder);
37303702
env->addMapping(signature->getGenericParams()[0], thisType);
37313703
Environment = env;
37323704

trunk/lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3519,10 +3519,6 @@ namespace {
35193519
printArchetypeCommon(T, "primary_archetype_type", label);
35203520
printField("name", T->getFullName());
35213521
OS << "\n";
3522-
auto genericEnv = T->getGenericEnvironment();
3523-
if (auto owningDC = genericEnv->getOwningDeclContext()) {
3524-
owningDC->printContext(OS, Indent + 2);
3525-
}
35263522
printArchetypeNestedTypes(T);
35273523
PrintWithColorRAII(OS, ParenthesisColor) << ')';
35283524
}

0 commit comments

Comments
 (0)