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);
}
}
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());
}
}
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());
}
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);
}
}
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;
}
Aggregations