Search in sources :

Example 26 with RVMArray

use of org.jikesrvm.classloader.RVMArray in project JikesRVM by JikesRVM.

the class MemoryManager method allocateCode.

/**
 * Allocate a CodeArray into a code space.
 * Currently the interface is fairly primitive;
 * just the number of instructions in the code array and a boolean
 * to indicate hot or cold code.
 * @param numInstrs number of instructions
 * @param isHot is this a request for hot code space allocation?
 * @return The  array
 */
@NoInline
@Interruptible
public static CodeArray allocateCode(int numInstrs, boolean isHot) {
    RVMArray type = RVMType.CodeArrayType;
    int headerSize = ObjectModel.computeArrayHeaderSize(type);
    int align = ObjectModel.getAlignment(type);
    int offset = ObjectModel.getOffsetForAlignment(type, false);
    int width = type.getLogElementSize();
    TIB tib = type.getTypeInformationBlock();
    int allocator = isHot ? Plan.ALLOC_HOT_CODE : Plan.ALLOC_COLD_CODE;
    return (CodeArray) allocateArray(numInstrs, width, headerSize, tib, allocator, align, offset, Plan.DEFAULT_SITE);
}
Also used : CodeArray(org.jikesrvm.compilers.common.CodeArray) RVMArray(org.jikesrvm.classloader.RVMArray) TIB(org.jikesrvm.objectmodel.TIB) Entrypoint(org.vmmagic.pragma.Entrypoint) Interruptible(org.vmmagic.pragma.Interruptible) NoInline(org.vmmagic.pragma.NoInline)

Example 27 with RVMArray

use of org.jikesrvm.classloader.RVMArray in project JikesRVM by JikesRVM.

the class MemoryManager method newNonMovingWordArray.

/**
 * Allocates a non moving word array.
 *
 * @param size The size of the array
 * @return the new non moving word array
 */
@NoInline
@Interruptible
public static WordArray newNonMovingWordArray(int size) {
    if (!VM.runningVM) {
        return WordArray.create(size);
    }
    RVMArray arrayType = RVMType.WordArrayType;
    int headerSize = ObjectModel.computeArrayHeaderSize(arrayType);
    int align = ObjectModel.getAlignment(arrayType);
    int offset = ObjectModel.getOffsetForAlignment(arrayType, false);
    int width = arrayType.getLogElementSize();
    TIB arrayTib = arrayType.getTypeInformationBlock();
    return (WordArray) allocateArray(size, width, headerSize, arrayTib, Plan.ALLOC_NON_MOVING, align, offset, Plan.DEFAULT_SITE);
}
Also used : RVMArray(org.jikesrvm.classloader.RVMArray) WordArray(org.vmmagic.unboxed.WordArray) TIB(org.jikesrvm.objectmodel.TIB) Entrypoint(org.vmmagic.pragma.Entrypoint) Interruptible(org.vmmagic.pragma.Interruptible) NoInline(org.vmmagic.pragma.NoInline)

Example 28 with RVMArray

use of org.jikesrvm.classloader.RVMArray in project JikesRVM by JikesRVM.

the class MemoryManager method newNonMovingDoubleArray.

/**
 * Allocates a non moving double array.
 *
 * @param size The size of the array
 * @return the new non moving double array
 */
@NoInline
@Interruptible
public static double[] newNonMovingDoubleArray(int size) {
    if (!VM.runningVM) {
        return new double[size];
    }
    RVMArray arrayType = RVMArray.DoubleArray;
    int headerSize = ObjectModel.computeArrayHeaderSize(arrayType);
    int align = ObjectModel.getAlignment(arrayType);
    int offset = ObjectModel.getOffsetForAlignment(arrayType, false);
    int width = arrayType.getLogElementSize();
    TIB arrayTib = arrayType.getTypeInformationBlock();
    return (double[]) allocateArray(size, width, headerSize, arrayTib, Plan.ALLOC_NON_MOVING, align, offset, Plan.DEFAULT_SITE);
}
Also used : RVMArray(org.jikesrvm.classloader.RVMArray) TIB(org.jikesrvm.objectmodel.TIB) Entrypoint(org.vmmagic.pragma.Entrypoint) Interruptible(org.vmmagic.pragma.Interruptible) NoInline(org.vmmagic.pragma.NoInline)

Example 29 with RVMArray

use of org.jikesrvm.classloader.RVMArray in project JikesRVM by JikesRVM.

the class MemoryManager method newNonMovingIntArray.

/**
 * Allocates a non moving int array.
 *
 * @param size The size of the array
 * @return the new non moving int array
 */
@NoInline
@Interruptible
public static int[] newNonMovingIntArray(int size) {
    if (!VM.runningVM) {
        return new int[size];
    }
    RVMArray arrayType = RVMArray.IntArray;
    int headerSize = ObjectModel.computeArrayHeaderSize(arrayType);
    int align = ObjectModel.getAlignment(arrayType);
    int offset = ObjectModel.getOffsetForAlignment(arrayType, false);
    int width = arrayType.getLogElementSize();
    TIB arrayTib = arrayType.getTypeInformationBlock();
    return (int[]) allocateArray(size, width, headerSize, arrayTib, Plan.ALLOC_NON_MOVING, align, offset, Plan.DEFAULT_SITE);
}
Also used : RVMArray(org.jikesrvm.classloader.RVMArray) TIB(org.jikesrvm.objectmodel.TIB) Entrypoint(org.vmmagic.pragma.Entrypoint) Interruptible(org.vmmagic.pragma.Interruptible) NoInline(org.vmmagic.pragma.NoInline)

Example 30 with RVMArray

use of org.jikesrvm.classloader.RVMArray in project JikesRVM by JikesRVM.

the class JNIFunctions method GetObjectArrayElement.

/**
 * GetObjectArrayElement: retrieve an object from an object array
 * @param env A JREF index for the JNI environment object
 * @param arrayJREF a JREF index for the source array
 * @param index the index for the targeted element
 * @return the object at the specified index
 * @throws ArrayIndexOutOfBoundsException if the index is out of range
 */
private static int GetObjectArrayElement(JNIEnvironment env, int arrayJREF, int index) {
    if (traceJNI)
        VM.sysWriteln("JNI called: GetObjectArrayElement");
    RuntimeEntrypoints.checkJNICountDownToGC();
    try {
        Object[] sourceArray = (Object[]) env.getJNIRef(arrayJREF);
        if (sourceArray == null) {
            return 0;
        }
        RVMArray arrayType = Magic.getObjectType(sourceArray).asArray();
        RVMType elementType = arrayType.getElementType();
        if (elementType.isPrimitiveType() || elementType.isUnboxedType()) {
            return 0;
        }
        if (index >= Magic.getArrayLength(sourceArray)) {
            env.recordException(new ArrayIndexOutOfBoundsException());
            return 0;
        }
        return env.pushJNIRef(sourceArray[index]);
    } catch (Throwable unexpected) {
        if (traceJNI)
            unexpected.printStackTrace(System.err);
        env.recordException(unexpected);
        return 0;
    }
}
Also used : RVMArray(org.jikesrvm.classloader.RVMArray) RVMType(org.jikesrvm.classloader.RVMType)

Aggregations

RVMArray (org.jikesrvm.classloader.RVMArray)32 TIB (org.jikesrvm.objectmodel.TIB)14 Entrypoint (org.vmmagic.pragma.Entrypoint)14 RVMType (org.jikesrvm.classloader.RVMType)11 RVMClass (org.jikesrvm.classloader.RVMClass)9 NoInline (org.vmmagic.pragma.NoInline)8 TypeReference (org.jikesrvm.classloader.TypeReference)7 Interruptible (org.vmmagic.pragma.Interruptible)7 RVMMethod (org.jikesrvm.classloader.RVMMethod)6 Address (org.vmmagic.unboxed.Address)6 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)4 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)4 Test (org.junit.Test)4 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)3 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)3 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)3 LocationOperand (org.jikesrvm.compilers.opt.ir.operand.LocationOperand)3 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)3 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)3 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)3