6767#include < algorithm>
6868#include < memory>
6969
70- #include " RequirementMachine/RequirementMachine.h"
7170#include " RequirementMachine/RewriteContext.h"
7271
7372using namespace swift ;
@@ -538,14 +537,6 @@ struct ASTContext::Implementation {
538537
539538 // / Memory allocation arena for the term rewriting system.
540539 std::unique_ptr<rewriting::RewriteContext> TheRewriteContext;
541-
542- // / Stored requirement machines for canonical generic signatures.
543- // /
544- // / This should come after TheRewriteContext above, since various destructors
545- // / compile stats in the histograms stored in our RewriteContext.
546- llvm::DenseMap<GenericSignature,
547- std::unique_ptr<rewriting::RequirementMachine>>
548- RequirementMachines;
549540};
550541
551542ASTContext::Implementation::Implementation ()
@@ -1965,32 +1956,7 @@ ASTContext::getOrCreateRequirementMachine(CanGenericSignature sig) {
19651956 if (!rewriteCtx)
19661957 rewriteCtx.reset (new rewriting::RewriteContext (*this ));
19671958
1968- // Check whether we already have a requirement machine for this
1969- // signature.
1970- auto &machines = getImpl ().RequirementMachines ;
1971-
1972- auto &machinePtr = machines[sig];
1973- if (machinePtr) {
1974- auto *machine = machinePtr.get ();
1975- if (!machine->isComplete ()) {
1976- llvm::errs () << " Re-entrant construction of requirement "
1977- << " machine for " << sig << " \n " ;
1978- abort ();
1979- }
1980-
1981- return machine;
1982- }
1983-
1984- auto *machine = new rewriting::RequirementMachine (*rewriteCtx);
1985-
1986- // Store this requirement machine before adding the signature,
1987- // to catch re-entrant construction via addGenericSignature()
1988- // below.
1989- machinePtr.reset (machine);
1990-
1991- machine->addGenericSignature (sig);
1992-
1993- return machine;
1959+ return rewriteCtx->getRequirementMachine (sig);
19941960}
19951961
19961962bool ASTContext::isRecursivelyConstructingRequirementMachine (
@@ -1999,13 +1965,7 @@ bool ASTContext::isRecursivelyConstructingRequirementMachine(
19991965 if (!rewriteCtx)
20001966 return false ;
20011967
2002- auto &machines = getImpl ().RequirementMachines ;
2003-
2004- auto found = machines.find (sig);
2005- if (found == machines.end ())
2006- return false ;
2007-
2008- return !found->second ->isComplete ();
1968+ return rewriteCtx->isRecursivelyConstructingRequirementMachine (sig);
20091969}
20101970
20111971Optional<llvm::TinyPtrVector<ValueDecl *>>
0 commit comments