5 ms·
The compiler would be forced to create copies in that case. In general (using my proposed ABI), taking the address of an object will cause this, because it is
by moonchild 5y ago
The compiler would be forced to create copies in that case. In general (using my proposed ABI), taking the address of an object will cause this, because it is possible to mutate an object through its address.
It's still a win because 1) you can avoid making copies in many places, and 2) code size decreases because the copy happens one time in the callee rather than many times for every caller.
- gpderetta 5y agoSo the caller might have to copy if the the pointer escapes and the callee might have to copy if it needs to mutate the value. In practice in many cases you might end up with more copies than the "bad" ABI.