Skip to content

Implement verification that noescape closures passed to Objective-C are not escaped #16236

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

Conversation

aschwaighofer
Copy link
Contributor

The series of commit introduces a copy_block_without_escaping block instruction that ties a swift closure sentinel to the block that is escaped.

SILGen emits this instruction when it generates a conversion from a @noescape swift closure to a block.

       %noescape_closure = ...
       %wae_Thunk = function_ref @$withoutActuallyEscapingThunk
       %sentinel =
         partial_apply [callee_guaranteed] %wae_thunk(%noescape_closure)
       %noescaped_wrapped = mark_dependence %sentinel on %noescape_closure
       %sentinel_copy = copy_value %noescaped_wrapped
       %storage = alloc_stack
       %storage_address = project_block_storage %storage
       store %noescaped_wrapped to [init] %storage_address
       %block = init_block_storage_header %storage ...
       %block = copy_block_without_escaping %block withoutEscaping %noescaped_wrapped

The ClosureLifetimeFixup pass then lowers copy_block_without_escaping into a copy_block and is_escaping/cond_fail/destroy_value combination at a point that succeeds the end of the block's lifetime.

As a result whenever a semantic noescape Swift closure synchronously escapes to Objective C we will trap with an error after we return from the Objective C call.

rdar://39682865

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test source compatibility

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

1 similar comment
@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 785c073aae0ce8f5d5a6f0864080f48cc5c85cc3

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 785c073aae0ce8f5d5a6f0864080f48cc5c85cc3

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 7a0fa745487c44249610fbbc7f10e633329134ef

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 7a0fa745487c44249610fbbc7f10e633329134ef

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 46cdf62567fb189ebda1c311007b6158ce220757

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 46cdf62567fb189ebda1c311007b6158ce220757

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please clean test linux

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test source compatibility

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 44c5339568f92d9997fa5bfbe1b46d9944b56cb7

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 44c5339568f92d9997fa5bfbe1b46d9944b56cb7

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 44c5339568f92d9997fa5bfbe1b46d9944b56cb7

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test source compatibility

@aschwaighofer
Copy link
Contributor Author

Latest source compatibility run here: https://ci.swift.org/view/Pull%20Request/job/swift-PR-source-compat-suite/1124/

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please benchmark

@aschwaighofer
Copy link
Contributor Author

@swift-ci
Copy link
Contributor

swift-ci commented May 1, 2018

Build comment file:

Optimized (O)

Regression (5)
TEST OLD NEW DELTA SPEEDUP
NSDictionaryCastToSwift 5285 7100 +34.3% 0.74x
DataReplaceSmallBuffer 9550 11146 +16.7% 0.86x (?)
DataReplaceMediumBuffer 12451 13929 +11.9% 0.89x (?)
DataAppendSequence 19177 21453 +11.9% 0.89x (?)
IterateData 1856 1955 +5.3% 0.95x
Improvement (5)
TEST OLD NEW DELTA SPEEDUP
FatCompactMap 261467 205438 -21.4% 1.27x
DictionarySwapAt 8513 6974 -18.1% 1.22x
AngryPhonebook 3933 3723 -5.3% 1.06x (?)
PrefixAnySequence 4586 4352 -5.1% 1.05x
DataAppendDataMediumToMedium 7936 7533 -5.1% 1.05x (?)
No Changes (414)
TEST OLD NEW DELTA SPEEDUP
AnyHashableWithAClass 83796 84342 +0.7% 0.99x (?)
Array2D 2518 2513 -0.2% 1.00x (?)
ArrayAppend 1062 1061 -0.1% 1.00x (?)
ArrayAppendArrayOfInt 789 789 +0.0% 1.00x
ArrayAppendAscii 13942 13918 -0.2% 1.00x (?)
ArrayAppendFromGeneric 799 798 -0.1% 1.00x (?)
ArrayAppendGenericStructs 1427 1425 -0.1% 1.00x (?)
ArrayAppendLatin1 40954 40923 -0.1% 1.00x (?)
ArrayAppendLazyMap 1340 1337 -0.2% 1.00x (?)
ArrayAppendOptionals 1401 1420 +1.4% 0.99x (?)
ArrayAppendRepeatCol 1367 1332 -2.6% 1.03x (?)
ArrayAppendReserved 790 791 +0.1% 1.00x (?)
ArrayAppendSequence 1120 1121 +0.1% 1.00x (?)
ArrayAppendStrings 6220 6216 -0.1% 1.00x (?)
ArrayAppendToFromGeneric 796 791 -0.6% 1.01x (?)
ArrayAppendToGeneric 797 798 +0.1% 1.00x (?)
ArrayAppendUTF16 41885 41896 +0.0% 1.00x (?)
ArrayInClass 85 85 +0.0% 1.00x
ArrayLiteral 0 0 +0.0% 1.00x
ArrayOfGenericPOD2 150 150 +0.0% 1.00x
ArrayOfGenericRef 4399 4377 -0.5% 1.01x (?)
ArrayOfPOD 183 183 +0.0% 1.00x
ArrayOfRef 4368 4342 -0.6% 1.01x (?)
ArrayPlusEqualArrayOfInt 796 798 +0.3% 1.00x (?)
ArrayPlusEqualFiveElementCollection 5400 5441 +0.8% 0.99x (?)
ArrayPlusEqualSingleElementCollection 1057 1060 +0.3% 1.00x (?)
ArrayPlusEqualThreeElements 1669 1644 -1.5% 1.02x (?)
ArraySubscript 1534 1530 -0.3% 1.00x (?)
ArrayValueProp 8 8 +0.0% 1.00x
ArrayValueProp2 8 8 +0.0% 1.00x
ArrayValueProp3 8 8 +0.0% 1.00x
ArrayValueProp4 8 8 +0.0% 1.00x
BinaryFloatingPointPropertiesBinade 31 31 +0.0% 1.00x
BinaryFloatingPointPropertiesNextUp 28 28 +0.0% 1.00x
BinaryFloatingPointPropertiesUlp 37 37 +0.0% 1.00x
BitCount 211 211 +0.0% 1.00x
ByteSwap 104 103 -1.0% 1.01x (?)
COWTree 5349 5340 -0.2% 1.00x (?)
CSVParsing 712997 713899 +0.1% 1.00x (?)
CSVParsingAlt 779168 777150 -0.3% 1.00x (?)
CSVParsingAltIndices 342001 344819 +0.8% 0.99x (?)
CStringLongAscii 4879 4880 +0.0% 1.00x (?)
CStringLongNonAscii 2249 2248 -0.0% 1.00x (?)
CStringShortAscii 3192 3164 -0.9% 1.01x (?)
Calculator 1114 1126 +1.1% 0.99x
CaptureProp 4078 4075 -0.1% 1.00x (?)
ChainedFilterMap 1246 1245 -0.1% 1.00x (?)
CharIndexing_ascii_unicodeScalars 17356 17361 +0.0% 1.00x (?)
CharIndexing_ascii_unicodeScalars_Backwards 16352 16348 -0.0% 1.00x (?)
CharIndexing_chinese_unicodeScalars 13142 13144 +0.0% 1.00x (?)
CharIndexing_chinese_unicodeScalars_Backwards 12389 12386 -0.0% 1.00x (?)
CharIndexing_japanese_unicodeScalars 20786 20792 +0.0% 1.00x (?)
CharIndexing_japanese_unicodeScalars_Backwards 19582 19580 -0.0% 1.00x (?)
CharIndexing_korean_unicodeScalars 16830 16839 +0.1% 1.00x (?)
CharIndexing_korean_unicodeScalars_Backwards 15867 15858 -0.1% 1.00x (?)
CharIndexing_punctuatedJapanese_unicodeScalars 3136 3135 -0.0% 1.00x (?)
CharIndexing_punctuatedJapanese_unicodeScalars_Backwards 2967 2971 +0.1% 1.00x (?)
CharIndexing_punctuated_unicodeScalars 3925 3927 +0.1% 1.00x (?)
CharIndexing_punctuated_unicodeScalars_Backwards 3713 3711 -0.1% 1.00x (?)
CharIndexing_russian_unicodeScalars 14464 14463 -0.0% 1.00x (?)
CharIndexing_russian_unicodeScalars_Backwards 13623 13627 +0.0% 1.00x (?)
CharIndexing_tweet_unicodeScalars 33829 33834 +0.0% 1.00x (?)
CharIndexing_tweet_unicodeScalars_Backwards 32242 32233 -0.0% 1.00x (?)
CharIndexing_utf16_unicodeScalars 23130 23096 -0.1% 1.00x
CharIndexing_utf16_unicodeScalars_Backwards 23671 23605 -0.3% 1.00x (?)
CharIteration_ascii_unicodeScalars 21405 21166 -1.1% 1.01x (?)
CharIteration_ascii_unicodeScalars_Backwards 15104 15105 +0.0% 1.00x (?)
CharIteration_chinese_unicodeScalars 16219 15996 -1.4% 1.01x
CharIteration_chinese_unicodeScalars_Backwards 11440 11442 +0.0% 1.00x (?)
CharIteration_japanese_unicodeScalars 25651 25378 -1.1% 1.01x
CharIteration_japanese_unicodeScalars_Backwards 18089 18081 -0.0% 1.00x (?)
CharIteration_korean_unicodeScalars 20692 20530 -0.8% 1.01x (?)
CharIteration_korean_unicodeScalars_Backwards 14644 14647 +0.0% 1.00x (?)
CharIteration_punctuatedJapanese_unicodeScalars 3822 3787 -0.9% 1.01x
CharIteration_punctuatedJapanese_unicodeScalars_Backwards 2737 2737 +0.0% 1.00x
CharIteration_punctuated_unicodeScalars 4798 4758 -0.8% 1.01x
CharIteration_punctuated_unicodeScalars_Backwards 3424 3424 +0.0% 1.00x
CharIteration_russian_unicodeScalars 17826 17631 -1.1% 1.01x (?)
CharIteration_russian_unicodeScalars_Backwards 12586 12583 -0.0% 1.00x (?)
CharIteration_tweet_unicodeScalars 42277 41892 -0.9% 1.01x (?)
CharIteration_tweet_unicodeScalars_Backwards 29840 29840 +0.0% 1.00x
CharIteration_utf16_unicodeScalars 28003 27923 -0.3% 1.00x
CharIteration_utf16_unicodeScalars_Backwards 18611 18655 +0.2% 1.00x (?)
CharacterLiteralsLarge 5763 5782 +0.3% 1.00x (?)
CharacterLiteralsSmall 220 220 +0.0% 1.00x
CharacterPropertiesFetch 4563 4534 -0.6% 1.01x (?)
CharacterPropertiesPrecomputed 1091 1084 -0.6% 1.01x (?)
CharacterPropertiesStashed 1480 1472 -0.5% 1.01x (?)
CharacterPropertiesStashedMemo 1549 1556 +0.5% 1.00x (?)
Chars 1215 1215 +0.0% 1.00x
ClassArrayGetter 15 15 +0.0% 1.00x
Combos 492 485 -1.4% 1.01x (?)
DataAccessBytes 1219 1222 +0.2% 1.00x (?)
DataAppendArray 6066 6246 +3.0% 0.97x (?)
DataAppendBytes 5975 6134 +2.7% 0.97x (?)
DataAppendDataLargeToLarge 68788 68380 -0.6% 1.01x (?)
DataAppendDataLargeToMedium 36477 36167 -0.8% 1.01x (?)
DataAppendDataLargeToSmall 35469 35236 -0.7% 1.01x (?)
DataAppendDataMediumToLarge 38530 38804 +0.7% 0.99x (?)
DataAppendDataMediumToSmall 6903 6898 -0.1% 1.00x (?)
DataAppendDataSmallToLarge 37789 37749 -0.1% 1.00x (?)
DataAppendDataSmallToMedium 7366 7125 -3.3% 1.03x (?)
DataAppendDataSmallToSmall 6768 6843 +1.1% 0.99x (?)
DataCopyBytes 2514 2506 -0.3% 1.00x (?)
DataCount 37 37 +0.0% 1.00x
DataMutateBytes 4263 4299 +0.8% 0.99x (?)
DataReplaceLarge 41910 40529 -3.3% 1.03x (?)
DataReplaceLargeBuffer 57933 60083 +3.7% 0.96x (?)
DataReplaceMedium 11474 11156 -2.8% 1.03x (?)
DataReplaceSmall 8994 8812 -2.0% 1.02x (?)
DataReset 3178 3220 +1.3% 0.99x (?)
DataSetCount 890 903 +1.5% 0.99x
DataSubscript 237 240 +1.3% 0.99x
DictOfArraysToArrayOfDicts 812 803 -1.1% 1.01x (?)
Dictionary 677 676 -0.1% 1.00x (?)
Dictionary2 811 816 +0.6% 0.99x (?)
Dictionary2OfObjects 2214 2206 -0.4% 1.00x (?)
Dictionary3 256 253 -1.2% 1.01x (?)
Dictionary3OfObjects 759 757 -0.3% 1.00x (?)
Dictionary4 322 322 +0.0% 1.00x
Dictionary4Legacy 728 726 -0.3% 1.00x (?)
Dictionary4OfObjects 441 442 +0.2% 1.00x (?)
Dictionary4OfObjectsLegacy 939 938 -0.1% 1.00x (?)
DictionaryBridge 1213 1201 -1.0% 1.01x (?)
DictionaryCopy 105103 105734 +0.6% 0.99x (?)
DictionaryFilter 105476 105662 +0.2% 1.00x (?)
DictionaryGroup 214 214 +0.0% 1.00x
DictionaryGroupOfObjects 2106 2112 +0.3% 1.00x (?)
DictionaryLiteral 1919 1920 +0.1% 1.00x (?)
DictionaryOfObjects 2453 2446 -0.3% 1.00x (?)
DictionaryRemove 4349 4238 -2.6% 1.03x
DictionaryRemoveOfObjects 25902 25799 -0.4% 1.00x (?)
DictionarySubscriptDefaultMutation 265 264 -0.4% 1.00x (?)
DictionarySubscriptDefaultMutationArray 624 622 -0.3% 1.00x (?)
DictionarySubscriptDefaultMutationArrayOfObjects 4022 4009 -0.3% 1.00x (?)
DictionarySubscriptDefaultMutationOfObjects 1715 1707 -0.5% 1.00x (?)
DictionarySwap 1036 1027 -0.9% 1.01x
DictionarySwapAtOfObjects 52525 52234 -0.6% 1.01x (?)
DictionarySwapOfObjects 8513 8566 +0.6% 0.99x (?)
DoubleWidthDivision 0 0 +0.0% 1.00x
DropFirstAnyCollection 83 83 +0.0% 1.00x
DropFirstAnyCollectionLazy 62639 63410 +1.2% 0.99x (?)
DropFirstAnySeqCRangeIter 21771 21570 -0.9% 1.01x (?)
DropFirstAnySeqCRangeIterLazy 21758 21575 -0.8% 1.01x (?)
DropFirstAnySeqCntRange 41 41 +0.0% 1.00x
DropFirstAnySeqCntRangeLazy 41 41 +0.0% 1.00x
DropFirstAnySequence 5241 5127 -2.2% 1.02x (?)
DropFirstAnySequenceLazy 5240 5149 -1.7% 1.02x (?)
DropFirstArray 35 35 +0.0% 1.00x
DropFirstArrayLazy 35 35 +0.0% 1.00x
DropFirstCountableRange 35 35 +0.0% 1.00x
DropFirstCountableRangeLazy 35 35 +0.0% 1.00x
DropFirstSequence 2682 2681 -0.0% 1.00x (?)
DropFirstSequenceLazy 2767 2769 +0.1% 1.00x (?)
DropLastAnyCollection 31 31 +0.0% 1.00x
DropLastAnyCollectionLazy 20602 20751 +0.7% 0.99x (?)
DropLastAnySeqCRangeIter 3620 3628 +0.2% 1.00x (?)
DropLastAnySeqCRangeIterLazy 3621 3630 +0.2% 1.00x (?)
DropLastAnySeqCntRange 13 13 +0.0% 1.00x
DropLastAnySeqCntRangeLazy 13 13 +0.0% 1.00x
DropLastAnySequence 5040 5049 +0.2% 1.00x (?)
DropLastAnySequenceLazy 5155 5165 +0.2% 1.00x (?)
DropLastCountableRange 11 11 +0.0% 1.00x
DropLastCountableRangeLazy 12 12 +0.0% 1.00x
DropLastSequence 539 539 +0.0% 1.00x
DropLastSequenceLazy 540 538 -0.4% 1.00x (?)
DropWhileAnyCollection 107 107 +0.0% 1.00x
DropWhileAnyCollectionLazy 125 125 +0.0% 1.00x
DropWhileAnySeqCRangeIter 17034 16912 -0.7% 1.01x
DropWhileAnySeqCRangeIterLazy 125 125 +0.0% 1.00x
DropWhileAnySeqCntRange 50 50 +0.0% 1.00x
DropWhileAnySeqCntRangeLazy 125 125 +0.0% 1.00x
DropWhileAnySequence 5089 5160 +1.4% 0.99x (?)
DropWhileAnySequenceLazy 1855 1856 +0.1% 1.00x (?)
DropWhileArrayLazy 88 88 +0.0% 1.00x
DropWhileCountableRange 36 36 +0.0% 1.00x
DropWhileCountableRangeLazy 105 105 +0.0% 1.00x
DropWhileSequence 2223 2210 -0.6% 1.01x
DropWhileSequenceLazy 88 88 +0.0% 1.00x
EqualStringSubstring 56 56 +0.0% 1.00x
EqualSubstringString 64 65 +1.6% 0.98x
EqualSubstringSubstring 48 49 +2.1% 0.98x
EqualSubstringSubstringGenericEquatable 48 49 +2.1% 0.98x
ErrorHandling 1487 1495 +0.5% 0.99x (?)
ExclusivityGlobal 5 5 +0.0% 1.00x
ExclusivityIndependent 2 2 +0.0% 1.00x
FilterEvenUsingReduce 1292 1293 +0.1% 1.00x (?)
FilterEvenUsingReduceInto 147 149 +1.4% 0.99x (?)
FloatingPointPrinting_Double_description_small 23486 23432 -0.2% 1.00x (?)
FloatingPointPrinting_Double_description_uniform 23216 23060 -0.7% 1.01x (?)
FloatingPointPrinting_Double_interpolated 78312 77424 -1.1% 1.01x (?)
FloatingPointPrinting_Float80_description_small 30667 30552 -0.4% 1.00x (?)
FloatingPointPrinting_Float80_description_uniform 29862 29718 -0.5% 1.00x (?)
FloatingPointPrinting_Float80_interpolated 81010 81164 +0.2% 1.00x (?)
FloatingPointPrinting_Float_description_small 5292 5257 -0.7% 1.01x
FloatingPointPrinting_Float_description_uniform 5116 5087 -0.6% 1.01x
FloatingPointPrinting_Float_interpolated 52828 52896 +0.1% 1.00x (?)
FrequenciesUsingReduce 4932 4888 -0.9% 1.01x (?)
FrequenciesUsingReduceInto 1512 1513 +0.1% 1.00x (?)
Hanoi 2160 2163 +0.1% 1.00x (?)
HashTest 1015 1014 -0.1% 1.00x (?)
Histogram 701 696 -0.7% 1.01x (?)
Integrate 337 351 +4.2% 0.96x
Join 189 187 -1.1% 1.01x
LazilyFilteredArrayContains 36267 36263 -0.0% 1.00x (?)
LazilyFilteredArrays 65089 65036 -0.1% 1.00x (?)
LazilyFilteredRange 3725 3857 +3.5% 0.97x (?)
LessSubstringSubstring 48 49 +2.1% 0.98x
LessSubstringSubstringGenericComparable 48 49 +2.1% 0.98x
LinkedList 7531 7562 +0.4% 1.00x (?)
LuhnAlgoEager 295 299 +1.4% 0.99x (?)
LuhnAlgoLazy 298 299 +0.3% 1.00x (?)
MapReduce 371 370 -0.3% 1.00x (?)
MapReduceAnyCollection 429 429 +0.0% 1.00x
MapReduceAnyCollectionShort 2245 2228 -0.8% 1.01x (?)
MapReduceClass 2994 3002 +0.3% 1.00x (?)
MapReduceClassShort 4541 4544 +0.1% 1.00x (?)
MapReduceLazyCollection 13 13 +0.0% 1.00x
MapReduceLazyCollectionShort 34 34 +0.0% 1.00x
MapReduceLazySequence 86 86 +0.0% 1.00x
MapReduceSequence 454 456 +0.4% 1.00x (?)
MapReduceShort 2050 2004 -2.2% 1.02x
MapReduceShortString 30 30 +0.0% 1.00x
MapReduceString 79 79 +0.0% 1.00x
Memset 216 213 -1.4% 1.01x (?)
MonteCarloE 10333 10310 -0.2% 1.00x (?)
MonteCarloPi 42722 42723 +0.0% 1.00x (?)
NSError 171 171 +0.0% 1.00x
NSStringConversion 727 727 +0.0% 1.00x
NibbleSort 3670 3670 +0.0% 1.00x
NopDeinit 30162 30170 +0.0% 1.00x (?)
ObjectAllocation 131 131 +0.0% 1.00x
ObjectiveCBridgeFromNSArrayAnyObject 25539 26345 +3.2% 0.97x (?)
ObjectiveCBridgeFromNSArrayAnyObjectForced 4717 4495 -4.7% 1.05x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToString 46041 44935 -2.4% 1.02x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToStringForced 42915 44196 +3.0% 0.97x (?)
ObjectiveCBridgeFromNSDictionaryAnyObject 115093 115058 -0.0% 1.00x (?)
ObjectiveCBridgeFromNSSetAnyObject 50010 50704 +1.4% 0.99x (?)
ObjectiveCBridgeFromNSSetAnyObjectForced 4750 4731 -0.4% 1.00x (?)
ObjectiveCBridgeFromNSSetAnyObjectToString 64479 64189 -0.4% 1.00x (?)
ObjectiveCBridgeFromNSString 1221 1215 -0.5% 1.00x (?)
ObjectiveCBridgeFromNSStringForced 2671 2657 -0.5% 1.01x (?)
ObjectiveCBridgeStubDataAppend 11353 11468 +1.0% 0.99x (?)
ObjectiveCBridgeStubDateMutation 400 400 +0.0% 1.00x
ObjectiveCBridgeStubFromArrayOfNSString 33063 32716 -1.0% 1.01x (?)
ObjectiveCBridgeStubFromNSDate 6423 6423 +0.0% 1.00x
ObjectiveCBridgeStubFromNSString 1027 1044 +1.7% 0.98x (?)
ObjectiveCBridgeStubFromNSStringRef 159 158 -0.6% 1.01x (?)
ObjectiveCBridgeStubNSDataAppend 2492 2501 +0.4% 1.00x (?)
ObjectiveCBridgeStubNSDateMutationRef 12737 13138 +3.1% 0.97x (?)
ObjectiveCBridgeStubToArrayOfNSString 38703 38642 -0.2% 1.00x (?)
ObjectiveCBridgeStubToNSDate 14576 14812 +1.6% 0.98x (?)
ObjectiveCBridgeStubToNSDateRef 3405 3418 +0.4% 1.00x (?)
ObjectiveCBridgeStubToNSString 2379 2373 -0.3% 1.00x (?)
ObjectiveCBridgeStubToNSStringRef 113 113 +0.0% 1.00x
ObjectiveCBridgeStubURLAppendPath 285492 292446 +2.4% 0.98x (?)
ObjectiveCBridgeStubURLAppendPathRef 287262 278954 -2.9% 1.03x (?)
ObjectiveCBridgeToNSArray 14938 14680 -1.7% 1.02x (?)
ObjectiveCBridgeToNSDictionary 26203 26773 +2.2% 0.98x (?)
ObjectiveCBridgeToNSSet 16712 17174 +2.8% 0.97x (?)
ObjectiveCBridgeToNSString 490 493 +0.6% 0.99x (?)
ObserverClosure 2143 2175 +1.5% 0.99x
ObserverForwarderStruct 1251 1256 +0.4% 1.00x (?)
ObserverPartiallyAppliedMethod 3722 3791 +1.9% 0.98x
ObserverUnappliedMethod 2605 2602 -0.1% 1.00x (?)
OpenClose 263 263 +0.0% 1.00x
PartialApplyDynamicType 0 0 +0.0% 1.00x
Phonebook 5232 5167 -1.2% 1.01x
PointerArithmetics 31502 31498 -0.0% 1.00x (?)
PolymorphicCalls 25 25 +0.0% 1.00x
PopFrontArray 1863 1864 +0.1% 1.00x (?)
PopFrontArrayGeneric 1880 1876 -0.2% 1.00x (?)
PopFrontUnsafePointer 8647 8745 +1.1% 0.99x (?)
PrefixAnyCollection 83 83 +0.0% 1.00x
PrefixAnyCollectionLazy 61850 62337 +0.8% 0.99x (?)
PrefixAnySeqCRangeIter 16888 16724 -1.0% 1.01x (?)
PrefixAnySeqCRangeIterLazy 16879 16717 -1.0% 1.01x (?)
PrefixAnySeqCntRange 27 28 +3.7% 0.96x
PrefixAnySeqCntRangeLazy 28 28 +0.0% 1.00x
PrefixAnySequenceLazy 4341 4433 +2.1% 0.98x
PrefixArray 35 35 +0.0% 1.00x
PrefixArrayLazy 35 35 +0.0% 1.00x
PrefixCountableRange 35 35 +0.0% 1.00x
PrefixCountableRangeLazy 35 35 +0.0% 1.00x
PrefixSequence 2223 2213 -0.4% 1.00x (?)
PrefixSequenceLazy 2275 2274 -0.0% 1.00x (?)
PrefixWhileAnyCollection 154 154 +0.0% 1.00x
PrefixWhileAnyCollectionLazy 90 90 +0.0% 1.00x
PrefixWhileAnySeqCRangeIter 8998 8989 -0.1% 1.00x (?)
PrefixWhileAnySeqCRangeIterLazy 72 72 +0.0% 1.00x
PrefixWhileAnySeqCntRange 59 60 +1.7% 0.98x
PrefixWhileAnySeqCntRangeLazy 90 90 +0.0% 1.00x
PrefixWhileAnySequence 10169 10135 -0.3% 1.00x (?)
PrefixWhileAnySequenceLazy 1392 1392 +0.0% 1.00x
PrefixWhileArray 88 88 +0.0% 1.00x
PrefixWhileArrayLazy 70 70 +0.0% 1.00x
PrefixWhileCountableRange 36 36 +0.0% 1.00x
PrefixWhileCountableRangeLazy 35 35 +0.0% 1.00x
PrefixWhileSequence 360 360 +0.0% 1.00x
PrefixWhileSequenceLazy 52 52 +0.0% 1.00x
Prims 897 899 +0.2% 1.00x (?)
PrimsSplit 900 897 -0.3% 1.00x (?)
QueueConcrete 1148 1146 -0.2% 1.00x (?)
QueueGeneric 1147 1147 +0.0% 1.00x
RC4 168 168 +0.0% 1.00x
RGBHistogram 3350 3359 +0.3% 1.00x (?)
RGBHistogramOfObjects 24377 24228 -0.6% 1.01x (?)
RangeAssignment 337 335 -0.6% 1.01x (?)
RangeIterationSigned 200 200 +0.0% 1.00x
RangeReplaceableCollectionPlusDefault 981 980 -0.1% 1.00x (?)
RecursiveOwnedParameter 115 115 +0.0% 1.00x
RemoveWhereFilterInts 46 46 +0.0% 1.00x
RemoveWhereFilterString 325 325 +0.0% 1.00x
RemoveWhereFilterStrings 436 436 +0.0% 1.00x
RemoveWhereMoveInts 14 14 +0.0% 1.00x
RemoveWhereMoveStrings 706 707 +0.1% 1.00x (?)
RemoveWhereQuadraticInts 1287 1285 -0.2% 1.00x (?)
RemoveWhereQuadraticString 480 480 +0.0% 1.00x
RemoveWhereQuadraticStrings 2752 2756 +0.1% 1.00x (?)
RemoveWhereSwapInts 19 19 +0.0% 1.00x
RemoveWhereSwapStrings 854 855 +0.1% 1.00x (?)
ReversedArray 57 57 +0.0% 1.00x
ReversedBidirectional 16326 16505 +1.1% 0.99x (?)
ReversedDictionary 259 261 +0.8% 0.99x (?)
RomanNumbers 138642 141849 +2.3% 0.98x
SequenceAlgosAnySequence 11924 11910 -0.1% 1.00x (?)
SequenceAlgosArray 1579 1565 -0.9% 1.01x (?)
SequenceAlgosContiguousArray 1574 1575 +0.1% 1.00x (?)
SequenceAlgosList 1348 1350 +0.1% 1.00x (?)
SequenceAlgosRange 2576 2577 +0.0% 1.00x (?)
SequenceAlgosUnfoldSequence 1102 1102 +0.0% 1.00x
SetExclusiveOr 5219 5315 +1.8% 0.98x
SetExclusiveOr_OfObjects 11671 11772 +0.9% 0.99x (?)
SetIntersect 696 697 +0.1% 1.00x (?)
SetIntersect_OfObjects 1567 1553 -0.9% 1.01x (?)
SetIsSubsetOf 354 354 +0.0% 1.00x
SetIsSubsetOf_OfObjects 435 435 +0.0% 1.00x
SetUnion 4626 4548 -1.7% 1.02x (?)
SetUnion_OfObjects 10239 10181 -0.6% 1.01x (?)
SevenBoom 874 873 -0.1% 1.00x (?)
Sim2DArray 599 599 +0.0% 1.00x
SortLargeExistentials 6107 6086 -0.3% 1.00x
SortLettersInPlace 1053 1054 +0.1% 1.00x (?)
SortSortedStrings 1031 1035 +0.4% 1.00x
SortStrings 2100 2078 -1.0% 1.01x
SortStringsUnicode 2572 2585 +0.5% 0.99x (?)
StackPromo 22508 22492 -0.1% 1.00x (?)
StaticArray 9 9 +0.0% 1.00x
StrComplexWalk 1790 1789 -0.1% 1.00x (?)
StrToInt 2879 2841 -1.3% 1.01x
StringAdder 736 735 -0.1% 1.00x (?)
StringBuilder 779 767 -1.5% 1.02x
StringBuilderLong 1239 1257 +1.5% 0.99x (?)
StringBuilderWithLongSubstring 1410 1448 +2.7% 0.97x (?)
StringComparison_abnormal 772 775 +0.4% 1.00x (?)
StringComparison_ascii 1298 1304 +0.5% 1.00x
StringComparison_emoji 817 811 -0.7% 1.01x (?)
StringComparison_fastPrenormal 823 824 +0.1% 1.00x (?)
StringComparison_latin1 641 645 +0.6% 0.99x
StringComparison_longSharedPrefix 937 931 -0.6% 1.01x
StringComparison_nonBMPSlowestPrenormal 1608 1568 -2.5% 1.03x
StringComparison_slowerPrenormal 1717 1682 -2.0% 1.02x
StringComparison_zalgo 124223 124254 +0.0% 1.00x (?)
StringEdits 168369 169897 +0.9% 0.99x (?)
StringEnumRawValueInitialization 928 935 +0.8% 0.99x (?)
StringEqualPointerComparison 286 286 +0.0% 1.00x
StringFromLongWholeSubstring 21 21 +0.0% 1.00x
StringFromLongWholeSubstringGeneric 21 21 +0.0% 1.00x
StringHasPrefixAscii 2032 2033 +0.0% 1.00x (?)
StringHasPrefixUnicode 110798 110787 -0.0% 1.00x (?)
StringHasSuffixAscii 2185 2176 -0.4% 1.00x (?)
StringHasSuffixUnicode 114151 114082 -0.1% 1.00x (?)
StringInterpolation 10437 10392 -0.4% 1.00x (?)
StringInterpolationManySmallSegments 19027 19113 +0.5% 1.00x (?)
StringInterpolationSmall 6532 6511 -0.3% 1.00x (?)
StringMatch 11608 11676 +0.6% 0.99x
StringRemoveDupes 693 692 -0.1% 1.00x (?)
StringUTF16Builder 2753 2740 -0.5% 1.00x (?)
StringUTF16SubstringBuilder 5765 5797 +0.6% 0.99x (?)
StringWalk 1422 1421 -0.1% 1.00x (?)
StringWithCString 42929 43021 +0.2% 1.00x (?)
StringWordBuilder 2333 2335 +0.1% 1.00x (?)
StringWordBuilderReservingCapacity 2071 2007 -3.1% 1.03x
SubstringComparable 27 27 +0.0% 1.00x
SubstringEqualString 785 779 -0.8% 1.01x (?)
SubstringEquatable 1435 1372 -4.4% 1.05x
SubstringFromLongString 10 10 +0.0% 1.00x
SubstringFromLongStringGeneric 75 75 +0.0% 1.00x
SuffixAnyCollection 31 31 +0.0% 1.00x
SuffixAnyCollectionLazy 21002 21269 +1.3% 0.99x (?)
SuffixAnySeqCRangeIter 3850 3831 -0.5% 1.00x (?)
SuffixAnySeqCRangeIterLazy 3855 3822 -0.9% 1.01x (?)
SuffixAnySeqCntRange 20 20 +0.0% 1.00x
SuffixAnySeqCntRangeLazy 20 20 +0.0% 1.00x
SuffixAnySequence 5035 5016 -0.4% 1.00x (?)
SuffixAnySequenceLazy 5118 5106 -0.2% 1.00x (?)
SuffixCountableRange 11 11 +0.0% 1.00x
SuffixCountableRangeLazy 11 11 +0.0% 1.00x
SuffixSequence 3694 3688 -0.2% 1.00x (?)
SuffixSequenceLazy 3704 3689 -0.4% 1.00x
SumUsingReduce 97 97 +0.0% 1.00x
SumUsingReduceInto 102 102 +0.0% 1.00x
SuperChars 14759 14722 -0.3% 1.00x (?)
TwoSum 1460 1451 -0.6% 1.01x (?)
TypeFlood 0 0 +0.0% 1.00x
UTF8Decode 294 295 +0.3% 1.00x (?)
Walsh 403 405 +0.5% 1.00x (?)
WordCountHistogramASCII 8108 8123 +0.2% 1.00x (?)
WordCountHistogramUTF16 14589 14563 -0.2% 1.00x (?)
WordCountUniqueASCII 2163 2137 -1.2% 1.01x (?)
WordCountUniqueUTF16 7560 7504 -0.7% 1.01x (?)
WordSplitASCII 6813 6902 +1.3% 0.99x (?)
WordSplitUTF16 8483 8652 +2.0% 0.98x (?)
XorLoop 400 401 +0.2% 1.00x (?)

