Skip to content

[NameLookup ] UnqualifiedLookup refactoring #22578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 70 commits into from
Mar 1, 2019

Conversation

davidungar
Copy link
Contributor

@davidungar davidungar commented Feb 13, 2019

Refactor UnqualifiedLookup. All the work was done in the constructor. This PR adds an UnqualifiedLookupFactory, and refactors all the code in the constructor for the sake of clarity. It should be no functional change. It retains the legacy code for now, and performs a cross-check when assertions are enabled.

@davidungar
Copy link
Contributor Author

@swift-ci please test os x platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - abcb74f2f8002a221f22ab4b8a2de52956595c77

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test os x platform

1 similar comment
@davidungar
Copy link
Contributor Author

@swift-ci please smoke test os x platform

@davidungar
Copy link
Contributor Author

@swift-ci please test os x platform

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - abcb74f2f8002a221f22ab4b8a2de52956595c77

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test os x platform

4 similar comments
@davidungar
Copy link
Contributor Author

@swift-ci please smoke test os x platform

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test os x platform

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test os x platform

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test os x platform

@davidungar davidungar force-pushed the A-2-12 branch 2 times, most recently from d52f8b6 to fef5b50 Compare February 16, 2019 16:41
@davidungar
Copy link
Contributor Author

@swift-ci please smoke test os x platform

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test os x platform

@davidungar
Copy link
Contributor Author

@swift-ci please test os x platform

@davidungar
Copy link
Contributor Author

@swift-ci please test source compatibility

@davidungar
Copy link
Contributor Author

@swift-ci please ASAN test

@davidungar
Copy link
Contributor Author

@swift-ci please test compiler performance

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test compiler performance

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test os x platform

@swift-ci
Copy link
Contributor

Summary for master full

Unexpected test results, excluded stats for CoreStore, Tagged, ProcedureKit, Wordy, Deferred

Regressions found (see below)

Debug-batch

debug-batch brief

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 26,808,751,495,244 26,730,444,105,998 -78,307,389,246 -0.29%
LLVM.NumLLVMBytesOutput 962,231,274 962,230,246 -1,028 -0.0%
time.swift-driver.wall 2563.3s 2555.8s -7.5s -0.29%

debug-batch detailed

Regressed (2)
name old new delta delta_pct
Driver.NumDriverPipePolls 166,121 169,479 3,358 2.02% ⛔
Driver.NumDriverPipeReads 183,142 186,662 3,520 1.92% ⛔
Improved (1)
name old new delta delta_pct
Sema.USRGenerationRequest 12,282,475 12,142,855 -139,620 -1.14% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (96)
name old new delta delta_pct
AST.NumASTBytesAllocated 65,413,444,797 65,270,570,837 -142,873,960 -0.22%
AST.NumDecls 80,406 80,406 0 0.0%
AST.NumDependencies 204,745 204,750 5 0.0%
AST.NumImportedExternalDefinitions 1,085,694 1,085,694 0 0.0%
AST.NumInfixOperators 30,936 30,936 0 0.0%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 243,927 243,927 0 0.0%
AST.NumLocalTypeDecls 108 108 0 0.0%
AST.NumObjCMethods 9,687 9,687 0 0.0%
AST.NumPostfixOperators 18 18 0 0.0%
AST.NumPrecedenceGroups 14,464 14,464 0 0.0%
AST.NumPrefixOperators 70 70 0 0.0%
AST.NumReferencedDynamicNames 91 91 0 0.0%
AST.NumReferencedMemberNames 3,496,806 3,496,806 0 0.0%
AST.NumReferencedTopLevelNames 269,829 269,829 0 0.0%
AST.NumSourceBuffers 331,076 331,076 0 0.0%
AST.NumSourceLines 2,419,297 2,419,297 0 0.0%
AST.NumSourceLinesPerSecond 2,244,605 2,244,201 -404 -0.02%
AST.NumTotalClangImportedEntities 4,127,012 4,119,630 -7,382 -0.18%
AST.NumUsedConformances 226,008 226,008 0 0.0%
Driver.ChildrenMaxRSS 105,170,270,208 105,480,001,536 309,731,328 0.29%
Driver.DriverDepCascadingDynamic 0 0 0 0.0%
Driver.DriverDepCascadingExternal 0 0 0 0.0%
Driver.DriverDepCascadingMember 0 0 0 0.0%
Driver.DriverDepCascadingNominal 0 0 0 0.0%
Driver.DriverDepCascadingTopLevel 0 0 0 0.0%
Driver.DriverDepDynamic 0 0 0 0.0%
Driver.DriverDepExternal 0 0 0 0.0%
Driver.DriverDepMember 0 0 0 0.0%
Driver.DriverDepNominal 0 0 0 0.0%
Driver.DriverDepTopLevel 0 0 0 0.0%
Driver.NumDriverJobsRun 16,159 16,159 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.MaxMallocUsage 684,671,200,800 683,357,826,152 -1,313,374,648 -0.19%
Frontend.NumInstructionsExecuted 26,808,751,495,244 26,730,444,105,998 -78,307,389,246 -0.29%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 107,181 107,181 0 0.0%
IRModule.NumIRBasicBlocks 3,816,950 3,816,950 0 0.0%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 1,786,413 1,786,413 0 0.0%
IRModule.NumIRGlobals 1,844,860 1,844,860 0 0.0%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 46,201,913 46,201,913 0 0.0%
IRModule.NumIRNamedMetaData 78,212 78,212 0 0.0%
IRModule.NumIRValueSymbols 3,275,268 3,275,268 0 0.0%
LLVM.NumLLVMBytesOutput 962,231,274 962,230,246 -1,028 -0.0%
Parse.NumFunctionsParsed 141,912 141,912 0 0.0%
Parse.NumIterableDeclContextParsed 1,000,666 1,000,666 0 0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 926,114 926,114 0 0.0%
SILModule.NumSILGenGlobalVariables 37,118 37,118 0 0.0%
SILModule.NumSILGenVtables 10,668 10,668 0 0.0%
SILModule.NumSILGenWitnessTables 39,093 39,093 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 1,315,543 1,315,543 0 0.0%
SILModule.NumSILOptGlobalVariables 37,865 37,865 0 0.0%
SILModule.NumSILOptVtables 17,156 17,156 0 0.0%
SILModule.NumSILOptWitnessTables 86,043 86,043 0 0.0%
Sema.AccessLevelRequest 2,319,700 2,318,704 -996 -0.04%
Sema.DefaultAndMaxAccessLevelRequest 54,270 54,259 -11 -0.02%
Sema.DefaultTypeRequest 315,078 315,078 0 0.0%
Sema.EnumRawTypeRequest 16,934 16,934 0 0.0%
Sema.ExtendedNominalRequest 3,667,974 3,663,628 -4,346 -0.12%
Sema.InheritedDeclsReferencedRequest 4,428,872 4,403,033 -25,839 -0.58%
Sema.InheritedTypeRequest 528,395 528,065 -330 -0.06%
Sema.IsDynamicRequest 1,822,377 1,822,377 0 0.0%
Sema.IsObjCRequest 1,555,671 1,555,614 -57 -0.0%
Sema.MangleLocalTypeDeclRequest 216 216 0 0.0%
Sema.NamedLazyMemberLoadFailureCount 18,932 18,851 -81 -0.43%
Sema.NamedLazyMemberLoadSuccessCount 17,104,222 17,102,537 -1,685 -0.01%
Sema.NominalTypeLookupDirectCount 29,002,485 28,965,594 -36,891 -0.13%
Sema.NumConformancesDeserialized 6,435,998 6,401,375 -34,623 -0.54%
Sema.NumConstraintScopes 16,792,439 16,788,763 -3,676 -0.02%
Sema.NumConstraintsConsideredForEdgeContraction 52,761,684 52,760,059 -1,625 -0.0%
Sema.NumDeclsDeserialized 47,128,389 46,915,265 -213,124 -0.45%
Sema.NumDeclsFinalized 1,636,616 1,636,616 0 0.0%
Sema.NumDeclsTypechecked 890,865 890,865 0 0.0%
Sema.NumDeclsValidated 1,935,526 1,935,521 -5 -0.0%
Sema.NumFunctionsTypechecked 943,228 943,228 0 0.0%
Sema.NumGenericSignatureBuilders 1,134,561 1,132,878 -1,683 -0.15%
Sema.NumLazyGenericEnvironments 9,357,116 9,350,685 -6,431 -0.07%
Sema.NumLazyGenericEnvironmentsLoaded 195,639 195,543 -96 -0.05%
Sema.NumLazyIterableDeclContexts 6,581,970 6,574,004 -7,966 -0.12%
Sema.NumLeafScopes 10,940,489 10,937,538 -2,951 -0.03%
Sema.NumTypesDeserialized 15,846,650 15,817,473 -29,177 -0.18%
Sema.NumTypesValidated 1,310,239 1,310,233 -6 -0.0%
Sema.NumUnloadedLazyIterableDeclContexts 4,341,042 4,341,108 66 0.0%
Sema.OverriddenDeclsRequest 7,336,290 7,279,612 -56,678 -0.77%
Sema.RequirementRequest 62,070 62,069 -1 -0.0%
Sema.SelfBoundsFromWhereClauseRequest 6,220,903 6,189,329 -31,574 -0.51%
Sema.SetterAccessLevelRequest 136,714 136,714 0 0.0%
Sema.SuperclassDeclRequest 66,916 66,783 -133 -0.2%
Sema.SuperclassTypeRequest 30,706 30,706 0 0.0%
Sema.TypeDeclsFromWhereClauseRequest 29,804 29,793 -11 -0.04%
Sema.UnderlyingTypeDeclsReferencedRequest 195,063 194,406 -657 -0.34%

Release

release brief

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 25,734,773,670,212 25,741,530,059,575 6,756,389,363 0.03%
LLVM.NumLLVMBytesOutput 786,779,156 786,779,696 540 0.0%
time.swift-driver.wall 4615.9s 4617.2s 1.3s 0.03%

release detailed

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (23)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 214,673 214,673 0 0.0%
AST.NumLoadedModules 16,334 16,334 0 0.0%
AST.NumTotalClangImportedEntities 730,672 730,672 0 0.0%
AST.NumUsedConformances 226,971 226,971 0 0.0%
IRModule.NumIRBasicBlocks 3,231,955 3,231,955 0 0.0%
IRModule.NumIRFunctions 1,491,848 1,491,848 0 0.0%
IRModule.NumIRGlobals 1,630,708 1,630,708 0 0.0%
IRModule.NumIRInsts 29,508,261 29,508,261 0 0.0%
IRModule.NumIRValueSymbols 2,909,967 2,909,967 0 0.0%
LLVM.NumLLVMBytesOutput 786,779,156 786,779,696 540 0.0%
SILModule.NumSILGenFunctions 649,573 649,573 0 0.0%
SILModule.NumSILOptFunctions 881,817 881,817 0 0.0%
Sema.NumConformancesDeserialized 2,205,934 2,205,934 0 0.0%
Sema.NumConstraintScopes 15,153,048 15,153,048 0 0.0%
Sema.NumDeclsDeserialized 5,930,204 5,930,204 0 0.0%
Sema.NumDeclsValidated 1,031,834 1,031,834 0 0.0%
Sema.NumFunctionsTypechecked 426,176 426,176 0 0.0%
Sema.NumGenericSignatureBuilders 189,254 189,254 0 0.0%
Sema.NumLazyGenericEnvironments 1,218,680 1,218,680 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 21,344 21,344 0 0.0%
Sema.NumLazyIterableDeclContexts 751,253 751,253 0 0.0%
Sema.NumTypesDeserialized 3,136,862 3,136,862 0 0.0%
Sema.NumTypesValidated 613,387 613,387 0 0.0%

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test os x platform

@swift-ci
Copy link
Contributor

Summary for master smoketest

Unexpected test results, excluded stats for ReactiveCocoa

No regressions above thresholds

Debug

debug brief

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 98,943,956,666 98,959,904,959 15,948,293 0.02%
LLVM.NumLLVMBytesOutput 6,169,484 6,169,448 -36 -0.0%
time.swift-driver.wall 12.7s 12.8s 54.4ms 0.43%

debug detailed

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (23)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 1,032 1,032 0 0.0%
AST.NumLoadedModules 828 828 0 0.0%
AST.NumTotalClangImportedEntities 4,210 4,210 0 0.0%
AST.NumUsedConformances 886 886 0 0.0%
IRModule.NumIRBasicBlocks 18,028 18,028 0 0.0%
IRModule.NumIRFunctions 10,554 10,554 0 0.0%
IRModule.NumIRGlobals 8,013 8,013 0 0.0%
IRModule.NumIRInsts 314,096 314,096 0 0.0%
IRModule.NumIRValueSymbols 17,630 17,630 0 0.0%
LLVM.NumLLVMBytesOutput 6,169,484 6,169,448 -36 -0.0%
SILModule.NumSILGenFunctions 5,382 5,382 0 0.0%
SILModule.NumSILOptFunctions 7,052 7,052 0 0.0%
Sema.NumConformancesDeserialized 16,171 16,171 0 0.0%
Sema.NumConstraintScopes 41,540 41,540 0 0.0%
Sema.NumDeclsDeserialized 133,467 133,467 0 0.0%
Sema.NumDeclsValidated 11,208 11,208 0 0.0%
Sema.NumFunctionsTypechecked 2,516 2,516 0 0.0%
Sema.NumGenericSignatureBuilders 4,776 4,776 0 0.0%
Sema.NumLazyGenericEnvironments 29,504 29,504 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 2,012 2,012 0 0.0%
Sema.NumLazyIterableDeclContexts 23,537 23,537 0 0.0%
Sema.NumTypesDeserialized 59,369 59,369 0 0.0%
Sema.NumTypesValidated 11,902 11,902 0 0.0%

