2 ms·
If the address of the object escapes on the caller side then it has to make a copy as the object could be mutated or even just break the distinct address guaran
by gpderetta 6y ago
If the address of the object escapes on the caller side then it has to make a copy as the object could be mutated or even just break the distinct address guarantee of the language.
- mort96 6y agoI still don't understand, sorry. If the callee does something which could cause the caller's object to change, such as calling an unknown function or modifying through another pointer which might alias the parameter, the callee would just have to make a copy. Could you provide an example of a situation where there would be more copies made using the proposed ABI than in traditional ABIs?
- gpderetta 6y agoSure, if calling any external function or writing though any pointer would force the callee to copy the object then yes you can have only the callee do the copy, but then it seems that this optimization would apply only to a very small subset of functions.
- mort96 6y agoRight. That was my understanding, but I now see that there are more ways to understand it. I don't know which is correct, so I wrote a response to moonchild's comment here: https://news.ycombinator.com/item?id=27091726 https://news.ycombinator.com/item?id=27091726