From: <ste...@us...> - 2007-09-15 22:28:20
|
Revision: 13604 http://jikesrvm.svn.sourceforge.net/jikesrvm/?rev=13604&view=rev Author: steveb-oss Date: 2007-09-15 15:28:18 -0700 (Sat, 15 Sep 2007) Log Message: ----------- Fix a bit of abstraction-rot Modified Paths: -------------- rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/Barriers.java rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/Strings.java rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/TraceInterface.java rvmroot/trunk/rvm/src/org/jikesrvm/VM_Services.java 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 2007-09-15 09:40:47 UTC (rev 13603) +++ rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/Barriers.java 2007-09-15 22:28:18 UTC (rev 13604) @@ -12,9 +12,9 @@ */ package org.jikesrvm.mm.mmtk; +import org.jikesrvm.VM_Services; import org.jikesrvm.VM_SizeConstants; import org.jikesrvm.runtime.VM_Magic; -import org.jikesrvm.VM; import org.vmmagic.unboxed.*; import org.vmmagic.pragma.*; @@ -97,15 +97,8 @@ */ @Override public final void setArrayNoBarrier(Object [] dst, int index, Object value) { - setArrayNoBarrierStatic(dst, index, value); + VM_Services.setArrayNoBarrier(dst, index, value); } - @UninterruptibleNoWarn - public static void setArrayNoBarrierStatic(Object [] dst, int index, Object value) { - if (VM.runningVM) - VM_Magic.setObjectAtOffset(dst, Offset.fromIntZeroExtend(index << LOG_BYTES_IN_ADDRESS), value); - else - dst[index] = value; - } /** * Sets an element of a char array without invoking any write @@ -118,14 +111,8 @@ * @param value the new value for the element */ public final void setArrayNoBarrier(char [] dst, int index, char value) { - setArrayNoBarrierStatic(dst, index, value); + VM_Services.setArrayNoBarrier(dst, index, value); } - public static void setArrayNoBarrierStatic(char [] dst, int index, char value) { - if (VM.runningVM) - VM_Magic.setCharAtOffset(dst, Offset.fromIntZeroExtend(index << LOG_BYTES_IN_CHAR), value); - else - dst[index] = value; - } /** * Gets an element of a char array without invoking any read barrier @@ -136,14 +123,8 @@ * @return the new value of element */ public final char getArrayNoBarrier(char [] src, int index) { - return getArrayNoBarrierStatic(src, index); + return VM_Services.getArrayNoBarrier(src, index); } - public static char getArrayNoBarrierStatic(char [] src, int index) { - if (VM.runningVM) - return VM_Magic.getCharAtOffset(src, Offset.fromIntZeroExtend(index << LOG_BYTES_IN_CHAR)); - else - return src[index]; - } /** * Gets an element of a byte array without invoking any read barrier @@ -154,15 +135,8 @@ * @return the new value of element */ public final byte getArrayNoBarrier(byte [] src, int index) { - return getArrayNoBarrierStatic(src, index); + return VM_Services.getArrayNoBarrier(src, index); } - public static byte getArrayNoBarrierStatic(byte [] src, int index) { - if (VM.runningVM) - return VM_Magic.getByteAtOffset(src, Offset.fromIntZeroExtend(index)); - else - return src[index]; - } - /** * Gets an element of an int array without invoking any read barrier * or performing bounds checks. @@ -172,10 +146,7 @@ * @return the new value of element */ public final int getArrayNoBarrier(int [] src, int index) { - if (VM.runningVM) - return VM_Magic.getIntAtOffset(src, Offset.fromIntZeroExtend(index<<LOG_BYTES_IN_INT)); - else - return src[index]; + return VM_Services.getArrayNoBarrier(src, index); } /** @@ -187,10 +158,7 @@ * @return the new value of element */ public final Object getArrayNoBarrier(Object [] src, int index) { - if (VM.runningVM) - return VM_Magic.getObjectAtOffset(src, Offset.fromIntZeroExtend(index<<LOG_BYTES_IN_ADDRESS)); - else - return src[index]; + return VM_Services.getArrayNoBarrier(src, index); } @@ -203,12 +171,6 @@ * @return the new value of element */ public final byte[] getArrayNoBarrier(byte[][] src, int index) { - return getArrayNoBarrierStatic(src, index); + return VM_Services.getArrayNoBarrier(src, index); } - public static byte[] getArrayNoBarrierStatic(byte[][] src, int index) { - if (VM.runningVM) - return VM_Magic.addressAsByteArray(VM_Magic.objectAsAddress(VM_Magic.getObjectAtOffset(src, Offset.fromIntZeroExtend(index << LOG_BYTES_IN_ADDRESS)))); - else - return src[index]; - } } Modified: rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/Strings.java =================================================================== --- rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/Strings.java 2007-09-15 09:40:47 UTC (rev 13603) +++ rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/Strings.java 2007-09-15 22:28:18 UTC (rev 13604) @@ -13,6 +13,7 @@ package org.jikesrvm.mm.mmtk; import org.jikesrvm.VM; +import org.jikesrvm.VM_Services; import org.jikesrvm.scheduler.VM_Processor; import org.vmmagic.pragma.*; @@ -60,7 +61,7 @@ int len = src.length(); int n = (dstBegin + len <= dstEnd) ? len : (dstEnd - dstBegin); for (int i = 0; i < n; i++) - Barriers.setArrayNoBarrierStatic(dst, dstBegin + i, src.charAt(i)); + VM_Services.setArrayNoBarrier(dst, dstBegin + i, src.charAt(i)); if (VM.runningVM) VM_Processor.getCurrentProcessor().enableThreadSwitching(); return n; Modified: rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/TraceInterface.java =================================================================== --- rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/TraceInterface.java 2007-09-15 09:40:47 UTC (rev 13603) +++ rvmroot/trunk/MMTk/ext/vm/jikesrvm/org/jikesrvm/mm/mmtk/TraceInterface.java 2007-09-15 22:28:18 UTC (rev 13604) @@ -21,6 +21,7 @@ import org.jikesrvm.compilers.opt.VM_OptEncodedCallSiteTree; import org.jikesrvm.VM; +import org.jikesrvm.VM_Services; import org.jikesrvm.runtime.VM_Magic; import org.jikesrvm.compilers.baseline.VM_BaselineCompiledMethod; import org.jikesrvm.compilers.common.VM_CompiledMethod; @@ -87,13 +88,13 @@ */ private boolean isAllocCall(byte[] name) { for (int i = 0; i < allocCallMethods.length; i++) { - byte[] funcName = Barriers.getArrayNoBarrierStatic(allocCallMethods, i); + byte[] funcName = VM_Services.getArrayNoBarrier(allocCallMethods, i); if (VM_Magic.getArrayLength(name) == VM_Magic.getArrayLength(funcName)) { /* Compare the letters in the allocCallMethod */ int j = VM_Magic.getArrayLength(funcName) - 1; while (j >= 0) { - if (Barriers.getArrayNoBarrierStatic(name, j) != - Barriers.getArrayNoBarrierStatic(funcName, j)) + if (VM_Services.getArrayNoBarrier(name, j) != + VM_Services.getArrayNoBarrier(funcName, j)) break; j--; } Modified: rvmroot/trunk/rvm/src/org/jikesrvm/VM_Services.java =================================================================== --- rvmroot/trunk/rvm/src/org/jikesrvm/VM_Services.java 2007-09-15 09:40:47 UTC (rev 13603) +++ rvmroot/trunk/rvm/src/org/jikesrvm/VM_Services.java 2007-09-15 22:28:18 UTC (rev 13604) @@ -12,20 +12,20 @@ */ package org.jikesrvm; -import org.jikesrvm.mm.mmtk.Barriers; import org.jikesrvm.runtime.VM_Entrypoints; import org.jikesrvm.runtime.VM_Magic; import org.jikesrvm.scheduler.VM_Synchronization; import org.vmmagic.pragma.Interruptible; import org.vmmagic.pragma.NoInline; import org.vmmagic.pragma.Uninterruptible; +import org.vmmagic.pragma.UninterruptibleNoWarn; import org.vmmagic.unboxed.Offset; /** * Various service utilities. This is a common place for some shared utility routines */ @Uninterruptible -public class VM_Services { +public class VM_Services implements VM_SizeConstants { /** * Biggest buffer you would possibly need for {@link #dump(char[], int)} * Modify this if you modify that method. @@ -152,7 +152,7 @@ */ public static int sprintf(char[] dest, int destOffset, char[] src, int srcStart, int srcEnd) { for (int i = srcStart; i < srcEnd; ++i) { - char nextChar = Barriers.getArrayNoBarrierStatic(src, i); + char nextChar = getArrayNoBarrier(src, i); destOffset = sprintf(dest, destOffset, nextChar); } return destOffset; @@ -165,7 +165,7 @@ } if (destOffset < dest.length) { - Barriers.setArrayNoBarrierStatic(dest, destOffset, c); + setArrayNoBarrier(dest, destOffset, c); } return destOffset + 1; } @@ -206,19 +206,19 @@ char[] intBuffer = grabIntBuffer(); nextDigit = (int) (l % 10); - nextChar = Barriers.getArrayNoBarrierStatic(hexDigitCharacter, negative ? -nextDigit : nextDigit); - Barriers.setArrayNoBarrierStatic(intBuffer, index--, nextChar); + nextChar = getArrayNoBarrier(hexDigitCharacter, negative ? -nextDigit : nextDigit); + setArrayNoBarrier(intBuffer, index--, nextChar); l = l / 10; while (l != 0) { nextDigit = (int) (l % 10); - nextChar = Barriers.getArrayNoBarrierStatic(hexDigitCharacter, negative ? -nextDigit : nextDigit); - Barriers.setArrayNoBarrierStatic(intBuffer, index--, nextChar); + nextChar = getArrayNoBarrier(hexDigitCharacter, negative ? -nextDigit : nextDigit); + setArrayNoBarrier(intBuffer, index--, nextChar); l = l / 10; } if (negative) { - Barriers.setArrayNoBarrierStatic(intBuffer, index--, '-'); + setArrayNoBarrier(intBuffer, index--, '-'); } int newOffset = sprintf(dest, offset, intBuffer, index + 1, INT_BUFFER_SIZE); @@ -320,4 +320,112 @@ print("% of "); println(quantity); } + + /** + * Sets an element of a object array without invoking any write + * barrier. + * + * @param dst the destination array + * @param index the index of the element to set + * @param value the new value for the element + */ + @UninterruptibleNoWarn + public static void setArrayNoBarrier(Object[] dst, int index, Object value) { + if (VM.runningVM) + VM_Magic.setObjectAtOffset(dst, Offset.fromIntZeroExtend(index << LOG_BYTES_IN_ADDRESS), value); + else + dst[index] = value; + } + + /** + * Sets an element of a char array without invoking any write + * barrier. This method is called by the Log method, as it will be + * used during garbage collection and needs to manipulate character + * arrays without causing a write barrier operation. + * + * @param dst the destination array + * @param index the index of the element to set + * @param value the new value for the element + */ + public static void setArrayNoBarrier(char[] dst, int index, char value) { + if (VM.runningVM) + VM_Magic.setCharAtOffset(dst, Offset.fromIntZeroExtend(index << LOG_BYTES_IN_CHAR), value); + else + dst[index] = value; + } + + /** + * Gets an element of an Object array without invoking any read + * barrier or performing bounds checks. + * + * @param src the source array + * @param index the natural array index of the element to get + * @return the new value of element + */ + public static Object getArrayNoBarrier(Object[] src, int index) { + if (VM.runningVM) + return VM_Magic.getObjectAtOffset(src, Offset.fromIntZeroExtend(index << LOG_BYTES_IN_ADDRESS)); + else + return src[index]; + } + + /** + * Gets an element of an int array without invoking any read barrier + * or performing bounds checks. + * + * @param src the source array + * @param index the natural array index of the element to get + * @return the new value of element + */ + public static int getArrayNoBarrier(int[] src, int index) { + if (VM.runningVM) + return VM_Magic.getCharAtOffset(src, Offset.fromIntZeroExtend(index << LOG_BYTES_IN_INT)); + else + return src[index]; + } + + /** + * Gets an element of a char array without invoking any read barrier + * or performing bounds check. + * + * @param src the source array + * @param index the natural array index of the element to get + * @return the new value of element + */ + public static char getArrayNoBarrier(char[] src, int index) { + if (VM.runningVM) + return VM_Magic.getCharAtOffset(src, Offset.fromIntZeroExtend(index << LOG_BYTES_IN_CHAR)); + else + return src[index]; + } + + /** + * Gets an element of a byte array without invoking any read barrier + * or bounds check. + * + * @param src the source array + * @param index the natural array index of the element to get + * @return the new value of element + */ + public static byte getArrayNoBarrier(byte[] src, int index) { + if (VM.runningVM) + return VM_Magic.getByteAtOffset(src, Offset.fromIntZeroExtend(index)); + else + return src[index]; + } + + /** + * Gets an element of an array of byte arrays without causing the potential + * thread switch point that array accesses normally cause. + * + * @param src the source array + * @param index the index of the element to get + * @return the new value of element + */ + public static byte[] getArrayNoBarrier(byte[][] src, int index) { + if (VM.runningVM) + return VM_Magic.addressAsByteArray(VM_Magic.objectAsAddress(VM_Magic.getObjectAtOffset(src, Offset.fromIntZeroExtend(index << LOG_BYTES_IN_ADDRESS)))); + else + return src[index]; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |