11.03.2012 3:45, Robert Jacques пишет:
[...]
Manu, please go read the D ABI (http://dlang.org/abi.html). Remember, your example of returning two values using Tuple vs 'real' MRV? The D ABI states that those values will be returned via registers. Returning something larger? Then the NVRO kicks in which gives you a zero copy approach. On x86-64 these limits are different, since you have more registers to play with, but the concept is the same. In fact, returning arguments has always been more efficient than passing arguments.

It doesn't work with FPU stack however, so returning these packed into structure should be slower that via ref parameters. E.g:

Tuple!(float, float) callee() {
do something to achieve result in st0,st1
fst st0, st1 into stack
load stack values into EAX, EDX
ret
}

void caller() {
call callee()
push EAX, EDX into a stack
fld stack values into st0, st1
do something with st0, st1
}

As opposed to:

Tuple!(float, float) callee() {
do something to achieve result in st0,st1
ret
}

void caller() {
call callee()
do something with st0, st1
}

Is there something I miss here?

Reply via email to