use of org.jikesrvm.classloader.TypeReference in project JikesRVM by JikesRVM.
the class NonFinalReferenceDensityComparator method compare.
@Override
public int compare(BootImageMap.Entry a, BootImageMap.Entry b) {
TypeReference aRef = TypeReference.findOrCreate(a.getJdkObject().getClass());
TypeReference bRef = TypeReference.findOrCreate(b.getJdkObject().getClass());
if ((!aRef.isResolved() && !bRef.isResolved()) || (aRef == bRef)) {
return identicalSizeComparator.compare(a, b);
} else if (!aRef.isResolved()) {
return 1;
} else if (!bRef.isResolved()) {
return -1;
} else {
double aSize = (double) getNumberOfNonFinalReferences(aRef.peekType(), a.getJdkObject()) / (double) getSize(aRef.peekType(), a.getJdkObject());
double bSize = (double) getNumberOfNonFinalReferences(bRef.peekType(), b.getJdkObject()) / (double) getSize(bRef.peekType(), b.getJdkObject());
int result = Double.compare(bSize, aSize);
if (result == 0) {
return identicalSizeComparator.compare(a, b);
} else {
return result;
}
}
}
use of org.jikesrvm.classloader.TypeReference in project JikesRVM by JikesRVM.
the class NumberOfReferencesComparator method compare.
@Override
public int compare(BootImageMap.Entry a, BootImageMap.Entry b) {
TypeReference aRef = TypeReference.findOrCreate(a.getJdkObject().getClass());
TypeReference bRef = TypeReference.findOrCreate(b.getJdkObject().getClass());
if ((!aRef.isResolved() && !bRef.isResolved()) || (aRef == bRef)) {
return identicalSizeComparator.compare(a, b);
} else if (!aRef.isResolved()) {
return 1;
} else if (!bRef.isResolved()) {
return -1;
} else {
int aSize = getNumberOfReferences(aRef.peekType(), a.getJdkObject());
int bSize = getNumberOfReferences(bRef.peekType(), b.getJdkObject());
if (aSize == bSize) {
return identicalSizeComparator.compare(a, b);
} else {
return bSize - aSize;
}
}
}
use of org.jikesrvm.classloader.TypeReference in project JikesRVM by JikesRVM.
the class ObjectSizeComparator method compare.
@Override
public int compare(BootImageMap.Entry a, BootImageMap.Entry b) {
TypeReference aRef = TypeReference.findOrCreate(a.getJdkObject().getClass());
TypeReference bRef = TypeReference.findOrCreate(b.getJdkObject().getClass());
if ((!aRef.isResolved() && !bRef.isResolved()) || (aRef == bRef)) {
return identicalSizeComparator.compare(a, b);
} else if (!aRef.isResolved()) {
return -1;
} else if (!bRef.isResolved()) {
return 1;
} else {
int aSize = getSize(aRef.peekType(), a.getJdkObject());
int bSize = getSize(bRef.peekType(), b.getJdkObject());
if (aSize == bSize) {
return identicalSizeComparator.compare(a, b);
} else {
return aSize - bSize;
}
}
}
use of org.jikesrvm.classloader.TypeReference in project JikesRVM by JikesRVM.
the class TypeReferenceComparator method compare.
@Override
public int compare(BootImageMap.Entry a, BootImageMap.Entry b) {
TypeReference aRef = TypeReference.findOrCreate(a.getJdkObject().getClass());
TypeReference bRef = TypeReference.findOrCreate(b.getJdkObject().getClass());
return aRef.getId() - bRef.getId();
}
use of org.jikesrvm.classloader.TypeReference in project JikesRVM by JikesRVM.
the class JNIHelpers method packageParameterFromVarArg.
/**
* Repackage the arguments passed as a variable argument list into an array of Object,
* used by the JNI functions CallStatic<type>MethodV
* @param targetMethod The target {@link RVMMethod}
* @param argAddress an address into the C space for the array of jvalue unions;
* each element is 2-word and holds the argument of the appropriate type
* @return an Object array holding the arguments wrapped at Objects
*/
static Object[] packageParameterFromVarArg(MethodReference targetMethod, Address argAddress) {
TypeReference[] argTypes = targetMethod.getParameterTypes();
int argCount = argTypes.length;
Object[] argObjectArray = new Object[argCount];
Address vaListCopy = SysCall.sysCall.sysVaCopy(argAddress);
JNIEnvironment env = RVMThread.getCurrentThread().getJNIEnv();
for (int i = 0; i < argCount; i++) {
// convert and wrap the argument according to the expected type
if (argTypes[i].isReferenceType()) {
argObjectArray[i] = env.getJNIRef(SysCall.sysCall.sysVaArgJobject(vaListCopy));
} else if (argTypes[i].isIntType()) {
argObjectArray[i] = SysCall.sysCall.sysVaArgJint(vaListCopy);
} else if (argTypes[i].isLongType()) {
argObjectArray[i] = SysCall.sysCall.sysVaArgJlong(vaListCopy);
} else if (argTypes[i].isBooleanType()) {
argObjectArray[i] = SysCall.sysCall.sysVaArgJboolean(vaListCopy);
} else if (argTypes[i].isByteType()) {
argObjectArray[i] = SysCall.sysCall.sysVaArgJbyte(vaListCopy);
} else if (argTypes[i].isCharType()) {
argObjectArray[i] = SysCall.sysCall.sysVaArgJchar(vaListCopy);
} else if (argTypes[i].isShortType()) {
argObjectArray[i] = SysCall.sysCall.sysVaArgJshort(vaListCopy);
} else if (argTypes[i].isFloatType()) {
argObjectArray[i] = SysCall.sysCall.sysVaArgJfloat(vaListCopy);
} else {
if (VM.VerifyAssertions)
VM._assert(argTypes[i].isDoubleType());
argObjectArray[i] = SysCall.sysCall.sysVaArgJdouble(vaListCopy);
}
}
SysCall.sysCall.sysVaEnd(vaListCopy);
return argObjectArray;
}
Aggregations