Re: Garbage collection, part two...

From: Felix Lee <>
Date: Sun, 16 Apr 2000 16:57:55 -0700

Erick Gallesio <>:
> Felix Lee writes:
> > declaring it volatile forces the compiler to keep it on the
> > stack, not in a register, so the value won't ever be
> > eliminated by live-range analysis.
> Thats a good idea, and I have should have thought to it. The only
> problem that I see, is that, as far as I remember, the norm says that
> the access should not be optimized (as often norms are at a level of
> detail which are not very helpful). I don't know if it implies that it
> cannot be placed in register (probably) or that the compiler must
> prevent to deduce some result by itself.

More specifically, 'volatile' tells the compiler that
factors that the compiler does not know about may read or
write the variable's value. This means it must avoid
optimizations and cannot allocate it to a register.

> example such as
> int var = (int *) A_constant_hardware_address;
> for (i = 0; i < n; i++)
> *i = 0;

You mean *var = 0, yes?

> A clever compiler could replace this by
> int var = (int *) A_constant_hardware_address;
> *i = 0;
> Since doing it n times seems not very useful.

The compiler can't reduce it like that if var is declared
Received on Mon Apr 17 2000 - 01:58:28 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST