www.digitalmars.com         C & C++   DMDScript  

D.gnu - [Issue 1066] New: Variadic arguments being passed in registers

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1066

           Summary: Variadic arguments being passed in registers
           Product: DGCC aka GDC
           Version: 0.23
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: glue layer
        AssignedTo: dvdfrdmn users.sf.net
        ReportedBy: madou madou.org


On several architectures, optional arguments to variadic functions get passed
in registers, just like regular arguments. This prevents the use of _argptr,
among others. In our opinion (my own and that of several Tango library
developers), even if the platform ABI dictates the use of registers for
variadic arguments, this approach should only ever be taken for extern (C)
functions. D functions are better off using stack-borne varargs, for the reason
mentioned above, and also since register based varargs incur a heavy
performance penalty due to most platforms' inability to dynamically index their
register files.


-- 
Mar 16 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1066


fvbommel wxs.nl changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fvbommel wxs.nl





I just found out that gphobos also suffers because of this.
std/format.d, line 897+:
---
else version(X86_64)
{
    throw new FormatError("cannot portably format a struct on this target");
}
---
This seems to be because it can't obtain a pointer to the struct to pass to
TypeInfo_Struct.xtoString(void*)...

This _really_ needs to be fixed. Neither of gphobos and tango can fully support
their respective formatted text output facilities on amd64 (and any similar
platforms, presumably) because of this.

(workaround for gphobos: explicitly calling .toString on arguments)


-- 
Mar 18 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1066


Iain Buclaw <ibuclaw ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID



The spec does not dictate that variadic functions must be passed on the stack.
This does not prevent the use of _argptr, to protect against the vagaries of
stack layouts on different CPU architectures, use std.stdarg (or core.vararg on
D2) to access the variadic arguments.

Regards

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 31 2011