Search in sources :

Example 71 with RVMType

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

the class ObjectModel method bytesUsed.

/**
 * @param obj an object
 * @return the number of bytes used by the object
 */
public static int bytesUsed(Object obj) {
    TIB tib = getTIB(obj);
    RVMType type = tib.getType();
    if (type.isClassType()) {
        return bytesUsed(obj, type.asClass());
    } else {
        int numElements = Magic.getArrayLength(obj);
        return bytesUsed(obj, type.asArray(), numElements);
    }
}
Also used : RVMType(org.jikesrvm.classloader.RVMType) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 72 with RVMType

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

the class ObjectModel method getReferenceWhenCopiedTo.

/**
 * Gets the reference of an object after copying to a specified region.
 *
 * @param obj the object to copy
 * @param to the target address for the copy
 * @return the reference of the copy
 */
public static Object getReferenceWhenCopiedTo(Object obj, Address to) {
    TIB tib = getTIB(obj);
    RVMType type = tib.getType();
    if (type.isClassType()) {
        return getReferenceWhenCopiedTo(obj, to, type.asClass());
    } else {
        return getReferenceWhenCopiedTo(obj, to, type.asArray());
    }
}
Also used : RVMType(org.jikesrvm.classloader.RVMType)

Example 73 with RVMType

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

the class ObjectModel method describeObject.

/**
 * For debugging: dumps descriptor of an object.
 *
 * @param addr the object to dump
 */
public static void describeObject(ObjectReference addr) {
    Object obj = addr.toObject();
    RVMType type = Magic.getObjectType(obj);
    VM.sysWrite(type.getDescriptor());
}
Also used : RVMType(org.jikesrvm.classloader.RVMType)

Example 74 with RVMType

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

the class ObjectModel method bytesRequiredWhenCopied.

/**
 * @param obj the object
 * @return number of bytes that are required when the object is copied by GC
 */
public static int bytesRequiredWhenCopied(Object obj) {
    TIB tib = getTIB(obj);
    RVMType type = tib.getType();
    if (type.isClassType()) {
        return bytesRequiredWhenCopied(obj, type.asClass());
    } else {
        int numElements = Magic.getArrayLength(obj);
        return bytesRequiredWhenCopied(obj, type.asArray(), numElements);
    }
}
Also used : RVMType(org.jikesrvm.classloader.RVMType) Entrypoint(org.vmmagic.pragma.Entrypoint)

Example 75 with RVMType

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

the class MemoryManager method pickAllocatorForType.

/**
 * Determine the default allocator to be used for a given type.
 *
 * @param type The type in question
 * @return The allocator to use for allocating instances of type
 * <code>type</code>.
 */
@Interruptible
private static int pickAllocatorForType(RVMType type) {
    int allocator = Plan.ALLOC_DEFAULT;
    if (type.isArrayType()) {
        RVMType elementType = type.asArray().getElementType();
        if (elementType.isPrimitiveType() || elementType.isUnboxedType()) {
            allocator = Plan.ALLOC_NON_REFERENCE;
        }
    }
    if (type.isNonMoving()) {
        allocator = Plan.ALLOC_NON_MOVING;
    }
    byte[] typeBA = type.getDescriptor().toByteArray();
    if (Selected.Constraints.get().withGCspy()) {
        if (isPrefix("Lorg/mmtk/vm/gcspy/", typeBA) || isPrefix("[Lorg/mmtk/vm/gcspy/", typeBA)) {
            allocator = Plan.ALLOC_GCSPY;
        }
    }
    if (isPrefix("Lorg/jikesrvm/tuningfork", typeBA) || isPrefix("[Lorg/jikesrvm/tuningfork", typeBA) || isPrefix("Lcom/ibm/tuningfork/", typeBA) || isPrefix("[Lcom/ibm/tuningfork/", typeBA) || isPrefix("Lorg/mmtk/", typeBA) || isPrefix("[Lorg/mmtk/", typeBA) || isPrefix("Lorg/jikesrvm/mm/", typeBA) || isPrefix("[Lorg/jikesrvm/mm/", typeBA) || isPrefix("Lorg/jikesrvm/jni/JNIEnvironment;", typeBA)) {
        allocator = Plan.ALLOC_NON_MOVING;
    }
    return allocator;
}
Also used : RVMType(org.jikesrvm.classloader.RVMType) Entrypoint(org.vmmagic.pragma.Entrypoint) Interruptible(org.vmmagic.pragma.Interruptible)

Aggregations

RVMType (org.jikesrvm.classloader.RVMType)77 RVMClass (org.jikesrvm.classloader.RVMClass)23 TypeReference (org.jikesrvm.classloader.TypeReference)18 Address (org.vmmagic.unboxed.Address)16 RVMMethod (org.jikesrvm.classloader.RVMMethod)15 RegisterOperand (org.jikesrvm.compilers.opt.ir.operand.RegisterOperand)15 TIB (org.jikesrvm.objectmodel.TIB)13 Entrypoint (org.vmmagic.pragma.Entrypoint)13 IntConstantOperand (org.jikesrvm.compilers.opt.ir.operand.IntConstantOperand)12 Operand (org.jikesrvm.compilers.opt.ir.operand.Operand)12 RVMArray (org.jikesrvm.classloader.RVMArray)11 ConditionOperand (org.jikesrvm.compilers.opt.ir.operand.ConditionOperand)11 MethodOperand (org.jikesrvm.compilers.opt.ir.operand.MethodOperand)11 BranchProfileOperand (org.jikesrvm.compilers.opt.ir.operand.BranchProfileOperand)10 NullConstantOperand (org.jikesrvm.compilers.opt.ir.operand.NullConstantOperand)10 TrapCodeOperand (org.jikesrvm.compilers.opt.ir.operand.TrapCodeOperand)10 TrueGuardOperand (org.jikesrvm.compilers.opt.ir.operand.TrueGuardOperand)10 Instruction (org.jikesrvm.compilers.opt.ir.Instruction)9 TypeOperand (org.jikesrvm.compilers.opt.ir.operand.TypeOperand)9 Offset (org.vmmagic.unboxed.Offset)8