4 ms·
> How would you know what to type-cast FROM? It's not like C compilers pass type information around, nor are C values self describing. That happens to be true,
by boulos 7y ago
> How would you know what to type-cast FROM? It's not like C compilers pass type information around, nor are C values self describing.
That happens to be true, but one could imagine a calling convention that does do this, e.g. something like:
fixed0, fixed1, ..., fixedN, numVarArgs, type0, ..., typeM, arg0, ..., argM
it's just that it burns tons more registers than the promotion scheme does. And you'd still end up with a mini "interpreter" in the callee to at least switch over types.
- dahart 7y agoI’d be fibbing if I said I’d thought it out that far before commenting... :P But thank you for offering a plausible explanation, Solomon.
- boulos 7y agoNo problem, Dave! I had to do precisely this for PHP’s variadic arguments. I think HHVM made up even more calling conventions. Fwiw, the next optimization is to “compress” the type signatures into a handful of bits, to save registers. But it’s still not that big of a safety win for actual C code because of the clumsy switch inside the callee.