|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
SF.net SVN: jikesrvm:[15787] rvmroot/trunkRevision: 15787
http://jikesrvm.svn.sourceforge.net/jikesrvm/?rev=15787&view=rev Author: steveb-oss Date: 2009-09-19 03:23:17 +0000 (Sat, 19 Sep 2009) Log Message: ----------- Pad out barrier plumbing to include primitive types. This should conclude RVM-589. Modified Paths: -------------- rvmroot/trunk/MMTk/ext/vm/harness/org/mmtk/harness/vm/Barriers.java rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/Barriers.java rvmroot/trunk/MMTk/src/org/mmtk/plan/MutatorContext.java rvmroot/trunk/MMTk/src/org/mmtk/plan/PlanConstraints.java rvmroot/trunk/MMTk/src/org/mmtk/vm/Barriers.java rvmroot/trunk/rvm/src/org/jikesrvm/mm/mminterface/Barriers.java rvmroot/trunk/rvm/src/org/jikesrvm/runtime/Entrypoints.java Modified: rvmroot/trunk/MMTk/ext/vm/harness/org/mmtk/harness/vm/Barriers.java =================================================================== --- rvmroot/trunk/MMTk/ext/vm/harness/org/mmtk/harness/vm/Barriers.java 2009-09-19 02:54:48 UTC (rev 15786) +++ rvmroot/trunk/MMTk/ext/vm/harness/org/mmtk/harness/vm/Barriers.java 2009-09-19 03:23:17 UTC (rev 15787) @@ -21,21 +21,21 @@ @Uninterruptible public class Barriers extends org.mmtk.vm.Barriers { /** - * Perform the actual write of the write barrier. + * Perform the actual write of a boolean write barrier. * * @param ref The object that has the reference field - * @param target The value that the slot will be updated to + * @param value The value that the slot will be updated to * @param slot The address to be written to * @param unused Unused * @param mode The context in which the write is occurring */ @Override - public void objectReferenceWrite(ObjectReference ref, ObjectReference target, Word slot, Word unused, int mode) { - slot.toAddress().store(target); + public void booleanWrite(ObjectReference ref, boolean value, Word slot, Word unused, int mode) { + slot.toAddress().store((byte) (value ? 1 : 0)); } /** - * Perform the actual read of the read barrier. + * Perform the actual read of a boolean read barrier. * * @param ref The object that has the reference field * @param slot The address to be read from @@ -44,6 +44,230 @@ * @return the read value */ @Override + public boolean booleanRead(ObjectReference ref, Word slot, Word unused, int mode) { + return slot.toAddress().loadByte() != 0; + } + + /** + * Perform the actual write of a byte write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param slot The address to be written to + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Override + public void byteWrite(ObjectReference ref, byte value, Word slot, Word unused, int mode) { + slot.toAddress().store(value); + } + + /** + * Perform the actual read of a byte read barrier. + * + * @param ref The object that has the reference field + * @param slot The address to be read from + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Override + public byte byteRead(ObjectReference ref, Word slot, Word unused, int mode) { + return slot.toAddress().loadByte(); + } + + /** + * Perform the actual write of a char write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param slot The address to be written to + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Override + public void charWrite(ObjectReference ref, char value, Word slot, Word unused, int mode) { + slot.toAddress().store(value); + } + + /** + * Perform the actual read of a char read barrier. + * + * @param ref The object that has the reference field + * @param slot The address to be read from + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Override + public char charRead(ObjectReference ref, Word slot, Word unused, int mode) { + return slot.toAddress().loadChar(); + } + + /** + * Perform the actual write of a short write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param slot The address to be written to + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Override + public void shortWrite(ObjectReference ref, short value, Word slot, Word unused, int mode) { + slot.toAddress().store(value); + } + + /** + * Perform the actual read of a short read barrier. + * + * @param ref The object that has the reference field + * @param slot The address to be read from + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Override + public short shortRead(ObjectReference ref, Word slot, Word unused, int mode) { + return slot.toAddress().loadShort(); + } + + /** + * Perform the actual write of a int write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param slot The address to be written to + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Override + public void intWrite(ObjectReference ref, int value, Word slot, Word unused, int mode) { + slot.toAddress().store(value); + } + + /** + * Perform the actual read of a int read barrier. + * + * @param ref The object that has the reference field + * @param slot The address to be read from + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Override + public int intRead(ObjectReference ref, Word slot, Word unused, int mode) { + return slot.toAddress().loadInt(); + } + + /** + * Perform the actual write of a long write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param slot The address to be written to + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Override + public void longWrite(ObjectReference ref, long value, Word slot, Word unused, int mode) { + slot.toAddress().store(value); + } + + /** + * Perform the actual read of a long read barrier. + * + * @param ref The object that has the reference field + * @param slot The address to be read from + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Override + public long longRead(ObjectReference ref, Word slot, Word unused, int mode) { + return slot.toAddress().loadLong(); + } + + /** + * Perform the actual write of a float write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param slot The address to be written to + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Override + public void floatWrite(ObjectReference ref, float value, Word slot, Word unused, int mode) { + slot.toAddress().store(value); + } + + /** + * Perform the actual read of a float read barrier. + * + * @param ref The object that has the reference field + * @param slot The address to be read from + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Override + public float floatRead(ObjectReference ref, Word slot, Word unused, int mode) { + return slot.toAddress().loadFloat(); + } + + /** + * Perform the actual write of a double write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param slot The address to be written to + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Override + public void doubleWrite(ObjectReference ref, double value, Word slot, Word unused, int mode) { + slot.toAddress().store(value); + } + + /** + * Perform the actual read of a double read barrier. + * + * @param ref The object that has the reference field + * @param slot The address to be read from + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Override + public double doubleRead(ObjectReference ref, Word slot, Word unused, int mode) { + return slot.toAddress().loadDouble(); + } + + /** + * Perform the actual write of an object reference write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param slot The address to be written to + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Override + public void objectReferenceWrite(ObjectReference ref, ObjectReference value, Word slot, Word unused, int mode) { + slot.toAddress().store(value); + } + + /** + * Perform the actual read of an object reference read barrier. + * + * @param ref The object that has the reference field + * @param slot The address to be read from + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Override public ObjectReference objectReferenceRead(ObjectReference ref,Word slot, Word unused, int mode) { return slot.toAddress().loadObjectReference(); } Modified: rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/Barriers.java =================================================================== --- rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/Barriers.java 2009-09-19 02:54:48 UTC (rev 15786) +++ rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/Barriers.java 2009-09-19 03:23:17 UTC (rev 15787) @@ -22,29 +22,271 @@ @Uninterruptible public class Barriers extends org.mmtk.vm.Barriers implements SizeConstants { /** - * Perform the actual write of the write barrier. + * Perform the actual write of a boolean write barrier. * * @param objref The object that has the reference field - * @param target The value that the slot will be updated to + * @param value The value that the slot will be updated to * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Inline + @Override + public final void booleanWrite(ObjectReference objref, boolean value, Word offset, Word location, int mode) { + Magic.setByteAtOffset(objref.toObject(), offset.toOffset(), (byte) (value ? 1 : 0)); + } + + /** + * Perform the actual read of a boolean read barrier. + * + * @param objref The object that has the reference field + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Inline + @Override + public final boolean booleanRead(ObjectReference objref, Word offset, Word location, int mode) { + return Magic.getByteAtOffset(objref.toObject(), offset.toOffset()) == 0; + } + + /** + * Perform the actual write of a byte write barrier. + * + * @param objref The object that has the reference field + * @param value The value that the slot will be updated to + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Inline + @Override + public final void byteWrite(ObjectReference objref, byte value, Word offset, Word location, int mode) { + Magic.setByteAtOffset(objref.toObject(), offset.toOffset(), value); + } + + /** + * Perform the actual read of a byte read barrier. + * + * @param objref The object that has the reference field + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Inline + @Override + public final byte byteRead(ObjectReference objref, Word offset, Word location, int mode) { + return Magic.getByteAtOffset(objref.toObject(), offset.toOffset()); + } + + /** + * Perform the actual write of a char write barrier. + * + * @param objref The object that has the reference field + * @param value The value that the slot will be updated to + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Inline + @Override + public final void charWrite(ObjectReference objref, char value, Word offset, Word location, int mode) { + Magic.setCharAtOffset(objref.toObject(), offset.toOffset(), value); + } + + /** + * Perform the actual read of a char read barrier. + * + * @param objref The object that has the reference field + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Inline + @Override + public final char charRead(ObjectReference objref, Word offset, Word location, int mode) { + return Magic.getCharAtOffset(objref.toObject(), offset.toOffset()); + } + + /** + * Perform the actual write of a short write barrier. + * + * @param objref The object that has the reference field + * @param value The value that the slot will be updated to + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Inline + @Override + public final void shortWrite(ObjectReference objref, short value, Word offset, Word location, int mode) { + Magic.setShortAtOffset(objref.toObject(), offset.toOffset(), value); + } + + /** + * Perform the actual read of a short read barrier. + * + * @param objref The object that has the reference field + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Inline + @Override + public final short shortRead(ObjectReference objref, Word offset, Word location, int mode) { + return Magic.getShortAtOffset(objref.toObject(), offset.toOffset()); + } + + /** + * Perform the actual write of a int write barrier. + * + * @param objref The object that has the reference field + * @param value The value that the slot will be updated to + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Inline + @Override + public final void intWrite(ObjectReference objref, int value, Word offset, Word location, int mode) { + Magic.setIntAtOffset(objref.toObject(), offset.toOffset(), value); + } + + /** + * Perform the actual read of a int read barrier. + * + * @param objref The object that has the reference field + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Inline + @Override + public final int intRead(ObjectReference objref, Word offset, Word location, int mode) { + return Magic.getIntAtOffset(objref.toObject(), offset.toOffset()); + } + + /** + * Perform the actual write of a long write barrier. + * + * @param objref The object that has the reference field + * @param value The value that the slot will be updated to + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Inline + @Override + public final void longWrite(ObjectReference objref, long value, Word offset, Word location, int mode) { + Magic.setLongAtOffset(objref.toObject(), offset.toOffset(), value); + } + + /** + * Perform the actual read of a long read barrier. + * + * @param objref The object that has the reference field + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Inline + @Override + public final long longRead(ObjectReference objref, Word offset, Word location, int mode) { + return Magic.getLongAtOffset(objref.toObject(), offset.toOffset()); + } + + /** + * Perform the actual write of a float write barrier. + * + * @param objref The object that has the reference field + * @param value The value that the slot will be updated to + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Inline + @Override + public final void floatWrite(ObjectReference objref, float value, Word offset, Word location, int mode) { + Magic.setFloatAtOffset(objref.toObject(), offset.toOffset(), value); + } + + /** + * Perform the actual read of a float read barrier. + * + * @param objref The object that has the reference field + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Inline + @Override + public final float floatRead(ObjectReference objref, Word offset, Word location, int mode) { + return Magic.getFloatAtOffset(objref.toObject(), offset.toOffset()); + } + + /** + * Perform the actual write of a double write barrier. + * + * @param objref The object that has the reference field + * @param value The value that the slot will be updated to + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + */ + @Inline + @Override + public final void doubleWrite(ObjectReference objref, double value, Word offset, Word location, int mode) { + Magic.setDoubleAtOffset(objref.toObject(), offset.toOffset(), value); + } + + /** + * Perform the actual read of a double read barrier. + * + * @param objref The object that has the reference field + * @param offset The offset from the ref + * @param unused Unused + * @param mode The context in which the write is occurring + * @return the read value + */ + @Inline + @Override + public final double doubleRead(ObjectReference objref, Word offset, Word location, int mode) { + return Magic.getDoubleAtOffset(objref.toObject(), offset.toOffset()); + } + + /** + * Perform the actual write of an object reference write barrier. + * + * @param objref The object that has the reference field + * @param value The value that the slot will be updated to + * @param offset The offset from the ref * @param location The index of the FieldReference * @param mode The context in which the write is occurring */ @Inline - public final void objectReferenceWrite(ObjectReference objref, ObjectReference target, Word offset, Word location, int mode) { - Magic.setObjectAtOffset(objref.toObject(), offset.toOffset(), target.toObject(), location.toInt()); + @Override + public final void objectReferenceWrite(ObjectReference objref, ObjectReference value, Word offset, Word location, int mode) { + Magic.setObjectAtOffset(objref.toObject(), offset.toOffset(), value.toObject(), location.toInt()); } /** - * Perform the actual read of the read barrier. + * Perform the actual read of an object reference read barrier. * * @param objref The object that has the reference field * @param offset The offset from the ref * @param location The index of the FieldReference * @param mode The context in which the write is occurring - * @return the read value + * @return the object reference read value */ @Inline + @Override public final ObjectReference objectReferenceRead(ObjectReference objref, Word offset, Word location, int mode) { return ObjectReference.fromObject(Magic.getObjectAtOffset(objref.toObject(), offset.toOffset(), location.toInt())); } @@ -59,6 +301,7 @@ * @param ref The object that has the reference field */ @Inline + @Override public final void objectReferenceNonHeapWrite(Address slot, ObjectReference target, Word unusedA, Word unusedB) { slot.store(target); } @@ -75,6 +318,7 @@ * @return The value that was replaced by the write. */ @Inline + @Override public final ObjectReference objectReferenceAtomicWrite(ObjectReference objref, ObjectReference target, Word offset, Word unused, int mode) { Object obj = objref.toObject(); Object newObject = target.toObject(); @@ -97,6 +341,7 @@ * @return True if the compare and swap was successful */ @Inline + @Override public final boolean objectReferenceTryCompareAndSwap(ObjectReference objref, ObjectReference old, ObjectReference target, Word offset, Word unused, int mode) { Object oldValue; do { @@ -116,6 +361,7 @@ * @param mode The context in which the write is occurring */ @Inline + @Override public final void wordWrite(ObjectReference ref, Word target, Word offset, Word location, int mode) { Magic.setWordAtOffset(ref.toObject(), offset.toOffset(), target, location.toInt()); @@ -133,6 +379,7 @@ * @return The value that was replaced by the write. */ @Inline + @Override public final Word wordAtomicWrite(ObjectReference ref, Word target, Word offset, Word unused, int mode) { Word oldValue; @@ -154,6 +401,7 @@ * @return True if the compare and swap was successful */ @Inline + @Override public final boolean wordTryCompareAndSwap(ObjectReference ref, Word old, Word target, Word offset, Word unused, int mode) { do { @@ -173,6 +421,7 @@ * @return the read value */ @Inline + @Override public final Word wordRead(ObjectReference ref, Word offset, Word location, int mode) { return Magic.getWordAtOffset(ref.toObject(), offset.toOffset(), location.toInt()); @@ -189,6 +438,7 @@ * @param value the new value for the element */ @UninterruptibleNoWarn + @Override public final void objectArrayStoreNoGCBarrier(Object[] dst, int index, Object value) { if (org.jikesrvm.VM.runningVM) { Address base = ObjectReference.fromObject(dst).toAddress(); Modified: rvmroot/trunk/MMTk/src/org/mmtk/plan/MutatorContext.java =================================================================== --- rvmroot/trunk/MMTk/src/org/mmtk/plan/MutatorContext.java 2009-09-19 02:54:48 UTC (rev 15786) +++ rvmroot/trunk/MMTk/src/org/mmtk/plan/MutatorContext.java 2009-09-19 03:23:17 UTC (rev 15787) @@ -282,6 +282,518 @@ } /** + * Write a boolean. Take appropriate write barrier actions.<p> + * + * <b>By default do nothing, override if appropriate.</b> + * + * @param src The object into which the new reference will be stored + * @param slot The address into which the new reference will be + * stored. + * @param value The value of the new boolean + * @param metaDataA A value that assists the host VM in creating a store + * @param metaDataB A value that assists the host VM in creating a store + * @param mode The context in which the store occurred + */ + public void booleanWrite(ObjectReference src, Address slot, boolean value, Word metaDataA, Word metaDataB, int mode) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + } + + /** + * Read a boolean. Take appropriate read barrier action, and + * return the value that was read.<p> This is a <b>substituting<b> + * barrier. The call to this barrier takes the place of a load.<p> + * + * @param src The object reference holding the field being read. + * @param slot The address of the slot being read. + * @param metaDataA A value that assists the host VM in creating a load + * @param metaDataB A value that assists the host VM in creating a load + * @param mode The context in which the load occurred + * @return The boolean that was read. + */ + @Inline + public boolean booleanRead(ObjectReference src, Address slot, Word metaDataA, Word metaDataB, int mode) { + // Either: read barriers are used and this is overridden, or + // read barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return false; + } + + /** + * A number of booleans are about to be copied from object + * <code>src</code> to object <code>dst</code> (as in an array + * copy). Thus, <code>dst</code> is the mutated object. Take + * appropriate write barrier actions.<p> + * + * @param src The source of the values to be copied + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param dst The mutated object, i.e. the destination of the copy. + * @param dstOffset The offset of the first destination address, in + * bytes relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + public boolean booleanBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return false; + } + + /** + * Write a byte. Take appropriate write barrier actions.<p> + * + * <b>By default do nothing, override if appropriate.</b> + * + * @param src The object into which the new reference will be stored + * @param slot The address into which the new reference will be + * stored. + * @param value The value of the new byte + * @param metaDataA A value that assists the host VM in creating a store + * @param metaDataB A value that assists the host VM in creating a store + * @param mode The context in which the store occurred + */ + public void byteWrite(ObjectReference src, Address slot, byte value, Word metaDataA, Word metaDataB, int mode) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + } + + /** + * Read a byte. Take appropriate read barrier action, and + * return the value that was read.<p> This is a <b>substituting<b> + * barrier. The call to this barrier takes the place of a load.<p> + * + * @param src The object reference holding the field being read. + * @param slot The address of the slot being read. + * @param metaDataA A value that assists the host VM in creating a load + * @param metaDataB A value that assists the host VM in creating a load + * @param mode The context in which the load occurred + * @return The byte that was read. + */ + @Inline + public byte byteRead(ObjectReference src, Address slot, Word metaDataA, Word metaDataB, int mode) { + // Either: read barriers are used and this is overridden, or + // read barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return 0; + } + + /** + * A number of bytes are about to be copied from object + * <code>src</code> to object <code>dst</code> (as in an array + * copy). Thus, <code>dst</code> is the mutated object. Take + * appropriate write barrier actions.<p> + * + * @param src The source of the values to be copied + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param dst The mutated object, i.e. the destination of the copy. + * @param dstOffset The offset of the first destination address, in + * bytes relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + public boolean byteBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return false; + } + + /** + * Write a char. Take appropriate write barrier actions.<p> + * + * <b>By default do nothing, override if appropriate.</b> + * + * @param src The object into which the new reference will be stored + * @param slot The address into which the new reference will be + * stored. + * @param value The value of the new char + * @param metaDataA A value that assists the host VM in creating a store + * @param metaDataB A value that assists the host VM in creating a store + * @param mode The context in which the store occurred + */ + public void charWrite(ObjectReference src, Address slot, char value, Word metaDataA, Word metaDataB, int mode) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + } + + /** + * Read a char. Take appropriate read barrier action, and + * return the value that was read.<p> This is a <b>substituting<b> + * barrier. The call to this barrier takes the place of a load.<p> + * + * @param src The object reference holding the field being read. + * @param slot The address of the slot being read. + * @param metaDataA A value that assists the host VM in creating a load + * @param metaDataB A value that assists the host VM in creating a load + * @param mode The context in which the load occurred + * @return The char that was read. + */ + @Inline + public char charRead(ObjectReference src, Address slot, Word metaDataA, Word metaDataB, int mode) { + // Either: read barriers are used and this is overridden, or + // read barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return 0; + } + + /** + * A number of chars are about to be copied from object + * <code>src</code> to object <code>dst</code> (as in an array + * copy). Thus, <code>dst</code> is the mutated object. Take + * appropriate write barrier actions.<p> + * + * @param src The source of the values to be copied + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param dst The mutated object, i.e. the destination of the copy. + * @param dstOffset The offset of the first destination address, in + * bytes relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + public boolean charBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return false; + } + + /** + * Write a short. Take appropriate write barrier actions.<p> + * + * <b>By default do nothing, override if appropriate.</b> + * + * @param src The object into which the new reference will be stored + * @param slot The address into which the new reference will be + * stored. + * @param value The value of the new short + * @param metaDataA A value that assists the host VM in creating a store + * @param metaDataB A value that assists the host VM in creating a store + * @param mode The context in which the store occurred + */ + public void shortWrite(ObjectReference src, Address slot, short value, Word metaDataA, Word metaDataB, int mode) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + } + + /** + * Read a short. Take appropriate read barrier action, and + * return the value that was read.<p> This is a <b>substituting<b> + * barrier. The call to this barrier takes the place of a load.<p> + * + * @param src The object reference holding the field being read. + * @param slot The address of the slot being read. + * @param metaDataA A value that assists the host VM in creating a load + * @param metaDataB A value that assists the host VM in creating a load + * @param mode The context in which the load occurred + * @return The short that was read. + */ + @Inline + public short shortRead(ObjectReference src, Address slot, Word metaDataA, Word metaDataB, int mode) { + // Either: read barriers are used and this is overridden, or + // read barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return 0; + } + + /** + * A number of shorts are about to be copied from object + * <code>src</code> to object <code>dst</code> (as in an array + * copy). Thus, <code>dst</code> is the mutated object. Take + * appropriate write barrier actions.<p> + * + * @param src The source of the values to be copied + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param dst The mutated object, i.e. the destination of the copy. + * @param dstOffset The offset of the first destination address, in + * bytes relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + public boolean shortBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return false; + } + + /** + * Write a int. Take appropriate write barrier actions.<p> + * + * <b>By default do nothing, override if appropriate.</b> + * + * @param src The object into which the new reference will be stored + * @param slot The address into which the new reference will be + * stored. + * @param value The value of the new int + * @param metaDataA A value that assists the host VM in creating a store + * @param metaDataB A value that assists the host VM in creating a store + * @param mode The context in which the store occurred + */ + public void intWrite(ObjectReference src, Address slot, int value, Word metaDataA, Word metaDataB, int mode) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + } + + /** + * Read a int. Take appropriate read barrier action, and + * return the value that was read.<p> This is a <b>substituting<b> + * barrier. The call to this barrier takes the place of a load.<p> + * + * @param src The object reference holding the field being read. + * @param slot The address of the slot being read. + * @param metaDataA A value that assists the host VM in creating a load + * @param metaDataB A value that assists the host VM in creating a load + * @param mode The context in which the load occurred + * @return The int that was read. + */ + @Inline + public int intRead(ObjectReference src, Address slot, Word metaDataA, Word metaDataB, int mode) { + // Either: read barriers are used and this is overridden, or + // read barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return 0; + } + + /** + * A number of ints are about to be copied from object + * <code>src</code> to object <code>dst</code> (as in an array + * copy). Thus, <code>dst</code> is the mutated object. Take + * appropriate write barrier actions.<p> + * + * @param src The source of the values to be copied + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param dst The mutated object, i.e. the destination of the copy. + * @param dstOffset The offset of the first destination address, in + * bytes relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + public boolean intBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return false; + } + + /** + * Write a long. Take appropriate write barrier actions.<p> + * + * <b>By default do nothing, override if appropriate.</b> + * + * @param src The object into which the new reference will be stored + * @param slot The address into which the new reference will be + * stored. + * @param value The value of the new int + * @param metaDataA A value that assists the host VM in creating a store + * @param metaDataB A value that assists the host VM in creating a store + * @param mode The context in which the store occurred + */ + public void longWrite(ObjectReference src, Address slot, long value, Word metaDataA, Word metaDataB, int mode) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + } + + /** + * Read a long. Take appropriate read barrier action, and + * return the value that was read.<p> This is a <b>substituting<b> + * barrier. The call to this barrier takes the place of a load.<p> + * + * @param src The object reference holding the field being read. + * @param slot The address of the slot being read. + * @param metaDataA A value that assists the host VM in creating a load + * @param metaDataB A value that assists the host VM in creating a load + * @param mode The context in which the load occurred + * @return The long that was read. + */ + @Inline + public long longRead(ObjectReference src, Address slot, Word metaDataA, Word metaDataB, int mode) { + // Either: read barriers are used and this is overridden, or + // read barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return 0; + } + + /** + * A number of longs are about to be copied from object + * <code>src</code> to object <code>dst</code> (as in an array + * copy). Thus, <code>dst</code> is the mutated object. Take + * appropriate write barrier actions.<p> + * + * @param src The source of the values to be copied + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param dst The mutated object, i.e. the destination of the copy. + * @param dstOffset The offset of the first destination address, in + * bytes relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + public boolean longBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return false; + } + + /** + * Write a float. Take appropriate write barrier actions.<p> + * + * <b>By default do nothing, override if appropriate.</b> + * + * @param src The object into which the new reference will be stored + * @param slot The address into which the new reference will be + * stored. + * @param value The value of the new float + * @param metaDataA A value that assists the host VM in creating a store + * @param metaDataB A value that assists the host VM in creating a store + * @param mode The context in which the store occurred + */ + public void floatWrite(ObjectReference src, Address slot, float value, Word metaDataA, Word metaDataB, int mode) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + } + + /** + * Read a float. Take appropriate read barrier action, and + * return the value that was read.<p> This is a <b>substituting<b> + * barrier. The call to this barrier takes the place of a load.<p> + * + * @param src The object reference holding the field being read. + * @param slot The address of the slot being read. + * @param metaDataA A value that assists the host VM in creating a load + * @param metaDataB A value that assists the host VM in creating a load + * @param mode The context in which the load occurred + * @return The float that was read. + */ + @Inline + public float floatRead(ObjectReference src, Address slot, Word metaDataA, Word metaDataB, int mode) { + // Either: read barriers are used and this is overridden, or + // read barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return 0; + } + + /** + * A number of floats are about to be copied from object + * <code>src</code> to object <code>dst</code> (as in an array + * copy). Thus, <code>dst</code> is the mutated object. Take + * appropriate write barrier actions.<p> + * + * @param src The source of the values to be copied + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param dst The mutated object, i.e. the destination of the copy. + * @param dstOffset The offset of the first destination address, in + * bytes relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + public boolean floatBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return false; + } + + /** + * Write a double. Take appropriate write barrier actions.<p> + * + * <b>By default do nothing, override if appropriate.</b> + * + * @param src The object into which the new reference will be stored + * @param slot The address into which the new reference will be + * stored. + * @param value The value of the new double + * @param metaDataA A value that assists the host VM in creating a store + * @param metaDataB A value that assists the host VM in creating a store + * @param mode The context in which the store occurred + */ + public void doubleWrite(ObjectReference src, Address slot, double value, Word metaDataA, Word metaDataB, int mode) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + } + + /** + * Read a double. Take appropriate read barrier action, and + * return the value that was read.<p> This is a <b>substituting<b> + * barrier. The call to this barrier takes the place of a load.<p> + * + * @param src The object reference holding the field being read. + * @param slot The address of the slot being read. + * @param metaDataA A value that assists the host VM in creating a load + * @param metaDataB A value that assists the host VM in creating a load + * @param mode The context in which the load occurred + * @return The double that was read. + */ + @Inline + public double doubleRead(ObjectReference src, Address slot, Word metaDataA, Word metaDataB, int mode) { + // Either: read barriers are used and this is overridden, or + // read barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return 0; + } + + /** + * A number of doubles are about to be copied from object + * <code>src</code> to object <code>dst</code> (as in an array + * copy). Thus, <code>dst</code> is the mutated object. Take + * appropriate write barrier actions.<p> + * + * @param src The source of the values to be copied + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param dst The mutated object, i.e. the destination of the copy. + * @param dstOffset The offset of the first destination address, in + * bytes relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + public boolean doubleBulkCopy(ObjectReference src, Offset srcOffset, ObjectReference dst, Offset dstOffset, int bytes) { + // Either: write barriers are used and this is overridden, or + // write barriers are not used and this is never called + if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); + return false; + } + + /** * Write an object reference. Take appropriate write barrier actions.<p> * * <b>By default do nothing, override if appropriate.</b> @@ -289,12 +801,12 @@ * @param src The object into which the new reference will be stored * @param slot The address into which the new reference will be * stored. - * @param tgt The target of the new reference + * @param value The value of the new reference * @param metaDataA A value that assists the host VM in creating a store * @param metaDataB A value that assists the host VM in creating a store * @param mode The context in which the store occurred */ - public void objectReferenceWrite(ObjectReference src, Address slot, ObjectReference tgt, Word metaDataA, Word metaDataB, int mode) { + public void objectReferenceWrite(ObjectReference src, Address slot, ObjectReference value, Word metaDataA, Word metaDataB, int mode) { // Either: write barriers are used and this is overridden, or // write barriers are not used and this is never called if (VM.VERIFY_ASSERTIONS) VM.assertions._assert(false); Modified: rvmroot/trunk/MMTk/src/org/mmtk/plan/PlanConstraints.java =================================================================== --- rvmroot/trunk/MMTk/src/org/mmtk/plan/PlanConstraints.java 2009-09-19 02:54:48 UTC (rev 15786) +++ rvmroot/trunk/MMTk/src/org/mmtk/plan/PlanConstraints.java 2009-09-19 03:23:17 UTC (rev 15787) @@ -25,6 +25,54 @@ /** @return True of this Plan requires read barriers on java.lang.reference types. */ public boolean needsJavaLangReferenceReadBarrier() { return false; } + /** @return True if this Plan requires write barriers on booleans. */ + public boolean needsBooleanWriteBarrier() { return false; } + + /** @return True of this Plan requires read barriers on booleans. */ + public boolean needsBooleanReadBarrier() { return false; } + + /** @return True if this Plan requires write barriers on bytes. */ + public boolean needsByteWriteBarrier() { return false; } + + /** @return True of this Plan requires read barriers on bytes. */ + public boolean needsByteReadBarrier() { return false; } + + /** @return True if this Plan requires write barriers on chars. */ + public boolean needsCharWriteBarrier() { return false; } + + /** @return True of this Plan requires read barriers on chars. */ + public boolean needsCharReadBarrier() { return false; } + + /** @return True if this Plan requires write barriers on shorts. */ + public boolean needsShortWriteBarrier() { return false; } + + /** @return True of this Plan requires read barriers on shorts. */ + public boolean needsShortReadBarrier() { return false; } + + /** @return True if this Plan requires write barriers on ints. */ + public boolean needsIntWriteBarrier() { return false; } + + /** @return True of this Plan requires read barriers on ints. */ + public boolean needsIntReadBarrier() { return false; } + + /** @return True if this Plan requires write barriers on longs. */ + public boolean needsLongWriteBarrier() { return false; } + + /** @return True of this Plan requires read barriers on longs. */ + public boolean needsLongReadBarrier() { return false; } + + /** @return True if this Plan requires write barriers on floats. */ + public boolean needsFloatWriteBarrier() { return false; } + + /** @return True of this Plan requires read barriers on floats. */ + public boolean needsFloatReadBarrier() { return false; } + + /** @return True if this Plan requires write barriers on doubles. */ + public boolean needsDoubleWriteBarrier() { return false; } + + /** @return True of this Plan requires read barriers on doubles. */ + public boolean needsDoubleReadBarrier() { return false; } + /** @return True if this Plan requires write barriers on object references. */ public boolean needsObjectReferenceWriteBarrier() { return false; } Modified: rvmroot/trunk/MMTk/src/org/mmtk/vm/Barriers.java =================================================================== --- rvmroot/trunk/MMTk/src/org/mmtk/vm/Barriers.java 2009-09-19 02:54:48 UTC (rev 15786) +++ rvmroot/trunk/MMTk/src/org/mmtk/vm/Barriers.java 2009-09-19 03:23:17 UTC (rev 15787) @@ -18,18 +18,194 @@ @Uninterruptible public abstract class Barriers { /** + * Perform the actual write of a boolean write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + */ + public abstract void booleanWrite(ObjectReference ref, boolean value, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual read of a boolean read barrier. + * + * @param ref The object that has the reference field + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + * @return the read value + */ + public abstract boolean booleanRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual write of a byte write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + */ + public abstract void byteWrite(ObjectReference ref, byte value, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual read of a byte read barrier. + * + * @param ref The object that has the reference field + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + * @return the read value + */ + public abstract byte byteRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual write of a char write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + */ + public abstract void charWrite(ObjectReference ref, char value, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual read of a char read barrier. + * + * @param ref The object that has the reference field + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + * @return the read value + */ + public abstract char charRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual write of a short write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + */ + public abstract void shortWrite(ObjectReference ref, short value, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual read of a short read barrier. + * + * @param ref The object that has the reference field + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + * @return the read value + */ + public abstract short shortRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual write of a int write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + */ + public abstract void intWrite(ObjectReference ref, int value, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual read of a int read barrier. + * + * @param ref The object that has the reference field + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + * @return the read value + */ + public abstract int intRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual write of a long write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + */ + public abstract void longWrite(ObjectReference ref, long value, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual read of a long read barrier. + * + * @param ref The object that has the reference field + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + * @return the read value + */ + public abstract long longRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual write of a float write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + */ + public abstract void floatWrite(ObjectReference ref, float value, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual read of a float read barrier. + * + * @param ref The object that has the reference field + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + * @return the read value + */ + public abstract float floatRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual write of a double write barrier. + * + * @param ref The object that has the reference field + * @param value The value that the slot will be updated to + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + */ + public abstract void doubleWrite(ObjectReference ref, double value, Word metaDataA, Word metaDataB, int mode); + + /** + * Perform the actual read of a double read barrier. + * + * @param ref The object that has the reference field + * @param metaDataA Opaque, VM-specific, meta-data identifying the slot + * @param metaDataB Opaque, VM-specific, meta-data identifying the slot + * @param mode The context in which the write is occurring + * @return the read value + */ + public abstract double doubleRead(ObjectReference ref, Word metaDataA, Word metaDataB, int mode); + + /** * Perform the actual write of an object reference write barrier. * * @param ref The object that has the reference field - * @param target The value that the slot will be updated to + * @param value The value that the slot will be updated to * @param metaDataA Opaque, VM-specific, meta-data identifying the slot * @param metaDataB Opaque, VM-specific, meta-data identifying the slot * @param mode The context in which the write is occurring */ - public abstract void objectReferenceWrite(ObjectReference ref, ObjectReference target, Word metaDataA, Word metaDataB, int mode); + public abstract void objectReferenceWrite(ObjectReference ref, ObjectReference value, Word metaDataA, Word metaDataB, int mode); /** - * Perform the actual read of the read barrier. + * Perform the actual read of a read barrier. * * @param ref The object that has the reference field * @param metaDataA Opaque, VM-specific, meta-data identifying the slot Modified: rvmroot/trunk/rvm/src/org/jikesrvm/mm/mminterface/Barriers.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/mm/mminterface/Barriers.java 2009-09-19 02:54:48 UTC (rev 15786) +++ rvmroot/trunk/rvm/src/org/jikesrvm/mm/mminterface/Barriers.java 2009-09-19 03:23:17 UTC (rev 15787) @@ -43,6 +43,919 @@ return null; } + /* bool byte char short int long float double */ + + /** True if the garbage collector requires write barriers on boolean putfield, arraystore or modifycheck */ + private static final boolean NEEDS_BOOLEAN_GC_WRITE_BARRIER = Selected.Constraints.get().needsBooleanWriteBarrier(); + /** True if the VM requires write barriers on boolean putfield */ + public static final boolean NEEDS_BOOLEAN_PUTFIELD_BARRIER = NEEDS_BOOLEAN_GC_WRITE_BARRIER; + /** True if the VM requires write barriers on boolean arraystore */ + public static final boolean NEEDS_BOOLEAN_ASTORE_BARRIER = NEEDS_BOOLEAN_GC_WRITE_BARRIER; + /** True if the garbage collector requires read barriers on boolean getfield or arrayload */ + private static final boolean NEEDS_BOOLEAN_GC_READ_BARRIER = Selected.Constraints.get().needsBooleanReadBarrier(); + /** True if the VM requires read barriers on boolean getfield */ + public static final boolean NEEDS_BOOLEAN_GETFIELD_BARRIER = NEEDS_BOOLEAN_GC_READ_BARRIER; + /** True if the VM requires read barriers on boolean arrayload */ + public static final boolean NEEDS_BOOLEAN_ALOAD_BARRIER = NEEDS_BOOLEAN_GC_READ_BARRIER; + + /** + * Barrier for writes of booleans into fields of instances (ie putfield). + * + * @param ref the object which is the subject of the putfield + * @param value the new value for the field + * @param offset the offset of the field to be modified + * @param locationMetadata an int that encodes the source location being modified + */ + @Inline + @Entrypoint + public static void booleanFieldWrite(Object ref, boolean value, Offset offset, int locationMetadata) { + if (NEEDS_BOOLEAN_GC_WRITE_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + Selected.Mutator.get().booleanWrite(src, src.toAddress().plus(offset), value, offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for writes of booleans into arrays (ie astore). + * + * @param ref the array which is the subject of the astore + * @param index the index into the array where the new reference + * resides. The index is the "natural" index into the array, for + * example a[index]. + * @param value the value to be stored. + */ + @Inline + @Entrypoint + public static void booleanArrayWrite(Object ref, int index, boolean value) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + Selected.Mutator.get().booleanWrite(array, array.toAddress().plus(offset), value, offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for loads of booleans from fields of instances (ie getfield). + * + * @param ref the object which is the subject of the getfield + * @param offset the offset of the field to be read + * @param locationMetadata an int that encodes the source location being read + * @return The value read from the field. + */ + @Inline + @Entrypoint + public static boolean booleanFieldRead(Object ref, Offset offset, int locationMetadata) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + return Selected.Mutator.get().booleanRead(src, src.toAddress().plus(offset), offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return false; + } + + /** + * Barrier for loads of booleans from fields of arrays (ie aload). + * + * @param ref the array containing the reference. + * @param index the index into the array were the reference resides. + * @return the value read from the array + */ + @Inline + @Entrypoint + public static boolean booleanArrayRead(Object ref, int index) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + return Selected.Mutator.get().booleanRead(array, array.toAddress().plus(offset), offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return false; + } + + /** + * Barrier for a bulk copy of booleans (i.e. in an array copy). + * + * @param src The source object + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param tgt The target object + * @param tgtOffset The offset of the first target address, in bytes + * relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + @Inline + public static boolean booleanBulkCopy(Object src, Offset srcOffset, Object tgt, Offset tgtOffset, int bytes) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER || NEEDS_OBJECT_GC_READ_BARRIER) { + return Selected.Mutator.get().booleanBulkCopy(ObjectReference.fromObject(src), srcOffset, ObjectReference.fromObject(tgt), tgtOffset, bytes); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return false; + } + + /** True if the garbage collector requires write barriers on byte putfield, arraystore or modifycheck */ + private static final boolean NEEDS_BYTE_GC_WRITE_BARRIER = Selected.Constraints.get().needsByteWriteBarrier(); + /** True if the VM requires write barriers on byte putfield */ + public static final boolean NEEDS_BYTE_PUTFIELD_BARRIER = NEEDS_BYTE_GC_WRITE_BARRIER; + /** True if the VM requires write barriers on byte arraystore */ + public static final boolean NEEDS_BYTE_ASTORE_BARRIER = NEEDS_BYTE_GC_WRITE_BARRIER; + /** True if the garbage collector requires read barriers on byte getfield or arrayload */ + private static final boolean NEEDS_BYTE_GC_READ_BARRIER = Selected.Constraints.get().needsByteReadBarrier(); + /** True if the VM requires read barriers on byte getfield */ + public static final boolean NEEDS_BYTE_GETFIELD_BARRIER = NEEDS_BYTE_GC_READ_BARRIER; + /** True if the VM requires read barriers on byte arrayload */ + public static final boolean NEEDS_BYTE_ALOAD_BARRIER = NEEDS_BYTE_GC_READ_BARRIER; + + /** + * Barrier for writes of bytes into fields of instances (ie putfield). + * + * @param ref the object which is the subject of the putfield + * @param value the new value for the field + * @param offset the offset of the field to be modified + * @param locationMetadata an int that encodes the source location being modified + */ + @Inline + @Entrypoint + public static void byteFieldWrite(Object ref, byte value, Offset offset, int locationMetadata) { + if (NEEDS_BYTE_GC_WRITE_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + Selected.Mutator.get().byteWrite(src, src.toAddress().plus(offset), value, offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for writes of objects into arrays (ie astore). + * + * @param ref the array which is the subject of the astore + * @param index the index into the array where the new reference + * resides. The index is the "natural" index into the array, for + * example a[index]. + * @param value the value to be stored. + */ + @Inline + @Entrypoint + public static void byteArrayWrite(Object ref, int index, byte value) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + Selected.Mutator.get().byteWrite(array, array.toAddress().plus(offset), value, offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for loads of objects from fields of instances (ie getfield). + * + * @param ref the object which is the subject of the getfield + * @param offset the offset of the field to be read + * @param locationMetadata an int that encodes the source location being read + * @return The value read from the field. + */ + @Inline + @Entrypoint + public static byte byteFieldRead(Object ref, Offset offset, int locationMetadata) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + return Selected.Mutator.get().byteRead(src, src.toAddress().plus(offset), offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return 0; + } + + /** + * Barrier for loads of objects from fields of arrays (ie aload). + * + * @param ref the array containing the reference. + * @param index the index into the array were the reference resides. + * @return the value read from the array + */ + @Inline + @Entrypoint + public static byte byteArrayRead(Object ref, int index) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + return Selected.Mutator.get().byteRead(array, array.toAddress().plus(offset), offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return 0; + } + + /** + * Barrier for a bulk copy of objects (i.e. in an array copy). + * + * @param src The source object + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param tgt The target object + * @param tgtOffset The offset of the first target address, in bytes + * relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + @Inline + public static boolean byteBulkCopy(Object src, Offset srcOffset, Object tgt, Offset tgtOffset, int bytes) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER || NEEDS_OBJECT_GC_READ_BARRIER) { + return Selected.Mutator.get().byteBulkCopy(ObjectReference.fromObject(src), srcOffset, ObjectReference.fromObject(tgt), tgtOffset, bytes); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return false; + } + + + /** True if the garbage collector requires write barriers on char putfield, arraystore or modifycheck */ + private static final boolean NEEDS_CHAR_GC_WRITE_BARRIER = Selected.Constraints.get().needsCharWriteBarrier(); + /** True if the VM requires write barriers on char putfield */ + public static final boolean NEEDS_CHAR_PUTFIELD_BARRIER = NEEDS_CHAR_GC_WRITE_BARRIER; + /** True if the VM requires write barriers on char arraystore */ + public static final boolean NEEDS_CHAR_ASTORE_BARRIER = NEEDS_CHAR_GC_WRITE_BARRIER; + /** True if the garbage collector requires read barriers on char getfield or arrayload */ + private static final boolean NEEDS_CHAR_GC_READ_BARRIER = Selected.Constraints.get().needsCharReadBarrier(); + /** True if the VM requires read barriers on char getfield */ + public static final boolean NEEDS_CHAR_GETFIELD_BARRIER = NEEDS_CHAR_GC_READ_BARRIER; + /** True if the VM requires read barriers on char arrayload */ + public static final boolean NEEDS_CHAR_ALOAD_BARRIER = NEEDS_CHAR_GC_READ_BARRIER; + + /** + * Barrier for writes of chars into fields of instances (ie putfield). + * + * @param ref the object which is the subject of the putfield + * @param value the new value for the field + * @param offset the offset of the field to be modified + * @param locationMetadata an int that encodes the source location being modified + */ + @Inline + @Entrypoint + public static void charFieldWrite(Object ref, char value, Offset offset, int locationMetadata) { + if (NEEDS_CHAR_GC_WRITE_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + Selected.Mutator.get().charWrite(src, src.toAddress().plus(offset), value, offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for writes of objects into arrays (ie astore). + * + * @param ref the array which is the subject of the astore + * @param index the index into the array where the new reference + * resides. The index is the "natural" index into the array, for + * example a[index]. + * @param value the value to be stored. + */ + @Inline + @Entrypoint + public static void charArrayWrite(Object ref, int index, char value) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + Selected.Mutator.get().charWrite(array, array.toAddress().plus(offset), value, offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for loads of objects from fields of instances (ie getfield). + * + * @param ref the object which is the subject of the getfield + * @param offset the offset of the field to be read + * @param locationMetadata an int that encodes the source location being read + * @return The value read from the field. + */ + @Inline + @Entrypoint + public static char charFieldRead(Object ref, Offset offset, int locationMetadata) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + return Selected.Mutator.get().charRead(src, src.toAddress().plus(offset), offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return 0; + } + + /** + * Barrier for loads of objects from fields of arrays (ie aload). + * + * @param ref the array containing the reference. + * @param index the index into the array were the reference resides. + * @return the value read from the array + */ + @Inline + @Entrypoint + public static char charArrayRead(Object ref, int index) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + return Selected.Mutator.get().charRead(array, array.toAddress().plus(offset), offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return 0; + } + + /** + * Barrier for a bulk copy of objects (i.e. in an array copy). + * + * @param src The source object + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param tgt The target object + * @param tgtOffset The offset of the first target address, in bytes + * relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + @Inline + public static boolean charBulkCopy(Object src, Offset srcOffset, Object tgt, Offset tgtOffset, int bytes) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER || NEEDS_OBJECT_GC_READ_BARRIER) { + return Selected.Mutator.get().charBulkCopy(ObjectReference.fromObject(src), srcOffset, ObjectReference.fromObject(tgt), tgtOffset, bytes); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return false; + } + + + /** True if the garbage collector requires write barriers on short putfield, arraystore or modifycheck */ + private static final boolean NEEDS_SHORT_GC_WRITE_BARRIER = Selected.Constraints.get().needsShortWriteBarrier(); + /** True if the VM requires write barriers on short putfield */ + public static final boolean NEEDS_SHORT_PUTFIELD_BARRIER = NEEDS_SHORT_GC_WRITE_BARRIER; + /** True if the VM requires write barriers on short arraystore */ + public static final boolean NEEDS_SHORT_ASTORE_BARRIER = NEEDS_SHORT_GC_WRITE_BARRIER; + /** True if the garbage collector requires read barriers on short getfield or arrayload */ + private static final boolean NEEDS_SHORT_GC_READ_BARRIER = Selected.Constraints.get().needsShortReadBarrier(); + /** True if the VM requires read barriers on short getfield */ + public static final boolean NEEDS_SHORT_GETFIELD_BARRIER = NEEDS_SHORT_GC_READ_BARRIER; + /** True if the VM requires read barriers on short arrayload */ + public static final boolean NEEDS_SHORT_ALOAD_BARRIER = NEEDS_SHORT_GC_READ_BARRIER; + + /** + * Barrier for writes of shorts into fields of instances (ie putfield). + * + * @param ref the object which is the subject of the putfield + * @param value the new value for the field + * @param offset the offset of the field to be modified + * @param locationMetadata an int that encodes the source location being modified + */ + @Inline + @Entrypoint + public static void shortFieldWrite(Object ref, short value, Offset offset, int locationMetadata) { + if (NEEDS_SHORT_GC_WRITE_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + Selected.Mutator.get().shortWrite(src, src.toAddress().plus(offset), value, offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for writes of objects into arrays (ie astore). + * + * @param ref the array which is the subject of the astore + * @param index the index into the array where the new reference + * resides. The index is the "natural" index into the array, for + * example a[index]. + * @param value the value to be stored. + */ + @Inline + @Entrypoint + public static void shortArrayWrite(Object ref, int index, short value) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + Selected.Mutator.get().shortWrite(array, array.toAddress().plus(offset), value, offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for loads of objects from fields of instances (ie getfield). + * + * @param ref the object which is the subject of the getfield + * @param offset the offset of the field to be read + * @param locationMetadata an int that encodes the source location being read + * @return The value read from the field. + */ + @Inline + @Entrypoint + public static short shortFieldRead(Object ref, Offset offset, int locationMetadata) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + return Selected.Mutator.get().shortRead(src, src.toAddress().plus(offset), offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return 0; + } + + /** + * Barrier for loads of objects from fields of arrays (ie aload). + * + * @param ref the array containing the reference. + * @param index the index into the array were the reference resides. + * @return the value read from the array + */ + @Inline + @Entrypoint + public static short shortArrayRead(Object ref, int index) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + return Selected.Mutator.get().shortRead(array, array.toAddress().plus(offset), offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return 0; + } + + /** + * Barrier for a bulk copy of objects (i.e. in an array copy). + * + * @param src The source object + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param tgt The target object + * @param tgtOffset The offset of the first target address, in bytes + * relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + @Inline + public static boolean shortBulkCopy(Object src, Offset srcOffset, Object tgt, Offset tgtOffset, int bytes) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER || NEEDS_OBJECT_GC_READ_BARRIER) { + return Selected.Mutator.get().shortBulkCopy(ObjectReference.fromObject(src), srcOffset, ObjectReference.fromObject(tgt), tgtOffset, bytes); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return false; + } + + + /** True if the garbage collector requires write barriers on int putfield, arraystore or modifycheck */ + private static final boolean NEEDS_INT_GC_WRITE_BARRIER = Selected.Constraints.get().needsIntWriteBarrier(); + /** True if the VM requires write barriers on int putfield */ + public static final boolean NEEDS_INT_PUTFIELD_BARRIER = NEEDS_INT_GC_WRITE_BARRIER; + /** True if the VM requires write barriers on int arraystore */ + public static final boolean NEEDS_INT_ASTORE_BARRIER = NEEDS_INT_GC_WRITE_BARRIER; + /** True if the garbage collector requires read barriers on int getfield or arrayload */ + private static final boolean NEEDS_INT_GC_READ_BARRIER = Selected.Constraints.get().needsIntReadBarrier(); + /** True if the VM requires read barriers on int getfield */ + public static final boolean NEEDS_INT_GETFIELD_BARRIER = NEEDS_INT_GC_READ_BARRIER; + /** True if the VM requires read barriers on int arrayload */ + public static final boolean NEEDS_INT_ALOAD_BARRIER = NEEDS_INT_GC_READ_BARRIER; + + /** + * Barrier for writes of ints into fields of instances (ie putfield). + * + * @param ref the object which is the subject of the putfield + * @param value the new value for the field + * @param offset the offset of the field to be modified + * @param locationMetadata an int that encodes the source location being modified + */ + @Inline + @Entrypoint + public static void intFieldWrite(Object ref, int value, Offset offset, int locationMetadata) { + if (NEEDS_INT_GC_WRITE_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + Selected.Mutator.get().intWrite(src, src.toAddress().plus(offset), value, offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for writes of objects into arrays (ie astore). + * + * @param ref the array which is the subject of the astore + * @param index the index into the array where the new reference + * resides. The index is the "natural" index into the array, for + * example a[index]. + * @param value the value to be stored. + */ + @Inline + @Entrypoint + public static void intArrayWrite(Object ref, int index, int value) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + Selected.Mutator.get().intWrite(array, array.toAddress().plus(offset), value, offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for loads of objects from fields of instances (ie getfield). + * + * @param ref the object which is the subject of the getfield + * @param offset the offset of the field to be read + * @param locationMetadata an int that encodes the source location being read + * @return The value read from the field. + */ + @Inline + @Entrypoint + public static int intFieldRead(Object ref, Offset offset, int locationMetadata) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + return Selected.Mutator.get().intRead(src, src.toAddress().plus(offset), offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return 0; + } + + /** + * Barrier for loads of objects from fields of arrays (ie aload). + * + * @param ref the array containing the reference. + * @param index the index into the array were the reference resides. + * @return the value read from the array + */ + @Inline + @Entrypoint + public static int intArrayRead(Object ref, int index) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + return Selected.Mutator.get().intRead(array, array.toAddress().plus(offset), offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return 0; + } + + /** + * Barrier for a bulk copy of objects (i.e. in an array copy). + * + * @param src The source object + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param tgt The target object + * @param tgtOffset The offset of the first target address, in bytes + * relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + @Inline + public static boolean intBulkCopy(Object src, Offset srcOffset, Object tgt, Offset tgtOffset, int bytes) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER || NEEDS_OBJECT_GC_READ_BARRIER) { + return Selected.Mutator.get().intBulkCopy(ObjectReference.fromObject(src), srcOffset, ObjectReference.fromObject(tgt), tgtOffset, bytes); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return false; + } + + + /** True if the garbage collector requires write barriers on long putfield, arraystore or modifycheck */ + private static final boolean NEEDS_LONG_GC_WRITE_BARRIER = Selected.Constraints.get().needsLongWriteBarrier(); + /** True if the VM requires write barriers on long putfield */ + public static final boolean NEEDS_LONG_PUTFIELD_BARRIER = NEEDS_LONG_GC_WRITE_BARRIER; + /** True if the VM requires write barriers on long arraystore */ + public static final boolean NEEDS_LONG_ASTORE_BARRIER = NEEDS_LONG_GC_WRITE_BARRIER; + /** True if the garbage collector requires read barriers on long getfield or arrayload */ + private static final boolean NEEDS_LONG_GC_READ_BARRIER = Selected.Constraints.get().needsLongReadBarrier(); + /** True if the VM requires read barriers on long getfield */ + public static final boolean NEEDS_LONG_GETFIELD_BARRIER = NEEDS_LONG_GC_READ_BARRIER; + /** True if the VM requires read barriers on long arrayload */ + public static final boolean NEEDS_LONG_ALOAD_BARRIER = NEEDS_LONG_GC_READ_BARRIER; + + /** + * Barrier for writes of longs into fields of instances (ie putfield). + * + * @param ref the object which is the subject of the putfield + * @param value the new value for the field + * @param offset the offset of the field to be modified + * @param locationMetadata an int that encodes the source location being modified + */ + @Inline + @Entrypoint + public static void longFieldWrite(Object ref, long value, Offset offset, int locationMetadata) { + if (NEEDS_LONG_GC_WRITE_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + Selected.Mutator.get().longWrite(src, src.toAddress().plus(offset), value, offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for writes of objects into arrays (ie astore). + * + * @param ref the array which is the subject of the astore + * @param index the index into the array where the new reference + * resides. The index is the "natural" index into the array, for + * example a[index]. + * @param value the value to be stored. + */ + @Inline + @Entrypoint + public static void longArrayWrite(Object ref, int index, long value) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + Selected.Mutator.get().longWrite(array, array.toAddress().plus(offset), value, offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for loads of objects from fields of instances (ie getfield). + * + * @param ref the object which is the subject of the getfield + * @param offset the offset of the field to be read + * @param locationMetadata an int that encodes the source location being read + * @return The value read from the field. + */ + @Inline + @Entrypoint + public static long longFieldRead(Object ref, Offset offset, int locationMetadata) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + return Selected.Mutator.get().longRead(src, src.toAddress().plus(offset), offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return 0; + } + + /** + * Barrier for loads of objects from fields of arrays (ie aload). + * + * @param ref the array containing the reference. + * @param index the index into the array were the reference resides. + * @return the value read from the array + */ + @Inline + @Entrypoint + public static long longArrayRead(Object ref, int index) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + return Selected.Mutator.get().longRead(array, array.toAddress().plus(offset), offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return 0; + } + + /** + * Barrier for a bulk copy of objects (i.e. in an array copy). + * + * @param src The source object + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param tgt The target object + * @param tgtOffset The offset of the first target address, in bytes + * relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + @Inline + public static boolean longBulkCopy(Object src, Offset srcOffset, Object tgt, Offset tgtOffset, int bytes) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER || NEEDS_OBJECT_GC_READ_BARRIER) { + return Selected.Mutator.get().longBulkCopy(ObjectReference.fromObject(src), srcOffset, ObjectReference.fromObject(tgt), tgtOffset, bytes); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return false; + } + + + /** True if the garbage collector requires write barriers on float putfield, arraystore or modifycheck */ + private static final boolean NEEDS_FLOAT_GC_WRITE_BARRIER = Selected.Constraints.get().needsFloatWriteBarrier(); + /** True if the VM requires write barriers on float putfield */ + public static final boolean NEEDS_FLOAT_PUTFIELD_BARRIER = NEEDS_FLOAT_GC_WRITE_BARRIER; + /** True if the VM requires write barriers on float arraystore */ + public static final boolean NEEDS_FLOAT_ASTORE_BARRIER = NEEDS_FLOAT_GC_WRITE_BARRIER; + /** True if the garbage collector requires read barriers on float getfield or arrayload */ + private static final boolean NEEDS_FLOAT_GC_READ_BARRIER = Selected.Constraints.get().needsFloatReadBarrier(); + /** True if the VM requires read barriers on float getfield */ + public static final boolean NEEDS_FLOAT_GETFIELD_BARRIER = NEEDS_FLOAT_GC_READ_BARRIER; + /** True if the VM requires read barriers on float arrayload */ + public static final boolean NEEDS_FLOAT_ALOAD_BARRIER = NEEDS_FLOAT_GC_READ_BARRIER; + + /** + * Barrier for writes of floats into fields of instances (ie putfield). + * + * @param ref the object which is the subject of the putfield + * @param value the new value for the field + * @param offset the offset of the field to be modified + * @param locationMetadata an int that encodes the source location being modified + */ + @Inline + @Entrypoint + public static void floatFieldWrite(Object ref, float value, Offset offset, int locationMetadata) { + if (NEEDS_FLOAT_GC_WRITE_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + Selected.Mutator.get().floatWrite(src, src.toAddress().plus(offset), value, offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for writes of objects into arrays (ie astore). + * + * @param ref the array which is the subject of the astore + * @param index the index into the array where the new reference + * resides. The index is the "natural" index into the array, for + * example a[index]. + * @param value the value to be stored. + */ + @Inline + @Entrypoint + public static void floatArrayWrite(Object ref, int index, float value) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + Selected.Mutator.get().floatWrite(array, array.toAddress().plus(offset), value, offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for loads of objects from fields of instances (ie getfield). + * + * @param ref the object which is the subject of the getfield + * @param offset the offset of the field to be read + * @param locationMetadata an int that encodes the source location being read + * @return The value read from the field. + */ + @Inline + @Entrypoint + public static float floatFieldRead(Object ref, Offset offset, int locationMetadata) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + return Selected.Mutator.get().floatRead(src, src.toAddress().plus(offset), offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return 0; + } + + /** + * Barrier for loads of objects from fields of arrays (ie aload). + * + * @param ref the array containing the reference. + * @param index the index into the array were the reference resides. + * @return the value read from the array + */ + @Inline + @Entrypoint + public static float floatArrayRead(Object ref, int index) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + return Selected.Mutator.get().floatRead(array, array.toAddress().plus(offset), offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return 0; + } + + /** + * Barrier for a bulk copy of objects (i.e. in an array copy). + * + * @param src The source object + * @param srcOffset The offset of the first source address, in + * bytes, relative to <code>src</code> (in principle, this could be + * negative). + * @param tgt The target object + * @param tgtOffset The offset of the first target address, in bytes + * relative to <code>tgt</code> (in principle, this could be + * negative). + * @param bytes The size of the region being copied, in bytes. + * @return True if the update was performed by the barrier, false if + * left to the caller (always false in this case). + */ + @Inline + public static boolean floatBulkCopy(Object src, Offset srcOffset, Object tgt, Offset tgtOffset, int bytes) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER || NEEDS_OBJECT_GC_READ_BARRIER) { + return Selected.Mutator.get().floatBulkCopy(ObjectReference.fromObject(src), srcOffset, ObjectReference.fromObject(tgt), tgtOffset, bytes); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return false; + } + + + /** True if the garbage collector requires write barriers on double putfield, arraystore or modifycheck */ + private static final boolean NEEDS_DOUBLE_GC_WRITE_BARRIER = Selected.Constraints.get().needsDoubleWriteBarrier(); + /** True if the VM requires write barriers on double putfield */ + public static final boolean NEEDS_DOUBLE_PUTFIELD_BARRIER = NEEDS_DOUBLE_GC_WRITE_BARRIER; + /** True if the VM requires write barriers on double arraystore */ + public static final boolean NEEDS_DOUBLE_ASTORE_BARRIER = NEEDS_DOUBLE_GC_WRITE_BARRIER; + /** True if the garbage collector requires read barriers on double getfield or arrayload */ + private static final boolean NEEDS_DOUBLE_GC_READ_BARRIER = Selected.Constraints.get().needsDoubleReadBarrier(); + /** True if the VM requires read barriers on double getfield */ + public static final boolean NEEDS_DOUBLE_GETFIELD_BARRIER = NEEDS_DOUBLE_GC_READ_BARRIER; + /** True if the VM requires read barriers on double arrayload */ + public static final boolean NEEDS_DOUBLE_ALOAD_BARRIER = NEEDS_DOUBLE_GC_READ_BARRIER; + + /** + * Barrier for writes of doubles into fields of instances (ie putfield). + * + * @param ref the object which is the subject of the putfield + * @param value the new value for the field + * @param offset the offset of the field to be modified + * @param locationMetadata an int that encodes the source location being modified + */ + @Inline + @Entrypoint + public static void doubleFieldWrite(Object ref, double value, Offset offset, int locationMetadata) { + if (NEEDS_DOUBLE_GC_WRITE_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + Selected.Mutator.get().doubleWrite(src, src.toAddress().plus(offset), value, offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for writes of objects into arrays (ie astore). + * + * @param ref the array which is the subject of the astore + * @param index the index into the array where the new reference + * resides. The index is the "natural" index into the array, for + * example a[index]. + * @param value the value to be stored. + */ + @Inline + @Entrypoint + public static void doubleArrayWrite(Object ref, int index, double value) { + if (NEEDS_OBJECT_GC_WRITE_BARRIER) { + ObjectReference array = ObjectReference.fromObject(ref); + Offset offset = Offset.fromIntZeroExtend(index << MemoryManagerConstants.LOG_BYTES_IN_ADDRESS); + Selected.Mutator.get().doubleWrite(array, array.toAddress().plus(offset), value, offset.toWord(), Word.zero(), ARRAY_ELEMENT); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + } + + /** + * Barrier for loads of objects from fields of instances (ie getfield). + * + * @param ref the object which is the subject of the getfield + * @param offset the offset of the field to be read + * @param locationMetadata an int that encodes the source location being read + * @return The value read from the field. + */ + @Inline + @Entrypoint + public static double doubleFieldRead(Object ref, Offset offset, int locationMetadata) { + if (NEEDS_OBJECT_GC_READ_BARRIER) { + ObjectReference src = ObjectReference.fromObject(ref); + return Selected.Mutator.get().doubleRead(src, src.toAddress().plus(offset), offset.toWord(), Word.fromIntZeroExtend(locationMetadata), INSTANCE_FIELD); + } else if (VM.VERIFY_ASSERTIONS) + VM.assertions._assert(false); + return 0; + } + + /** + * Barrier for loads of objects from fields of arrays (ie aload). + * + * @param ref the array containing the reference. @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Jikesrvm-commits mailing list Jikesrvm-commits@... https://lists.sourceforge.net/lists/listinfo/jikesrvm-commits |
| Free embeddable forum powered by Nabble | Forum Help |