top | item 14677553

(no title)

topkekz | 8 years ago

Only skimmed the article but i think they want something like this

  <T> objc_msgSend(Object *receiver, String *method, ...)
  {
    return get_method(receiver->class, method)(receiver, ...);
  }
where the tail call is translated into an unconditional jump (like goto).

EDIT: this GNU C extension could help avoiding assembly for implementing objc_msgSend

https://gcc.gnu.org/onlinedocs/gcc-7.1.0/gcc/Constructing-Ca...

discuss

order

mikeash|8 years ago

That's nifty, but I don't think it quite gets you there:

"It is not always simple to compute the proper value for size. The value is used by __builtin_apply to compute the amount of data that should be pushed on the stack and copied from the incoming argument area."

If there was a variant that didn't need this size argument (would probably require being a tail call) then that would do it.

panic|8 years ago

Could you do it with a C++ variadic template?