|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
SF.net SVN: jikesrvm:[15689] rvmroot/trunkRevision: 15689
http://jikesrvm.svn.sourceforge.net/jikesrvm/?rev=15689&view=rev Author: pizlo Date: 2009-05-09 21:46:05 +0000 (Sat, 09 May 2009) Log Message: ----------- Fixed RC collectors by disabling biased locking for those collectors in which the mutator needs to be able to CAS on the status word. This fix has the potential to be extended to add support for disabling biased locking at runtime. According to my tests, this change adds no measurable overhead. Modified Paths: -------------- rvmroot/trunk/MMTk/src/org/mmtk/plan/PlanConstraints.java rvmroot/trunk/MMTk/src/org/mmtk/plan/refcount/RCBaseConstraints.java rvmroot/trunk/rvm/src/org/jikesrvm/mm/mminterface/MemoryManagerConstants.java rvmroot/trunk/rvm/src/org/jikesrvm/scheduler/ThinLock.java Modified: rvmroot/trunk/MMTk/src/org/mmtk/plan/PlanConstraints.java =================================================================== --- rvmroot/trunk/MMTk/src/org/mmtk/plan/PlanConstraints.java 2009-05-08 22:14:51 UTC (rev 15688) +++ rvmroot/trunk/MMTk/src/org/mmtk/plan/PlanConstraints.java 2009-05-09 21:46:05 UTC (rev 15689) @@ -69,6 +69,10 @@ /** @return The number of header words that are required. */ public abstract int gcHeaderWords(); + /** @return If the mutator needs to be able to CAS the header bits even + * when the world is not stopped. */ + public boolean mutatorNeedsToCASHeaderBits() { return false; } + /** @return True if this plan contains GCspy. */ public boolean withGCspy() { return false; } Modified: rvmroot/trunk/MMTk/src/org/mmtk/plan/refcount/RCBaseConstraints.java =================================================================== --- rvmroot/trunk/MMTk/src/org/mmtk/plan/refcount/RCBaseConstraints.java 2009-05-08 22:14:51 UTC (rev 15688) +++ rvmroot/trunk/MMTk/src/org/mmtk/plan/refcount/RCBaseConstraints.java 2009-05-09 21:46:05 UTC (rev 15689) @@ -33,4 +33,6 @@ public boolean needsWriteBarrier() { return true; } @Override public int maxNonLOSDefaultAllocBytes() { return MAX_FREELIST_OBJECT_BYTES; } + @Override + public boolean mutatorNeedsToCASHeaderBits() { return true; } } Modified: rvmroot/trunk/rvm/src/org/jikesrvm/mm/mminterface/MemoryManagerConstants.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/mm/mminterface/MemoryManagerConstants.java 2009-05-08 22:14:51 UTC (rev 15688) +++ rvmroot/trunk/rvm/src/org/jikesrvm/mm/mminterface/MemoryManagerConstants.java 2009-05-09 21:46:05 UTC (rev 15689) @@ -27,6 +27,9 @@ public static final int GC_HEADER_BITS = Selected.Constraints.get().gcHeaderBits(); /** Number of additional bytes required in the header by the selected plan */ public static final int GC_HEADER_BYTES = Selected.Constraints.get().gcHeaderWords() << LOG_BYTES_IN_WORD; + /** If the mutator needs to be able to CAS the header bits even when the world + is not stopped. */ + public static final boolean MUTATOR_NEEDS_TO_CAS_HEADER_BITS = Selected.Constraints.get().mutatorNeedsToCASHeaderBits(); /** True if the selected plan requires a read barrier on reference types */ public static final boolean NEEDS_REFTYPE_READ_BARRIER = Selected.Constraints.get().needsReferenceTypeReadBarrier(); /** True if the selected plan requires write barriers on putfield, arraystore or modifycheck */ Modified: rvmroot/trunk/rvm/src/org/jikesrvm/scheduler/ThinLock.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/scheduler/ThinLock.java 2009-05-08 22:14:51 UTC (rev 15688) +++ rvmroot/trunk/rvm/src/org/jikesrvm/scheduler/ThinLock.java 2009-05-09 21:46:05 UTC (rev 15689) @@ -16,6 +16,7 @@ import org.jikesrvm.Services; import org.jikesrvm.objectmodel.ThinLockConstants; import org.jikesrvm.runtime.Magic; +import org.jikesrvm.mm.mminterface.MemoryManagerConstants; import org.vmmagic.pragma.Inline; import org.vmmagic.pragma.NoInline; import org.vmmagic.pragma.NoNullCheck; @@ -30,6 +31,8 @@ @Uninterruptible public final class ThinLock implements ThinLockConstants { + public static final boolean biasingAllowed=!MemoryManagerConstants.MUTATOR_NEEDS_TO_CAS_HEADER_BITS; + @Inline @NoNullCheck @Unpreemptible @@ -91,13 +94,25 @@ if (stat.EQ(TL_STAT_BIASABLE)) { Word id = old.and(TL_THREAD_ID_MASK); if (id.isZero()) { - // lock is unbiased, bias it in our favor and grab it - if (Synchronization.tryCompareAndSwap( - o, lockOffset, - old, - old.or(threadId).toAddress().plus(TL_LOCK_COUNT_UNIT).toWord())) { - Magic.isync(); - return; + if (biasingAllowed) { + // lock is unbiased, bias it in our favor and grab it + if (Synchronization.tryCompareAndSwap( + o, lockOffset, + old, + old.or(threadId).toAddress().plus(TL_LOCK_COUNT_UNIT).toWord())) { + Magic.isync(); + return; + } + } else { + // lock is unbiased but biasing is NOT allowed, so turn it into + // a thin lock + if (Synchronization.tryCompareAndSwap( + o, lockOffset, + old, + old.or(threadId).or(TL_STAT_THIN))) { + Magic.isync(); + return; + } } } else if (id.EQ(threadId)) { // lock is biased in our favor @@ -477,6 +492,7 @@ @NoNullCheck @Unpreemptible public static boolean lockHeader(Object o, Offset lockOffset) { + if (!biasingAllowed) return false; // what this should do: // 1) take advantage of the fact that if a lock is fat it can only go back to // being thin, so concurrent modification of the lock word is allowed. @@ -541,7 +557,8 @@ @Inline @Uninterruptible public static boolean allowHeaderCAS(Object o, Offset lockOffset) { - return Magic.getWordAtOffset(o,lockOffset).and(TL_STAT_MASK).NE(TL_STAT_BIASABLE); + return !biasingAllowed || + Magic.getWordAtOffset(o,lockOffset).and(TL_STAT_MASK).NE(TL_STAT_BIASABLE); } //////////////////////////////////////////////////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com _______________________________________________ Jikesrvm-commits mailing list Jikesrvm-commits@... https://lists.sourceforge.net/lists/listinfo/jikesrvm-commits |
| Free embeddable forum powered by Nabble | Forum Help |