[M3devel] a trouble with passing records by value..

Jay K jay.krell at cornell.edu
Thu Sep 2 16:59:13 CEST 2010


Short answer:
 
 
Consider:
  void F1(int a) { printf("%p\n", &a); }
  void F2(struct { int b,c;} d) { printf("%p\n", &d); }
 
 
Longer anser:
 
 
There is no ABI bug. Really.
 
 
How parameters are passed does not imply where they must be at all times.
 
 
C has the same feature set as Modula-3. In general and here specifically.
   You can pass structs by value in C and you can take the address of such a struct.
 
 
The ABI is never perfectly efficient for all scenarios.
If one could predict that all structed passed by value will have their
address taken, then a different choice might be made.
However the reality is that sometimes their address is taken, sometimes not.
One ABI must be formulated (for interop) that strikes an efficiency balance, and always works.
 
 
Consider that I can take the address of integers and floats and pointers passed by value!
 Yet they are very very often passed in registers. (see the "short answer").
 
 
A record is just a smaller or larger collection of integers/floats/pointers.
 
 
The difference is mainly in the layout of the in-memory location, and
the possibility of large size.
 
 
 
 - Jay

 
> Date: Thu, 2 Sep 2010 09:39:12 -0500
> From: rodney_bates
> To: m3devel
> Subject: Re: [M3devel] a trouble with passing records by value..
> 
> Jay K wrote:
> > > Date: Tue, 31 Aug 2010 21:24:07 -0500
> > > From: rodney_bates@
> > >
> > > If the writers of an ABI actually *required* that small 
> > structs/records be
> > > passed in registers
> > 
> > 
> > Yes, they have. The rules are hard for me to understand. It isn't just 
> > based on size.
> > 
> > 
> > > then they have made a big blunder.
> > 
> > 
> > No they have not. They know what they are doing.
> 
> When the ABI requires a compiler to do it wrong for the language semantics,
> which it must then compensate for at a place that's outside the jurisdiction
> of the ABI, the ABI has a design bug. At least when the language in question
> is one of those the ABI designers considered, which has to be the case
> with C.
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100902/aa3ab110/attachment-0002.html>


More information about the M3devel mailing list