This is the mail archive of the guile@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]

reordering (Re: Smob documentation)


> The compiler can't change the order of calls to other functions, so
> this reordering won't happen.

gcc has a special attribute flag to put on functions that are known to have
no side effects, I think that it is __attribute__ ((const)). In principle,
these functions can be optimised more aggressively than others and this
might include reordering. I am sure that optimisers don't go around will nilly
swapping the order of function calls. In practice, I have yet to see a case
where gcc notices the __attribute__ ((const)), even when I want it to take
a function with this attribute, put a known constant value in and optimise
the result to a known constant result! gcc seems to be lacking a lot of
optimisations that it will no doubt eventually get. IMHO, this should work:

	const int size = 42;
	int things[ size ];

But at the moment gcc will tell me that `size' is not constant!

> I'm sure there are legal optimizations that would break my code.  But
> we're already living beyond the law by using conservative GC at all.
> What's worth worrying about is actual observed optimizations that
> break code.  When we find those, we can decide what to do about them.

This approach is kind of OK but has the problem that it sets up potential
future bugs that we don't know about right now. gcc is changing and the
number of platforms that it supports is growing. Since the optimisation
bugs are tedious to trace down, thinking defensively is not such a bad
idea. Using volatile for local SCM variables is probably a good idea for
beginners. Worst case it only slows their code down a little. When they
really want to push it for speed they can knock volatiles out but then
they will think carefully about which ones to fix.

By the way, with reference to the earlier comment about the PPC system that
did something funny with pointers... I just recently got hold of a G3
running Linux-PPC and I'd be curious to know what strange situation this
was -- is there a URL reference somewhere?

	- Tel



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