Parameter packs as variadics ABI

Over the years I know we’ve regretted the choice of making our variadics ABI tied to the heap-allocated, easily-escapable Array. I noticed while reading the parameter pack proposal that it’s possible to generate the type (repeat Int), though it’s clear that the surface spelling must be leaving out the count derived from another pack. It occurred to me that the calling convention for “classic” variadics could be changed to this in the “unstable” ABI. For first implementation, this could immediately turn around and make an Array in the callee, but even that would allow better local optimization if the array doesn’t escape. In the long run, optimizations could probably avoid creating the array at all.

I put this in the Compiler Development topic because I think it can be done without changing the surface language at all. It’s entirely possible that creating the pack description at the call site ends up being worse than creating an array, though. And the stable ABI continues to be stuck.

(I’m not volunteering to implement this. I just wanted to share the idea.)

9 Likes