mozilla/rust — Issue #1736: Monomorphize generic functions
Author: marijnh
Created: 2012-02-02 13:19:14+00:00
State: open
Labels: perf, trans

There is consensus that we should at least experiment with generating single-type instances of generic functions. So if you have `map` and you call it on ``, the compiler can compile a version specifically for those types, and if you then call it on `<@int, (float, float)>`, it can generate another version.

We can reuse generated functions for similar types. For example, since generics can't look 'into' types, types like `int` and `uint` could be passed to the same version of a function without problems. We also store tydescs in boxes now, so a single version could be used for all `@` types, and simply look inside the box if it needs to call free or compare glue on them.

This is related to the project of cross-crate inlining. To monomorphize a function, you also need some representation of its code.