001    /*
002     *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003     *
004     *  This file is licensed to You under the Eclipse Public License (EPL);
005     *  You may not use this file except in compliance with the License. You
006     *  may obtain a copy of the License at
007     *
008     *      http://www.opensource.org/licenses/eclipse-1.0.php
009     *
010     *  See the COPYRIGHT.txt file distributed with this work for information
011     *  regarding copyright ownership.
012     */
013    package org.mmtk.plan.poisoned;
014    
015    import org.mmtk.plan.marksweep.MSMutator;
016    import org.mmtk.vm.VM;
017    
018    import org.vmmagic.pragma.*;
019    import org.vmmagic.unboxed.Address;
020    import org.vmmagic.unboxed.ObjectReference;
021    import org.vmmagic.unboxed.Word;
022    
023    /**
024     * This class implements a poisoned collector, that is essentially a test
025     * case for read and write barriers in the VM.
026     */
027    @Uninterruptible
028    public class PoisonedMutator extends MSMutator {
029    
030      /****************************************************************************
031       *
032       * Write and read barriers. By default do nothing, override if
033       * appropriate.
034       */
035    
036      /**
037       * {@inheritDoc}
038       */
039      @Inline
040      @Override
041      public void objectReferenceWrite(ObjectReference src, Address slot, ObjectReference tgt, Word metaDataA, Word metaDataB, int mode) {
042        VM.barriers.wordWrite(src, Poisoned.poison(tgt), metaDataA, metaDataB, mode);
043      }
044    
045      @Override
046      public boolean objectReferenceTryCompareAndSwap(ObjectReference src, Address slot, ObjectReference old, ObjectReference tgt,
047                                                   Word metaDataA, Word metaDataB, int mode) {
048        return VM.barriers.wordTryCompareAndSwap(src, Poisoned.poison(old), Poisoned.poison(tgt), metaDataA, metaDataB, mode);
049      }
050    
051      @Inline
052      @Override
053      public ObjectReference objectReferenceRead(ObjectReference src, Address slot, Word metaDataA, Word metaDataB, int mode) {
054        return Poisoned.depoison(VM.barriers.wordRead(src, metaDataA, metaDataB, mode));
055      }
056    }