Search in sources :

Example 51 with Inline

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();
    }
}
Also used : Offset(org.vmmagic.unboxed.Offset) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 52 with Inline

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();
    }
}
Also used : Offset(org.vmmagic.unboxed.Offset) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 53 with Inline

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();
    }
}
Also used : Offset(org.vmmagic.unboxed.Offset) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 54 with Inline

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();
    }
}
Also used : Offset(org.vmmagic.unboxed.Offset) Inline(org.vmmagic.pragma.Inline) NoInline(org.vmmagic.pragma.NoInline)

Example 55 with Inline

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);
}
Also used : Address(org.vmmagic.unboxed.Address) RVMArray(org.jikesrvm.classloader.RVMArray) RVMType(org.jikesrvm.classloader.RVMType) TIB(org.jikesrvm.objectmodel.TIB) RVMClass(org.jikesrvm.classloader.RVMClass) Inline(org.vmmagic.pragma.Inline)

Aggregations

Inline (org.vmmagic.pragma.Inline)110 NoInline (org.vmmagic.pragma.NoInline)42 Entrypoint (org.vmmagic.pragma.Entrypoint)40 Offset (org.vmmagic.unboxed.Offset)38 ObjectReference (org.vmmagic.unboxed.ObjectReference)35 Address (org.vmmagic.unboxed.Address)15 Word (org.vmmagic.unboxed.Word)15 TypeReference (org.jikesrvm.classloader.TypeReference)12 Uninterruptible (org.vmmagic.pragma.Uninterruptible)6 RVMType (org.jikesrvm.classloader.RVMType)5 RVMClass (org.jikesrvm.classloader.RVMClass)4 Unpreemptible (org.vmmagic.pragma.Unpreemptible)4 RVMClassLoader (org.jikesrvm.classloader.RVMClassLoader)3 TIB (org.jikesrvm.objectmodel.TIB)3 Extent (org.vmmagic.unboxed.Extent)3 MethodReference (org.jikesrvm.classloader.MethodReference)2 ForwardReference (org.jikesrvm.compilers.common.assembler.ForwardReference)2 RVMThread (org.jikesrvm.scheduler.RVMThread)2 CollectorContext (org.mmtk.plan.CollectorContext)2 NoNullCheck (org.vmmagic.pragma.NoNullCheck)2