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 */
013package org.mmtk.plan.semispace.usePrimitiveWriteBarriers;
014
015import org.mmtk.plan.semispace.SSMutator;
016import org.mmtk.vm.VM;
017
018import org.vmmagic.unboxed.*;
019import org.vmmagic.pragma.*;
020
021/**
022 * This class extends the {@link SSMutator} class as part of the
023 * {@link UsePrimitiveWriteBarriers} collector. It overrides various methods in
024 * {@link SSMutator} to implement primitive write barriers.
025 */
026@Uninterruptible
027public class UsePrimitiveWriteBarriersMutator extends SSMutator {
028
029  /**
030   * Write an Address. Take appropriate write barrier actions.
031   */
032  @Override
033  public void addressWrite(ObjectReference src, Address slot, Address value, Word metaDataA, Word metaDataB, int mode) {
034    VM.barriers.addressWrite(src, value, metaDataA, metaDataB, mode);
035  }
036
037  /**
038   * Attempt to atomically exchange the value in the given slot
039   * with the passed replacement value.
040   */
041  @Override
042  public boolean addressTryCompareAndSwap(ObjectReference src, Address slot, Address old, Address value, Word metaDataA, Word metaDataB, int mode) {
043    return VM.barriers.addressTryCompareAndSwap(src, old, value, metaDataA, metaDataB, mode);
044  }
045
046  /**
047   * Write a boolean. Take appropriate write barrier actions.
048   */
049  @Override
050  public void booleanWrite(ObjectReference src, Address slot, boolean value, Word metaDataA, Word metaDataB, int mode) {
051    VM.barriers.booleanWrite(src, value, metaDataA, metaDataB, mode);
052  }
053
054  @Override
055  public boolean booleanBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) {
056    return false;
057  }
058
059  /**
060   * Write a byte. Take appropriate write barrier actions.
061   */
062  @Override
063  public void byteWrite(ObjectReference src, Address slot, byte value, Word metaDataA, Word metaDataB, int mode) {
064    VM.barriers.byteWrite(src, value, metaDataA, metaDataB, mode);
065  }
066
067  @Override
068  public boolean byteBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) {
069    return false;
070  }
071
072  /**
073   * Write a char. Take appropriate write barrier actions.
074   */
075  @Override
076  public void charWrite(ObjectReference src, Address slot, char value, Word metaDataA, Word metaDataB, int mode) {
077    VM.barriers.charWrite(src, value, metaDataA, metaDataB, mode);
078  }
079
080  @Override
081  public boolean charBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) {
082    return false;
083  }
084
085  /**
086   * Write a double. Take appropriate write barrier actions.
087   */
088  @Override
089  public void doubleWrite(ObjectReference src, Address slot, double value, Word metaDataA, Word metaDataB, int mode) {
090    VM.barriers.doubleWrite(src, value, metaDataA, metaDataB, mode);
091  }
092
093  @Override
094  public boolean doubleBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) {
095    return false;
096  }
097
098  /**
099   * Write an Extent. Take appropriate write barrier actions.
100   */
101  @Override
102  public void extentWrite(ObjectReference src, Address slot, Extent value, Word metaDataA, Word metaDataB, int mode) {
103    VM.barriers.extentWrite(src, value, metaDataA, metaDataB, mode);
104  }
105
106  /**
107   * Write a float. Take appropriate write barrier actions.
108   */
109  @Override
110  public void floatWrite(ObjectReference src, Address slot, float value, Word metaDataA, Word metaDataB, int mode) {
111    VM.barriers.floatWrite(src, value, metaDataA, metaDataB, mode);
112  }
113
114  @Override
115  public boolean floatBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) {
116    return false;
117  }
118
119  /**
120   * Write a int. Take appropriate write barrier actions.
121   */
122  @Override
123  public void intWrite(ObjectReference src, Address slot, int value, Word metaDataA, Word metaDataB, int mode) {
124    VM.barriers.intWrite(src, value, metaDataA, metaDataB, mode);
125  }
126
127  @Override
128  public boolean intBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) {
129    return false;
130  }
131
132  @Override
133  public boolean intTryCompareAndSwap(ObjectReference src, Address slot, int old, int value, Word metaDataA, Word metaDataB, int mode) {
134    return VM.barriers.intTryCompareAndSwap(src, old, value, metaDataA, metaDataB, mode);
135  }
136
137  /**
138   * Write a long. Take appropriate write barrier actions.
139   */
140  @Override
141  public void longWrite(ObjectReference src, Address slot, long value, Word metaDataA, Word metaDataB, int mode) {
142    VM.barriers.longWrite(src, value, metaDataA, metaDataB, mode);
143  }
144
145  @Override
146  public boolean longBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) {
147    return false;
148  }
149
150  @Override
151  public boolean longTryCompareAndSwap(ObjectReference src, Address slot, long old, long value, Word metaDataA, Word metaDataB, int mode) {
152    return VM.barriers.longTryCompareAndSwap(src, old, value, metaDataA, metaDataB, mode);
153  }
154
155  /**
156   * Write an Offset. Take appropriate write barrier actions.
157   */
158  @Override
159  public void offsetWrite(ObjectReference src, Address slot, Offset value, Word metaDataA, Word metaDataB, int mode) {
160    VM.barriers.offsetWrite(src, value, metaDataA, metaDataB, mode);
161  }
162
163  /**
164   * Write a short. Take appropriate write barrier actions.
165   */
166  @Override
167  public void shortWrite(ObjectReference src, Address slot, short value, Word metaDataA, Word metaDataB, int mode) {
168    VM.barriers.shortWrite(src, value, metaDataA, metaDataB, mode);
169  }
170
171  @Override
172  public boolean shortBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) {
173    return false;
174  }
175
176  /**
177   * Write a Word. Take appropriate write barrier actions.
178   */
179  @Override
180  public void wordWrite(ObjectReference src, Address slot, Word value, Word metaDataA, Word metaDataB, int mode) {
181    VM.barriers.wordWrite(src, value, metaDataA, metaDataB, mode);
182  }
183
184  @Override
185  public boolean wordTryCompareAndSwap(ObjectReference src, Address slot, Word old, Word value, Word metaDataA, Word metaDataB, int mode) {
186    return VM.barriers.wordTryCompareAndSwap(src, old, value, metaDataA, metaDataB, mode);
187  }
188}