JavaMemoryModel: deleting dead volatile ref's

From: Cliff Click (cliff.click@sun.com)
Date: Thu Jul 11 2002 - 12:08:01 EDT


If I see a dead volatile load I can remove the actual load, but
a volatile ref includes a 'MemBarAcquire' (in HotSpot parlance)
to help prevent various compiler & hardware reorderings. Can I
remove the MemBarAcquire as well?

   static volatile int V1, V2, V3;
   static int I1, I2;

   /* MemBarRelease inserted before volatile store */
   V3 = ...; /* other volatile refs */
   ... = V2;
   /* MemBarAcquire inserted here after volatile ref */

   ... I1; /* other non-volatile refs */
   I2 = ...;
   int dead = V1; /* load global variable V1, ITS DEAD, NO LOAD ACTUALLY
EMITTED */
   /* MemBarAcquire inserted here <-- CAN I REMOVE THIS??? */
   ... I2; /* other non-volatile refs */
   I1 = ...;

   /* MemBarRelease inserted before volatile store */
   V2 = ...; /* other volatile refs */
   ... = V3;

I could always sink other non-volatile refs below a MemBarAcquire,
but not above it. Thus I could always sink the ref's to I1 & I2
down below the volatile load of V1 and optimize them with the reads
and writes down there. Since V1 is dead, there's no way to tell
if I do something out of order by hoisting I1 above the read of V1,
right?

Thanks,
Cliff

-- 
Dr. Cliff Click      Chief Architect, HotSpot Server  Sun Microsystems, Inc.
Cliff.Click@Sun.COM  Senior Staff Engineer            4150 Network Circle
(408) 276-7046       MS USCA14-102                    Santa Clara, CA 95054

------------------------------- JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:40 EDT