This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: typedef void * SCM


> I already talked about this to Jim and Maciej, but this is probably a
> no-go. As you point out, passing structs around will affect
> performance negatively, so a it would be a compilation-only feature.

Passing structs does not damage performance for gcc users and other
suitably optimised compilers:

`-freg-struct-return'
     Use the convention that `struct' and `union' values are returned
     in registers when possible.  This is more efficient for small
     structures than `-fpcc-struct-return'.

     If you specify neither `-fpcc-struct-return' nor its contrary
     `-freg-struct-return', GNU CC defaults to whichever convention is
     standard for the target.  If there is no standard convention, GNU
     CC defaults to `-fpcc-struct-return', except on targets where GNU
     CC is the principal compiler.  In those cases, we can choose the
     standard, and we chose the more efficient register return
     alternative.

Anyhow, performance should not be the issue against doing something
that is philosophically the correct way to do it and for which optimisations
can be made at a later date. At a basic level, it is the C programmers
responsibility to use the language in the most correct way and the compiler's
responsibility to adapt that to the machine in the most optimal way.

For example, if you want to multiply by two you can write X<<1 or X*2
but the latter is preferable to the former and on a good compiler they
should both give the same code (presuming X is unsigned). Trying to
outsmart the optimiser is a dumb idea when you have source code to the
optimiser anyhow. People trying these tricks are usually the ones that
give compiler writers nightmares, who prevent progress and who's code
finally gets broken when everyone gets fed up and pushes forward anyhow.

> I think that a compilation-only check will be too much work for a
> developer. I for one, can't see myself using
> -DGUILE_COMPILE_TIME_DEBUG_MODE on a regular basis, if it is an extra
> action I have to consciously make during development.

It should be a conscious extra action to switch it OFF.

> > BTW: I think especially SCM_BITS should be replaced by something else,
> > which can more easily be grepped.  Now you already get some entries with
> > SCM_BITS.  What about SCM_CONTENT, or SCM_EXTRACT, or I don't
> > know?  Native speakers?
> 
> I used SCM_AS_WORD for this; it is not only used for bit operations. 

Most of the macro names could do with some rethinking.

	- Tel

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]