Unoptimized (Onone)

Regression (12)
TEST OLD NEW DELTA SPEEDUP
NSDictionaryCastToSwift 6342 8170 +28.8% 0.78x
DataReplaceMediumBuffer 12031 15058 +25.2% 0.80x
DataReplaceSmallBuffer 9754 11483 +17.7% 0.85x
ObjectiveCBridgeFromNSSetAnyObjectForced 5586 6030 +7.9% 0.93x (?)
CharIndexing_japanese_unicodeScalars 439419 472750 +7.6% 0.93x (?)
PrefixAnySeqCntRange 15675 16850 +7.5% 0.93x
CharIndexing_ascii_unicodeScalars_Backwards 417161 447802 +7.3% 0.93x (?)
StringBuilder 5571 5969 +7.1% 0.93x (?)
DataReplaceLarge 38107 40388 +6.0% 0.94x
WordCountUniqueASCII 8481 8967 +5.7% 0.95x
PrefixAnyCollectionLazy 98213 103720 +5.6% 0.95x (?)
DataCopyBytes 2526 2665 +5.5% 0.95x
Improvement (22)
TEST OLD NEW DELTA SPEEDUP
StringFromLongWholeSubstring 17 12 -29.4% 1.42x
ArrayAppendLazyMap 214928 169205 -21.3% 1.27x
PrefixWhileArrayLazy 15791 12501 -20.8% 1.26x
MapReduceLazyCollection 28273 22695 -19.7% 1.25x
DropWhileArrayLazy 17438 14166 -18.8% 1.23x (?)
FatCompactMap 349112 292656 -16.2% 1.19x
MapReduceLazyCollectionShort 39071 33632 -13.9% 1.16x
ErrorHandling 7534 6564 -12.9% 1.15x (?)
SubstringComparable 1875 1634 -12.9% 1.15x
ObjectiveCBridgeStubFromArrayOfNSString 36790 32581 -11.4% 1.13x (?)
RangeReplaceableCollectionPlusDefault 12447 11027 -11.4% 1.13x
ChainedFilterMap 251916 232189 -7.8% 1.08x
LazilyFilteredArrayContains 814091 750603 -7.8% 1.08x
Dictionary4 1296 1202 -7.3% 1.08x (?)
ObjectiveCBridgeToNSArray 15865 14776 -6.9% 1.07x (?)
SequenceAlgosArray 799785 755444 -5.5% 1.06x
ObjectiveCBridgeFromNSArrayAnyObjectToString 51229 48425 -5.5% 1.06x (?)
LazilyFilteredArrays 1582210 1497420 -5.4% 1.06x
StringUTF16Builder 8812 8356 -5.2% 1.05x (?)
TypeFlood 217 206 -5.1% 1.05x (?)
MapReduceShort 39485 37597 -4.8% 1.05x
StringInterpolation 12186 11605 -4.8% 1.05x (?)
No Changes (390)
TEST OLD NEW DELTA SPEEDUP
AngryPhonebook 5514 5318 -3.6% 1.04x (?)
AnyHashableWithAClass 101955 101642 -0.3% 1.00x (?)
Array2D 636551 636569 +0.0% 1.00x (?)
ArrayAppend 4567 4553 -0.3% 1.00x (?)
ArrayAppendArrayOfInt 862 863 +0.1% 1.00x (?)
ArrayAppendAscii 39242 39535 +0.7% 0.99x
ArrayAppendFromGeneric 860 869 +1.0% 0.99x (?)
ArrayAppendGenericStructs 1504 1502 -0.1% 1.00x
ArrayAppendLatin1 65161 64795 -0.6% 1.01x
ArrayAppendOptionals 1501 1501 +0.0% 1.00x
ArrayAppendRepeatCol 190888 191546 +0.3% 1.00x (?)
ArrayAppendReserved 4403 4399 -0.1% 1.00x (?)
ArrayAppendSequence 105561 105641 +0.1% 1.00x (?)
ArrayAppendStrings 6335 6345 +0.2% 1.00x (?)
ArrayAppendToFromGeneric 865 865 +0.0% 1.00x
ArrayAppendToGeneric 876 874 -0.2% 1.00x (?)
ArrayAppendUTF16 64910 64977 +0.1% 1.00x (?)
ArrayInClass 6209 6233 +0.4% 1.00x (?)
ArrayLiteral 1813 1805 -0.4% 1.00x (?)
ArrayOfGenericPOD2 1185 1185 +0.0% 1.00x
ArrayOfGenericRef 10780 10751 -0.3% 1.00x (?)
ArrayOfPOD 845 845 +0.0% 1.00x
ArrayOfRef 9956 9890 -0.7% 1.01x
ArrayPlusEqualArrayOfInt 866 865 -0.1% 1.00x (?)
ArrayPlusEqualFiveElementCollection 237094 241959 +2.1% 0.98x (?)
ArrayPlusEqualSingleElementCollection 236162 236691 +0.2% 1.00x (?)
ArrayPlusEqualThreeElements 9491 9629 +1.5% 0.99x (?)
ArraySubscript 107204 107660 +0.4% 1.00x
ArrayValueProp 3671 3680 +0.2% 1.00x (?)
ArrayValueProp2 15488 15500 +0.1% 1.00x (?)
ArrayValueProp3 4379 4366 -0.3% 1.00x (?)
ArrayValueProp4 4179 4185 +0.1% 1.00x (?)
BinaryFloatingPointPropertiesBinade 88 88 +0.0% 1.00x
BinaryFloatingPointPropertiesNextUp 131 131 +0.0% 1.00x
BinaryFloatingPointPropertiesUlp 131 131 +0.0% 1.00x
BitCount 8895 8893 -0.0% 1.00x (?)
ByteSwap 9680 9645 -0.4% 1.00x (?)
COWTree 11857 11993 +1.1% 0.99x (?)
CSVParsing 2938531 2945254 +0.2% 1.00x (?)
CSVParsingAlt 1417035 1416715 -0.0% 1.00x (?)
CSVParsingAltIndices 2439046 2396267 -1.8% 1.02x (?)
CStringLongAscii 5506 5553 +0.9% 0.99x (?)
CStringLongNonAscii 2583 2511 -2.8% 1.03x
CStringShortAscii 6303 6204 -1.6% 1.02x (?)
Calculator 2108 2137 +1.4% 0.99x
CaptureProp 285281 284999 -0.1% 1.00x (?)
CharIndexing_ascii_unicodeScalars 368295 377107 +2.4% 0.98x (?)
CharIndexing_chinese_unicodeScalars 280566 288514 +2.8% 0.97x (?)
CharIndexing_chinese_unicodeScalars_Backwards 315480 320401 +1.6% 0.98x (?)
CharIndexing_japanese_unicodeScalars_Backwards 498472 514407 +3.2% 0.97x (?)
CharIndexing_korean_unicodeScalars 359702 365798 +1.7% 0.98x (?)
CharIndexing_korean_unicodeScalars_Backwards 394859 409365 +3.7% 0.96x (?)
CharIndexing_punctuatedJapanese_unicodeScalars 64656 67217 +4.0% 0.96x
CharIndexing_punctuatedJapanese_unicodeScalars_Backwards 73003 73308 +0.4% 1.00x (?)
CharIndexing_punctuated_unicodeScalars 81871 84905 +3.7% 0.96x (?)
CharIndexing_punctuated_unicodeScalars_Backwards 92495 94489 +2.2% 0.98x (?)
CharIndexing_russian_unicodeScalars 306286 314954 +2.8% 0.97x (?)
CharIndexing_russian_unicodeScalars_Backwards 340472 358296 +5.2% 0.95x (?)
CharIndexing_tweet_unicodeScalars 732520 751175 +2.5% 0.98x (?)
CharIndexing_tweet_unicodeScalars_Backwards 812141 845973 +4.2% 0.96x (?)
CharIndexing_utf16_unicodeScalars 310385 319240 +2.9% 0.97x (?)
CharIndexing_utf16_unicodeScalars_Backwards 334735 349324 +4.4% 0.96x
CharIteration_ascii_unicodeScalars 187996 195989 +4.3% 0.96x
CharIteration_ascii_unicodeScalars_Backwards 296668 308310 +3.9% 0.96x (?)
CharIteration_chinese_unicodeScalars 141962 147209 +3.7% 0.96x (?)
CharIteration_chinese_unicodeScalars_Backwards 223195 233558 +4.6% 0.96x
CharIteration_japanese_unicodeScalars 225508 234499 +4.0% 0.96x
CharIteration_japanese_unicodeScalars_Backwards 355346 369511 +4.0% 0.96x (?)
CharIteration_korean_unicodeScalars 182722 190496 +4.3% 0.96x
CharIteration_korean_unicodeScalars_Backwards 288011 299962 +4.1% 0.96x (?)
CharIteration_punctuatedJapanese_unicodeScalars 33041 34464 +4.3% 0.96x (?)
CharIteration_punctuatedJapanese_unicodeScalars_Backwards 52357 54430 +4.0% 0.96x
CharIteration_punctuated_unicodeScalars 41829 43173 +3.2% 0.97x
CharIteration_punctuated_unicodeScalars_Backwards 65205 67864 +4.1% 0.96x
CharIteration_russian_unicodeScalars 156526 162497 +3.8% 0.96x
CharIteration_russian_unicodeScalars_Backwards 246773 256396 +3.9% 0.96x (?)
CharIteration_tweet_unicodeScalars 373122 386116 +3.5% 0.97x
CharIteration_tweet_unicodeScalars_Backwards 587737 613626 +4.4% 0.96x (?)
CharIteration_utf16_unicodeScalars 153746 158419 +3.0% 0.97x (?)
CharIteration_utf16_unicodeScalars_Backwards 250097 257971 +3.1% 0.97x (?)
CharacterLiteralsLarge 5959 5958 -0.0% 1.00x (?)
CharacterLiteralsSmall 678 678 +0.0% 1.00x
CharacterPropertiesFetch 5415 5469 +1.0% 0.99x (?)
CharacterPropertiesPrecomputed 3586 3597 +0.3% 1.00x (?)
CharacterPropertiesStashed 2301 2292 -0.4% 1.00x (?)
CharacterPropertiesStashedMemo 4439 4578 +3.1% 0.97x (?)
Chars 36174 36263 +0.2% 1.00x
ClassArrayGetter 987 987 +0.0% 1.00x
Combos 2387 2347 -1.7% 1.02x (?)
DataAccessBytes 2398 2414 +0.7% 0.99x
DataAppendArray 5589 5823 +4.2% 0.96x (?)
DataAppendBytes 5245 5268 +0.4% 1.00x (?)
DataAppendDataLargeToLarge 66974 67751 +1.2% 0.99x (?)
DataAppendDataLargeToMedium 35418 35117 -0.8% 1.01x (?)
DataAppendDataLargeToSmall 34356 34326 -0.1% 1.00x (?)
DataAppendDataMediumToLarge 37840 37778 -0.2% 1.00x (?)
DataAppendDataMediumToMedium 6739 6748 +0.1% 1.00x (?)
DataAppendDataMediumToSmall 6071 6073 +0.0% 1.00x (?)
DataAppendDataSmallToLarge 37098 37074 -0.1% 1.00x (?)
DataAppendDataSmallToMedium 6166 6135 -0.5% 1.01x (?)
DataAppendDataSmallToSmall 6031 6015 -0.3% 1.00x (?)
DataAppendSequence 1978311 1980512 +0.1% 1.00x (?)
DataCount 223 223 +0.0% 1.00x
DataMutateBytes 5243 5211 -0.6% 1.01x (?)
DataReplaceLargeBuffer 58857 59599 +1.3% 0.99x (?)
DataReplaceMedium 9142 9404 +2.9% 0.97x (?)
DataReplaceSmall 6954 7064 +1.6% 0.98x (?)
DataReset 2952 2962 +0.3% 1.00x (?)
DataSetCount 564 567 +0.5% 0.99x (?)
DataSubscript 443 443 +0.0% 1.00x
DictOfArraysToArrayOfDicts 3606 3535 -2.0% 1.02x (?)
Dictionary 2343 2345 +0.1% 1.00x (?)
Dictionary2 1462 1459 -0.2% 1.00x (?)
Dictionary2OfObjects 4332 4352 +0.5% 1.00x (?)
Dictionary3 867 866 -0.1% 1.00x (?)
Dictionary3OfObjects 2127 2135 +0.4% 1.00x (?)
Dictionary4Legacy 1492 1490 -0.1% 1.00x (?)
Dictionary4OfObjects 1801 1814 +0.7% 0.99x (?)
Dictionary4OfObjectsLegacy 2110 2100 -0.5% 1.00x (?)
DictionaryBridge 1308 1324 +1.2% 0.99x (?)
DictionaryCopy 312763 312781 +0.0% 1.00x (?)
DictionaryFilter 329790 330705 +0.3% 1.00x (?)
DictionaryGroup 4576 4574 -0.0% 1.00x (?)
DictionaryGroupOfObjects 6981 6996 +0.2% 1.00x (?)
DictionaryLiteral 8922 8761 -1.8% 1.02x (?)
DictionaryOfObjects 5829 5879 +0.9% 0.99x (?)
DictionaryRemove 17356 17390 +0.2% 1.00x (?)
DictionaryRemoveOfObjects 52268 53405 +2.2% 0.98x (?)
DictionarySubscriptDefaultMutation 2000 1977 -1.1% 1.01x (?)
DictionarySubscriptDefaultMutationArray 2260 2240 -0.9% 1.01x (?)
DictionarySubscriptDefaultMutationArrayOfObjects 9200 9316 +1.3% 0.99x (?)
DictionarySubscriptDefaultMutationOfObjects 5253 5222 -0.6% 1.01x (?)
DictionarySwap 4908 4972 +1.3% 0.99x
DictionarySwapAt 34996 35045 +0.1% 1.00x (?)
DictionarySwapAtOfObjects 113423 113875 +0.4% 1.00x (?)
DictionarySwapOfObjects 19182 19855 +3.5% 0.97x (?)
DoubleWidthDivision 0 0 +0.0% 1.00x
DropFirstAnyCollection 15607 15703 +0.6% 0.99x (?)
DropFirstAnyCollectionLazy 102350 100958 -1.4% 1.01x (?)
DropFirstAnySeqCRangeIter 23943 23961 +0.1% 1.00x (?)
DropFirstAnySeqCRangeIterLazy 23963 23977 +0.1% 1.00x (?)
DropFirstAnySeqCntRange 15646 15719 +0.5% 1.00x (?)
DropFirstAnySeqCntRangeLazy 15606 15671 +0.4% 1.00x (?)
DropFirstAnySequence 13003 12957 -0.4% 1.00x (?)
DropFirstAnySequenceLazy 13034 12953 -0.6% 1.01x (?)
DropFirstArray 3340 3326 -0.4% 1.00x (?)
DropFirstArrayLazy 33497 33170 -1.0% 1.01x (?)
DropFirstCountableRange 323 323 +0.0% 1.00x
DropFirstCountableRangeLazy 34849 34879 +0.1% 1.00x (?)
DropFirstSequence 12656 12539 -0.9% 1.01x
DropFirstSequenceLazy 12579 12622 +0.3% 1.00x
DropLastAnyCollection 5236 5236 +0.0% 1.00x
DropLastAnyCollectionLazy 33841 33959 +0.3% 1.00x (?)
DropLastAnySeqCRangeIter 41434 41557 +0.3% 1.00x (?)
DropLastAnySeqCRangeIterLazy 41699 41853 +0.4% 1.00x
DropLastAnySeqCntRange 5213 5215 +0.0% 1.00x (?)
DropLastAnySeqCntRangeLazy 5210 5207 -0.1% 1.00x (?)
DropLastAnySequence 31139 31239 +0.3% 1.00x
DropLastAnySequenceLazy 31288 31418 +0.4% 1.00x
DropLastCountableRange 112 112 +0.0% 1.00x
DropLastCountableRangeLazy 11621 11614 -0.1% 1.00x (?)
DropLastSequence 31025 31132 +0.3% 1.00x (?)
DropLastSequenceLazy 31132 31414 +0.9% 0.99x
DropWhileAnyCollection 20309 20294 -0.1% 1.00x (?)
DropWhileAnyCollectionLazy 22712 22776 +0.3% 1.00x
DropWhileAnySeqCRangeIter 24902 24896 -0.0% 1.00x (?)
DropWhileAnySeqCRangeIterLazy 22618 22688 +0.3% 1.00x (?)
DropWhileAnySeqCntRange 20379 20264 -0.6% 1.01x (?)
DropWhileAnySeqCntRangeLazy 22757 22845 +0.4% 1.00x (?)
DropWhileAnySequence 13791 13843 +0.4% 1.00x (?)
DropWhileAnySequenceLazy 12499 12472 -0.2% 1.00x (?)
DropWhileCountableRange 4968 4947 -0.4% 1.00x
DropWhileCountableRangeLazy 22340 22353 +0.1% 1.00x (?)
DropWhileSequence 13403 13452 +0.4% 1.00x (?)
DropWhileSequenceLazy 12186 12124 -0.5% 1.01x (?)
EqualStringSubstring 72 73 +1.4% 0.99x
EqualSubstringString 71 72 +1.4% 0.99x
EqualSubstringSubstring 72 73 +1.4% 0.99x
EqualSubstringSubstringGenericEquatable 60 59 -1.7% 1.02x
ExclusivityGlobal 186 186 +0.0% 1.00x
ExclusivityIndependent 73 76 +4.1% 0.96x (?)
FilterEvenUsingReduce 3593 3591 -0.1% 1.00x (?)
FilterEvenUsingReduceInto 1887 1904 +0.9% 0.99x (?)
FloatingPointPrinting_Double_description_small 24336 24271 -0.3% 1.00x (?)
FloatingPointPrinting_Double_description_uniform 35870 35904 +0.1% 1.00x (?)
FloatingPointPrinting_Double_interpolated 96595 94167 -2.5% 1.03x (?)
FloatingPointPrinting_Float80_description_small 31308 31261 -0.2% 1.00x (?)
FloatingPointPrinting_Float80_description_uniform 61137 59000 -3.5% 1.04x
FloatingPointPrinting_Float80_interpolated 120311 119213 -0.9% 1.01x (?)
FloatingPointPrinting_Float_description_small 6589 6549 -0.6% 1.01x
FloatingPointPrinting_Float_description_uniform 17366 17415 +0.3% 1.00x (?)
FloatingPointPrinting_Float_interpolated 70681 74086 +4.8% 0.95x (?)
FrequenciesUsingReduce 10904 10785 -1.1% 1.01x (?)
FrequenciesUsingReduceInto 3189 3134 -1.7% 1.02x (?)
Hanoi 20760 20687 -0.4% 1.00x (?)
HashTest 21037 20907 -0.6% 1.01x (?)
Histogram 7380 7336 -0.6% 1.01x (?)
Integrate 458 464 +1.3% 0.99x
IterateData 5443 5480 +0.7% 0.99x
Join 778 779 +0.1% 1.00x (?)
LazilyFilteredRange 549361 551253 +0.3% 1.00x (?)
LessSubstringSubstring 72 73 +1.4% 0.99x
LessSubstringSubstringGenericComparable 59 59 +0.0% 1.00x
LinkedList 32285 32155 -0.4% 1.00x (?)
LuhnAlgoEager 5407 5487 +1.5% 0.99x (?)
LuhnAlgoLazy 5747 5558 -3.3% 1.03x (?)
MapReduce 25691 25654 -0.1% 1.00x (?)
MapReduceAnyCollection 25698 25614 -0.3% 1.00x
MapReduceAnyCollectionShort 37949 37370 -1.5% 1.02x (?)
MapReduceClass 29888 29698 -0.6% 1.01x (?)
MapReduceClassShort 41579 41366 -0.5% 1.01x (?)
MapReduceLazySequence 20614 20665 +0.2% 1.00x (?)
MapReduceSequence 30717 30940 +0.7% 0.99x
MapReduceShortString 239 239 +0.0% 1.00x
MapReduceString 1741 1748 +0.4% 1.00x
Memset 44126 44136 +0.0% 1.00x (?)
MonteCarloE 1142110 1142919 +0.1% 1.00x (?)
MonteCarloPi 5174220 5198728 +0.5% 1.00x
NSError 617 606 -1.8% 1.02x (?)
NSStringConversion 787 790 +0.4% 1.00x (?)
NibbleSort 503205 502061 -0.2% 1.00x
NopDeinit 193584 193811 +0.1% 1.00x (?)
ObjectAllocation 1252 1269 +1.4% 0.99x (?)
ObjectiveCBridgeFromNSArrayAnyObject 30005 28850 -3.8% 1.04x (?)
ObjectiveCBridgeFromNSArrayAnyObjectForced 9560 9266 -3.1% 1.03x (?)
ObjectiveCBridgeFromNSArrayAnyObjectToStringForced 45991 44393 -3.5% 1.04x (?)
ObjectiveCBridgeFromNSDictionaryAnyObject 119732 120283 +0.5% 1.00x (?)
ObjectiveCBridgeFromNSSetAnyObject 54981 57445 +4.5% 0.96x (?)
ObjectiveCBridgeFromNSSetAnyObjectToString 69858 70249 +0.6% 0.99x (?)
ObjectiveCBridgeFromNSString 2986 2850 -4.6% 1.05x (?)
ObjectiveCBridgeFromNSStringForced 2793 2803 +0.4% 1.00x (?)
ObjectiveCBridgeStubDataAppend 6197 6285 +1.4% 0.99x (?)
ObjectiveCBridgeStubDateMutation 773 773 +0.0% 1.00x
ObjectiveCBridgeStubFromNSDate 7995 8331 +4.2% 0.96x (?)
ObjectiveCBridgeStubFromNSString 1075 1089 +1.3% 0.99x
ObjectiveCBridgeStubFromNSStringRef 196 197 +0.5% 0.99x (?)
ObjectiveCBridgeStubNSDataAppend 2977 3020 +1.4% 0.99x (?)
ObjectiveCBridgeStubNSDateMutationRef 15685 15969 +1.8% 0.98x (?)
ObjectiveCBridgeStubToArrayOfNSString 40422 38945 -3.7% 1.04x (?)
ObjectiveCBridgeStubToNSDate 15904 15850 -0.3% 1.00x (?)
ObjectiveCBridgeStubToNSDateRef 3456 3482 +0.8% 0.99x (?)
ObjectiveCBridgeStubToNSString 2418 2412 -0.2% 1.00x (?)
ObjectiveCBridgeStubToNSStringRef 153 154 +0.7% 0.99x
ObjectiveCBridgeStubURLAppendPath 299495 299453 -0.0% 1.00x (?)
ObjectiveCBridgeStubURLAppendPathRef 302511 293470 -3.0% 1.03x (?)
ObjectiveCBridgeToNSDictionary 27765 28307 +2.0% 0.98x (?)
ObjectiveCBridgeToNSSet 17473 18070 +3.4% 0.97x (?)
ObjectiveCBridgeToNSString 528 539 +2.1% 0.98x
ObserverClosure 6465 6473 +0.1% 1.00x (?)
ObserverForwarderStruct 4363 4371 +0.2% 1.00x (?)
ObserverPartiallyAppliedMethod 8040 8103 +0.8% 0.99x (?)
ObserverUnappliedMethod 8209 8219 +0.1% 1.00x (?)
OpenClose 892 889 -0.3% 1.00x
PartialApplyDynamicType 39277 39441 +0.4% 1.00x (?)
Phonebook 19025 19019 -0.0% 1.00x (?)
PointerArithmetics 117418 117442 +0.0% 1.00x (?)
PolymorphicCalls 2377 2363 -0.6% 1.01x (?)
PopFrontArray 4647 4637 -0.2% 1.00x (?)
PopFrontArrayGeneric 5386 5421 +0.6% 0.99x (?)
PopFrontUnsafePointer 10661 10569 -0.9% 1.01x (?)
PrefixAnyCollection 15636 15667 +0.2% 1.00x (?)
PrefixAnySeqCRangeIter 19133 19148 +0.1% 1.00x (?)
PrefixAnySeqCRangeIterLazy 19111 19162 +0.3% 1.00x (?)
PrefixAnySeqCntRangeLazy 15594 15615 +0.1% 1.00x (?)
PrefixAnySequence 10631 10588 -0.4% 1.00x (?)
PrefixAnySequenceLazy 10661 10544 -1.1% 1.01x
PrefixArray 3400 3374 -0.8% 1.01x (?)
PrefixArrayLazy 33407 33393 -0.0% 1.00x (?)
PrefixCountableRange 323 323 +0.0% 1.00x
PrefixCountableRangeLazy 34867 34857 -0.0% 1.00x (?)
PrefixSequence 10189 10354 +1.6% 0.98x
PrefixSequenceLazy 10143 10191 +0.5% 1.00x (?)
PrefixWhileAnyCollection 29462 29595 +0.5% 1.00x
PrefixWhileAnyCollectionLazy 18682 18701 +0.1% 1.00x (?)
PrefixWhileAnySeqCRangeIter 34911 34913 +0.0% 1.00x (?)
PrefixWhileAnySeqCRangeIterLazy 18713 18629 -0.4% 1.00x
PrefixWhileAnySeqCntRange 29502 29542 +0.1% 1.00x (?)
PrefixWhileAnySeqCntRangeLazy 18699 18682 -0.1% 1.00x (?)
PrefixWhileAnySequence 27041 26991 -0.2% 1.00x (?)
PrefixWhileAnySequenceLazy 11143 11174 +0.3% 1.00x (?)
PrefixWhileArray 10444 10449 +0.0% 1.00x (?)
PrefixWhileCountableRange 14034 14002 -0.2% 1.00x
PrefixWhileCountableRangeLazy 18417 18413 -0.0% 1.00x (?)
PrefixWhileSequence 26557 26728 +0.6% 0.99x
PrefixWhileSequenceLazy 10799 10809 +0.1% 1.00x (?)
Prims 9675 9574 -1.0% 1.01x (?)
PrimsSplit 9781 9602 -1.8% 1.02x (?)
QueueConcrete 14251 14243 -0.1% 1.00x (?)
QueueGeneric 19558 19358 -1.0% 1.01x (?)
RC4 15953 16033 +0.5% 1.00x
RGBHistogram 26478 26456 -0.1% 1.00x (?)
RGBHistogramOfObjects 82568 81277 -1.6% 1.02x (?)
RangeAssignment 2622 2630 +0.3% 1.00x (?)
RangeIterationSigned 14754 14853 +0.7% 0.99x (?)
RecursiveOwnedParameter 5760 5782 +0.4% 1.00x (?)
RemoveWhereFilterInts 1975 1975 +0.0% 1.00x
RemoveWhereFilterString 1293 1287 -0.5% 1.00x (?)
RemoveWhereFilterStrings 2475 2472 -0.1% 1.00x (?)
RemoveWhereMoveInts 3408 3404 -0.1% 1.00x (?)
RemoveWhereMoveStrings 3925 3919 -0.2% 1.00x (?)
RemoveWhereQuadraticInts 8171 8161 -0.1% 1.00x (?)
RemoveWhereQuadraticString 2278 2275 -0.1% 1.00x (?)
RemoveWhereQuadraticStrings 9790 9781 -0.1% 1.00x (?)
RemoveWhereSwapInts 6142 6139 -0.0% 1.00x (?)
RemoveWhereSwapStrings 6867 6851 -0.2% 1.00x (?)
ReversedArray 13134 13269 +1.0% 0.99x
ReversedBidirectional 43013 43164 +0.4% 1.00x (?)
ReversedDictionary 23120 23049 -0.3% 1.00x (?)
RomanNumbers 1265143 1306068 +3.2% 0.97x (?)
SequenceAlgosAnySequence 13256 13277 +0.2% 1.00x (?)
SequenceAlgosContiguousArray 294393 291782 -0.9% 1.01x
SequenceAlgosList 8777 8728 -0.6% 1.01x (?)
SequenceAlgosRange 1298209 1297386 -0.1% 1.00x (?)
SequenceAlgosUnfoldSequence 6584 6633 +0.7% 0.99x
SetExclusiveOr 16501 16478 -0.1% 1.00x (?)
SetExclusiveOr_OfObjects 41044 41017 -0.1% 1.00x (?)
SetIntersect 6587 6603 +0.2% 1.00x (?)
SetIntersect_OfObjects 10306 10316 +0.1% 1.00x (?)
SetIsSubsetOf 1194 1183 -0.9% 1.01x
SetIsSubsetOf_OfObjects 2269 2275 +0.3% 1.00x (?)
SetUnion 11785 11746 -0.3% 1.00x (?)
SetUnion_OfObjects 29776 29823 +0.2% 1.00x (?)
SevenBoom 1126 1079 -4.2% 1.04x (?)
Sim2DArray 43254 43450 +0.5% 1.00x
SortLargeExistentials 11738 11646 -0.8% 1.01x (?)
SortLettersInPlace 1905 1924 +1.0% 0.99x (?)
SortSortedStrings 1165 1146 -1.6% 1.02x
SortStrings 2351 2325 -1.1% 1.01x
SortStringsUnicode 2822 2814 -0.3% 1.00x (?)
StackPromo 100414 98385 -2.0% 1.02x (?)
StaticArray 2574 2572 -0.1% 1.00x (?)
StrComplexWalk 7267 7267 +0.0% 1.00x
StrToInt 86364 84816 -1.8% 1.02x (?)
StringAdder 1178 1149 -2.5% 1.03x
StringBuilderLong 2960 2956 -0.1% 1.00x (?)
StringBuilderWithLongSubstring 5220 5124 -1.8% 1.02x (?)
StringComparison_abnormal 1337 1332 -0.4% 1.00x (?)
StringComparison_ascii 9469 9431 -0.4% 1.00x
StringComparison_emoji 2011 1997 -0.7% 1.01x (?)
StringComparison_fastPrenormal 4921 4909 -0.2% 1.00x
StringComparison_latin1 3827 3836 +0.2% 1.00x (?)
StringComparison_longSharedPrefix 2374 2380 +0.3% 1.00x (?)
StringComparison_nonBMPSlowestPrenormal 3744 3697 -1.3% 1.01x (?)
StringComparison_slowerPrenormal 4199 4187 -0.3% 1.00x (?)
StringComparison_zalgo 127945 127834 -0.1% 1.00x (?)
StringEdits 419591 406941 -3.0% 1.03x (?)
StringEnumRawValueInitialization 33989 33566 -1.2% 1.01x (?)
StringEqualPointerComparison 1589 1592 +0.2% 1.00x (?)
StringFromLongWholeSubstringGeneric 200 200 +0.0% 1.00x
StringHasPrefixAscii 3125 3126 +0.0% 1.00x (?)
StringHasPrefixUnicode 114846 115438 +0.5% 0.99x (?)
StringHasSuffixAscii 3294 3293 -0.0% 1.00x (?)
StringHasSuffixUnicode 106735 106127 -0.6% 1.01x (?)
StringInterpolationManySmallSegments 20685 21116 +2.1% 0.98x (?)
StringInterpolationSmall 8763 8851 +1.0% 0.99x (?)
StringMatch 40921 40510 -1.0% 1.01x (?)
StringRemoveDupes 727 721 -0.8% 1.01x (?)
StringUTF16SubstringBuilder 26146 25823 -1.2% 1.01x (?)
StringWalk 12552 12542 -0.1% 1.00x (?)
StringWithCString 41754 41770 +0.0% 1.00x (?)
StringWordBuilder 2542 2554 +0.5% 1.00x (?)
StringWordBuilderReservingCapacity 2141 2149 +0.4% 1.00x (?)
SubstringEqualString 1713 1710 -0.2% 1.00x (?)
SubstringEquatable 5685 5431 -4.5% 1.05x (?)
SubstringFromLongString 19 19 +0.0% 1.00x
SubstringFromLongStringGeneric 107 107 +0.0% 1.00x
SuffixAnyCollection 5252 5299 +0.9% 0.99x (?)
SuffixAnyCollectionLazy 32907 34044 +3.5% 0.97x (?)
SuffixAnySeqCRangeIter 36833 36951 +0.3% 1.00x (?)
SuffixAnySeqCRangeIterLazy 37070 37112 +0.1% 1.00x (?)
SuffixAnySeqCntRange 5205 5235 +0.6% 0.99x
SuffixAnySeqCntRangeLazy 5205 5214 +0.2% 1.00x (?)
SuffixAnySequence 26496 26660 +0.6% 0.99x (?)
SuffixAnySequenceLazy 26736 26525 -0.8% 1.01x
SuffixCountableRange 112 112 +0.0% 1.00x
SuffixCountableRangeLazy 11640 11617 -0.2% 1.00x (?)
SuffixSequence 26507 26466 -0.2% 1.00x (?)
SuffixSequenceLazy 26497 26411 -0.3% 1.00x (?)
SumUsingReduce 161232 160769 -0.3% 1.00x
SumUsingReduceInto 153309 153283 -0.0% 1.00x (?)
SuperChars 85875 85928 +0.1% 1.00x (?)
TwoSum 3496 3523 +0.8% 0.99x (?)
UTF8Decode 29801 29746 -0.2% 1.00x (?)
Walsh 11940 11942 +0.0% 1.00x (?)
WordCountHistogramASCII 40687 38968 -4.2% 1.04x (?)
WordCountHistogramUTF16 48262 46656 -3.3% 1.03x
WordCountUniqueUTF16 14201 14731 +3.7% 0.96x (?)
WordSplitASCII 9730 9778 +0.5% 1.00x (?)
WordSplitUTF16 11964 11707 -2.1% 1.02x (?)
XorLoop 23237 23251 +0.1% 1.00x (?)
Hardware Overview
  Model Name: Mac Pro
  Model Identifier: MacPro6,1
  Processor Name: 12-Core Intel Xeon E5
  Processor Speed: 2.7 GHz
  Number of Processors: 1
  Total Number of Cores: 12
  L2 Cache (per Core): 256 KB
  L3 Cache: 30 MB
  Memory: 64 GB

