rvalue references

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 9 10:38:00 PDT 2015


On 6/9/15 12:23 PM, kink wrote:
> On Tuesday, 9 June 2015 at 15:08:07 UTC, Steven Schveighoffer wrote:
>> Because it's not moved. It's written in the stack where it will be
>> passed to the next function.
>
> Hmm, you mean the callee's function parameters stack? That's not always
> going to work, e.g., on Win64 the first 4 args are passed in registers,
> always.

If that's what's required, that's what we do. I'm not strictly saying 
that we will *always* do stack passing in spite of the ABI. But passing 
a large rvalue by value does not involve any moving of data, and can be 
abstracted to a pass by ref if needed. It's never less performing than 
an explicit pass by ref.

> And, as I said, that ABI doesn't support byval passing of types
>  > 64 bits (let's exclude vector types here), so rvalues > 64 bits can
> sadly not be constructed in-place without violating the Win64 ABI -
> they'll have to be passed byref.

I don't think we violate the Win64 ABI. So if it requires pass by ref, 
it requires pass by ref. I am not an expert in this matter. You may want 
to try some disassembly and see what D does.

-Steve


More information about the Digitalmars-d mailing list