Yeah. If you call a generic function whose implementation is available to the compiler, the optimizer will generate a version where the type is substituted and the vtables become unnecessary, more like a C++ template. Sometimes we do this for non type arguments too like closures
I wrote an entire VM in C++ templates to interpret these layouts as quickly as possible to adjust reference counts and such. It was a large speed penalty (~30% of time profile of Rust code was spent in it or something) and didn’t even reduce code size that much.
-
-
But this was used for everything; the compiler had no specialization at all. So maybe things would be different if this was only for cold code.
-
I was pretty burned on the whole approach after that and resolved that I’ll just use an interpreter and/or a JIT if I ever wanted to avoid template specialization again. Maybe I should have tried harder, but that was the result.
- 7 more replies
New conversation -
-
-
I don't know why but to me this sounds very similar to Gecko's generated DOM bindings vs. XPCOM calls through XPConnect typelibs.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.