use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.
the class RVMArray method arraycopy.
/**
* Perform an array copy for arrays of ints.
*
* @param src The source array
* @param srcIdx The starting source index
* @param dst The destination array
* @param dstIdx The starting destination index
* @param len The number of array elements to be copied
*/
@Inline(value = Inline.When.ArgumentsAreConstant, arguments = { 1, 3, 4 })
public static void arraycopy(int[] src, int srcIdx, int[] dst, int dstIdx, int len) {
// are in error
if (srcIdx >= 0 && dstIdx >= 0 && len >= 0 && (srcIdx + len) >= 0 && (srcIdx + len) <= src.length && (dstIdx + len) >= 0 && (dstIdx + len) <= dst.length) {
if ((src != dst || srcIdx >= dstIdx) && INT_BULK_COPY_SUPPORTED) {
if (NEEDS_INT_ASTORE_BARRIER || NEEDS_INT_ALOAD_BARRIER) {
Offset srcOffset = Offset.fromIntZeroExtend(srcIdx << LOG_BYTES_IN_INT);
Offset dstOffset = Offset.fromIntZeroExtend(dstIdx << LOG_BYTES_IN_INT);
Barriers.intBulkCopy(src, srcOffset, dst, dstOffset, len << LOG_BYTES_IN_INT);
} else {
Memory.arraycopy32Bit(src, srcIdx, dst, dstIdx, len);
}
} else {
arraycopyPiecemeal(src, srcIdx, dst, dstIdx, len);
}
} else {
failWithIndexOutOfBoundsException();
}
}
use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.
the class RVMArray method arraycopy.
/**
* Perform an array copy for arrays of chars.
*
* @param src The source array
* @param srcIdx The starting source index
* @param dst The destination array
* @param dstIdx The starting destination index
* @param len The number of array elements to be copied
*/
@Inline(value = Inline.When.ArgumentsAreConstant, arguments = { 1, 3, 4 })
public static void arraycopy(char[] src, int srcIdx, char[] dst, int dstIdx, int len) {
// are in error
if (srcIdx >= 0 && dstIdx >= 0 && len >= 0 && (srcIdx + len) >= 0 && (srcIdx + len) <= src.length && (dstIdx + len) >= 0 && (dstIdx + len) <= dst.length) {
if ((src != dst || srcIdx >= (dstIdx + BYTES_IN_ADDRESS / BYTES_IN_CHAR)) && CHAR_BULK_COPY_SUPPORTED) {
if (NEEDS_CHAR_ASTORE_BARRIER || NEEDS_CHAR_ALOAD_BARRIER) {
Offset srcOffset = Offset.fromIntZeroExtend(srcIdx << LOG_BYTES_IN_CHAR);
Offset dstOffset = Offset.fromIntZeroExtend(dstIdx << LOG_BYTES_IN_CHAR);
Barriers.charBulkCopy(src, srcOffset, dst, dstOffset, len << LOG_BYTES_IN_CHAR);
} else {
Memory.arraycopy16Bit(src, srcIdx, dst, dstIdx, len);
}
} else {
arraycopyPiecemeal(src, srcIdx, dst, dstIdx, len);
}
} else {
failWithIndexOutOfBoundsException();
}
}
use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.
the class RVMArray method arraycopy.
/**
* Perform an array copy for arrays of shorts.
*
* @param src The source array
* @param srcIdx The starting source index
* @param dst The destination array
* @param dstIdx The starting destination index
* @param len The number of array elements to be copied
*/
@Inline(value = Inline.When.ArgumentsAreConstant, arguments = { 1, 3, 4 })
public static void arraycopy(short[] src, int srcIdx, short[] dst, int dstIdx, int len) {
// are in error
if (srcIdx >= 0 && dstIdx >= 0 && len >= 0 && (srcIdx + len) >= 0 && (srcIdx + len) <= src.length && (dstIdx + len) >= 0 && (dstIdx + len) <= dst.length) {
if ((src != dst || srcIdx >= (dstIdx + BYTES_IN_ADDRESS / BYTES_IN_SHORT)) && SHORT_BULK_COPY_SUPPORTED) {
if (NEEDS_SHORT_ASTORE_BARRIER || NEEDS_SHORT_ALOAD_BARRIER) {
Offset srcOffset = Offset.fromIntZeroExtend(srcIdx << LOG_BYTES_IN_SHORT);
Offset dstOffset = Offset.fromIntZeroExtend(dstIdx << LOG_BYTES_IN_SHORT);
Barriers.shortBulkCopy(src, srcOffset, dst, dstOffset, len << LOG_BYTES_IN_SHORT);
} else {
Memory.arraycopy16Bit(src, srcIdx, dst, dstIdx, len);
}
} else {
arraycopyPiecemeal(src, srcIdx, dst, dstIdx, len);
}
} else {
failWithIndexOutOfBoundsException();
}
}
use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.
the class RVMArray method arraycopy.
// --------------------------------------------------------------------------------------------------//
// Support for array copy //
// --------------------------------------------------------------------------------------------------//
/**
* Perform an array copy for arrays of bytes.
*
* @param src The source array
* @param srcIdx The starting source index
* @param dst The destination array
* @param dstIdx The starting destination index
* @param len The number of array elements to be copied
*/
@Inline(value = Inline.When.ArgumentsAreConstant, arguments = { 1, 3, 4 })
public static void arraycopy(byte[] src, int srcIdx, byte[] dst, int dstIdx, int len) {
// are in error
if (srcIdx >= 0 && dstIdx >= 0 && len >= 0 && (srcIdx + len) >= 0 && (srcIdx + len) <= src.length && (dstIdx + len) >= 0 && (dstIdx + len) <= dst.length) {
if ((src != dst || srcIdx >= (dstIdx + BYTES_IN_ADDRESS)) && BYTE_BULK_COPY_SUPPORTED) {
if (NEEDS_BYTE_ASTORE_BARRIER || NEEDS_BYTE_ALOAD_BARRIER) {
Offset srcOffset = Offset.fromIntZeroExtend(srcIdx);
Offset dstOffset = Offset.fromIntZeroExtend(dstIdx);
Barriers.byteBulkCopy(src, srcOffset, dst, dstOffset, len);
} else {
Memory.arraycopy8Bit(src, srcIdx, dst, dstIdx, len);
}
} else {
arraycopyPiecemeal(src, srcIdx, dst, dstIdx, len);
}
} else {
failWithIndexOutOfBoundsException();
}
}
use of org.vmmagic.pragma.Inline in project JikesRVM by JikesRVM.
the class ObjectModel method copyTo.
/**
* @param region The start (or an address less than) the region that was reserved for this object.
*/
@Override
@Inline
public Address copyTo(ObjectReference from, ObjectReference to, Address region) {
TIB tib = org.jikesrvm.objectmodel.ObjectModel.getTIB(from);
RVMType type = tib.getType();
int bytes;
boolean copy = (from != to);
if (copy) {
if (type.isClassType()) {
RVMClass classType = type.asClass();
bytes = org.jikesrvm.objectmodel.ObjectModel.bytesRequiredWhenCopied(from.toObject(), classType);
org.jikesrvm.objectmodel.ObjectModel.moveObject(from.toObject(), to.toObject(), bytes, classType);
} else {
RVMArray arrayType = type.asArray();
int elements = Magic.getArrayLength(from.toObject());
bytes = org.jikesrvm.objectmodel.ObjectModel.bytesRequiredWhenCopied(from.toObject(), arrayType, elements);
org.jikesrvm.objectmodel.ObjectModel.moveObject(from.toObject(), to.toObject(), bytes, arrayType);
}
} else {
bytes = getCurrentSize(to);
}
Address start = org.jikesrvm.objectmodel.ObjectModel.objectStartRef(to);
Allocator.fillAlignmentGap(region, start);
return start.plus(bytes);
}
Aggregations