Release

release brief

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (3)
name old new delta delta_pct
Frontend.NumInstructionsExecuted 140,951,243,080 141,015,242,972 63,999,892 0.05%
LLVM.NumLLVMBytesOutput 7,146,932 7,146,984 52 0.0%
time.swift-driver.wall 23.6s 23.6s -37.6ms -0.16%

release detailed

Regressed (0)
name old new delta delta_pct
Improved (0)
name old new delta delta_pct
Unchanged (delta < 1.0% or delta < 100.0ms) (23)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 402 402 0 0.0%
AST.NumLoadedModules 76 76 0 0.0%
AST.NumTotalClangImportedEntities 2,146 2,146 0 0.0%
AST.NumUsedConformances 890 890 0 0.0%
IRModule.NumIRBasicBlocks 20,921 20,921 0 0.0%
IRModule.NumIRFunctions 10,070 10,070 0 0.0%
IRModule.NumIRGlobals 8,102 8,102 0 0.0%
IRModule.NumIRInsts 220,767 220,767 0 0.0%
IRModule.NumIRValueSymbols 17,316 17,316 0 0.0%
LLVM.NumLLVMBytesOutput 7,146,932 7,146,984 52 0.0%
SILModule.NumSILGenFunctions 4,178 4,178 0 0.0%
SILModule.NumSILOptFunctions 5,856 5,856 0 0.0%
Sema.NumConformancesDeserialized 12,445 12,445 0 0.0%
Sema.NumConstraintScopes 40,618 40,618 0 0.0%
Sema.NumDeclsDeserialized 32,249 32,249 0 0.0%
Sema.NumDeclsValidated 7,874 7,874 0 0.0%
Sema.NumFunctionsTypechecked 2,204 2,204 0 0.0%
Sema.NumGenericSignatureBuilders 1,718 1,718 0 0.0%
Sema.NumLazyGenericEnvironments 6,785 6,785 0 0.0%
Sema.NumLazyGenericEnvironmentsLoaded 130 130 0 0.0%
Sema.NumLazyIterableDeclContexts 4,203 4,203 0 0.0%
Sema.NumTypesDeserialized 18,070 18,070 0 0.0%
Sema.NumTypesValidated 6,942 6,942 0 0.0%

@davidungar
Copy link
Contributor Author

@swift-ci please clean smoke test os x platform

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very few comments this time around; the new structure is far clearer, and should make it easier to improve this part of the code base in the future.

private:

// TODO: better name than DC
struct DCAndResolvedIsCascadingUse {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ContextAndResolvedCascadingUse?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Have made that change.

DeclContext *const dynamicContext;
/// Types are formally members of the metatype, i.e. the static type of the
/// activation record.
// DOUG: can you help clarify the above comments?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they're accurate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks!

/// But in addition, self could conform to any number of protocols.
/// For example, when there's a protocol extension, e.g. extension P where
/// self: P2, self also conforms to P2 so P2 must be searched.
class ResultFinderForSelfsConformances {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than "for Self's conformances", maybe we want to say this is for "for type contexts"? That's the general case; that we're collecting constraints on Self to find these types is more of an implementation detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thought. As it is, I believe that the structure is self-specific because the constructer calls findNominalTypesThatSelfMustConformTo which in turn calls dc->getSelfNominalTypeDecl(). But yes, it could certainly be parameterized and generalized, by for example passing in a NominalTypeDecl in to the constructor. Would there be a use for such a generalized facility?

SourceLoc Loc,
Options options,
UnqualifiedLookup &lookupToBeCreated)
:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formatting where the member initializations are at column zero makes my cringe ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Yes, I wanted one per line, but not at zero. I can move them to col 2, but is there a better way? Clang-format wants to pack >1 per line...

@davidungar
Copy link
Contributor Author

Thanks, @DougGregor for your review and for the encouragement.

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar
Copy link
Contributor Author

@swift-ci please test compiler performance

// When a generic has the same name as a member, Swift prioritizes the generic
// because the member could still be named by qualifying it. But there is no
// corresponding way to qualify a generic parameter.
// So, look for genrics first.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor typo "genrics"

@davidungar davidungar changed the title [DNM WIP ] Test UnqualifiedLookup refactoring [NameLookup ] UnqualifiedLookup refactoring Feb 28, 2019
@davidungar
Copy link
Contributor Author

@swift-ci please smoke test and merge

@davidungar
Copy link
Contributor Author

@swift-ci please smoke test

@davidungar davidungar merged commit 2ce6867 into swiftlang:master Mar 1, 2019
@davidungar
Copy link
Contributor Author

@DougGregor Thanks for spotting the typo! Have started another PR to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants