[Issue 4172] Improve varargs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 21 20:27:54 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4172



--- Comment #17 from Walter Bright <bugzilla at digitalmars.com> 2010-12-21 20:25:56 PST ---
(In reply to comment #16)
> Here we can see the result of the "old" varargs being ported to 64 bits:
> http://dsource.org/projects/phobos/changeset/2229
> The compiler got more complicated too. Good job, Walter.

It's not even the "old" varargs. I don't think it's possible to support the C
varargs correctly with the 64 bit ABI. (Note that gcc does not implement the 64
bit varargs ABI correctly - I had to do a lot of experiments to figure out how
it *really* worked.)

We could invent our own ABI for varargs, and it would be simple. But then,
we're screwed trying to interoperate with C code that uses varargs.

The 64 bit varargs works tolerably ok, though I'm not thrilled with it. The
reason for that changeset is I wished to avoid the varargs-style copying of the
argument in order to access it. Much better to point to whereever it is, so the
code has to dip under the hood to the dirty underbelly of varargs. Avoiding the
copy not only speeds things up, it avoids issues like where/when does the
destructor happen on the copy?

To me, the 64 bit varargs ABI looks like a giant mistake that was codified
instead of fixed in order to preserve backwards compatibility. (It suggests the
original designer tried to do some clever optimizations, but failed to think it
through and the result is an inefficient mess.)

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


More information about the Digitalmars-d-bugs mailing list