[SR-13221] No type erasure technique both specializes and generalizes to multiple operations #55661
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
generics
Feature: generic declarations and types
performance
SILOptimizer
Area → compiler: SIL optimization passes
Additional Detail from JIRA
md5: 9c1d28b2fc80561734765c514037f198
Issue Description:
This gist is a survey of known type erasure techniques along with a performance analysis.
Build with
swiftc -O -g -whole-module-optimization
.Set a breakpoint on line 17 and issue “
disassemble
” to LLDB when you hit it to inspectthe code generated for cases that I've noted fail to specialze.
The techniques that do specialize properly have the drawback of being poorly suited to type erasure over more than one operation. A manually-created table of functions would incur lots of ARC and can't be initialized in a static member of a generic type, which would lead one to build a threadsafe dictionaries mapping types to function tables—the kind of thing the runtime library implements—which users shouldn't have to build.
The text was updated successfully, but these errors were encountered: