use of org.jikesrvm.classloader.RVMArray in project JikesRVM by JikesRVM.
the class ShortArrayReplacer method getReplacer.
/**
* Returns an object representing this transformation for a given
* allocation site.
*
* @param inst the allocation site
* @param ir the governing IR
* @return the object, or {@code null} if illegal
*/
public static ShortArrayReplacer getReplacer(Instruction inst, IR ir) {
if (inst.operator() != NEWARRAY) {
return null;
}
Operand size = NewArray.getSize(inst);
if (!size.isIntConstant()) {
return null;
}
int s = size.asIntConstant().value;
if (s > ir.options.ESCAPE_MAX_ARRAY_SIZE) {
return null;
}
if (s < 0) {
return null;
}
Register r = NewArray.getResult(inst).getRegister();
RVMArray a = NewArray.getType(inst).getVMType().asArray();
// TODO :handle these cases
if (containsUnsupportedUse(ir, r, s, a, null)) {
return null;
}
return new ShortArrayReplacer(r, a, s, ir);
}
use of org.jikesrvm.classloader.RVMArray in project JikesRVM by JikesRVM.
the class RuntimeEntrypoints method buildMDAHelper.
/**
* @param method Apparently unused (!)
* @param numElements Number of elements to allocate for each dimension
* @param dimIndex Current dimension to build
* @param arrayType type of array that will result
* @return a multi-dimensional array
*/
public static Object buildMDAHelper(RVMMethod method, int[] numElements, int dimIndex, RVMArray arrayType) {
if (!arrayType.isInstantiated()) {
arrayType.resolve();
arrayType.instantiate();
}
int nelts = numElements[dimIndex];
Object newObject = resolvedNewArray(nelts, arrayType);
if (++dimIndex == numElements.length) {
// all dimensions have been built
return newObject;
}
Object[] newArray = (Object[]) newObject;
RVMArray newArrayType = arrayType.getElementType().asArray();
for (int i = 0; i < nelts; ++i) {
newArray[i] = buildMDAHelper(method, numElements, dimIndex, newArrayType);
}
return newArray;
}
use of org.jikesrvm.classloader.RVMArray in project JikesRVM by JikesRVM.
the class RuntimeEntrypoints method unresolvedNewArray.
/**
* Allocate something like "new Foo[]".
* @param numElements number of array elements
* @param id id of type reference of array to create.
* @param site the site id of the calling allocation site
* @return array with header installed and all fields set to zero/null
* See also: bytecode 0xbc ("anewarray")
*/
@Entrypoint
public static Object unresolvedNewArray(int numElements, int id, int site) throws NoClassDefFoundError, OutOfMemoryError, NegativeArraySizeException {
TypeReference tRef = TypeReference.getTypeRef(id);
RVMType t = tRef.peekType();
if (t == null) {
t = tRef.resolve();
}
RVMArray array = t.asArray();
if (!array.isInitialized()) {
array.resolve();
array.instantiate();
}
return resolvedNewArray(numElements, array, site);
}
use of org.jikesrvm.classloader.RVMArray in project JikesRVM by JikesRVM.
the class RuntimeEntrypoints method cloneArray.
/**
* Clone an array
*
* @param obj the array to clone
* @param type the type information for the array
* @return the cloned object
*/
private static Object cloneArray(Object obj, RVMType type) throws OutOfMemoryError {
RVMArray ary = type.asArray();
int nelts = ObjectModel.getArrayLength(obj);
Object newObj = resolvedNewArray(nelts, ary);
System.arraycopy(obj, 0, newObj, 0, nelts);
return newObj;
}
use of org.jikesrvm.classloader.RVMArray in project JikesRVM by JikesRVM.
the class MemoryManager method newNonMovingShortArray.
/**
* Allocates a non moving short array.
*
* @param size The size of the array
* @return the new non moving short array
*/
@NoInline
@Interruptible
public static short[] newNonMovingShortArray(int size) {
if (!VM.runningVM) {
return new short[size];
}
RVMArray arrayType = RVMArray.ShortArray;
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 (short[]) allocateArray(size, width, headerSize, arrayTib, Plan.ALLOC_NON_MOVING, align, offset, Plan.DEFAULT_SITE);
}
Aggregations