001 /*
002 * This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 * This file is licensed to You under the Common Public License (CPL);
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/cpl1.0.php
009 *
010 * See the COPYRIGHT.txt file distributed with this work for information
011 * regarding copyright ownership.
012 */
013 package org.mmtk.vm;
014
015 import org.vmmagic.pragma.Uninterruptible;
016 import org.vmmagic.unboxed.*;
017
018 @Uninterruptible
019 public abstract class Barriers {
020 /**
021 * Sets an element of an object array without invoking any write
022 * barrier. This method is called by the Map class to ensure
023 * potentially-allocation-triggering write barriers do not occur in
024 * allocation slow path code.
025 *
026 * @param dst the destination array
027 * @param index the index of the element to set
028 * @param value the new value for the element
029 */
030 public abstract void setArrayNoBarrier(Object [] dst, int index, Object value);
031
032 /**
033 * Perform the actual write of the write barrier.
034 *
035 * @param ref The object that has the reference field
036 * @param slot The slot that holds the reference
037 * @param target The value that the slot will be updated to
038 * @param metaDataA VM specific meta data
039 * @param metaDataB VM specific meta data
040 * @param mode The context in which the write is occuring
041 */
042 public abstract void performWriteInBarrier(ObjectReference ref, Address slot,
043 ObjectReference target, Word metaDataA,
044 Word metaDataB, int mode);
045
046 /**
047 * Perform the actual write of the write barrier, writing the value as a raw Word.
048 *
049 * @param ref The object that has the reference field
050 * @param slot The slot that holds the reference
051 * @param rawTarget The value that the slot will be updated to
052 * @param metaDataA VM specific meta data
053 * @param metaDataB VM specific meta data
054 * @param mode The context in which the write is occuring
055 */
056 public abstract void performRawWriteInBarrier(ObjectReference ref, Address slot,
057 Word rawTarget, Word metaDataA,
058 Word metaDataB, int mode);
059
060 /**
061 * Perform the actual read of the read barrier.
062 *
063 * @param ref The object that has the reference field
064 * @param slot The slot that holds the reference
065 * @param metaDataA VM specific meta data
066 * @param metaDataB VM specific meta data
067 * @param mode The context in which the write is occuring
068 * @return the read value
069 */
070 public abstract ObjectReference performReadInBarrier(ObjectReference ref, Address slot,
071 Word metaDataA, Word metaDataB, int mode);
072
073 /**
074 * Perform the actual read of the read barrier, returning the value as a raw Word.
075 *
076 * @param ref The object that has the reference field
077 * @param slot The slot that holds the reference
078 * @param metaDataA VM specific meta data
079 * @param metaDataB VM specific meta data
080 * @param mode The context in which the write is occuring
081 * @return the read value
082 */
083 public abstract Word performRawReadInBarrier(ObjectReference ref, Address slot,
084 Word metaDataA, Word metaDataB, int mode);
085
086 /**
087 * Atomically write a reference field of an object or array and return
088 * the old value of the reference field.
089 *
090 * @param ref The object that has the reference field
091 * @param slot The slot that holds the reference
092 * @param target The value that the slot will be updated to
093 * @param metaDataA VM specific meta data
094 * @param metaDataB VM specific meta data
095 * @param mode The context in which the write is occuring
096 * @return The value that was replaced by the write.
097 */
098 public abstract ObjectReference performWriteInBarrierAtomic(ObjectReference ref, Address slot,
099 ObjectReference target, Word metaDataA,
100 Word metaDataB, int mode);
101
102 /**
103 * Atomically write a reference field of an object or array and return
104 * the old value of the reference field.
105 *
106 * @param ref The object that has the reference field
107 * @param slot The slot that holds the reference
108 * @param rawTarget The raw value that the slot will be updated to
109 * @param metaDataA VM specific meta data
110 * @param metaDataB VM specific meta data
111 * @param mode The context in which the write is occuring
112 * @return The raw value that was replaced by the write.
113 */
114 public abstract Word performRawWriteInBarrierAtomic(ObjectReference ref, Address slot,
115 Word rawTarget, Word metaDataA,
116 Word metaDataB, int mode);
117
118 /**
119 * Attempt an atomic compare and exchange in a write barrier sequence.
120 *
121 * @param ref The object that has the reference field
122 * @param slot The slot that holds the reference
123 * @param old The old reference to be swapped out
124 * @param target The value that the slot will be updated to
125 * @param metaDataA VM specific meta data
126 * @param metaDataB VM specific meta data
127 * @param mode The context in which the write is occuring
128 * @return True if the compare and swap was successful
129 */
130 public abstract boolean tryCompareAndSwapWriteInBarrier(ObjectReference ref, Address slot,
131 ObjectReference old, ObjectReference target,
132 Word metaDataA, Word metaDataB, int mode);
133
134 /**
135 * Attempt an atomic compare and exchange in a write barrier sequence.
136 *
137 * @param ref The object that has the reference field
138 * @param slot The slot that holds the reference
139 * @param rawOld The old reference to be swapped out
140 * @param rawTarget The value that the slot will be updated to
141 * @param metaDataA VM specific meta data
142 * @param metaDataB VM specific meta data
143 * @param mode The context in which the write is occuring
144 * @return True if the compare and swap was successful
145 */
146 public abstract boolean tryRawCompareAndSwapWriteInBarrier(ObjectReference ref, Address slot,
147 Word rawOld, Word rawTarget,
148 Word metaDataA, Word metaDataB, int mode);
149 }