…truction

Mandatory pass will clean it up and replace it by a copy_block and
is_escaping/cond_fail/release combination on the %closure in follow-up
patches.

The instruction marks the dependence of a block on a closure that is
used as an 'withoutActuallyEscaping' sentinel.

rdar://39682865
I am going to introduce a third use in a follow-up
…tructions

Replace:

  %copy = copy_block_without_escaping %block withoutEscaping %closure

  ...
  destroy_value %copy

by (roughly) the instruction sequence:

  %copy = copy_block %block

  ...
  destroy_value %copy
  %e = is_escaping %closure
  cond_fail %e
  destroy_value %closure

rdar://39682865
After the copy_block_without_actually_escaping change it might see a
mark_dependence instruction on a noescape closure.

rdar://39682865
The pattern we see for noescape closure passed to objective c is different:
There is the additional without actually escaping closure sentinel.

rdar://39682865
escapes the closure.

We expect the program to crash with an explanation.

rdar://39682865
Objective C closures when reporting that a closure has escaped

rdar://39682865
@aschwaighofer aschwaighofer force-pushed the objc_without_actually_escaping_noescape_wip branch from 950dbb8 to 1f65ee2 Compare May 1, 2018 14:24
@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented May 1, 2018

Build failed
Swift Test Linux Platform
Git Sha - 950dbb8415b322b351d903ae3f212bfd58c95c76

@swift-ci
Copy link
Contributor

swift-ci commented May 1, 2018

Build failed
Swift Test OS X Platform
Git Sha - 950dbb8415b322b351d903ae3f212bfd58c95c76

@aschwaighofer aschwaighofer changed the title WIP: Implement verification that noescape closures passed to Objective-C are not escaped Implement verification that noescape closures passed to Objective-C are not escaped May 1, 2018
@aschwaighofer aschwaighofer merged commit 8054e7d into swiftlang:master May 1, 2018
aschwaighofer added a commit to aschwaighofer/swift that referenced this pull request May 3, 2018
…ve-C are not escaped

The series of commit introduces a ``copy_block_without_escaping`` block
instruction that ties a swift closure sentinel to the block that is
escaped.

SILGen emits this instruction when it generates a conversion from a
``@noescape`` swift closure to a block.

```
       %noescape_closure = ...
       %wae_Thunk = function_ref @$withoutActuallyEscapingThunk
       %sentinel =
         partial_apply [callee_guaranteed] %wae_thunk(%noescape_closure)
       %noescaped_wrapped = mark_dependence %sentinel on %noescape_closure
       %sentinel_copy = copy_value %noescaped_wrapped
       %storage = alloc_stack
       %storage_address = project_block_storage %storage
       store %noescaped_wrapped to [init] %storage_address
       %block = init_block_storage_header %storage ...
       %block = copy_block_without_escaping %block withoutEscaping %noescaped_wrapped
```

The ClosureLifetimeFixup pass then lowers
``copy_block_without_escaping`` into a ``copy_block`` and
``is_escaping``/``cond_fail``/``destroy_value`` combination at a point
that succeeds the end of the block's lifetime.

As a result whenever a semantic noescape Swift closure synchronously
escapes to Objective C we will trap with an error after we return from
the Objective C call.

rdar://39682865

Cherry-pick of swiftlang#16236

Commits:

* Add a copy_block_without_escaping %block withoutEscaping %closure instruction

Mandatory pass will clean it up and replace it by a copy_block and
is_escaping/cond_fail/release combination on the %closure in follow-up
patches.

The instruction marks the dependence of a block on a closure that is
used as an 'withoutActuallyEscaping' sentinel.

* SIL: Allow is_escaping_closure on optional closure types

* SILGen: Emit withoutActuallyEscaping verification for @NoEscape closures stored in blocks

* SIL: Add getSingleDealloc to AllocStack and remove two copies of it

I am going to introduce a third use in a follow-up

* ClosureLifetimeFixup: Add support for copy_block_without_escaping instructions

Replace:

  %copy = copy_block_without_escaping %block withoutEscaping %closure

  ...
  destroy_value %copy

by (roughly) the instruction sequence:

  %copy = copy_block %block

  ...
  destroy_value %copy
  %e = is_escaping %closure
  cond_fail %e
  destroy_value %closure

* Fix DiagnoseStaticExclusivity

After the copy_block_without_actually_escaping change it might see a
mark_dependence instruction on a noescape closure.

* Fixes to AccessSummaryAnalysis

The pattern we see for noescape closure passed to objective c is different:
There is the additional without actually escaping closure sentinel.

* Fix test cases after SIL representation changes

* Executable test case for passing a noescape closure to Objective-c which
escapes the closure.

We expect the program to crash with an explanation.

* Distinguish between withoutActuallyEscaping and passing @NoEscape
Objective C closures when reporting that a closure has escaped

rdar://39682865
aschwaighofer added a commit to aschwaighofer/swift that referenced this pull request May 3, 2018
…ve-C are not escaped

The series of commit introduces a ``copy_block_without_escaping`` block
instruction that ties a swift closure sentinel to the block that is
escaped.

SILGen emits this instruction when it generates a conversion from a
``@noescape`` swift closure to a block.

```
       %noescape_closure = ...
       %wae_Thunk = function_ref @$withoutActuallyEscapingThunk
       %sentinel =
         partial_apply [callee_guaranteed] %wae_thunk(%noescape_closure)
       %noescaped_wrapped = mark_dependence %sentinel on %noescape_closure
       %sentinel_copy = copy_value %noescaped_wrapped
       %storage = alloc_stack
       %storage_address = project_block_storage %storage
       store %noescaped_wrapped to [init] %storage_address
       %block = init_block_storage_header %storage ...
       %block = copy_block_without_escaping %block withoutEscaping %noescaped_wrapped
```

