2017 LLVM Developers’ Meeting: “Implementing Swift Generics ”

preview_player
Показать описание

Implementing Swift Generics - Douglas Gregor, Slava Pestov and John McCall

Slides: Coming Soon

Swift is a safe and efficient systems language with support for generic programming via its static type system. Various existing implementations of generic programming use either a uniform runtime representation for values (e.g., Java generics) or compile-time monomorphization (e.g., C++, Rust). Swift takes a “dictionary-passing” approach, similar to type-classes in Haskell, using reified type metadata to allow generic code to abstract over the memory layout of data types and avoid boxing. In this talk, we will describe the compilation of Swift’s generics from the type checker down to LLVM IR lowering and interaction with the Swift runtime, illustrating the how the core representation of generics flows through the system, from answering type-checking queries to the calling convention of generic functions and runtime representation of the “dictionaries”.

Рекомендации по теме
Комментарии
Автор

Thanks for a wonderful talk! This (+ watching generated LLVM IR on compiler explorer) is helping me a lot in implementing my own programming language's frontend.

daniilgavrilikhin
Автор

Very interesting way to reduce monomorphisation overhead
Also to make dynamic libraries possible with purely generic code. Seems kind of very slow though to actually use these generic functions.

Lircking
Автор

7:15 is there a reason why one call is _f() and the other is f()?

IanPartridge