This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: BC ABI: handling volatile
- From: Bryce McKinlay <mckinlay at redhat dot com>
- To: Andrew Haley <aph at redhat dot com>
- Cc: java at gcc dot gnu dot org
- Date: Wed, 14 Jun 2006 16:42:50 -0400
- Subject: Re: BC ABI: handling volatile
- References: <17551.59361.564266.89384@dell.pink>
Andrew Haley wrote:
There is one other idea that I am somewhat reluctant to contemplate:
always emit a fence when accessing volatiles declared outside the
current class. This might not be so awful, because accessing fields
outside the current class is not much done in well-written
object-oriented code. However, these fences can be quite slow on
some architectures.
As ugly as it sounds at first, this actually seems to me to be the most
simple and attractive solution. I agree that it shouldn't have a huge
impact on most applications since accessing fields across classes is
rare. Also, while the barrier/fence instructions may be slow, they are
probably always going to be faster than a "synchronized".
Also, going this route in no way precludes switching to a more
sophisticated implementation later, should it prove necessary - the old
code will still work just fine.
Perhaps we can add an -fno-volatiles flag so that the impact of this can
be easily measured, or so users who know their code does not use
volatiles can optimize.
Bryce