The ClosureLifetimeFixup pass then lowers
``copy_block_without_escaping`` into a ``copy_block`` and
``is_escaping``/``cond_fail``/``destroy_value`` combination at a point
that succeeds the end of the block's lifetime.

As a result whenever a semantic noescape Swift closure synchronously
escapes to Objective C we will trap with an error after we return from
the Objective C call.

rdar://39682865

Cherry-pick of swiftlang#16236

Commits:

* Add a copy_block_without_escaping %block withoutEscaping %closure instruction

Mandatory pass will clean it up and replace it by a copy_block and
is_escaping/cond_fail/release combination on the %closure in follow-up
patches.

The instruction marks the dependence of a block on a closure that is
used as an 'withoutActuallyEscaping' sentinel.

* SIL: Allow is_escaping_closure on optional closure types

* SILGen: Emit withoutActuallyEscaping verification for @NoEscape closures stored in blocks

* SIL: Add getSingleDealloc to AllocStack and remove two copies of it

I am going to introduce a third use in a follow-up

* ClosureLifetimeFixup: Add support for copy_block_without_escaping instructions

Replace:

  %copy = copy_block_without_escaping %block withoutEscaping %closure

  ...
  destroy_value %copy

by (roughly) the instruction sequence:

  %copy = copy_block %block

  ...
  destroy_value %copy
  %e = is_escaping %closure
  cond_fail %e
  destroy_value %closure

* Fix DiagnoseStaticExclusivity

After the copy_block_without_actually_escaping change it might see a
mark_dependence instruction on a noescape closure.

* Fixes to AccessSummaryAnalysis

The pattern we see for noescape closure passed to objective c is different:
There is the additional without actually escaping closure sentinel.

* Fix test cases after SIL representation changes

* Executable test case for passing a noescape closure to Objective-c which
escapes the closure.

We expect the program to crash with an explanation.

* Distinguish between withoutActuallyEscaping and passing @NoEscape
Objective C closures when reporting that a closure has escaped

rdar://39682865
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