Skip to content

[Name lookup] Make shadowing less reliant on the type checker. #18562

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

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented Aug 8, 2018

Perform name shadowing with less semantic information. Swift's name-shadowing rules depend on type information. However, much of the time we can determine that there is no shadowing without type information, so delay the resolution of type information until we absolutely need it.

@DougGregor
Copy link
Member Author

@swift-ci please test compiler performance

@swift-ci
Copy link
Contributor

swift-ci commented Aug 8, 2018

Build comment file:

Summary for master full

Unexpected test results, excluded stats for RxSwift, ReactiveCocoa, Wordy, DatabaseKit, ReactiveSwift

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) (2)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 515,220,870 515,425,928 205,058 0.04%
time.swift-driver.wall 1008.3s 1011.8s 3.5s 0.35%

debug-batch detailed

Regressed (6)
name old new delta delta_pct
AST.NumImportedExternalDefinitions 673,829 686,967 13,138 1.95% ⛔
AST.NumTotalClangImportedEntities 2,223,572 2,276,020 52,448 2.36% ⛔
Sema.NamedLazyMemberLoadFailureCount 12,900 13,918 1,018 7.89% ⛔
Sema.NamedLazyMemberLoadSuccessCount 2,002,087 2,161,204 159,117 7.95% ⛔
Sema.NominalTypeLookupDirectCount 16,168,707 16,387,440 218,733 1.35% ⛔
Sema.NumFunctionsTypechecked 411,979 416,555 4,576 1.11% ⛔
Improved (3)
name old new delta delta_pct
Driver.NumDriverPipePolls 82,018 79,489 -2,529 -3.08% ✅
Driver.NumDriverPipeReads 83,429 81,164 -2,265 -2.71% ✅
Sema.InheritedTypeRequest 23,230 22,475 -755 -3.25% ✅
Unchanged (delta < 1.0% or delta < 100.0ms) (78)
name old new delta delta_pct
AST.NumASTBytesAllocated 11,270,520,285 11,284,663,181 14,142,896 0.13%
AST.NumDecls 33,060 33,060 0 0.0%
AST.NumDependencies 66,953 66,951 -2 -0.0%
AST.NumInfixOperators 13,323 13,323 0 0.0%
AST.NumLinkLibraries 0 0 0 0.0%
AST.NumLoadedModules 77,666 77,666 0 0.0%
AST.NumLocalTypeDecls 13 13 0 0.0%
AST.NumObjCMethods 12,902 12,902 0 0.0%
AST.NumPostfixOperators 14 14 0 0.0%
AST.NumPrecedenceGroups 6,996 6,996 0 0.0%
AST.NumPrefixOperators 60 60 0 0.0%
AST.NumReferencedDynamicNames 45 45 0 0.0%
AST.NumReferencedMemberNames 1,907,444 1,909,413 1,969 0.1%
AST.NumReferencedTopLevelNames 115,928 115,920 -8 -0.01%
AST.NumSourceBuffers 104,977 104,978 1 0.0%
AST.NumSourceLines 1,198,590 1,198,590 0 0.0%
AST.NumSourceLinesPerSecond 759,312 755,496 -3,816 -0.5%
AST.NumUsedConformances 101,091 101,091 0 0.0%
Driver.ChildrenMaxRSS 33,653,026,816 33,809,383,424 156,356,608 0.46%
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 7,072 7,072 0 0.0%
Driver.NumDriverJobsSkipped 0 0 0 0.0%
Driver.NumProcessFailures 0 0 0 0.0%
Frontend.NumProcessFailures 0 0 0 0.0%
IRModule.NumIRAliases 26,417 26,417 0 0.0%
IRModule.NumIRBasicBlocks 1,763,975 1,764,223 248 0.01%
IRModule.NumIRComdatSymbols 0 0 0 0.0%
IRModule.NumIRFunctions 967,565 968,010 445 0.05%
IRModule.NumIRGlobals 1,197,098 1,197,863 765 0.06%
IRModule.NumIRIFuncs 0 0 0 0.0%
IRModule.NumIRInsts 20,608,412 20,612,760 4,348 0.02%
IRModule.NumIRNamedMetaData 34,928 34,928 0 0.0%
IRModule.NumIRValueSymbols 1,869,909 1,870,871 962 0.05%
LLVM.NumLLVMBytesOutput 515,220,870 515,425,928 205,058 0.04%
Parse.NumFunctionsParsed 63,471 63,471 0 0.0%
SILModule.NumSILGenDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILGenFunctions 1,038,406 1,039,628 1,222 0.12%
SILModule.NumSILGenGlobalVariables 14,900 14,900 0 0.0%
SILModule.NumSILGenVtables 3,966 3,966 0 0.0%
SILModule.NumSILGenWitnessTables 18,928 18,928 0 0.0%
SILModule.NumSILOptDefaultWitnessTables 0 0 0 0.0%
SILModule.NumSILOptFunctions 724,976 725,252 276 0.04%
SILModule.NumSILOptGlobalVariables 15,334 15,334 0 0.0%
SILModule.NumSILOptVtables 7,636 7,636 0 0.0%
SILModule.NumSILOptWitnessTables 36,905 36,905 0 0.0%
Sema.AccessLevelRequest 846,670 843,044 -3,626 -0.43%
Sema.DefaultAndMaxAccessLevelRequest 19,369 19,369 0 0.0%
Sema.EnumRawTypeRequest 6,509 6,504 -5 -0.08%
Sema.ExtendedNominalRequest 1,205,893 1,212,206 6,313 0.52%
Sema.InheritedDeclsReferencedRequest 53,368,323 53,745,718 377,395 0.71%
Sema.IsDynamicRequest 677,560 673,861 -3,699 -0.55%
Sema.IsObjCRequest 605,208 600,069 -5,139 -0.85%
Sema.NumConformancesDeserialized 2,168,340 2,169,761 1,421 0.07%
Sema.NumConstraintScopes 7,298,243 7,300,154 1,911 0.03%
Sema.NumConstraintsConsideredForEdgeContraction 13,078,884 13,082,712 3,828 0.03%
Sema.NumDeclsDeserialized 14,126,003 14,188,836 62,833 0.44%
Sema.NumDeclsValidated 964,173 958,211 -5,962 -0.62%
Sema.NumGenericSignatureBuilders 660,449 657,588 -2,861 -0.43%
Sema.NumLazyGenericEnvironments 2,602,577 2,603,782 1,205 0.05%
Sema.NumLazyGenericEnvironmentsLoaded 266,581 268,034 1,453 0.55%
Sema.NumLazyIterableDeclContexts 2,275,630 2,279,689 4,059 0.18%
Sema.NumTypesDeserialized 14,740,485 14,799,094 58,609 0.4%
Sema.NumTypesValidated 782,758 779,552 -3,206 -0.41%
Sema.NumUnloadedLazyIterableDeclContexts 1,501,560 1,494,936 -6,624 -0.44%
Sema.OverriddenDeclsRequest 1,353,642 1,353,791 149 0.01%
Sema.SetterAccessLevelRequest 52,145 52,113 -32 -0.06%
Sema.SuperclassDeclRequest 41,472,409 41,778,276 305,867 0.74%
Sema.SuperclassTypeRequest 14,688 14,668 -20 -0.14%
Sema.UnderlyingTypeDeclsReferencedRequest 2,395,731 2,408,909 13,178 0.55%

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) (2)
name old new delta delta_pct
LLVM.NumLLVMBytesOutput 478,986,270 478,986,042 -228 -0.0%
time.swift-driver.wall 1906.7s 1908.4s 1.7s 0.09%

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 146,062 146,166 104 0.07%
AST.NumLoadedModules 6,370 6,370 0 0.0%
AST.NumTotalClangImportedEntities 464,990 465,540 550 0.12%
AST.NumUsedConformances 103,289 103,289 0 0.0%
IRModule.NumIRBasicBlocks 1,710,346 1,710,346 0 0.0%
IRModule.NumIRFunctions 766,966 766,966 0 0.0%
IRModule.NumIRGlobals 883,648 883,648 0 0.0%
IRModule.NumIRInsts 14,686,805 14,686,805 0 0.0%
IRModule.NumIRValueSymbols 1,497,962 1,497,962 0 0.0%
LLVM.NumLLVMBytesOutput 478,986,270 478,986,042 -228 -0.0%
SILModule.NumSILGenFunctions 335,123 335,123 0 0.0%
SILModule.NumSILOptFunctions 452,942 452,942 0 0.0%
Sema.NumConformancesDeserialized 1,098,892 1,098,877 -15 -0.0%
Sema.NumConstraintScopes 7,240,006 7,240,034 28 0.0%
Sema.NumDeclsDeserialized 3,002,515 3,002,410 -105 -0.0%
Sema.NumDeclsValidated 548,486 548,486 0 0.0%
Sema.NumFunctionsTypechecked 172,313 172,341 28 0.02%
Sema.NumGenericSignatureBuilders 124,288 123,825 -463 -0.37%
Sema.NumLazyGenericEnvironments 507,947 507,911 -36 -0.01%
Sema.NumLazyGenericEnvironmentsLoaded 58,120 58,120 0 0.0%
Sema.NumLazyIterableDeclContexts 330,887 330,814 -73 -0.02%
Sema.NumTypesDeserialized 3,708,939 3,707,892 -1,047 -0.03%
Sema.NumTypesValidated 273,787 273,787 0 0.0%

@DougGregor DougGregor force-pushed the remove-shadowed-without-validation branch from d6b1bbf to cb8fcaf Compare August 14, 2018 03:49
@DougGregor DougGregor changed the title [WIP] [Name lookup] Teach shadowing to avoid validating decls until needed. [Name lookup] Avoid extraneous use of type checking during name lookup Aug 14, 2018
@DougGregor DougGregor changed the title [Name lookup] Avoid extraneous use of type checking during name lookup [Name lookup] Make shadowing less reliant on the type checker. Aug 14, 2018
@DougGregor
Copy link
Member Author

Most of these commits are part of #18539, which I plan to merge first.

Rather than validating the signature of any declaration found by
name lookup, first check whether there is a collision on the full name
of the declaration. This should result in fewer declaration validations.
@DougGregor DougGregor force-pushed the remove-shadowed-without-validation branch from cb8fcaf to 8d11ce1 Compare August 14, 2018 09:19
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor DougGregor merged commit 32d8f8a into swiftlang:master Aug 14, 2018
@DougGregor DougGregor deleted the remove-shadowed-without-validation branch August 14, 2018 14:50
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.

2 participants