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