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.vm;
014
015 import org.vmmagic.pragma.Uninterruptible;
016 import org.vmmagic.unboxed.*;
017
018 @Uninterruptible
019 public abstract class Barriers {
020 /**
021 * Perform the actual write of a boolean write barrier.
022 *
023 * @param ref The object that has the boolean field
024 * @param value The value that the slot will be updated to
025 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
026 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
027 * @param mode The context in which the write is occurring
028 */
029 public abstract void booleanWrite(ObjectReference ref, boolean value, Word metaDataA, Word metaDataB, int mode);
030
031 /**
032 * Perform the actual read of a boolean read barrier.
033 *
034 * @param ref The object that has the boolean field
035 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
036 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
037 * @param mode The context in which the write is occurring
038 * @return the read value
039 */
040 public abstract boolean booleanRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode);
041
042 /**
043 * Perform the actual write of a byte write barrier.
044 *
045 * @param ref The object that has the byte field
046 * @param value The value that the slot will be updated to
047 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
048 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
049 * @param mode The context in which the write is occurring
050 */
051 public abstract void byteWrite(ObjectReference ref, byte value, Word metaDataA, Word metaDataB, int mode);
052
053 /**
054 * Perform the actual read of a byte read barrier.
055 *
056 * @param ref The object that has the byte field
057 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
058 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
059 * @param mode The context in which the write is occurring
060 * @return the read value
061 */
062 public abstract byte byteRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode);
063
064 /**
065 * Perform the actual write of a char write barrier.
066 *
067 * @param ref The object that has the char field
068 * @param value The value that the slot will be updated to
069 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
070 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
071 * @param mode The context in which the write is occurring
072 */
073 public abstract void charWrite(ObjectReference ref, char value, Word metaDataA, Word metaDataB, int mode);
074
075 /**
076 * Perform the actual read of a char read barrier.
077 *
078 * @param ref The object that has the char field
079 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
080 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
081 * @param mode The context in which the write is occurring
082 * @return the read value
083 */
084 public abstract char charRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode);
085
086 /**
087 * Perform the actual write of a short write barrier.
088 *
089 * @param ref The object that has the short field
090 * @param value The value that the slot will be updated to
091 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
092 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
093 * @param mode The context in which the write is occurring
094 */
095 public abstract void shortWrite(ObjectReference ref, short value, Word metaDataA, Word metaDataB, int mode);
096
097 /**
098 * Perform the actual read of a short read barrier.
099 *
100 * @param ref The object that has the short field
101 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
102 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
103 * @param mode The context in which the write is occurring
104 * @return the read value
105 */
106 public abstract short shortRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode);
107
108 /**
109 * Perform the actual write of a int write barrier.
110 *
111 * @param ref The object that has the int field
112 * @param value The value that the slot will be updated to
113 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
114 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
115 * @param mode The context in which the write is occurring
116 */
117 public abstract void intWrite(ObjectReference ref, int value, Word metaDataA, Word metaDataB, int mode);
118
119 /**
120 * Perform the actual read of a int read barrier.
121 *
122 * @param ref The object that has the int field
123 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
124 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
125 * @param mode The context in which the write is occurring
126 * @return the read value
127 */
128 public abstract int intRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode);
129
130 /**
131 * Attempt an atomic compare and exchange in a write barrier sequence.
132 *
133 * @param objref The object that has the int field
134 * @param old The old int to be swapped out
135 * @param value the new int
136 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
137 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
138 * @param mode The context in which the write is occurring
139 * @return True if the compare and swap was successful
140 */
141 public abstract boolean intTryCompareAndSwap(ObjectReference objref, int old, int value, Word metaDataA, Word metaDataB, int mode);
142
143
144 /**
145 * Perform the actual write of a long write barrier.
146 *
147 * @param ref The object that has the long field
148 * @param value The value that the slot will be updated to
149 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
150 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
151 * @param mode The context in which the write is occurring
152 */
153 public abstract void longWrite(ObjectReference ref, long value, Word metaDataA, Word metaDataB, int mode);
154
155 /**
156 * Perform the actual read of a long read barrier.
157 *
158 * @param ref The object that has the long field
159 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
160 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
161 * @param mode The context in which the write is occurring
162 * @return the read value
163 */
164 public abstract long longRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode);
165
166 /**
167 * Attempt an atomic compare and exchange in a write barrier sequence.
168 *
169 * @param objref The object that has the long field
170 * @param old The old long to be swapped out
171 * @param value the new long
172 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
173 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
174 * @param mode The context in which the write is occurring
175 * @return True if the compare and swap was successful
176 */
177 public abstract boolean longTryCompareAndSwap(ObjectReference objref, long old, long value, Word metaDataA, Word metaDataB, int mode);
178
179 /**
180 * Perform the actual write of a float write barrier.
181 *
182 * @param ref The object that has the float field
183 * @param value The value that the slot will be updated to
184 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
185 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
186 * @param mode The context in which the write is occurring
187 */
188 public abstract void floatWrite(ObjectReference ref, float value, Word metaDataA, Word metaDataB, int mode);
189
190 /**
191 * Perform the actual read of a float read barrier.
192 *
193 * @param ref The object that has the float field
194 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
195 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
196 * @param mode The context in which the write is occurring
197 * @return the read value
198 */
199 public abstract float floatRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode);
200
201 /**
202 * Perform the actual write of a double write barrier.
203 *
204 * @param ref The object that has the double field
205 * @param value The value that the slot will be updated to
206 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
207 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
208 * @param mode The context in which the write is occurring
209 */
210 public abstract void doubleWrite(ObjectReference ref, double value, Word metaDataA, Word metaDataB, int mode);
211
212 /**
213 * Perform the actual read of a double read barrier.
214 *
215 * @param ref The object that has the double field
216 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
217 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
218 * @param mode The context in which the write is occurring
219 * @return the read value
220 */
221 public abstract double doubleRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode);
222
223 /**
224 * Perform the actual write of an object reference write barrier.
225 *
226 * @param ref The object that has the reference field
227 * @param value The value that the slot will be updated to
228 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
229 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
230 * @param mode The context in which the write is occurring
231 */
232 public abstract void objectReferenceWrite(ObjectReference ref, ObjectReference value, Word metaDataA, Word metaDataB, int mode);
233
234 /**
235 * Perform the actual read of a read barrier.
236 *
237 * @param ref The object that has the reference field
238 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
239 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
240 * @param mode The context in which the write is occurring
241 * @return the read value
242 */
243 public abstract ObjectReference objectReferenceRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode);
244
245 /**
246 * Perform the actual write of the non-heap write barrier. This is
247 * used when the store is not to an object, but to a non-heap location
248 * such as statics or the stack.
249 *
250 * @param slot The address that contains the reference field
251 * @param target The value that the slot will be updated to
252 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
253 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
254 */
255 public abstract void objectReferenceNonHeapWrite(Address slot, ObjectReference target, Word metaDataA, Word metaDataB);
256
257 /**
258 * Atomically write a reference field of an object or array and return
259 * the old value of the reference field.
260 *
261 * @param ref The object that has the reference field
262 * @param target The value that the slot will be updated to
263 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
264 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
265 * @param mode The context in which the write is occurring
266 * @return The value that was replaced by the write.
267 */
268 public abstract ObjectReference objectReferenceAtomicWrite(ObjectReference ref, ObjectReference target, Word metaDataA, Word metaDataB, int mode);
269
270 /**
271 * Attempt an atomic compare and exchange in a write barrier sequence.
272 *
273 * @param ref The object that has the reference field
274 * @param old The old reference to be swapped out
275 * @param target The value that the slot will be updated to
276 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
277 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
278 * @param mode The context in which the write is occurring
279 * @return True if the compare and swap was successful
280 */
281 public abstract boolean objectReferenceTryCompareAndSwap(ObjectReference ref, ObjectReference old, ObjectReference target, Word metaDataA, Word metaDataB, int mode);
282
283 /**
284 * Perform the actual write of the write barrier, writing the value as a raw Word.
285 *
286 * @param ref The object that has the Word field
287 * @param target The value that the slot will be updated to
288 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
289 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
290 * @param mode The context in which the write is occurring
291 */
292 public abstract void wordWrite(ObjectReference ref, Word target, Word metaDataA, Word metaDataB, int mode);
293
294 /**
295 * Atomically write a Word field of an object or array and return
296 * the old value of the Word field.
297 *
298 * @param ref The object that has the Word field
299 * @param rawTarget The value that the slot will be updated to
300 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
301 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
302 * @param mode The context in which the write is occurring
303 * @return The raw value that was replaced by the write.
304 */
305 public abstract Word wordAtomicWrite(ObjectReference ref, Word rawTarget, Word metaDataA, Word metaDataB, int mode);
306
307 /**
308 * Attempt an atomic compare and exchange in a write barrier sequence.
309 *
310 * @param ref The object that has the Word field
311 * @param old The old Word to be swapped out
312 * @param target The value that the slot will be updated to
313 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
314 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
315 * @param mode The context in which the write is occurring
316 * @return True if the compare and swap was successful
317 */
318 public abstract boolean wordTryCompareAndSwap(ObjectReference ref, Word old, Word target, Word metaDataA, Word metaDataB, int mode);
319
320 /**
321 * Perform the actual read of the read barrier, returning the value as a raw Word.
322 *
323 * @param ref The object that has the Word field
324 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
325 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
326 * @param mode The context in which the write is occurring
327 * @return the read value
328 */
329 public abstract Word wordRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode);
330
331 /**
332 * Perform the actual write of the write barrier, writing the value as a raw Address.
333 *
334 * @param ref The object that has the Address field
335 * @param target The value that the slot will be updated to
336 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
337 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
338 * @param mode The context in which the write is occurring
339 */
340 public abstract void addressWrite(ObjectReference ref, Address target, Word metaDataA, Word metaDataB, int mode);
341
342 /**
343 * Perform the actual read of the read barrier, returning the value as a raw Address.
344 *
345 * @param ref The object that has the Address field
346 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
347 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
348 * @param mode The context in which the write is occurring
349 * @return the read value
350 */
351 public abstract Address addressRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode);
352
353 /**
354 * Attempt an atomic compare and exchange in a write barrier sequence.
355 *
356 * @param ref The object that has the Address field
357 * @param old The old address to be swapped out
358 * @param target The value that the slot will be updated to
359 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
360 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
361 * @param mode The context in which the write is occurring
362 * @return True if the compare and swap was successful
363 */
364 public abstract boolean addressTryCompareAndSwap(ObjectReference ref, Address old, Address target, Word metaDataA, Word metaDataB, int mode);
365
366 /**
367 * Perform the actual write of the write barrier, writing the value as a raw Offset.
368 *
369 * @param ref The object that has the Offset field
370 * @param target The value that the slot will be updated to
371 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
372 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
373 * @param mode The context in which the write is occurring
374 */
375 public abstract void offsetWrite(ObjectReference ref, Offset target, Word metaDataA, Word metaDataB, int mode);
376
377 /**
378 * Perform the actual read of the read barrier, returning the value as a raw Offset.
379 *
380 * @param ref The object that has the Offset field
381 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
382 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
383 * @param mode The context in which the write is occurring
384 * @return the read value
385 */
386 public abstract Offset offsetRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode);
387
388 /**
389 * Perform the actual write of the write barrier, writing the value as a raw Extent.
390 *
391 * @param ref The object that has the Extent field
392 * @param target The value that the slot will be updated to
393 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
394 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
395 * @param mode The context in which the write is occurring
396 */
397 public abstract void extentWrite(ObjectReference ref, Extent target, Word metaDataA, Word metaDataB, int mode);
398
399 /**
400 * Perform the actual read of the read barrier, returning the value as a raw Extent.
401 *
402 * @param ref The object that has the Extent field
403 * @param metaDataA Opaque, VM-specific, meta-data identifying the slot
404 * @param metaDataB Opaque, VM-specific, meta-data identifying the slot
405 * @param mode The context in which the write is occurring
406 * @return the read value
407 */
408 public abstract Extent extentRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode);
409
410 /**
411 * Sets an element of an object array without invoking any write
412 * barrier. This method is called by the Map class to ensure
413 * potentially-allocation-triggering write barriers do not occur in
414 * allocation slow path code.
415 *
416 * @param dst the destination array
417 * @param index the index of the element to set
418 * @param value the new value for the element
419 */
420 public abstract void objectArrayStoreNoGCBarrier(Object [] dst, int index, Object value);
421 }