From: <dgr...@us...> - 2008-07-28 22:04:05
|
Revision: 14817 http://jikesrvm.svn.sourceforge.net/jikesrvm/?rev=14817&view=rev Author: dgrove-oss Date: 2008-07-28 22:04:01 +0000 (Mon, 28 Jul 2008) Log Message: ----------- Implement one of the memory barriers needed for JMM compliance on PowerPC. We must generate a StoreStore barrier before returning from the constructor of any class that directly declares a final instance field. Fix motivated by the observation that our current most common regression failure on SMP PPC machines (piano and piccolo) looks like an "impossible" situation that can only be explained by either a memory model violation (most probable) or other memory corruption (for an example crash, see http://jikesrvm.anu.edu.au/cattrack/results/piano.watson.ibm.com/core-ppc64/4555/regression_report). Modified Paths: -------------- rvmroot/trunk/rvm/src/org/jikesrvm/classloader/RVMClass.java rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ppc/BaselineCompilerImpl.java rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/bc2ir/BC2IR.java Modified: rvmroot/trunk/rvm/src/org/jikesrvm/classloader/RVMClass.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/classloader/RVMClass.java 2008-07-28 21:03:24 UTC (rev 14816) +++ rvmroot/trunk/rvm/src/org/jikesrvm/classloader/RVMClass.java 2008-07-28 22:04:01 UTC (rev 14817) @@ -407,6 +407,16 @@ } /** + * Does this class directly define a final instance field (has implications for JMM). + */ + public boolean declaresFinalInstanceField() { + for (RVMField f : declaredFields) { + if (f.isFinal() && !f.isStatic()) return true; + } + return false; + } + + /** * Methods defined directly by this class (ie. not including superclasses). */ @Uninterruptible Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ppc/BaselineCompilerImpl.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ppc/BaselineCompilerImpl.java 2008-07-28 21:03:24 UTC (rev 14816) +++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/baseline/ppc/BaselineCompilerImpl.java 2008-07-28 22:04:01 UTC (rev 14817) @@ -2424,6 +2424,10 @@ */ protected final void emit_return() { if (method.isSynchronized()) genSynchronizedMethodEpilogue(); + if (method.isObjectInitializer() && method.getDeclaringClass().declaresFinalInstanceField()) { + /* JMM compliance. Emit StoreStore barrier */ + asm.emitSYNC(); + } genEpilogue(); } Modified: rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/bc2ir/BC2IR.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/bc2ir/BC2IR.java 2008-07-28 21:03:24 UTC (rev 14816) +++ rvmroot/trunk/rvm/src/org/jikesrvm/compilers/opt/bc2ir/BC2IR.java 2008-07-28 22:04:01 UTC (rev 14817) @@ -2870,6 +2870,10 @@ gc.result = meet; } } + if (VM.BuildForPowerPC && gc.method.isObjectInitializer() && gc.method.getDeclaringClass().declaresFinalInstanceField()) { + /* JMM Compliance. Must insert StoreStore barrier before returning from constructor of class with final instance fields */ + appendInstruction(Empty.create(WRITE_FLOOR)); + } appendInstruction(gc.epilogue.makeGOTO()); currentBBLE.block.insertOut(gc.epilogue); if (DBG_CFG || DBG_SELECTED) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |