On 02/08/2013 02:06 AM, deadalnix wrote:
On Friday, 8 February 2013 at 06:28:54 UTC, Chad Joan wrote:

Destroy!


The cost of passing a delegate is way higher than the cost of passing
the extra pointer. Delegate cause an opaque function call so :
- All registers that the callee is allowed to trash must be saved
preventively (even if the callee don't trash them).
- CPU cannot really use branch prediction.
- The compiler must assume that the delegate call may have arbitrary
side effects so have to commit everything to memory and then take
everything back afterward. This prevent many instruction reordering,
register promotions, dead read/write elimination, constant propagation
and so on.

Considering passing by ref is sometime done to fasten things, this
defeat the whole point.

Note that the operation above are not dying slow, but clearly not a good
fit for ref.


Fair enough.

I wonder if we can learn something from it though. It does seem to provide a conceptual model that's very desirable.

Reply via email to